]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-489: Clean up extra entity resources created during tests. Now cleans up all...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 10 Dec 2009 02:52:53 +0000 (02:52 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 10 Dec 2009 02:52:53 +0000 (02:52 +0000)
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java

index 2bb1a1c21124b9a3e0d38f62269619293a863d4d..64ad4671a0e0e6e1046f2e37e298f38f2200938b 100644 (file)
@@ -58,7 +58,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     // Instance variables specific to this test.
     private CollectionObjectClient client = new CollectionObjectClient();
     private String knownResourceId = null;
-    private List<String> additionalResourceIds = new ArrayList();
+    private List<String> allResourceIdsCreated = new ArrayList();
 
     /*
      * This method is called only by the parent class, AbstractServiceTest
@@ -108,11 +108,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
             }
-        // Store the IDs from any additional resources created by tests,
-        // so they can be deleted after all tests have been run.
-        } else {
-            additionalResourceIds.add(extractId(res));
         }
+
+        // Store the IDs from every resource created by tests,
+        // so they can be deleted after tests have been run.
+        allResourceIdsCreated.add(extractId(res));
     }
 
     /* (non-Javadoc)
@@ -607,15 +607,20 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     // ---------------------------------------------------------------
     
     /**
-     * Deletes any additional resources created by tests,
-     * after all tests have been run.
+     * Deletes all resources created by tests, after all tests have been run.
+     *
+     * This cleanup method will always be run, even if one or more tests fail.
+     * For this reason, it attempts to remove all resources created
+     * at any point during testing, even if some of those resources
+     * may be expected to be deleted by certain tests.
      */
-    @AfterClass
+    @AfterClass(alwaysRun=true)
     public void cleanUp() {
         if (logger.isDebugEnabled()) {
             logger.debug("Cleaning up temporary resources created for testing ...");
         }
-        for (String resourceId : additionalResourceIds) {
+        for (String resourceId : allResourceIdsCreated) {
+            // Note: Any non-success responses are ignored and not reported.
             ClientResponse<Response> res = client.delete(resourceId);
         }
     }