use of org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl in project xtext-eclipse by eclipse.
the class Storage2UriMapperJdtImplTest 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.notindexed", "//empty")), true, monitor());
addJarToClasspath(project, file);
Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("bar.notindexed");
fileInJar.setParent(foo);
File jarFile = file.getRawLocation().toFile();
assertTrue("exists", jarFile.exists());
assertTrue("delete", jarFile.delete());
URI uri = impl.getUri(fileInJar);
assertEquals("archive:platform:/resource/foo/foo.jar!/foo/bar.notindexed", uri.toString());
}
use of org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl in project xtext-eclipse by eclipse.
the class Storage2UriMapperJdtImplTest method testBug463258_04.
@Test
public void testBug463258_04() throws Exception {
IFolder externalFolder = createExternalFolder("externalFolder");
IJavaProject project = createJavaProject("foo");
addExternalFolderToClasspath(project, externalFolder);
Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
IPackageFragmentRoot root = project.getPackageFragmentRoot(externalFolder);
IPackageFragment foo = root.getPackageFragment("foo");
NonJavaResource fileInFolder = new NonJavaResource(foo, externalFolder.getFile("foo/does.notexist"));
externalFolder.delete(true, null);
URI uri = impl.getUri(fileInFolder);
assertNull(uri);
}
use of org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl in project xtext-eclipse by eclipse.
the class Storage2UriMapperJdtImplTest 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);
Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("unknown");
JarEntryFile fileInJar = new JarEntryFile("doesNotExist.notindexed");
fileInJar.setParent(foo);
URI uri = impl.getUri(fileInJar);
assertEquals("archive:platform:/resource/foo/foo.jar!/unknown/doesNotExist.notindexed", uri.toString());
}
use of org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl in project xtext-eclipse by eclipse.
the class Storage2UriMapperJdtImplTest method testResourceInJar.
@Test
public void testResourceInJar() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.indexed", "//empty"), new TextFile("foo/bar.notIndexed", "//empty")), true, monitor());
// we do cache per timestamp - test is to fast and tries to update the file content in the very same millisecond
// that's why we fake the timestamp here
file.setLocalTimeStamp(123L);
addJarToClasspath(project, file);
Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
Map<URI, IStorage> rootData = impl.getAllEntries(root);
assertEquals(1, rootData.size());
assertEquals("archive:platform:/resource/foo/foo.jar!/foo/bar.indexed", rootData.keySet().iterator().next().toString());
file.setContents(jarInputStream(new TextFile("foo/bar.notindexed", "//empty"), new TextFile("foo/bar.notIndexed", "//empty")), IResource.FORCE, monitor());
rootData = impl.getAllEntries(root);
assertTrue(rootData.isEmpty());
}
use of org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl in project xtext-eclipse by eclipse.
the class Storage2UriMapperJdtImplTest method testBug463258_03b.
@Test
public void testBug463258_03b() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.notindexed", "//empty")), true, monitor());
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());
URI uri = impl.getUri(fileInJar);
assertNull(uri);
}
Aggregations