org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil Java Examples
The following examples show how to use
org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.
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: PerformanceTestProjectSetup.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static void setUp() throws Exception { testProject = createJavaProject("performance.test.project", new String[] { JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature" } ); new ToggleXtextNatureCommand().toggleNature(testProject.getProject()); IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(testProject, "src"); JavaProjectSetupUtil.addSourceFolder(testProject, "xtend-gen"); List<String> filesToCopy = readResource("/files.list"); for(String fileToCopy: filesToCopy) { IPath filePath = new Path(fileToCopy); IFolder packageFolder = sourceFolder.getFolder(filePath.removeLastSegments(1)); if (!packageFolder.exists()) createFolderRecursively(packageFolder); List<String> content = readResource(fileToCopy); String contentAsString = Strings.concat("\n", content); String fileName = filePath.lastSegment(); createFile(fileName.substring(0, fileName.length() - ".txt".length()), packageFolder, contentAsString); } waitForBuild(); }
Example #2
Source File: JdtClasspathUriResolverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testClasspathUriForFileInWorkspaceInOtherProjectRoot() throws Exception { _javaProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME); IJavaProject otherProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME + "2"); try { JavaProjectSetupUtil.addProjectReference(_javaProject, otherProject); _project = otherProject.getProject(); _project.getFolder("model").create(true, true, null); PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), "/testfiles/" + MODEL_FILE, _project, "model/" + MODEL_FILE); URI classpathUri = URI.createURI("classpath:/model/" + MODEL_FILE + "#/"); String expectedUri = "platform:/resource/" + TEST_PROJECT_NAME + "2/model/" + MODEL_FILE + "#/"; URI normalizedUri = _resolver.resolve(_javaProject, classpathUri); assertResourceLoadable(classpathUri, normalizedUri, expectedUri); } finally { otherProject.getProject().delete(true, null); } }
Example #3
Source File: Storage2UriMapperJavaImplTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testOnCloseOpenRemoveProject() { try { Assert.assertEquals(0, this.getCachedPackageFragmentRootData().size()); final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject"); final IJavaProject project2 = JavaProjectSetupUtil.createJavaProject("testProject2"); final int sizeBefore = this.getCachedPackageFragmentRootData().size(); final IFile file = this.createJar(project); JavaProjectSetupUtil.addJarToClasspath(project, file); JavaProjectSetupUtil.addJarToClasspath(project2, file); this.assertBothProjects(sizeBefore); project2.getProject().close(IResourcesSetupUtil.monitor()); this.assertFirstProject(sizeBefore); project.getProject().close(IResourcesSetupUtil.monitor()); this.assertNonProjects(); project.getProject().open(IResourcesSetupUtil.monitor()); this.assertFirstProject(sizeBefore); project2.getProject().open(IResourcesSetupUtil.monitor()); this.assertBothProjects(sizeBefore); project.getProject().delete(true, IResourcesSetupUtil.monitor()); project2.getProject().delete(true, IResourcesSetupUtil.monitor()); this.assertNonProjects(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #4
Source File: Storage2UriMapperJavaImplTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testOnRemoveTwoProjects() { try { Assert.assertEquals(0, this.getCachedPackageFragmentRootData().size()); final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject"); final IJavaProject project2 = JavaProjectSetupUtil.createJavaProject("testProject2"); final int sizeBefore = this.getCachedPackageFragmentRootData().size(); final IFile file = this.createJar(project); JavaProjectSetupUtil.addJarToClasspath(project, file); JavaProjectSetupUtil.addJarToClasspath(project2, file); this.assertBothProjects(sizeBefore); final WorkspaceModifyOperation op = new WorkspaceModifyOperation() { @Override protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { project.getProject().delete(true, monitor); project2.getProject().delete(true, monitor); } }; op.run(IResourcesSetupUtil.monitor()); this.assertNonProjects(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #5
Source File: GrammarLinkingInWorkspaceTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testReferencedGrammarIsPlatformResourceURI() throws Exception { IJavaProject project = JavaProjectSetupUtil.createJavaProject("p1"); IFile grammar1 = project.getProject().getFile("src/Grammar1.xtext"); grammar1.create(new StringInputStream("grammar Grammar1 MyRule : 'foo';"), true, null); Injector injector = Activator.getDefault().getInjector(org.eclipse.xtext.xtext.ui.internal.Activator.ORG_ECLIPSE_XTEXT_XTEXT); XtextResourceSetProvider resourceSetProvider = injector.getInstance(XtextResourceSetProvider.class); ResourceSet resourceSet = resourceSetProvider.get(project.getProject()); XtextResourceFactory resourceFactory = injector.getInstance(XtextResourceFactory.class); Resource resource = resourceFactory.createResource(URI.createURI("synthetic://MyGrammar.xtext")); resourceSet.getResources().add(resource); resource.load(new StringInputStream("grammar g2 with Grammar1 OtherRule : MyRule ;"), null); EcoreUtil.resolveAll(resource); assertEquals(2, resourceSet.getResources().size()); assertTrue(resourceSet.getResources().get(1).getURI().isPlatformResource()); }
Example #6
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testNewlyAddedReexportedSource() throws Exception { IJavaProject foo = createJavaProject("foo"); IJavaProject bar = createJavaProject("bar"); IJavaProject baz = createJavaProject("baz"); addNature(foo.getProject(), XtextProjectHelper.NATURE_ID); addNature(bar.getProject(), XtextProjectHelper.NATURE_ID); addNature(baz.getProject(), XtextProjectHelper.NATURE_ID); addToClasspath(bar, JavaCore.newProjectEntry(foo.getPath(), true)); addToClasspath(baz, JavaCore.newProjectEntry(bar.getPath(), false)); addSourceFolder(baz, "src"); IFile bazFile = createFile("baz/src/Baz"+F_EXT, "object Baz references Foo"); build(); assertEquals(1,countMarkers(bazFile)); IFile file = foo.getProject().getFile("foo.jar"); file.create(JavaProjectSetupUtil.jarInputStream(new TextFile("foo/Foo"+F_EXT, "object Foo")), true, monitor()); IClasspathEntry newLibraryEntry = JavaCore.newLibraryEntry(file.getFullPath(), null, null,true); addToClasspath(foo, newLibraryEntry); build(); assertEquals(0,countMarkers(bazFile)); }
Example #7
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testReexportedJarRemoved() throws Exception { IJavaProject foo = createJavaProject("foo"); IJavaProject bar = createJavaProject("bar"); IJavaProject baz = createJavaProject("baz"); addNature(foo.getProject(), XtextProjectHelper.NATURE_ID); addNature(bar.getProject(), XtextProjectHelper.NATURE_ID); addNature(baz.getProject(), XtextProjectHelper.NATURE_ID); IFile file = foo.getProject().getFile("foo.jar"); file.create(JavaProjectSetupUtil.jarInputStream(new TextFile("foo/Foo"+F_EXT, "object Foo")), true, monitor()); IClasspathEntry newLibraryEntry = JavaCore.newLibraryEntry(file.getFullPath(), null, null,true); addToClasspath(foo, newLibraryEntry); addToClasspath(bar, JavaCore.newProjectEntry(foo.getPath(), true)); addToClasspath(baz, JavaCore.newProjectEntry(bar.getPath(), false)); addSourceFolder(baz, "src"); IFile bazFile = createFile("baz/src/Baz"+F_EXT, "object Baz references Foo"); build(); assertEquals(0,countMarkers(bazFile)); deleteClasspathEntry(foo, newLibraryEntry.getPath()); build(); assertEquals(1, countMarkers(bazFile)); assertEquals(1, countResourcesInIndex()); Iterator<IReferenceDescription> references = getContainedReferences(URI.createPlatformResourceURI(bazFile.getFullPath().toString(),true)).iterator(); assertFalse(references.hasNext()); }
Example #8
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testJarOnTwoProjectsRemovedFromOne() throws Exception { IJavaProject foo = createJavaProject("foo"); IJavaProject bar = createJavaProject("bar"); IJavaProject baz = createJavaProject("baz"); addNature(foo.getProject(), XtextProjectHelper.NATURE_ID); addNature(bar.getProject(), XtextProjectHelper.NATURE_ID); addNature(baz.getProject(), XtextProjectHelper.NATURE_ID); IFile file = foo.getProject().getFile("foo.jar"); file.create(JavaProjectSetupUtil.jarInputStream(new TextFile("foo/Foo"+F_EXT, "object Foo")), true, monitor()); IClasspathEntry newLibraryEntry = JavaCore.newLibraryEntry(file.getFullPath(), null, null,true); addToClasspath(foo, newLibraryEntry); addToClasspath(bar, JavaCore.newProjectEntry(foo.getPath(), true)); addToClasspath(bar, JavaCore.newLibraryEntry(file.getFullPath(), null, null,true)); addToClasspath(baz, JavaCore.newProjectEntry(bar.getPath(), false)); addSourceFolder(baz, "src"); IFile bazFile = createFile("baz/src/Baz"+F_EXT, "object Baz references Foo"); build(); assertEquals(0,countMarkers(bazFile)); assertEquals(2, countResourcesInIndex()); deleteClasspathEntry(foo, newLibraryEntry.getPath()); build(); assertEquals(0,countMarkers(bazFile)); assertEquals(2, countResourcesInIndex()); }
Example #9
Source File: IntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@SuppressWarnings("restriction") @Test public void testBuildOrderIsWrong() throws Exception { foo_project = createJavaProjectWithRootSrc("foo"); bar_project = createJavaProjectWithRootSrc("bar"); org.eclipse.core.internal.resources.Workspace workspace = (org.eclipse.core.internal.resources.Workspace) ResourcesPlugin.getWorkspace(); IBuildConfiguration[] buildOrder = workspace.getBuildOrder(); assertEquals(bar_project.getProject(), buildOrder[0].getProject()); assertEquals(foo_project.getProject(), buildOrder[1].getProject()); // here we do only add a classpath entry and no core.resources project reference JavaProjectSetupUtil.addProjectReference(bar_project, foo_project); buildOrder = workspace.getBuildOrder(); assertEquals(bar_project.getProject(), buildOrder[0].getProject()); assertEquals(foo_project.getProject(), buildOrder[1].getProject()); }
Example #10
Source File: AbstractXbaseUITestCase.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public static IProject createPluginProject(String name) throws CoreException { Injector injector = XbaseActivator.getInstance().getInjector("org.eclipse.xtext.xbase.Xbase"); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setProjectName(name); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds( JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); projectFactory.addRequiredBundles(Collections.singletonList("org.eclipse.xtext.xbase.lib")); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); JavaProjectSetupUtil.makeJava8Compliant(JavaCore.create(result)); JavaProjectSetupUtil.setUnixLineEndings(result); return result; }
Example #11
Source File: WorkbenchTestHelper.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static IProject createPluginProject(String name, JavaVersion javaVersion, String... requiredBundles) throws CoreException { Injector injector = XtendActivator.getInstance().getInjector(XtendActivator.ORG_ECLIPSE_XTEND_CORE_XTEND); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setProjectName(name); projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name()); projectFactory.setBreeToUse(getBree(javaVersion)); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID, JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"); projectFactory.addProjectNatures( XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"); projectFactory.addRequiredBundles(newArrayList(requiredBundles)); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); IJavaProject javaProject = JavaCore.create(result); if (javaVersion == null) JavaProjectSetupUtil.makeJava8Compliant(javaProject); else makeCompliantFor(javaProject, javaVersion); JavaProjectSetupUtil.addJreClasspathEntry(javaProject); return result; }
Example #12
Source File: ContentAssistTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static IProject createPluginProject(String name) throws CoreException { Injector injector = XtendActivator.getInstance().getInjector("org.eclipse.xtend.core.Xtend"); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.setProjectName(name); projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name()); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds( JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); projectFactory.addRequiredBundles(Lists.newArrayList( "org.eclipse.xtext.xbase.lib", "org.eclipse.xtend.lib")); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); JavaProjectSetupUtil.makeJava8Compliant(JavaCore.create(result)); return result; }
Example #13
Source File: XtendLibClasspathAdderTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddToJavaProject() throws Exception { javaProjectFactory.setProjectName("test"); javaProjectFactory.addFolders(Collections.singletonList("src")); javaProjectFactory.addBuilderIds(JavaCore.BUILDER_ID, XtextProjectHelper.BUILDER_ID); javaProjectFactory.addProjectNatures(JavaCore.NATURE_ID, XtextProjectHelper.NATURE_ID); IProject project = javaProjectFactory.createProject(null, null); IJavaProject javaProject = JavaCore.create(project); JavaProjectSetupUtil.makeJava8Compliant(javaProject); IFile file = project.getFile("src/Foo.xtend"); file.create(new StringInputStream("import org.eclipse.xtend.lib.annotations.Accessors class Foo { @Accessors int bar }"), true, null); syncUtil.waitForBuild(null); markerAssert.assertErrorMarker(file, IssueCodes.XBASE_LIB_NOT_ON_CLASSPATH); adder.addLibsToClasspath(javaProject, null); waitForAutoBuild(); syncUtil.waitForBuild(null); markerAssert.assertNoErrorMarker(file); }
Example #14
Source File: XtendLibClasspathAdderTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddToPlugin() throws Exception { pluginProjectFactory.setProjectName("test"); pluginProjectFactory.addFolders(Collections.singletonList("src")); pluginProjectFactory.addBuilderIds(JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); pluginProjectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); IProject project = pluginProjectFactory.createProject(null, null); IJavaProject javaProject = JavaCore.create(project); JavaProjectSetupUtil.makeJava8Compliant(javaProject); IFile file = project.getFile("src/Foo.xtend"); file.create(new StringInputStream("import org.eclipse.xtend.lib.annotations.Accessors class Foo { @Accessors int bar }"), true, null); syncUtil.waitForBuild(null); markerAssert.assertErrorMarker(file, IssueCodes.XBASE_LIB_NOT_ON_CLASSPATH); adder.addLibsToClasspath(javaProject, null); waitForAutoBuild(); markerAssert.assertNoErrorMarker(file); }
Example #15
Source File: XtendLibClasspathAdderTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddToBrokenPlugin() throws Exception { pluginProjectFactory.setProjectName("test"); pluginProjectFactory.addFolders(Collections.singletonList("src")); pluginProjectFactory.addBuilderIds(JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); pluginProjectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); IProject project = pluginProjectFactory.createProject(null, null); IJavaProject javaProject = JavaCore.create(project); JavaProjectSetupUtil.makeJava8Compliant(javaProject); project.findMember("META-INF").delete(true, null); IFile file = project.getFile("src/Foo.xtend"); file.create(new StringInputStream("import org.eclipse.xtend.lib.annotations.Accessors class Foo { @Accessors int bar }"), true, null); syncUtil.waitForBuild(null); markerAssert.assertErrorMarker(file, IssueCodes.XBASE_LIB_NOT_ON_CLASSPATH); adder.addLibsToClasspath(javaProject, null); waitForAutoBuild(); syncUtil.waitForBuild(null); markerAssert.assertNoErrorMarker(file); }
Example #16
Source File: Bug462915Test.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public IJavaProject getJavaProject(final ResourceSet resourceSet) { IJavaProject javaProject = JavaProjectSetupUtil.findJavaProject(Bug462915Test.NO_GUICE_PROJECT_NAME); if (((javaProject == null) || (!javaProject.exists()))) { try { this.noGuiceProject = WorkbenchTestHelper.createPluginProject(Bug462915Test.NO_GUICE_PROJECT_NAME, ((String[])Conversions.unwrapArray(this.getTestProjectRequiredBundles(), String.class))); javaProject = JavaProjectSetupUtil.findJavaProject(Bug462915Test.NO_GUICE_PROJECT_NAME); } catch (final Throwable _t) { if (_t instanceof CoreException) { final CoreException e = (CoreException)_t; String _message = e.getMessage(); String _plus = ("cannot create java project due to: " + _message); String _plus_1 = (_plus + " / "); String _plus_2 = (_plus_1 + e); Assert.fail(_plus_2); } else { throw Exceptions.sneakyThrow(_t); } } } return javaProject; }
Example #17
Source File: SameClassNamesTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public IProject createPluginProject(final String name, final String... requiredBundles) throws CoreException { final PluginProjectFactory projectFactory = this.projectFactoryProvider.get(); projectFactory.setProjectName(name); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.addFolders(Collections.<String>singletonList("src")); projectFactory.addBuilderIds( XtextProjectHelper.BUILDER_ID, JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"); projectFactory.addProjectNatures( XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"); projectFactory.addRequiredBundles(((List<String>)Conversions.doWrapArray(requiredBundles))); projectFactory.addExportedPackages(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("com.acme"))); NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor(); final IProject result = projectFactory.createProject(_nullProgressMonitor, null); final IJavaProject javaProject = JavaCore.create(result); WorkbenchTestHelper.makeCompliantFor(javaProject, JavaVersion.JAVA8); JavaProjectSetupUtil.addJreClasspathEntry(javaProject); return result; }
Example #18
Source File: XtendEditorChangingClasspathTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddXtendLibWithDirtyEditor() { try { final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject"); final IFile file = IResourcesSetupUtil.createFile("testProject/src/Foo.xtend", "class Foo {}"); IResourcesSetupUtil.waitForBuild(); final XtextEditor editor = this.workbenchTestHelper.openEditor(file); final Procedure0 _function = () -> { this.changeContent(editor, "{}", "{ def foo () {} }"); }; this.waitForChangeEvent(_function); this.assertAddLibsToClasspath(project); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #19
Source File: Bug456868Test.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * https://bugs.eclipse.org/bugs/show_bug.cgi?id=452821 */ @Test public void testProjectWithWhitespaceInNameWorks() { try { this.project = JavaProjectSetupUtil.createJavaProject("my project"); JavaProjectSetupUtil.makeJava8Compliant(this.project); NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor(); this.libAdder.addLibsToClasspath(this.project, _nullProgressMonitor); this.natureAdder.toggleNature(this.project.getProject()); StringConcatenation _builder = new StringConcatenation(); _builder.append("class MyClass {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("}"); _builder.newLine(); IResourcesSetupUtil.createFile("my project/src/MyClass.xtend", _builder.toString()); IResourcesSetupUtil.waitForBuild(); IResourcesSetupUtil.assertNoErrorsInWorkspace(); final IResource generatedJava = IResourcesSetupUtil.file("my project/xtend-gen/MyClass.java"); Assert.assertTrue(generatedJava.exists()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #20
Source File: WorkbenchTestHelper.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * @return a {@link Pair}, where the <code>key</code> is the BREE that was set and the <code>value</code> indicates that the BREE was changed. */ public static Pair<String, Boolean> changeBree(IJavaProject javaProject, final JavaVersion javaVersion) throws Exception { final AtomicReference<String> bree = new AtomicReference<String>(); boolean changed = changeManifest(javaProject.getProject(), new Function<MergeableManifest2, Boolean>() { @Override public Boolean apply(MergeableManifest2 mf) { mf.setBREE(getBree(javaVersion)); return mf.isModified(); } }); if (changed) { JavaProjectSetupUtil.addJreClasspathEntry(javaProject, bree.get()); } return Pair.of(bree.get(), changed); }
Example #21
Source File: ActiveAnnotationsInSameProjectTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testActiveAnnotationInSameProjectInJar() { try { final IJavaProject project = JavaCore.create( WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME, "com.google.inject", "org.eclipse.xtend.lib", "org.eclipse.xtext.xbase.lib")); final IFile jarFile = this.copyFile(project, "Bug414992.jar", "Bug414992.jar"); JavaProjectSetupUtil.addJarToClasspath(project, jarFile); StringConcatenation _builder = new StringConcatenation(); _builder.append("package mypack"); _builder.newLine(); _builder.newLine(); _builder.append("import myannotation.Bug414992"); _builder.newLine(); _builder.newLine(); _builder.append("@Bug414992 class Client {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.workbenchTestHelper.createFile("mypack/Client.xtend", _builder.toString()); IResourcesSetupUtil.waitForBuild(); this.assertNoErrorsInWorkspace(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #22
Source File: Bug330096Test.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected IProject createPluginProject(String name) throws CoreException { Injector injector = TestlanguagesActivator.getInstance().getInjector("org.eclipse.xtext.testlanguages.backtracking.SimpleBeeLangTestLanguage"); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setProjectName(name); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds( JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); JavaProjectSetupUtil.setUnixLineEndings(result); return result; }
Example #23
Source File: AbstractXtendUITestCase.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void setJavaVersion(JavaVersion javaVersion) throws Exception { IJavaProject javaProject = JavaProjectSetupUtil.findJavaProject(WorkbenchTestHelper.TESTPROJECT_NAME); Pair<String,Boolean> result = WorkbenchTestHelper.changeBree(javaProject, javaVersion); IExecutionEnvironment execEnv = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(result.getKey()); Assume.assumeNotNull("Execution environment not found for: " + javaVersion.getLabel(), execEnv); Assume.assumeTrue("No compatible VM was found for: " + javaVersion.getLabel(), execEnv.getCompatibleVMs().length > 0); if(result.getValue()) { WorkbenchTestHelper.makeCompliantFor(javaProject, javaVersion); IResourcesSetupUtil.reallyWaitForAutoBuild(); } }
Example #24
Source File: AutoEditTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected IProject createPluginProject(String name) throws CoreException { final IProject[] result = new IProject[1]; IWorkspaceRunnable creatorTask = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { Injector injector = XtendActivator.getInstance().getInjector("org.eclipse.xtend.core.Xtend"); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.setProjectName(name); projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name()); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds( JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); projectFactory.addRequiredBundles(newArrayList("org.eclipse.xtext.xbase.lib")); IProject project = projectFactory.createProject(new NullProgressMonitor(), null); JavaProjectSetupUtil.setUnixLineEndings(project); result[0] = project; } }; ResourcesPlugin.getWorkspace().run(creatorTask, new NullProgressMonitor()); return result[0]; }
Example #25
Source File: WorkspaceClasspathUriResolverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testClasspathUriForFileInWorkspace() throws Exception { _javaProject = JavaProjectSetupUtil.createJavaProject(TEST_PROJECT_NAME); _project = _javaProject.getProject(); PluginUtil.copyFileToWorkspace(TestsActivator.getInstance(), "/testfiles/" + MODEL_FILE, _project, "src/" + MODEL_FILE); URI classpathUri = URI.createURI("classpath:/" + MODEL_FILE); String expectedUri = "platform:/resource/" + TEST_PROJECT_NAME + "/src/" + MODEL_FILE; URI normalizedUri = _resolver.resolve(_project, classpathUri); assertResourceLoadable(classpathUri, normalizedUri, expectedUri); }
Example #26
Source File: Bug369087Test.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected static IProject createPluginProject(String name) throws CoreException { Injector injector = TestlanguagesActivator.getInstance().getInjector(TestlanguagesActivator.ORG_ECLIPSE_XTEXT_TESTLANGUAGES_XTEXTGRAMMAR_XTEXTGRAMMARTESTLANGUAGE); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.setProjectName(name); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID); projectFactory.addProjectNatures(XtextProjectHelper.NATURE_ID); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); JavaProjectSetupUtil.setUnixLineEndings(result); return result; }
Example #27
Source File: Bug462915Test.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@After @Override public void tearDown() throws Exception { if ((this.noGuiceProject != null)) { JavaProjectSetupUtil.deleteProject(this.noGuiceProject); } super.tearDown(); }
Example #28
Source File: MarkOccurrencesTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); IJavaProject project = JavaProjectSetupUtil.createJavaProject("MarkOccurrencesTest"); IResourcesSetupUtil.addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IResourcesSetupUtil.waitForBuild(); setMarkOccurrences(false); }
Example #29
Source File: BuildAffectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private IFile createClientProjectFile(final String name, final CharSequence content) { try { IFile _xblockexpression = null; { this.clientProject = WorkbenchTestHelper.createPluginProject("test.client"); JavaProjectSetupUtil.addProjectReference(JavaCore.create(this.clientProject), JavaCore.create(this.workbenchTestHelper.getProject())); Path _path = new Path((("test.client/src/" + name) + ".xtend")); _xblockexpression = IResourcesSetupUtil.createFile(_path, content.toString()); } return _xblockexpression; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #30
Source File: XtendJavaElementDelegateJunitLaunchTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Before public void setup() { try { JavaProjectSetupUtil.createJavaProject(this.getProjectName()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }