/** * Removes contents of {@link #getPackageP()}, of {@link #getRoot()} (except for p) and of the * Java project (except for src and the JRE library). * * @throws Exception in case of errors */ protected void tearDown() throws Exception { refreshFromLocal(); performDummySearch(); final boolean pExists = getPackageP().exists(); if (pExists) { tryDeletingAllJavaChildren(getPackageP()); tryDeletingAllNonJavaChildResources(getPackageP()); } if (getRoot().exists()) { IJavaElement[] packages = getRoot().getChildren(); for (int i = 0; i < packages.length; i++) { IPackageFragment pack = (IPackageFragment) packages[i]; if (!pack.equals(getPackageP()) && pack.exists() && !pack.isReadOnly()) if (pack.isDefaultPackage()) pack.delete(true, null); else JavaProjectHelper.delete(pack.getResource()); // also delete packages with subpackages } // Restore package 'p' if (!pExists) getRoot().createPackageFragment("p", true, null); tryDeletingAllNonJavaChildResources(getRoot()); } restoreTestProject(); }
/** * Tests that removing a package updates the workspace baseline This test removes the a.b.c * package being used in all tests thus far, and should be run last */ public void testWPUpdatePackageRemoved() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); // add the package IPath srcroot = new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute(); IPackageFragment fragment = assertTestPackage(project, srcroot, "a.test2"); assertNotNull("the package " + TESTING_PACKAGE + " must exist", fragment); // remove the package fragment.delete(true, new NullProgressMonitor()); IApiDescription desc = getTestProjectApiDescription(); assertNotNull("the testing project api description must exist", desc); IApiAnnotations annot = desc.resolveAnnotations(Factory.packageDescriptor("a.test2")); assertNull("the annotations for package " + TESTING_PACKAGE + " should not exist", annot); }