public void testVirtualFolderInLinkedFolder() { // setup handles IFolder topFolder = existingProject.getFolder("topFolder"); IFolder linkedFolder = topFolder.getFolder("linkedFolder"); IFolder subFolder = linkedFolder.getFolder("subFolder"); IFolder virtualFolder = subFolder.getFolder("virtualFolder"); IPath linkedFolderLocation = getRandomLocation(); IPath subFolderLocation = linkedFolderLocation.append(subFolder.getName()); try { try { // create the structure on disk linkedFolderLocation.toFile().mkdir(); subFolderLocation.toFile().mkdir(); // create the structure in the workspace ensureExistsInWorkspace(topFolder, true); linkedFolder.createLink(linkedFolderLocation, IResource.NONE, getMonitor()); virtualFolder.create(IResource.VIRTUAL, true, getMonitor()); } catch (CoreException e) { fail("1.0", e); } // assert locations assertEquals("2.0", linkedFolderLocation, linkedFolder.getLocation()); assertEquals( "3.0", linkedFolderLocation.append(subFolder.getName()), subFolder.getLocation()); assertTrue("4.0", virtualFolder.isVirtual()); assertTrue("5.0", virtualFolder.getLocation() == null); // assert URIs assertEquals("6.0", URIUtil.toURI(linkedFolderLocation), linkedFolder.getLocationURI()); assertEquals("7.0", URIUtil.toURI(subFolderLocation), subFolder.getLocationURI()); // assertTrue("8.0", virtualFolder.getLocationURI() == null); } finally { Workspace.clear(subFolderLocation.toFile()); Workspace.clear(linkedFolderLocation.toFile()); } }
public void testLinkedFolderInVirtualFolder_FileStoreURI() { IPath folderLocation = getRandomLocation(); IFolder folder = existingVirtualFolderInExistingProject.getFolder(getUniqueString()); try { folder.createLink(folderLocation, IResource.ALLOW_MISSING_LOCAL, getMonitor()); } catch (CoreException e) { fail("1.0", e); } assertTrue("2.0", folder.exists()); assertEquals("3.0", folderLocation, folder.getLocation()); assertTrue("4.0", !folderLocation.toFile().exists()); // Check file store URI for the linked resource try { IFileStore fs = EFS.getStore(existingVirtualFolderInExistingProject.getLocationURI()); fs = fs.getChild(folder.getName()); assertNotNull("5.0", fs); assertNotNull("6.0", fs.toURI()); } catch (CoreException e) { fail("7.0", e); } }