Java Code Examples for org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#fullBuild()

The following examples show how to use org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#fullBuild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XtendJavaElementDelegateJunitLaunchTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private IFile dslFile(final CharSequence text) {
  try {
    IFile _xblockexpression = null;
    {
      final IFile file = IResourcesSetupUtil.createFile(this.getProjectName(), "src/foo/FooTest", this._fileExtensionProvider.getPrimaryFileExtension(), this.getContent(text));
      final IProject project = file.getProject();
      boolean _hasNature = project.hasNature(XtextProjectHelper.NATURE_ID);
      boolean _not = (!_hasNature);
      if (_not) {
        IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
      }
      IResourcesSetupUtil.fullBuild();
      _xblockexpression = file;
    }
    return _xblockexpression;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 2
Source File: TypeDefinitionsShadowingPluginTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Negative test case.
 *
 * Imports client, definition and implementation project that declare an invalid type definitions configuration.
 *
 * More specifically, the "definesPackage" property of the definition project does not point to the intended
 * implementation project. As a consequence, the client project cannot make use of any type information on the
 * implementation project.
 */
@Test
public void testInvalidTypeDefinitionsShadowing() throws CoreException {
	final File testdataLocation = new File(getResourceUri(PROBANDS, PROBANDS_SUBFOLDER, NEGATIVE_FIXTURE_FOLDER));

	ProjectTestsUtils.importYarnWorkspace(libraryManager, testdataLocation, YARN_WORKSPACE_PROJECT);

	final IProject clientProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Broken_Client");
	final IProject definitionProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Broken_Def");
	final IProject implProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Impl");

	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	IResource clientModule = clientProject.findMember("src/Client.n4js");

	assertIssues("Client module should have compilation issues, as type definitions cannot be resolved",
			clientModule,
			"line 2: Import of A cannot be resolved.",
			"line 6: Couldn't resolve reference to IdentifiableElement 'A'.");

	assertMarkers("Definition project should not have any markers (no compilation issues)", definitionProject, 0);
	assertMarkers("Implementation project should not have any markers (no compilation issues)", implProject, 0);
}
 
Example 3
Source File: TypeDefinitionsShadowingPluginTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Positive test case.
 *
 * Imports client, definition and implementation project and expects none of the projects to raise any compilation
 * issues.
 *
 * The client project imports both module 'A' and 'B'. For 'A', the definition project provides type information,
 * for 'B' it uses a dynamic namespace import, since the definition project does not provide any type information on
 * it.
 */
@Test
public void testValidTypeDefinitionsShadowing() throws CoreException {
	final File testdataLocation = new File(getResourceUri(PROBANDS, PROBANDS_SUBFOLDER, POSITIVE_FIXTURE_FOLDER));

	ProjectTestsUtils.importYarnWorkspace(libraryManager, testdataLocation, YARN_WORKSPACE_PROJECT);

	final IProject clientProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Client");
	final IProject definitionProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Def");
	final IProject implProject = ResourcesPlugin.getWorkspace().getRoot().getProject("Impl");

	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	assertMarkers("Client project should not have any markers (no compilation issues)", clientProject, 0);
	assertMarkers("Definition project should not have any markers (no compilation issues)", definitionProject, 0);
	assertMarkers("Implementation project should not have any markers (no compilation issues)", implProject, 0);
}
 
Example 4
Source File: ExcludePckJson_PluginUITest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks that only one package.json is contained in the index. This one package.json is the one from the project
 * root folder.
 */
@Test
public void checkIndex() throws CoreException {
	final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
	assertTrue("Test project is not accessible.", project.isAccessible());

	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	ResourceSet resourceSet = core.createResourceSet(Optional.absent());
	IResourceDescriptions index = core.getXtextIndex(resourceSet);

	for (IResourceDescription res : index.getAllResourceDescriptions()) {
		String resLocation = res.getURI().toString();

		if (resLocation.endsWith(".json")) {
			System.out.println("Indexing found: " + resLocation);
		}
	}
}
 
Example 5
Source File: ExcludePckJson_PluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks that there is exactly one error marker in the problems view. This single marker must be from the
 * package.json of the project root folder.
 */
@Test
public void checkProblemMarkers() throws CoreException {
	final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
	assertTrue("Test project is not accessible.", project.isAccessible());

	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();
	assertMarkers("Expected exactly 1 issues.", project, 1);
}
 
Example 6
Source File: KeepLocalHistoryTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void assertDelete(final IFile it, final int expectedLocalHistorySize) {
  try {
    it.delete(true, null);
    IResourcesSetupUtil.fullBuild();
    this.assertFileLocalHistory(KeepLocalHistoryTest.GENERATE_FILE_NAME, expectedLocalHistorySize);
    this.assertFileLocalHistoryEmpty(KeepLocalHistoryTest.GENERATE_TRACK_FILE_NAME);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 7
Source File: OpenEditorTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	workbenchTestHelper.createFile("outlinetest/Bar.java", "package outlinetest; public class Bar { public int bar; }");
	workbenchTestHelper.createFile("outlinetest/Foo.xtend", "package outlinetest class Foo extends Bar { public int foo }");
	IResourcesSetupUtil.fullBuild();
	javaProject = JavaCore.create(workbenchTestHelper.getProject());
}
 
Example 8
Source File: ClearCacheOnCleanPluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tests if the {@link MultiCleartriggerCache} is cleared when the user edits a 'package.json' file. Note that this
 * triggering is performed for the key {@link MultiCleartriggerCache#CACHE_KEY_API_IMPL_MAPPING} but not necessarily
 * for every other key in the cache.
 */
@Test
public void testClearOnModifyPackageJson() throws CoreException {
	File prjDir = new File(PROBANDS);
	IProject project = ProjectTestsUtils.importProject(prjDir, PROJECT_NAME);
	IResource packagejson = project.findMember(N4JSGlobals.PACKAGE_JSON);
	IFile filePJ = ResourcesPlugin.getWorkspace().getRoot().getFile(packagejson.getFullPath());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	syncExtAndBuild();
	assertNoIssues();

	// use key of API_IMPL_MAPPING
	SupplierWithPostAction testSupplier = new SupplierWithPostAction();
	assertTrue(testSupplier.postActionTriggerCount == 0);

	cache.clear(MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);

	// cache should be empty
	Object test = cache.get(testSupplier, MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);
	assertTrue(testSupplier.postActionTriggerCount == 1);
	assertTrue("test".equals(test));

	// cache should contain key
	cache.get(testSupplier, MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);
	assertTrue(testSupplier.postActionTriggerCount == 1);
	assertTrue("test".equals(test));

	// edit package.json should clear the cache and set a new instance of ApiImplMappings
	IWorkbenchPage page = EclipseUIUtils.getActivePage();
	XtextEditor editor = openAndGetXtextEditor(filePJ, page);
	editor.doSave(new NullProgressMonitor());
	waitForAutoBuild();
	test = cache.get(testSupplier, MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);
	assertTrue(test instanceof ApiImplMapping);
}
 
Example 9
Source File: ClearCacheOnCleanPluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tests if the {@link MultiCleartriggerCache} is cleared when a 'Clean Build' is triggered.
 */
@Test
public void testClearOnCleanBuild() throws CoreException {
	File prjDir = new File(PROBANDS);
	IProject project = ProjectTestsUtils.importProject(prjDir, PROJECT_NAME);
	IResource resourceABC = project.findMember("src/ABC.n4js");
	IFile fileABC = ResourcesPlugin.getWorkspace().getRoot().getFile(resourceABC.getFullPath());
	assertTrue(fileABC.exists());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	syncExtAndBuild();
	assertNoIssues();

	// use key of API_IMPL_MAPPING
	SupplierWithPostAction testSupplier = new SupplierWithPostAction();
	assertTrue(testSupplier.postActionTriggerCount == 0);

	cache.clear(MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);

	// cache should be empty
	Object test = cache.get(testSupplier, MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);
	assertTrue(testSupplier.postActionTriggerCount == 1);
	assertTrue("test".equals(test));

	// cache should contain key
	cache.get(testSupplier, MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);
	assertTrue(testSupplier.postActionTriggerCount == 1);
	assertTrue("test".equals(test));

	// cleanBuild should clear the cache and set a new instance of ApiImplMappings
	IResourcesSetupUtil.cleanBuild();
	waitForAutoBuild();
	test = cache.get(testSupplier, MultiCleartriggerCache.CACHE_KEY_API_IMPL_MAPPING);
	assertTrue(test instanceof ApiImplMapping);
}
 
Example 10
Source File: GHOLD_129_BrokenAstMustNotCauseBuildFailure_PluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * We expect validation errors which means the build was not broken and interrupted due to broken AST when inferring
 * the types.
 */
@Test
public void checkBrokenAstDoesNotCauseBuildFailure_ExpectValidationErrors() throws CoreException {
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
	assertTrue("Project '" + PROJECT_NAME + "' does not exist in workspace.", project.isAccessible());

	IResourcesSetupUtil.fullBuild();
	ProjectTestsUtils.waitForAutoBuild();

	// Couldn't resolve reference to IdentifiableElement 'A'.
	// Name missing in type declaration.
	ProjectTestsUtils.assertMarkers("Expected exactly two validation errors.", project, 2);
}
 
Example 11
Source File: KeepLocalHistoryTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public void assertGeneratedFiles(final int expectedLocalHistorySize) {
  try {
    IResourcesSetupUtil.fullBuild();
    this.assertFileLocalHistory(this.assertExist(KeepLocalHistoryTest.GENERATE_FILE_NAME), expectedLocalHistorySize);
    this.assertFileLocalHistoryEmpty(this.assertExist(KeepLocalHistoryTest.GENERATE_TRACK_FILE_NAME));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 12
Source File: DependencyNotInstalledPluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks that there is an issue in case of a non-yarn dependency to another workspace project.
 */
@Test
public void checkErrorOfMissingYarnWorkspaceProjects() throws CoreException {
	Path projectsRoot = new File(getResourceUri(PROBANDS_DIR)).toPath();
	ProjectTestsUtils.importProject(projectsRoot.toFile(), PROBAND_A);
	IProject prjB = ProjectTestsUtils.importProject(projectsRoot.toFile(), PROBAND_B);
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	IFile packageJsonB = prjB.getFile(IN4JSProject.PACKAGE_JSON);
	assertIssues(packageJsonB,
			"line 14: Project depends on workspace project A which is missing in the node_modules folder. Either install project A or introduce a yarn workspace of both of the projects.");
}
 
Example 13
Source File: DependencyNotInstalledPluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks that there is an issue in case an npm is not installed in the project's node_modules folder, even though
 * that npm is installed in another, unrelated project's node_modules folder.
 */
@Test
public void checkErrorOfMissingInstallationProjects() throws CoreException {
	Path projectsRoot = new File(getResourceUri(PROBANDS_DIR)).toPath();
	IProject prjA = ProjectTestsUtils.importProject(projectsRoot.toFile(), PROBAND_A);
	ProjectTestsUtils.importProject(projectsRoot.toFile(), PROBAND_B);
	IProject prjUnrelated = ProjectTestsUtils.importProject(projectsRoot.toFile(), PROBAND_UNRELATED);
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	libraryManager.installNPM(new N4JSProjectName("lodash"), new PlatformResourceURI(prjUnrelated).toFileURI(),
			new NullProgressMonitor());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();
	IFile packageJsonUnrelated = prjUnrelated.getFile(IN4JSProject.PACKAGE_JSON);
	assertMarkers("package.json of project 'Unrelated' should have no issues", packageJsonUnrelated, 0);

	// Now we want to see a marker in project 'A' about missing dependency 'lodash', even though 'lodash' is
	// installed in project 'Unrelated':
	IFile packageJsonA = prjA.getFile(IN4JSProject.PACKAGE_JSON);
	assertIssues(packageJsonA, "line 14: Project does not exist with project ID: lodash.");

	libraryManager.installNPM(new N4JSProjectName("lodash"), new PlatformResourceURI(prjA).toFileURI(),
			new NullProgressMonitor());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	assertMarkers("package.json of project A should have no issues", packageJsonA, 0);
}
 
Example 14
Source File: SideBySideNonYarnProjectsInstallNpmPluginUITest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Install the same npm package in two independent projects.
 *
 * <pre>
 * 2) P1, P2 in Eclipse workspace; no dependency between P1, P2; P1 -> lodash; P2 -> lodash
 * 	  a) full build -> errors in both projects
 *	  b) run "npm install" in P1 -> error of P1 gone
 * </pre>
 */
@Test
public void installSamepNpmInTwoIndependentProjects() throws CoreException {

	File prjDir = new File(getResourceUri(PROBANDS, SAME_NPM_SUBFOLDER));
	IProject prjP1 = ProjectTestsUtils.importProject(prjDir, new N4JSProjectName("P1"));
	IProject prjP2 = ProjectTestsUtils.importProject(prjDir, new N4JSProjectName("P2"));
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	IFile pkgJsonP1 = prjP1.getFile(getResourceName(N4JSGlobals.PACKAGE_JSON));
	IFile pkgJsonP2 = prjP2.getFile(getResourceName(N4JSGlobals.PACKAGE_JSON));

	assertIssues(pkgJsonP1,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: lodash.");
	assertIssues(pkgJsonP2,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: lodash.");

	FileURI prjP1URI = new PlatformResourceURI(prjP1).toFileURI();
	String lodashVersion = getDependencyVersion(prjP1URI, "lodash");
	libraryManager.installNPM(new N4JSProjectName("n4js-runtime"), prjP1URI, new NullProgressMonitor());
	libraryManager.installNPM(new N4JSProjectName("lodash"), lodashVersion, prjP1URI,
			new NullProgressMonitor());
	waitForAutoBuild();
	assertIssues(pkgJsonP1); // No errors in P1 anymore
	assertIssues(pkgJsonP2,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: lodash.");
}
 
Example 15
Source File: ReproduceInvalidIndexPluginTest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void importProjects(boolean incremental) throws CoreException {
	final File testdataLocation = new File(getResourceUri(PROBANDS, PROBANDS_SUBFOLDER));
	// not executing anything, so a dummy n4js-runtime is sufficient:
	ProjectTestsUtils.importProject(testdataLocation, N4JSGlobals.N4JS_RUNTIME);
	for (String projectName : projectsToImport) {
		ProjectTestsUtils.importProject(testdataLocation, new N4JSProjectName(projectName));
	}
	if (incremental) {
		// This should really be called incrementalBuild
		IResourcesSetupUtil.waitForBuild();
	} else {
		IResourcesSetupUtil.fullBuild();
	}
}
 
Example 16
Source File: TestReactExternalLibraryPluginTest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test that the alias for react must be React.
 */
@Test
public void testReactAlias() throws Exception {
	final File projectsRoot = new File(getResourceUri(PROBANDS, WORKSPACE_LOC));
	ProjectTestsUtils.importProject(projectsRoot, PB);
	waitForAutoBuild();

	final IProject project = ResourcesPlugin.getWorkspace().getRoot()
			.getProject(PB.toEclipseProjectName().getRawName());
	assertTrue(PB + " project is not accessible.", project.isAccessible());
	final IFile clientModule = project
			.getFile(getResourceName(SRC_FOLDER, PB + "." + N4JSGlobals.N4JSX_FILE_EXTENSION));
	assertTrue(clientModule + " client module B is not accessible.", clientModule.isAccessible());

	final IFile projectDescriptionFile = project.getFile(getResourceName(IN4JSProject.PACKAGE_JSON));
	assertTrue(projectDescriptionFile + " B module is not accessible.", projectDescriptionFile.isAccessible());

	libManager.installNPM(N4JS_RUNTIME, new PlatformResourceURI(project).toFileURI(), new NullProgressMonitor());
	libManager.installNPM(PACKAGE_REACT, new PlatformResourceURI(project).toFileURI(), new NullProgressMonitor());
	libManager.installNPM(PACKAGE_N4JSD_REACT, new PlatformResourceURI(project).toFileURI(),
			new NullProgressMonitor());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	assertMarkers("Expected exactly zero errors in package.json.", projectDescriptionFile, 0);
	assertMarkers("Expected exactly 1 error in B module.", clientModule, 1);

	libManager.uninstallNPM(PACKAGE_N4JSD_REACT, new NullProgressMonitor());
	libManager.uninstallNPM(PACKAGE_REACT, new NullProgressMonitor());
	libManager.uninstallNPM(N4JS_RUNTIME, new NullProgressMonitor());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();
}
 
Example 17
Source File: GHOLD_120_XtextIndexPersistence_PluginUITest.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/***/
@Test
public void checkNoCustomResourceDescriptionsLeaksToBuilderState() throws CoreException {

	final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
	assertTrue("Test project is not accessible.", project.isAccessible());

	libraryManager.runNpmYarnInstallOnAllProjects(new NullProgressMonitor());
	syncExtAndBuild();
	// Since we do not know whether the built-in initialization or the test project import happened earlier...
	// Make sure both test module and project description file get into the index.
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();
	assertMarkers("Expected exactly 0 issues.", project, 0); // issues are in external libraries

	final Resource resource = persister.createResource();
	assertNotNull("Test resource was null.", resource);

	final Set<URI> beforeCrashBuilderState = from(builderState.getAllResourceDescriptions())
			.transform(desc -> desc.getURI()).toSet();
	final int builderStateBeforeReloadSize = Iterables.size(beforeCrashBuilderState);
	final FluentIterable<IEObjectDescription> beforeTModulesInBuilderState = from(
			builderState.getAllResourceDescriptions()).transformAndConcat(desc -> desc.getExportedObjects())
					.filter(desc -> desc.getEClass() == TypesPackage.eINSTANCE.getTModule());
	int beforeTModulesInBuilderStateSize = size(beforeTModulesInBuilderState);
	int beforeTModulesInBuilderStateWithUserDataSize = size(
			beforeTModulesInBuilderState.filter(desc -> null != desc.getUserData(USER_DATA_KEY_SERIALIZED_SCRIPT)));

	persister.saveToResource(resource, builderState.getAllResourceDescriptions());
	final Iterable<EObject> beforeCrashResource = newArrayList(resource.getContents());
	final int persistedBeforeReloadSize = resource.getContents().size();

	// Imitate VM crash with forced built-in unload and reload.
	// NOTE: at this point, the former test code simulated a crash of Eclipse by unloading and loading shipped code
	// via ShippedCodeInitializeTestHelper#tearDownBuiltIns() and #setupBuiltIns(); however, since the removal of
	// shipped code, this is no longer possible and was thus removed.

	libraryManager.runNpmYarnInstallOnAllProjects(new NullProgressMonitor());
	syncExtAndBuild();

	resource.getContents().clear();
	assertMarkers("Expected exactly 0 issues.", project, 0); // issues are in external libraries

	final Set<URI> afterCrashBuilderState = from(builderState.getAllResourceDescriptions())
			.transform(desc -> desc.getURI()).toSet();
	final int builderStateAfterReloadSize = Iterables.size(afterCrashBuilderState);

	final FluentIterable<IEObjectDescription> afterTModulesInBuilderState = from(
			builderState.getAllResourceDescriptions()).transformAndConcat(desc -> desc.getExportedObjects())
					.filter(desc -> desc.getEClass() == TypesPackage.eINSTANCE.getTModule());
	int afterTModulesInBuilderStateSize = size(afterTModulesInBuilderState);
	int afterTModulesInBuilderStateWithUserDataSize = size(
			afterTModulesInBuilderState.filter(desc -> null != desc.getUserData(USER_DATA_KEY_SERIALIZED_SCRIPT)));

	persister.saveToResource(resource, builderState.getAllResourceDescriptions());
	final Iterable<EObject> afterCrashResource = newArrayList(resource.getContents());
	final int persistedAfterReloadSize = resource.getContents().size();

	boolean validBuilderState = builderStateBeforeReloadSize == builderStateAfterReloadSize
			&& persistedBeforeReloadSize == persistedAfterReloadSize
			&& builderStateBeforeReloadSize == persistedBeforeReloadSize;

	assertTrue("Expected same number of persisted and available resource description before and after crash. Was:"
			+ "\nBuilder state before reload size: " + builderStateBeforeReloadSize
			+ "\nBuilder state after reload size: " + builderStateAfterReloadSize
			+ "\nPersisted before reload size: " + persistedBeforeReloadSize
			+ "\nPersisted after reload size: " + persistedAfterReloadSize
			+ "\nDifferences: "
			+ printDiff(beforeCrashBuilderState, afterCrashBuilderState, beforeCrashResource, afterCrashResource),
			validBuilderState);

	assertTrue(
			"Expected same number for EObject descriptions for TModules before and after crash. Before was: "
					+ beforeTModulesInBuilderStateSize + " after was: " + afterTModulesInBuilderStateSize,
			beforeTModulesInBuilderStateSize == afterTModulesInBuilderStateSize);

	assertTrue(
			"Expected same number for EObject descriptions for TModules with serialized user data before and after crash. Before was: "
					+ beforeTModulesInBuilderStateWithUserDataSize + " after was: "
					+ afterTModulesInBuilderStateWithUserDataSize,
			beforeTModulesInBuilderStateWithUserDataSize == afterTModulesInBuilderStateWithUserDataSize);

}
 
Example 18
Source File: SideBySideNonYarnProjectsInstallNpmPluginUITest.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Install different npm packages. There is dependency between projects.
 *
 * <pre>
 * 3) P1, P2 im Eclipse workspace; P1 -> P2; P1 -> lodash; P2 -> immutable like 1) above
 * 	  but also test executing P1 with runner (reference to P2 must work at runtime)
 * </pre>
 *
 * NOTE: execution of code in the (invalid) side-by-side use case is no longer supported; hence, the execution step
 * in this test was removed.
 */
@Test
public void installDifferentNpmsInTwoDependentProjects() throws CoreException {
	System.out.println("start");

	File prjDir = new File(getResourceUri(PROBANDS, DIFFERENT_NPMS_DEPENDENT_PROJECTS_SUBFOLDER));
	IProject prjP1 = ProjectTestsUtils.importProject(prjDir, new N4JSProjectName("P1"));
	IProject prjP2 = ProjectTestsUtils.importProject(prjDir, new N4JSProjectName("P2"));
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	IFile pkgJsonP1 = prjP1.getFile(getResourceName(N4JSGlobals.PACKAGE_JSON));
	IFile pkgJsonP2 = prjP2.getFile(getResourceName(N4JSGlobals.PACKAGE_JSON));

	assertIssues(pkgJsonP1,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 17: Project depends on workspace project P2 which is missing in the node_modules folder. "
					+ "Either install project P2 or introduce a yarn workspace of both of the projects.",
			"line 16: Project does not exist with project ID: lodash.");
	assertIssues(pkgJsonP2,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: immutable.");

	FileURI prjP1URI = new PlatformResourceURI(prjP1).toFileURI();
	String lodashVersion = getDependencyVersion(prjP1URI, "lodash");
	libraryManager.installNPM(new N4JSProjectName("n4js-runtime"), prjP1URI, new NullProgressMonitor());
	libraryManager.installNPM(new N4JSProjectName("lodash"), lodashVersion, prjP1URI,
			new NullProgressMonitor());
	waitForAutoBuild();

	// lodash error gone
	assertIssues(pkgJsonP1,
			"line 15: Project depends on workspace project P2 which is missing in the node_modules folder. "
					+ "Either install project P2 or introduce a yarn workspace of both of the projects.");
	assertIssues(pkgJsonP2,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: immutable.");

	FileURI prjP2URI = new PlatformResourceURI(prjP2).toFileURI();
	String immutableVersion = getDependencyVersion(prjP2URI, "immutable");
	libraryManager.installNPM(new N4JSProjectName("n4js-runtime"), prjP2URI, new NullProgressMonitor());
	libraryManager.installNPM(new N4JSProjectName("immutable"), immutableVersion, prjP2URI,
			new NullProgressMonitor());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	assertIssues(pkgJsonP1,
			"line 15: Project depends on workspace project P2 which is missing in the node_modules folder. "
					+ "Either install project P2 or introduce a yarn workspace of both of the projects.");
	assertIssues(pkgJsonP2); // No errors in P2 anymore
}
 
Example 19
Source File: SideBySideNonYarnProjectsInstallNpmPluginUITest.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Install different npm packages in two independent projects.
 *
 * <pre>
 * 1) P1, P2 in Eclipse workspace; no dependency between P1, P2; P1 -> lodash; P2 -> immutable
 * 		a) full build -> errors in both projects
 * 		b) run "npm install" in P1 -> errors in P1 gone
 * 		c) run "npm install" in P2 -> all errors gone
 * </pre>
 */
@Test
public void installDifferentNpmInTwoIndependentProjects() throws CoreException {

	File prjDir = new File(getResourceUri(PROBANDS, DIFFERENT_NPM_SUBFOLDER));
	IProject prjP1 = ProjectTestsUtils.importProject(prjDir, new N4JSProjectName("P1"));
	IProject prjP2 = ProjectTestsUtils.importProject(prjDir, new N4JSProjectName("P2"));
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	IFile pkgJsonP1 = prjP1.getFile(getResourceName(N4JSGlobals.PACKAGE_JSON));
	IFile pkgJsonP2 = prjP2.getFile(getResourceName(N4JSGlobals.PACKAGE_JSON));

	assertIssues(pkgJsonP1,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: lodash.",
			"line 17: Project depends on workspace project P2 which is missing in the node_modules folder. "
					+ "Either install project P2 or introduce a yarn workspace of both of the projects.");
	assertIssues(pkgJsonP2,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: immutable.");

	FileURI prjP1URI = new PlatformResourceURI(prjP1).toFileURI();
	String lodashVersion = getDependencyVersion(prjP1URI, "lodash");
	libraryManager.installNPM(new N4JSProjectName("n4js-runtime"), prjP1URI, new NullProgressMonitor());
	libraryManager.installNPM(new N4JSProjectName("lodash"), lodashVersion, prjP1URI,
			new NullProgressMonitor());
	waitForAutoBuild();

	// no lodash error anymore
	assertIssues(pkgJsonP1,
			"line 15: Project depends on workspace project P2 which is missing in the node_modules folder. "
					+ "Either install project P2 or introduce a yarn workspace of both of the projects.");
	assertIssues(pkgJsonP2,
			"line 15: Project does not exist with project ID: n4js-runtime.",
			"line 16: Project does not exist with project ID: immutable.");

	FileURI prjP2URI = new PlatformResourceURI(prjP2).toFileURI();
	String immutableVersion = getDependencyVersion(prjP2URI, "immutable");
	libraryManager.installNPM(new N4JSProjectName("n4js-runtime"), prjP2URI, new NullProgressMonitor());
	libraryManager.installNPM(new N4JSProjectName("immutable"), immutableVersion, prjP2URI,
			new NullProgressMonitor());
	waitForAutoBuild();

	assertIssues(pkgJsonP1,
			"line 15: Project depends on workspace project P2 which is missing in the node_modules folder. "
					+ "Either install project P2 or introduce a yarn workspace of both of the projects.");
	assertIssues(pkgJsonP2); // No errors in P2 anymore
}
 
Example 20
Source File: TestReactExternalLibraryPluginTest.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Imports {@value #PA} project, checks for validation errors, installs {@code React npm} package, checks that
 * errors are gone. Then verify that running React/JSX code is successful.
 */
@Test
public void testInstallReactNpmThenRun() throws Exception {
	final File projectsRoot = new File(getResourceUri(PROBANDS, WORKSPACE_LOC));
	ProjectTestsUtils.importProject(projectsRoot, PA);
	waitForAutoBuild();

	final IProject project = ResourcesPlugin.getWorkspace().getRoot()
			.getProject(PA.toEclipseProjectName().getRawName());
	assertTrue(PA + " project is not accessible.", project.isAccessible());
	final IFile clientModule = project
			.getFile(getResourceName(SRC_FOLDER, PA + "." + N4JSGlobals.N4JSX_FILE_EXTENSION));
	assertTrue(clientModule + " client module is not accessible.", clientModule.isAccessible());

	final IFile projectDescriptionFile = project.getFile(getResourceName(IN4JSProject.PACKAGE_JSON));
	assertTrue(projectDescriptionFile + " client module is not accessible.", projectDescriptionFile.isAccessible());

	assertIssues(clientModule,
			"line 12: Cannot resolve plain module specifier (without project name as first segment): no matching module found.",
			"line 14: Cannot resolve JSX implementation.",
			"line 15: Couldn't resolve reference to IdentifiableElement 'Component'.");
	assertIssues(projectDescriptionFile,
			"line 5: Project does not exist with project ID: n4js-runtime.",
			"line 6: Project does not exist with project ID: react.",
			"line 7: Project does not exist with project ID: @n4jsd/react.");

	libManager.installNPM(N4JS_RUNTIME, new PlatformResourceURI(project).toFileURI(), new NullProgressMonitor());
	libManager.installNPM(PACKAGE_REACT, new PlatformResourceURI(project).toFileURI(), new NullProgressMonitor());
	libManager.installNPM(PACKAGE_N4JSD_REACT, new PlatformResourceURI(project).toFileURI(),
			new NullProgressMonitor());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();

	assertMarkers("Expected exactly zero errors in package.json.", projectDescriptionFile, 0);
	assertMarkers("Expected exactly no errors in client module.", clientModule, 0);

	final ProcessResult result = runClient();
	assertTrue("Unexpected output after running the client module: " + result.getStdOut(),
			result.getStdOut().contains("Symbol(react.element)"));

	libManager.uninstallNPM(PACKAGE_N4JSD_REACT, new NullProgressMonitor());
	libManager.uninstallNPM(PACKAGE_REACT, new NullProgressMonitor());
	libManager.uninstallNPM(N4JS_RUNTIME, new NullProgressMonitor());
	IResourcesSetupUtil.fullBuild();
	waitForAutoBuild();
}