/** Tests creating a linked folder under a virtual folder */
  public void testCreateLinkedFolderUnderVirtualFolder() {
    // get a non-existing location
    IPath location = getRandomLocation();
    IFolder linkedFolder = existingVirtualFolderInExistingProject.getFolder(getUniqueString());

    try {
      linkedFolder.createLink(location, IResource.ALLOW_MISSING_LOCAL, getMonitor());
    } catch (CoreException e) {
      fail("1.0", e);
    }

    assertTrue("2.0", linkedFolder.exists());
    assertEquals("3.0", location, linkedFolder.getLocation());
    assertTrue("4.0", !location.toFile().exists());

    // getting children should succeed (and be empty)
    try {
      assertEquals("5.0", 0, linkedFolder.members().length);
    } catch (CoreException e) {
      fail("6.0", e);
    }

    // delete should succeed
    try {
      linkedFolder.delete(IResource.NONE, getMonitor());
    } catch (CoreException e) {
      fail("7.0", e);
    }
  }
  public void testDeleteProjectWithVirtualFolderAndLink() {
    IPath folderLocation = getRandomLocation();

    IFolder virtualFolder = existingProject.getFolder(getUniqueString());
    IFolder linkedFolder = virtualFolder.getFolder("a_link");

    try {
      try {
        folderLocation.toFile().mkdir();
        virtualFolder.create(IResource.VIRTUAL, true, null);
        linkedFolder.createLink(folderLocation, IResource.NONE, getMonitor());
        existingProject.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, getMonitor());
        existingProject.create(getMonitor());
      } catch (CoreException e) {
        fail("1.0", e);
      }

      // virtual folder should not exist until the project is open
      assertTrue("2.0", !virtualFolder.exists());
      assertTrue("3.0", !linkedFolder.exists());

      try {
        existingProject.open(getMonitor());
      } catch (CoreException e) {
        fail("4.0", e);
      }

      // virtual folder should now exist
      assertTrue("5.0", virtualFolder.exists());
      assertTrue("6.0", virtualFolder.isVirtual());

      // link should now exist
      assertTrue("7.0", linkedFolder.exists());
      assertTrue("8.0", linkedFolder.isLinked());

      assertEquals("9.0", folderLocation, linkedFolder.getLocation());
    } finally {
      Workspace.clear(folderLocation.toFile());
    }
  }
  /** Tests creating a folder under a virtual folder */
  public void testCreateFolderUnderVirtualFolder() {
    IFolder folder = existingVirtualFolderInExistingProject.getFolder(getUniqueString());
    boolean failed = false;
    try {
      create(folder, true);
      fail("1.0");
    } catch (CoreException e) {
      failed = true;
    }

    assertTrue("2.0", !folder.exists());
    assertTrue("3.0", failed);
  }
  public void testDeleteProjectWithVirtualFolder() {
    IFolder virtualFolder = existingProject.getFolder(getUniqueString());

    try {
      virtualFolder.create(IResource.VIRTUAL, true, null);
      existingProject.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, getMonitor());
      existingProject.create(getMonitor());
    } catch (CoreException e) {
      fail("1.0", e);
    }

    // virtual folder should not exist until the project is open
    assertTrue("2.0", !virtualFolder.exists());

    try {
      existingProject.open(getMonitor());
    } catch (CoreException e) {
      fail("3.0", e);
    }

    // virtual folder should now exist
    assertTrue("4.0", virtualFolder.exists());
    assertTrue("5.0", virtualFolder.isVirtual());
  }
  /** Tests creating a virtual folder under a virtual folder */
  public void testCreateVirtualFolderUnderVirtualFolder() {
    IFolder virtualFolder = existingVirtualFolderInExistingProject.getFolder(getUniqueString());
    try {
      virtualFolder.create(IResource.VIRTUAL, true, null);
    } catch (CoreException e) {
      fail("1.0", e);
    }

    assertTrue("2.0", virtualFolder.exists());
    assertTrue("3.0", virtualFolder.isVirtual());

    // delete should succeed
    try {
      virtualFolder.delete(IResource.NONE, getMonitor());
    } catch (CoreException e) {
      fail("4.0", e);
    }
  }
  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);
    }
  }