use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class Storage2UriMapperJdtImplTest method testBug463258_03c.
@Test
public void testBug463258_03c() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.notindexed", "//empty")), true, monitor());
addJarToClasspath(project, file);
Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
IPackageFragmentRoot root = JarPackageFragmentRootTestUtil.getJarPackageFragmentRoot(file, (JavaProject) project);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("bar.notindexed");
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);
URI uri = impl.getUri(fileInJar);
assertNull(uri);
}
use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_03b.
@Test(expected = CoreException.class)
public void testBug463258_03b() throws Throwable {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor());
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());
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 JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_01.
@Test
public void testBug463258_01() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/A.testlanguage", "//empty")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("A.testlanguage");
fileInJar.setParent(foo);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
Resource resource = factory.createResource(editorInput);
assertNotNull(resource);
resource.load(null);
}
Aggregations