use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class IntegrationTest method testFileInJar.
@Test
public void testFileInJar() throws Exception {
IJavaProject project = createJavaProject("foo");
addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/Bar" + F_EXT, "object Foo")), true, monitor());
assertEquals(0, countResourcesInIndex());
addJarToClasspath(project, file);
assertEquals(1, countResourcesInIndex());
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class IntegrationTest method testEvents.
@Test
public void testEvents() throws Exception {
IJavaProject project = createJavaProject("foo");
addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
IProject someProject = createProject("bar");
IFile file = someProject.getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/Bar" + F_EXT, "object Foo")), true, monitor());
file.setLocalTimeStamp(100L);
addJarToClasspath(project, file);
someProject.delete(true, monitor());
build();
assertEmptyIndex();
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class ProfilerAbstractBuilderTest method testFullBuildBigProjectWithRefeernceToJar.
@Test
public void testFullBuildBigProjectWithRefeernceToJar() throws Exception {
IJavaProject project = workspace.createJavaProject("foo");
workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
IFolder folder = project.getProject().getFolder("src");
IFile jarFile = project.getProject().getFile("my.jar");
jarFile.create(jarInputStream(new TextFile("my/element" + F_EXT, "object ReferenceMe")), true, workspace.monitor());
workspace.addJarToClasspath(project, jarFile);
int NUM_FILES = 2000;
IFile[] files = new IFile[NUM_FILES];
StopWatch timer = new StopWatch();
for (int i = 0; i < NUM_FILES; i++) {
IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
files[i] = file;
String contents = "object Foo" + i + " references ReferenceMe";
file.create(new StringInputStream(contents), true, workspace.monitor());
}
logAndReset("Creating files", timer);
workspace.build();
logAndReset("Auto build", timer);
IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
for (IMarker iMarker : iMarkers) {
System.out.println(iMarker.getAttribute(IMarker.MESSAGE));
}
assertEquals(0, iMarkers.length);
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class SimpleProjectsIntegrationTest method testReexportedJarRemoved.
@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());
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class SimpleProjectsIntegrationTest method testReexportedSource.
@Test
public void testReexportedSource() 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));
assertEquals(2, countResourcesInIndex());
Iterator<IReferenceDescription> references = getContainedReferences(URI.createPlatformResourceURI(bazFile.getFullPath().toString(), true)).iterator();
IReferenceDescription next = references.next();
assertFalse(references.hasNext());
assertEquals("platform:/resource/baz/src/Baz.buildertestlanguage#/", next.getSourceEObjectUri().toString());
assertEquals("archive:platform:/resource/foo/foo.jar!/foo/Foo.buildertestlanguage#/", next.getTargetEObjectUri().toString());
assertEquals(-1, next.getIndexInList());
assertEquals(BuilderTestLanguagePackage.Literals.ELEMENT__REFERENCES, next.getEReference());
}
Aggregations