use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_02.
@Test
public void testBug463258_02() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("do/not", "care")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("unknown");
JarEntryFile fileInJar = new JarEntryFile("doesNotExist.testlanguage");
fileInJar.setParent(foo);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
Resource resource = factory.createResource(editorInput);
assertNotNull(resource);
try {
resource.load(null);
} catch (IOException e) {
// expected
}
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_03a.
@Test
public void testBug463258_03a() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage");
fileInJar.setParent(foo);
File jarFile = file.getRawLocation().toFile();
assertTrue("exists", jarFile.exists());
assertTrue("delete", jarFile.delete());
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
Resource resource = factory.createResource(editorInput);
assertNotNull(resource);
try {
resource.load(null);
} catch (IOException e) {
// expected
}
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_03c.
@Test(expected = CoreException.class)
public void testBug463258_03c() throws Throwable {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = JarPackageFragmentRootTestUtil.getJarPackageFragmentRoot(file, (JavaProject) project);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage");
fileInJar.setParent(foo);
File jarFile = file.getLocation().toFile();
assertTrue("exists", jarFile.exists());
assertTrue("delete", jarFile.delete());
// simulate an automated refresh
file.refreshLocal(IResource.DEPTH_ONE, null);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
try {
factory.createResource(editorInput);
} catch (WrappedException e) {
throw e.getCause();
}
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class IntegrationTest 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(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));
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());
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class IntegrationTest method testTwoJars.
@Test
public void testTwoJars() 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());
IFile file2 = project.getProject().getFile("bar.jar");
file2.create(jarInputStream(new TextFile("foo/Bar" + F_EXT, "object Foo"), new TextFile("foo/Bar2" + F_EXT, "object Bar references Foo")), true, monitor());
addJarToClasspath(project, file);
addJarToClasspath(project, file2);
assertEquals(3, countResourcesInIndex());
}
Aggregations