]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1792, CSPACE-1781: Fixing pagination problem in Person, Org, and Vocab service...
authorRichard Millet <richard.millet@berkeley.edu>
Tue, 11 May 2010 05:54:09 +0000 (05:54 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Tue, 11 May 2010 05:54:09 +0000 (05:54 +0000)
43 files changed:
services/IntegrationTests/src/test/java/org/collectionspace/services/ItegrationTests/test/RelationIntegrationTest.java
services/PerformanceTests/pom.xml
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java
services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java
services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java
services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java
services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountTest.java
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java
services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleClient.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/AbstractServiceClientImpl.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
services/client/src/main/java/org/collectionspace/services/client/TestServiceClient.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/test/ServiceTest.java
services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectClient.java
services/collectionobject/client/src/main/java/org/collectionspace/services/client/CollectionObjectProxy.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java
services/contact/client/src/test/java/org/collectionspace/services/client/test/ContactServiceTest.java
services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionClient.java
services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java
services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java
services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClientUtils.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/person/client/pom.xml
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/person/import/pom.xml
services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java
services/query/pom.xml
services/query/service/pom.xml
services/query/service/src/main/java/org/collectionspace/services/query/QueryResource.java

index 57d0e277bef1c3a3938351c0431a29e1ddf69b66..99f2e2c2b0adff090fabf7b75d570f3e934d5e1a 100644 (file)
  */
 package org.collectionspace.services.ItegrationTests.test;
 
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
 
 import org.testng.Assert;
 import org.testng.annotations.Test;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.OptionsMethod;
-import org.apache.commons.httpclient.methods.TraceMethod;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,19 +38,12 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 
-import org.collectionspace.services.client.TestServiceClient;
-
-import org.collectionspace.services.CollectionObjectJAXBSchema;
 import org.collectionspace.services.client.CollectionObjectClient;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
-import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
 
-import org.collectionspace.services.IntakeJAXBSchema;
 import org.collectionspace.services.client.IntakeClient;
 import org.collectionspace.services.intake.IntakesCommon;
-import org.collectionspace.services.intake.IntakesCommonList;
 
-import org.collectionspace.services.common.relation.RelationJAXBSchema;
 import org.collectionspace.services.client.RelationClient;
 import org.collectionspace.services.relation.RelationsCommon;
 import org.collectionspace.services.relation.RelationsCommonList;
@@ -103,11 +78,17 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                MultipartOutput multipart = new MultipartOutput();
                OutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
                commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName());
+               
                // Make the create call and check the response
                ClientResponse<Response> response = collectionObjectClient.create(multipart);
-               Assert.assertEquals(response.getStatus(), Response.Status.CREATED
-                               .getStatusCode());
-               String collectionObjectCsid = extractId(response);
+               String collectionObjectCsid = null;
+               try {
+                       Assert.assertEquals(response.getStatus(), Response.Status.CREATED
+                                       .getStatusCode());
+                       collectionObjectCsid = extractId(response);
+               } finally {
+                       response.releaseConnection();
+               }
            
            
            // Next, create an Intake object
@@ -117,10 +98,16 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            multipart = new MultipartOutput();
            commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
            commonPart.getHeaders().add("label", intakeClient.getCommonPartName());
+
            // Make the call to create and check the response
            response = intakeClient.create(multipart);
-           Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
-           String intakeCsid = extractId(response);
+           String intakeCsid = null;
+           try {
+                   Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+                   intakeCsid = extractId(response);
+           } finally {
+               response.releaseConnection();
+           }
            
            // Lastly, relate the two entities, by creating a new relation object
            RelationsCommon relation = new RelationsCommon();
@@ -131,10 +118,16 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            multipart = new MultipartOutput();
            commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
            commonPart.getHeaders().add("label", relationClient.getCommonPartName());
+
            // Make the call to crate
-           response = relationClient.create(multipart); 
-           Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
-           String relationCsid = extractId(response);
+           response = relationClient.create(multipart);
+           String relationCsid = null;
+           try {
+                   Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+                   relationCsid = extractId(response);
+           } finally {
+               response.releaseConnection();
+           }
            
            //
            // Now try to retrieve the Intake record of the CollectionObject.
@@ -143,24 +136,29 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            ClientResponse<RelationsCommonList> resultResponse = relationClient.readList_SPO(collectionObjectCsid,
                        predicate,
                        intakeCsid);
-           Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
+        RelationsCommonList relationList = null;
+           try {
+               Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
+               relationList = resultResponse.getEntity();
+           } finally {
+               resultResponse.releaseConnection();
+           }
            
            //
            // Each relation returned in the list needs to match what we
            // requested.
            //
-        RelationsCommonList relationList = resultResponse.getEntity();        
         List<RelationsCommonList.RelationListItem> relationListItems = relationList.getRelationListItem();
         Assert.assertFalse(relationListItems.isEmpty());
         
-        ClientResponse<RelationsCommon> resultRelationResponse;
-        RelationsCommon resultRelation = null;
         int i = 0;
+        RelationsCommon resultRelation = null;
         for(RelationsCommonList.RelationListItem listItem : relationListItems){
                
                String foundCsid = listItem.getCsid();
+               ClientResponse<MultipartInput> multiPartResponse = null;
                try {
-                       ClientResponse<MultipartInput> multiPartResponse = relationClient.read(foundCsid);
+                       multiPartResponse = relationClient.read(foundCsid);
                        int responseStatus = multiPartResponse.getStatus();
                        Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
                        MultipartInput input = (MultipartInput) multiPartResponse.getEntity();
@@ -169,7 +167,10 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                                        RelationsCommon.class);
                } catch (Exception e) {
                        e.printStackTrace();
+               } finally {
+                       multiPartResponse.releaseConnection();
                }
+               
                Assert.assertEquals(resultRelation.getDocumentId1(), collectionObjectCsid);
                Assert.assertEquals(resultRelation.getRelationshipType(), RelationshipType.COLLECTIONOBJECT_INTAKE);
                Assert.assertEquals(resultRelation.getDocumentId2(), intakeCsid);
index bad8ee02659305fd057dbdaa10cd4377d64ed6cf..427f276ce9dc948bb4830dc146c6527f5c5a6fc1 100644 (file)
             <scope>test</scope>\r
         </dependency>\r
         <!-- CollectionSpace dependencies -->\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.jaxb</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.client</artifactId>\r
index 03632f4a65686b49d5a21ba9b53c5a43c8570144..3e01d21e2d5e342bc4385274416f39fe75af11a1 100644 (file)
  */
 package org.collectionspace.services.PerformanceTests.test;
 
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Date;
 import java.util.Random;
 
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
 
-import org.testng.Assert;
-import org.testng.annotations.Test;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.OptionsMethod;
-import org.apache.commons.httpclient.methods.TraceMethod;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 
-import org.collectionspace.services.client.TestServiceClient;
-
-import org.collectionspace.services.CollectionObjectJAXBSchema;
+import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.client.CollectionObjectClient;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList.CollectionObjectListItem;
 
-import org.collectionspace.services.IntakeJAXBSchema;
-import org.collectionspace.services.client.IntakeClient;
-import org.collectionspace.services.intake.IntakesCommon;
-import org.collectionspace.services.intake.IntakesCommonList;
-
-import org.collectionspace.services.common.relation.RelationJAXBSchema;
-import org.collectionspace.services.client.RelationClient;
-import org.collectionspace.services.relation.RelationsCommon;
-import org.collectionspace.services.relation.RelationsCommonList;
-import org.collectionspace.services.relation.RelationshipType;
-
 /**
  * A ServiceTest.
  * 
@@ -84,25 +52,40 @@ import org.collectionspace.services.relation.RelationshipType;
  */
 public class PerformanceTest extends CollectionSpacePerformanceTest {
 
+       /** The Constant MAX_KEYWORDS. */
        private static final int MAX_KEYWORDS = 10;
+       
+       /** The Constant MAX_SEARCHES. */
        private static final int MAX_SEARCHES = 10;
+       
+       /** The logger. */
        final Logger logger = LoggerFactory
                        .getLogger(PerformanceTest.class);
        //
        // Get clients for the CollectionSpace services
        //
-       private static int MAX_RECORDS = 1000;
+       /** The MA x_ records. */
+       private static int MAX_RECORDS = 100;
 
+       /**
+        * Performance test.
+        */
        @Test
        public void performanceTest() {
                roundTripOverhead(10);
                deleteCollectionObjects();
                String[] coList = this.createCollectionObjects(MAX_RECORDS);
                this.searchCollectionObjects(MAX_RECORDS);
-//             this.deleteCollectionObjects(coList);
+               this.deleteCollectionObjects(coList);
                roundTripOverhead(10);
        }
        
+       /**
+        * Round trip overhead.
+        *
+        * @param numOfCalls the num of calls
+        * @return the long
+        */
        private long roundTripOverhead(int numOfCalls) {
                long result = 0;
                CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
@@ -110,7 +93,7 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                long totalTime = 0;
                for (int i = 0; i < numOfCalls; i++) {
                        Date startTime = new Date();
-                       collectionObjectClient.roundtrip();
+                       collectionObjectClient.roundtrip().releaseConnection();
                        Date stopTime = new Date();
                        totalTime = totalTime + (stopTime.getTime() - startTime.getTime());
                        System.out.println("Overhead roundtrip time is: " + (stopTime.getTime() - startTime.getTime()));
@@ -124,6 +107,11 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                return result;
        }
        
+       /**
+        * Search collection objects.
+        *
+        * @param numberOfObjects the number of objects
+        */
        private void searchCollectionObjects(int numberOfObjects) {
                CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
                Random randomGenerator = new Random(System.currentTimeMillis());                                
@@ -137,14 +125,24 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                                numOfKeywords++, totalTime = 0, totalSearchResults = 0, times = "") {
                        keywords = keywords + " " + OBJECT_NAME + randomGenerator.nextInt(numberOfObjects);
                        for (int i = 0; i < MAX_SEARCHES; i++) {
+                               //sandwich the call with timestamps
                                Date startTime = new Date();
-                               searchResults = collectionObjectClient.keywordSearch(keywords);
+                               searchResults = collectionObjectClient.keywordSearch(keywords);                         
                                Date stopTime = new Date();
+                               
+                               //extract the result list and release the ClientResponse
+                               CollectionobjectsCommonList coListItem = null;
+                               try {
+                                       coListItem = searchResults.getEntity();
+                               } finally {
+                                       searchResults.releaseConnection();
+                               }
+                               
                                long time = stopTime.getTime() - startTime.getTime();
                                times = times + " " + ((float)time / 1000);
                                totalTime = totalTime + time;                           
-                               totalSearchResults = totalSearchResults +
-                                       searchResults.getEntity().getCollectionObjectListItem().size();
+                               totalSearchResults = totalSearchResults + 
+                                       coListItem.getCollectionObjectListItem().size();
                        }
                        if (logger.isDebugEnabled()) {
                                System.out.println("------------------------------------------------------------------------------");
@@ -160,6 +158,13 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                return;
        }
        
+       /**
+        * Creates the collection object.
+        *
+        * @param collectionObjectClient the collection object client
+        * @param identifier the identifier
+        * @return the string
+        */
        private String createCollectionObject(CollectionObjectClient collectionObjectClient,
                        int identifier) {
                String result = null;
@@ -175,20 +180,29 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName());
                // Make the create call and check the response
                ClientResponse<Response> response = collectionObjectClient.create(multipart);
-               
-               int responseStatus = response.getStatus();
-               if (logger.isDebugEnabled() == true) {
-                       if (responseStatus != Response.Status.CREATED.getStatusCode())
-                               logger.debug("Status of call to create CollectionObject was: " +
-                                               responseStatus);
+               try {
+                       int responseStatus = response.getStatus();
+                       if (logger.isDebugEnabled() == true) {
+                               if (responseStatus != Response.Status.CREATED.getStatusCode())
+                                       logger.debug("Status of call to create CollectionObject was: " +
+                                                       responseStatus);
+                       }
+                       
+                       Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());             
+                       result = extractId(response);
+               } finally {
+                       response.releaseConnection();
                }
                
-               Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());             
-               result = extractId(response);
-               
                return result;
        }
        
+       /**
+        * Creates the collection objects.
+        *
+        * @param numberOfObjects the number of objects
+        * @return the string[]
+        */
        public String[] createCollectionObjects(int numberOfObjects) {
                Random randomGenerator = new Random(System.currentTimeMillis());
                CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
@@ -199,6 +213,9 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                        Date startTime = new Date();
                        for (int i = 0; i < numberOfObjects; i++, createdObjects++) {
                                coList[i] = createCollectionObject(collectionObjectClient, i + 1);
+                               if (logger.isDebugEnabled() == true) {
+                                       logger.debug("Created CollectionObject #: " + i);
+                               }
                        }
                        Date stopTime = new Date();
                        if (logger.isDebugEnabled()) {
@@ -214,42 +231,69 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                return coList;
        }
        
+       /**
+        * Delete collection object.
+        *
+        * @param collectionObjectClient the collection object client
+        * @param resourceId the resource id
+        */
        private void deleteCollectionObject(CollectionObjectClient collectionObjectClient,
                        String resourceId) {
-               ClientResponse<Response> res = collectionObjectClient.delete(resourceId);                       
+               ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
+               res.releaseConnection();
        }
 
+       /**
+        * Delete collection objects.
+        *
+        * @param arrayOfObjects the array of objects
+        */
        public void deleteCollectionObjects(String[] arrayOfObjects) {
                CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
 
                Date startTime = new Date();            
                for (int i = 0; i < arrayOfObjects.length; i++) {
                        deleteCollectionObject(collectionObjectClient, arrayOfObjects[i]);
-               }
-               
+               }               
                Date stopTime = new Date();
+               
                if (logger.isDebugEnabled()) {
                        System.out.println("Deleted " + arrayOfObjects.length + " CollectionObjects" +
                                        " in " + (stopTime.getTime() - startTime.getTime())/1000.0 + " seconds.");
                }
        }
        
+       /**
+        * Delete collection objects.
+        * FIXME: Deletes a page at a time until there are no more CollectionObjects.
+        */
        public void deleteCollectionObjects() {
                CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
-               ClientResponse<CollectionobjectsCommonList> commonsList;
-               commonsList = collectionObjectClient.readList();
-               List<CollectionObjectListItem> coListItems = commonsList.getEntity().getCollectionObjectListItem();
-               
-               Date startTime = new Date();
-               for (CollectionObjectListItem i:coListItems) {
-                       deleteCollectionObject(collectionObjectClient, i.getCsid());
-               }
-               Date stopTime = new Date();
+               ClientResponse<AbstractCommonList> response;
                
-               if (logger.isDebugEnabled()) {
-                       System.out.println("Deleted " + coListItems.size() + " CollectionObjects" +
-                                       " in " + (stopTime.getTime() - startTime.getTime())/1000.0 + " seconds.");
-               }
+               List<CollectionObjectListItem> coListItems = null;              
+               do {
+                       response = collectionObjectClient.readList(Integer.toString(MAX_RECORDS),
+                                       Integer.toString(0));
+                       try {
+                               CollectionobjectsCommonList commonListElement = 
+                                       (CollectionobjectsCommonList)response.getEntity(CollectionobjectsCommonList.class);
+                               coListItems = commonListElement.getCollectionObjectListItem();
+                       } finally {
+                               response.releaseConnection();
+                       }
+                       
+                       Date startTime = new Date();
+                       for (CollectionObjectListItem i:coListItems) {
+                               deleteCollectionObject(collectionObjectClient, i.getCsid());
+                       }
+                       Date stopTime = new Date();
+                       
+                       if (logger.isDebugEnabled()) {
+                               System.out.println("Deleted " + coListItems.size() + " CollectionObjects" +
+                                               " in " + (stopTime.getTime() - startTime.getTime())/1000.0 + " seconds.");
+                       }
+               } while (coListItems.size() > 0);
        }
 
 }
index 129c89d943af56213e08253b8b4f182057926a82..ade53c128d53aec335b2ae5ca188aad848998f22 100644 (file)
@@ -51,6 +51,7 @@ public class AccountClient extends AbstractServiceClientImpl {
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
      */
+    @Override
     public String getServicePathComponent() {
         return "accounts";
     }
@@ -85,7 +86,7 @@ public class AccountClient extends AbstractServiceClientImpl {
     }
 
     /**
-     * @return
+     * @return response
      * @see org.collectionspace.hello.client.AccountProxy#readList()
      */
     public ClientResponse<AccountsCommonList> readList() {
@@ -100,7 +101,7 @@ public class AccountClient extends AbstractServiceClientImpl {
 
     /**
      * @param csid
-     * @return
+     * @return response
      * @see org.collectionspace.hello.client.AccountProxy#getAccount(java.lang.String)
      */
     public ClientResponse<AccountsCommon> read(String csid) {
@@ -108,8 +109,9 @@ public class AccountClient extends AbstractServiceClientImpl {
     }
 
     /**
+     * @param multipart 
      * @param account
-     * @return
+     * @return response
      * @see org.collectionspace.hello.client.AccountProxy#create(org.collectionspace.services.account.AccountsCommon)
      */
     public ClientResponse<Response> create(AccountsCommon multipart) {
@@ -118,8 +120,9 @@ public class AccountClient extends AbstractServiceClientImpl {
 
     /**
      * @param csid
+     * @param multipart 
      * @param account
-     * @return
+     * @return response
      * @see org.collectionspace.hello.client.AccountProxy#updateAccount(java.lang.Long, org.collectionspace.services.account.AccountsCommon)
      */
     public ClientResponse<AccountsCommon> update(String csid, AccountsCommon multipart) {
@@ -128,10 +131,11 @@ public class AccountClient extends AbstractServiceClientImpl {
 
     /**
      * @param csid
-     * @return
+     * @return response
      * @see org.collectionspace.hello.client.AccountProxy#deleteAccount(java.lang.Long)
      */
-    public ClientResponse<Response> delete(String csid) {
+    @Override
+       public ClientResponse<Response> delete(String csid) {
         return accountProxy.delete(csid);
     }
 }
index d2f9d65b04dbd859ca1968257984e1b99b8cf50c..a64c61ee2aff87dd2bf6f1ffb334a453b08ad993 100644 (file)
@@ -63,22 +63,36 @@ import org.testng.annotations.BeforeClass;
  */
 public class AccountRoleServiceTest extends AbstractServiceTestImpl {
 
+    /** The Constant logger. */
     static private final Logger logger =
             LoggerFactory.getLogger(AccountRoleServiceTest.class);
     // Instance variables specific to this test.
+    /** The known resource id. */
     private String knownResourceId = null;
+    
+    /** The all resource ids created. */
     private List<String> allResourceIdsCreated = new ArrayList<String>();
+    
+    /** The acc values. */
     private Hashtable<String, AccountValue> accValues = new Hashtable<String, AccountValue>();
+    
+    /** The role values. */
     private Hashtable<String, RoleValue> roleValues = new Hashtable<String, RoleValue>();
     /*
      * This method is called only by the parent class, AbstractServiceTestImpl
      */
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     protected String getServicePathComponent() {
         return new AccountRoleClient().getServicePathComponent();
     }
 
+    /**
+     * Seed data.
+     */
     @BeforeClass(alwaysRun = true)
     public void seedData() {
         String userId = "acc-role-user1";
@@ -125,29 +139,35 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     protected CollectionSpaceClient getClientInstance() {
-        return new AccountRoleClient();
+       return new AccountRoleClient();
     }
-
+    
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
      */
     @Override
-    protected AbstractCommonList getAbstractCommonList(
-            ClientResponse<AbstractCommonList> response) {
-        //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
-        throw new UnsupportedOperationException();
+       protected AbstractCommonList getAbstractCommonList(
+                       ClientResponse<AbstractCommonList> response) {
+       //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
+       throw new UnsupportedOperationException();
     }
-
-    @Test(dataProvider = "testName")
-    @Override
+    
+       /* (non-Javadoc)
+        * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
+        */
+       @Test(dataProvider = "testName")
+       @Override
     public void readPaginatedList(String testName) throws Exception {
-        //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
-    }
-
+               //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
+       }    
+    
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
@@ -163,55 +183,73 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
                 roleValues.values(), true, true);
         AccountRoleClient client = new AccountRoleClient();
         ClientResponse<Response> res = client.create(pv.getAccountId(), accRole);
-        int statusCode = res.getStatus();
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Store the ID returned from this create operation
-        // for additional tests below.
-        //this is is not important in case of this relationship
-        knownResourceId = extractId(res);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": knownResourceId=" + knownResourceId);
+        try {
+               int statusCode = res.getStatus();
+       
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Store the ID returned from this create operation
+               // for additional tests below.
+               //this is is not important in case of this relationship
+               knownResourceId = extractId(res);
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": knownResourceId=" + knownResourceId);
+               }
+        } finally {
+               res.releaseConnection();
         }
-        res.releaseConnection();
     }
 
     //to not cause uniqueness violation for accRole, createList is removed
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     @Override
     public void createList(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
     // ---------------------------------------------------------------
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -225,22 +263,27 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         ClientResponse<AccountRole> res = client.read(
                 accValues.get("acc-role-user1").getAccountId(), "123");
         int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               AccountRole output = (AccountRole) res.getEntity();
+               Assert.assertNotNull(output);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        AccountRole output = (AccountRole) res.getEntity();
-        Assert.assertNotNull(output);
-        res.releaseConnection();
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void readNonExistent(String testName) throws Exception {
@@ -252,27 +295,32 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         AccountRoleClient client = new AccountRoleClient();
         ClientResponse<AccountRole> res = client.read(this.NON_EXISTENT_ID, "123");
         int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        res.releaseConnection();
     }
 
     // ---------------------------------------------------------------
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void readList(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
     // Failure outcomes
@@ -281,47 +329,64 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read", "readList", "readNonExistent"})
     public void update(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
     public void updateNonExistent(String testName) throws Exception {
-        //FIXME: Should this test really be empty?  If so, please comment accordingly.
+       //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
     // ---------------------------------------------------------------
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read"})
     public void delete(String testName) throws Exception {
-
         // Perform setup.
         setupDelete(testName);
 
@@ -330,16 +395,18 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         ClientResponse<Response> res = client.delete(
                 accValues.get("acc-role-user1").getAccountId(), "123");
         int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        res.releaseConnection();
     }
 
     // Failure outcomes
@@ -359,6 +426,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
     /**
      * Tests the code for manually submitting data that is used by several
      * of the methods above.
+     * @throws Exception 
      */
     @Test(dependsOnMethods = {"create"})
     public void testSubmitRequest() throws Exception {
@@ -408,32 +476,40 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         return accRole;
     }
 
+    /**
+     * Clean up.
+     */
     @AfterClass(alwaysRun = true)
+    @Override
     public void cleanUp() {
         setupDelete("delete");
+
         String noTest = System.getProperty("noTestCleanup");
-        if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Skipping Cleanup phase ...");
             }
             return;
-        }
+       }
         if (logger.isDebugEnabled()) {
             logger.debug("Cleaning up temporary resources created for testing ...");
         }
+        
         AccountRoleClient client = new AccountRoleClient();
         for (String resourceId : allResourceIdsCreated) {
-
             ClientResponse<Response> res = client.delete(resourceId, "123");
-            int statusCode = res.getStatus();
-            if (logger.isDebugEnabled()) {
-                logger.debug("clenaup: delete relationships for accission id="
-                        + resourceId + " status=" + statusCode);
+            try {
+                   int statusCode = res.getStatus();
+                   if (logger.isDebugEnabled()) {
+                       logger.debug("clenaup: delete relationships for accission id="
+                               + resourceId + " status=" + statusCode);
+                   }
+                   Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                           invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+                   Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            } finally {
+               res.releaseConnection();
             }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-            res.releaseConnection();
         }
 
         for (AccountValue pv : accValues.values()) {
@@ -445,6 +521,13 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Creates the account.
+     *
+     * @param userName the user name
+     * @param email the email
+     * @return the string
+     */
     private String createAccount(String userName, String email) {
         setupCreate();
         AccountClient accClient = new AccountClient();
@@ -464,21 +547,35 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         return extractId(res);
     }
 
+    /**
+     * Delete account.
+     *
+     * @param accId the acc id
+     */
     private void deleteAccount(String accId) {
         setupDelete();
         AccountClient accClient = new AccountClient();
         ClientResponse<Response> res = accClient.delete(accId);
         int statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug("deleteAccount: delete account id="
-                    + accId + " status=" + statusCode);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug("deleteAccount: delete account id="
+                           + accId + " status=" + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        res.releaseConnection();
     }
 
+    /**
+     * Creates the role.
+     *
+     * @param roleName the role name
+     * @return the string
+     */
     private String createRole(String roleName) {
         setupCreate();
         RoleClient roleClient = new RoleClient();
@@ -498,18 +595,26 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         return extractId(res);
     }
 
+    /**
+     * Delete role.
+     *
+     * @param roleId the role id
+     */
     private void deleteRole(String roleId) {
         setupDelete();
         RoleClient roleClient = new RoleClient();
         ClientResponse<Response> res = roleClient.delete(roleId);
         int statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug("deleteRole: delete role id=" + roleId
-                    + " status=" + statusCode);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug("deleteRole: delete role id=" + roleId
+                           + " status=" + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        res.releaseConnection();
     }
 }
index 3d00c9e6ddc2fac2cc2140d1ca857acee1e49451..91268ad99247818b29025bcc15a833ac88aa597a 100644 (file)
@@ -53,16 +53,22 @@ import org.testng.annotations.AfterClass;
  */
 public class AccountServiceTest extends AbstractServiceTestImpl {
 
+    /** The Constant logger. */
     static private final Logger logger =
             LoggerFactory.getLogger(AccountServiceTest.class);
     // Instance variables specific to this test.
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList();
+    
+    /** The add tenant. */
     static boolean addTenant = true;
 
     /*
      * This method is called only by the parent class, AbstractServiceTestImpl
      */
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     protected String getServicePathComponent() {
         return new AccountClient().getServicePathComponent();
@@ -99,6 +105,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
@@ -137,6 +146,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Creates the for unique user.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createForUniqueUser(String testName) throws Exception {
@@ -158,6 +173,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
     }
 
+    /**
+     * Creates the with invalid tenant.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithInvalidTenant(String testName) throws Exception {
@@ -181,6 +202,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
     }
 
+    /**
+     * Creates the without user.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithoutUser(String testName) throws Exception {
@@ -203,6 +230,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
     }
 
+    /**
+     * Creates the with invalid email.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithInvalidEmail(String testName) throws Exception {
@@ -225,6 +258,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
     }
 
+    /**
+     * Creates the without screen name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithoutScreenName(String testName) throws Exception {
@@ -247,6 +286,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
     }
 
+    /**
+     * Creates the with invalid password.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithInvalidPassword(String testName) throws Exception {
@@ -269,6 +314,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
     }
 
+        /**
+         * Creates the with most invalid.
+         *
+         * @param testName the test name
+         * @throws Exception the exception
+         */
         @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithMostInvalid(String testName) throws Exception {
@@ -292,6 +343,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     }
 
     //to not cause uniqueness violation for account, createList is removed
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -336,16 +390,25 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
@@ -355,6 +418,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -382,6 +448,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read"})
@@ -409,6 +478,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
@@ -439,6 +511,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Search screen name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void searchScreenName(String testName) throws Exception {
@@ -469,6 +547,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Search user id.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void searchUserId(String testName) throws Exception {
@@ -499,6 +583,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Search email.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void searchEmail(String testName) throws Exception {
@@ -529,6 +619,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Search screen name email.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void searchScreenNameEmail(String testName) throws Exception {
@@ -565,6 +661,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read", "readList", "readNonExistent"})
@@ -618,6 +717,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
                 "Data in updated object did not match submitted data.");
     }
 
+    /**
+     * Update password.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"update"})
     public void updatePassword(String testName) throws Exception {
@@ -671,6 +776,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 //                "Data in updated object did not match submitted data.");
     }
 
+    /**
+     * Update password without user.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"update"})
     public void updatePasswordWithoutUser(String testName) throws Exception {
@@ -703,6 +814,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
     }
 
+    /**
+     * Update invalid password.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"update"})
     public void updateInvalidPassword(String testName) throws Exception {
@@ -747,6 +864,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
     }
 
+    /**
+     * Deactivate.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"updatePasswordWithoutUser"})
     public void deactivate(String testName) throws Exception {
@@ -802,21 +925,33 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
@@ -847,6 +982,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Update wrong user.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
     public void updateWrongUser(String testName) throws Exception {
@@ -895,6 +1036,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"testSubmitRequest", "updateWrongUser"})
@@ -919,6 +1063,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"delete"})
@@ -948,6 +1095,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     /**
      * Tests the code for manually submitting data that is used by several
      * of the methods above.
+     * @throws Exception 
      */
     @Test(dependsOnMethods = {"create", "read"})
     public void testSubmitRequest() throws Exception {
@@ -1002,30 +1150,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    @AfterClass(alwaysRun = true)
-    public void cleanUp() {
-        setupDelete("delete");
-        String noTest = System.getProperty("noTestCleanup");
-        if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-        }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-        AccountClient client = new AccountClient();
-        for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-            int statusCode = res.getStatus();
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        }
-    }
-
+    /**
+     * Prints the list.
+     *
+     * @param testName the test name
+     * @param list the list
+     */
     private void printList(String testName, AccountsCommonList list) {
         List<AccountsCommonList.AccountListItem> items =
                 list.getAccountListItem();
index 0b18663d88d2001096394d38fb1cf1f4e3545c73..883911e32783ead8a2393b815affd46aec4ad97e 100644 (file)
@@ -17,7 +17,7 @@ import javax.persistence.Persistence;
 import javax.persistence.Query;
 import org.collectionspace.services.account.AccountTenant;
 import org.collectionspace.services.account.AccountsCommon;
-import org.collectionspace.services.account.Tenant;
+//import org.collectionspace.services.account.Tenant;
 import org.collectionspace.services.account.Status;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
index d58348b69c5ee2e368c8d1ff2a6bdafa00ba7153..d89c2630a05eebd1c1013b5440912c8922774db8 100644 (file)
@@ -38,7 +38,7 @@ import org.collectionspace.services.client.PersonAuthorityClientUtils;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.acquisition.AcquisitionsCommon;
-import org.collectionspace.services.acquisition.AcquisitionsCommonList;
+//import org.collectionspace.services.acquisition.AcquisitionsCommonList;
 
 import org.jboss.resteasy.client.ClientResponse;
 
@@ -68,8 +68,8 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest {
     final String SERVICE_PATH_COMPONENT = "acquisitions";
     final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
     private String knownResourceId = null;
-    private List<String> acquisitionIdsCreated = new ArrayList();
-    private List<String> personIdsCreated = new ArrayList();
+    private List<String> acquisitionIdsCreated = new ArrayList<String>();
+    private List<String> personIdsCreated = new ArrayList<String>();
     private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
     private int OK_STATUS = Response.Status.OK.getStatusCode();
     private String personAuthCSID = null; 
@@ -288,15 +288,18 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest {
         for (String resourceId : acquisitionIdsCreated) {
            // Note: Any non-success responses are ignored and not reported.
            ClientResponse<Response> res = acquisitionClient.delete(resourceId);
+           res.releaseConnection();
         }
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Delete persons before PersonAuth
         for (String resourceId : personIdsCreated) {
             // Note: Any non-success responses are ignored and not reported.
             ClientResponse<Response> res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+            res.releaseConnection();
         }
         // Note: Any non-success response is ignored and not reported.
         ClientResponse<Response> res = personAuthClient.delete(personAuthCSID);
+        res.releaseConnection();
     }
 
     // ---------------------------------------------------------------
index c15786e08f0e7a31acb9b30f4dc4414c8b9fc3dc..d00cead9f844f51a68b54ef44bc591b917d0e930 100644 (file)
@@ -22,7 +22,6 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -40,7 +39,6 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
@@ -55,12 +53,13 @@ import org.slf4j.LoggerFactory;
  */
 public class AcquisitionServiceTest extends AbstractServiceTestImpl {
 
+    /** The logger. */
     private final Logger logger =
         LoggerFactory.getLogger(AcquisitionServiceTest.class);
 
     // Instance variables specific to this test.
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList();
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -83,6 +82,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
@@ -128,6 +130,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
         allResourceIdsCreated.add(extractId(res));
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
        dependsOnMethods = {"create"})
@@ -140,16 +145,28 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -208,6 +225,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create"})
@@ -239,6 +259,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"read"})
@@ -266,6 +289,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"createList", "read"})
@@ -321,6 +347,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     // ---------------------------------------------------------------
 
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"read"})
@@ -383,16 +412,28 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -497,6 +538,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     }
      */
     
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"update", "testSubmitRequest"})
@@ -528,6 +572,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create", "read", "update"})
@@ -552,6 +599,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"delete"})
@@ -581,6 +631,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
     /**
      * Tests the code for manually submitting data that is used by several
      * of the methods above.
+     * @throws Exception 
      */
     @Test(dependsOnMethods = {"create", "read"})
     public void testSubmitRequest() throws Exception {
@@ -603,46 +654,24 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    // ---------------------------------------------------------------
-    // Cleanup of resources created during testing
-    // ---------------------------------------------------------------
-
-    /**
-     * 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(alwaysRun=true)
-    public void cleanUp() {
-        String noTest = System.getProperty("noTestCleanup");
-       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-       }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-        AcquisitionClient client = new AcquisitionClient();
-        for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
-    }
-
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     public String getServicePathComponent() {
         return new AcquisitionClient().getServicePathComponent();
     }
 
 
+    /**
+     * Creates the acquisition instance.
+     *
+     * @param identifier the identifier
+     * @return the multipart output
+     */
     private MultipartOutput createAcquisitionInstance(String identifier) {
         AcquisitionsCommon acquisition = new AcquisitionsCommon();
         acquisition.setAcquisitionReferenceNumber("acquisitionReferenceNumber-"  + identifier);
index 1406a7ee50e4a5ee5d9a2e0b2ff5dce6ab48e14d..f323ad90eeeda797b5c3f9ea372d3f884bf23e6a 100644 (file)
@@ -42,9 +42,7 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory;
  */
 public class PermissionRoleClient extends AbstractServiceClientImpl {
 
-    /**
-     *
-     */
+    /** The permission role proxy. */
     private PermissionRoleProxy permissionRoleProxy;
 
     /* (non-Javadoc)
@@ -65,13 +63,16 @@ public class PermissionRoleClient extends AbstractServiceClientImpl {
         setProxy();
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
+     */
     @Override
     public CollectionSpaceProxy getProxy() {
        return this.permissionRoleProxy;
     }    
 
     /**
-     * allow to reset proxy as per security needs
+     * allow to reset proxy as per security needs.
      */
     public void setProxy() {
         if (useAuth()) {
@@ -85,32 +86,39 @@ public class PermissionRoleClient extends AbstractServiceClientImpl {
 
 
     /**
-     * @param csid
+     * Read.
+     *
+     * @param csid the csid
      * @param prcsid relationship does not have an id, junk is fine
-     * @return
-     * @see 
+     * @return the client response
+     * @see
      */
     public ClientResponse<PermissionRole> read(String csid, String prcsid) {
         return permissionRoleProxy.read(csid, prcsid);
     }
 
     /**
-     * @param permRole
-     * @return
-     * @see 
+     * Creates the.
+     *
+     * @param csid the csid
+     * @param permRole the perm role
+     * @return the client response
+     * @see
      */
     public ClientResponse<Response> create(String csid, PermissionRole permRole) {
         return permissionRoleProxy.create(csid, permRole);
     }
 
-
     /**
-     * @param csid
+     * Delete.
+     *
+     * @param csid the csid
      * @param prcsid relationship does not have an id, junk is fine
-     * @return
-     * @see 
+     * @return response
+     * @see
      */
     public ClientResponse<Response> delete(String csid, String prcsid) {
         return permissionRoleProxy.delete(csid, prcsid);
     }
+        
 }
index d280004b04a57b52a9045e83f8070d26b5ae2e15..2471d408e73038ab7b0112927318c91dd564d2b6 100644 (file)
@@ -64,22 +64,36 @@ import org.testng.annotations.BeforeClass;
  */
 public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
 
+    /** The Constant logger. */
     static private final Logger logger =
             LoggerFactory.getLogger(PermissionRoleServiceTest.class);
     // Instance variables specific to this test.
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList();
+    
+    /** The all resource ids created. */
+    private List<String> allResourceIdsCreated = new ArrayList<String>();
+    
+    /** The perm values. */
     private Hashtable<String, PermissionValue> permValues = new Hashtable<String, PermissionValue>();
+    
+    /** The role values. */
     private Hashtable<String, RoleValue> roleValues = new Hashtable<String, RoleValue>();
     /*
      * This method is called only by the parent class, AbstractServiceTestImpl
      */
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     protected String getServicePathComponent() {
         return new PermissionRoleClient().getServicePathComponent();
     }
 
+    /**
+     * Seed data.
+     */
     @BeforeClass(alwaysRun = true)
     public void seedData() {
         String ra = "accounts";
@@ -123,29 +137,34 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     protected CollectionSpaceClient getClientInstance() {
-        return new PermissionRoleClient();
+       return new PermissionRoleClient();
     }
-
+    
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
      */
     @Override
-    protected AbstractCommonList getAbstractCommonList(
-            ClientResponse<AbstractCommonList> response) {
-        //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
-        throw new UnsupportedOperationException();
+       protected AbstractCommonList getAbstractCommonList(
+                       ClientResponse<AbstractCommonList> response) {
+       //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
+       throw new UnsupportedOperationException();
     }
-
-    @Test(dataProvider = "testName")
-    @Override
+    
+       /* (non-Javadoc)
+        * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
+        */
+       @Test(dataProvider = "testName")
+       @Override
     public void readPaginatedList(String testName) throws Exception {
-        //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
-    }
+               //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
+       }    
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
-
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
@@ -180,31 +199,50 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     }
 
     //to not cause uniqueness violation for permRole, createList is removed
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createList(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     // ---------------------------------------------------------------
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -234,6 +272,9 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void readNonExistent(String testName) throws Exception {
@@ -261,10 +302,14 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void readList(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     // Failure outcomes
@@ -273,37 +318,60 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read", "readList", "readNonExistent"})
     public void update(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
     public void updateNonExistent(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     // ---------------------------------------------------------------
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read"})
@@ -330,6 +398,9 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void deleteNonExistent(String testName) throws Exception {
@@ -343,6 +414,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     /**
      * Tests the code for manually submitting data that is used by several
      * of the methods above.
+     * @throws Exception 
      */
     @Test(dependsOnMethods = {"create"})
     public void testSubmitRequest() throws Exception {
@@ -371,11 +443,14 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     // ---------------------------------------------------------------
     /**
      * create permRolerole instance
+     * @param pv 
+     * @param rvs 
+     * @param usePermId 
      * @param permId
      * @param roleValues array of role ids
      * @param userPermId
      * @param useRoleId
-     * @return
+     * @return PermissionRole
      */
     public static PermissionRole createPermissionRoleInstance(PermissionValue pv,
             Collection<RoleValue> rvs,
@@ -391,19 +466,42 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
         return permRole;
     }
 
+    /**
+     * Clean up.
+     */
     @AfterClass(alwaysRun = true)
+    @Override
     public void cleanUp() {
         setupDelete("cleanup");
         String noTest = System.getProperty("noTestCleanup");
-        if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Skipping Cleanup phase ...");
             }
             return;
-        }
+       }
         if (logger.isDebugEnabled()) {
             logger.debug("Cleaning up temporary resources created for testing ...");
         }
+        
+        PermissionRoleClient client = new PermissionRoleClient();
+        for (String resourceId : allResourceIdsCreated) {
+
+            ClientResponse<Response> res = client.delete(resourceId, "123");
+            int statusCode = res.getStatus();
+            try {
+                   if (logger.isDebugEnabled()) {
+                       logger.debug("cleanup: delete relationships for permission id="
+                               + resourceId + " status=" + statusCode);
+                   }
+                   Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                           invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+                   Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            } finally {
+               res.releaseConnection();
+            }
+        }
+
         for (PermissionValue pv : permValues.values()) {
             deletePermission(pv.getPermissionId());
         }
@@ -412,6 +510,13 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Creates the permission.
+     *
+     * @param resName the res name
+     * @param effect the effect
+     * @return the string
+     */
     private String createPermission(String resName, EffectType effect) {
         setupCreate();
         PermissionClient permClient = new PermissionClient();
@@ -432,21 +537,36 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
         return extractId(res);
     }
 
+    /**
+     * Delete permission.
+     *
+     * @param permId the perm id
+     */
     private void deletePermission(String permId) {
         setupDelete();
         PermissionClient permClient = new PermissionClient();
         ClientResponse<Response> res = permClient.delete(permId);
         int statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug("deletePermission: delete permission id="
-                    + permId + " status=" + statusCode);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug("deletePermission: delete permission id="
+                           + permId + " status=" + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         res.releaseConnection();
     }
 
+    /**
+     * Creates the role.
+     *
+     * @param roleName the role name
+     * @return the string
+     */
     private String createRole(String roleName) {
         setupCreate();
         RoleClient roleClient = new RoleClient();
@@ -466,18 +586,27 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
         return extractId(res);
     }
 
+    /**
+     * Delete role.
+     *
+     * @param roleId the role id
+     */
     private void deleteRole(String roleId) {
         setupDelete();
         RoleClient roleClient = new RoleClient();
         ClientResponse<Response> res = roleClient.delete(roleId);
         int statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug("deleteRole: delete role id=" + roleId
-                    + " status=" + statusCode);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug("deleteRole: delete role id=" + roleId
+                           + " status=" + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         res.releaseConnection();
     }
 }
index 2ced449268009080364e28f855573fc598e99647..06cafd955460d001fd45fec97ce755499c5f001f 100644 (file)
@@ -22,7 +22,7 @@
  */
 package org.collectionspace.services.authorization.client.test;
 
-import java.util.ArrayList;
+//import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.Response;
 //import org.collectionspace.services.authorization.ActionType;
@@ -44,7 +44,6 @@ import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterClass;
 
 /**
  * PermissionServiceTest, carries out tests against a
@@ -55,16 +54,22 @@ import org.testng.annotations.AfterClass;
  */
 public class PermissionServiceTest extends AbstractServiceTestImpl {
 
+    /** The Constant logger. */
     static private final Logger logger =
             LoggerFactory.getLogger(PermissionServiceTest.class);
     // Instance variables specific to this test.
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
+    
+    /** The add tenant. */
     boolean addTenant = true;
     /*
      * This method is called only by the parent class, AbstractServiceTestImpl
      */
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     protected String getServicePathComponent() {
         return new PermissionClient().getServicePathComponent();
@@ -88,6 +93,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
        throw new UnsupportedOperationException();
     }
     
+       /* (non-Javadoc)
+        * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
+        */
        @Test(dataProvider = "testName")
        @Override
     public void readPaginatedList(String testName) throws Exception {
@@ -98,7 +106,10 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
-    @Override
+    /* (non-Javadoc)
+        * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+        */
+       @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
 
@@ -141,6 +152,12 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Creates the without resource name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithoutResourceName(String testName) throws Exception {
@@ -169,6 +186,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     }
 
     //to not cause uniqueness violation for permission, createList is removed
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -224,16 +244,25 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
@@ -243,6 +272,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -270,6 +302,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read"})
@@ -297,6 +332,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
@@ -327,6 +365,12 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Search resource name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void searchResourceName(String testName) throws Exception {
@@ -366,6 +410,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read", "readList", "readNonExistent"})
@@ -404,6 +451,12 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
                 "Data in updated object did not match submitted data.");
     }
 
+    /**
+     * Update actions.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"update"})
     public void updateActions(String testName) throws Exception {
@@ -455,21 +508,33 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
@@ -509,6 +574,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"updateActions"})
@@ -533,6 +601,9 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"delete"})
@@ -562,6 +633,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
     /**
      * Tests the code for manually submitting data that is used by several
      * of the methods above.
+     * @throws Exception 
      */
     @Test(dependsOnMethods = {"create", "read"})
     public void testSubmitRequest() throws Exception {
@@ -596,7 +668,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
      * @param useResourceName
      * @param useAction
      * @param useEffect
-     * @return
+     * @return permission
      */
     public static Permission createPermissionInstance(String resourceName,
             String description,
@@ -617,29 +689,13 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         return permission;
     }
 
-    @AfterClass(alwaysRun = true)
-    public void cleanUp() {
-        setupDelete("delete");
-        String noTest = System.getProperty("noTestCleanup");
-        if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-        }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-        PermissionClient client = new PermissionClient();
-        for (String resourceId : allResourceIdsCreated) {
-            ClientResponse<Response> res = client.delete(resourceId);
-            int statusCode = res.getStatus();
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        }
-    }
-
+    /**
+     * Prints the list.
+     *
+     * @param testName the test name
+     * @param list the list
+     * @return the int
+     */
     private int printList(String testName, PermissionsList list) {
 
         int i = 0;
index 697faa1a8aed0c9d1fcecb418f2d56197616febf..507d6e7cea91ddedb65c6785a218037e8301806e 100644 (file)
@@ -22,8 +22,8 @@
  */
 package org.collectionspace.services.authorization.client.test;
 
-import java.util.ArrayList;
-import java.util.List;
+//import java.util.ArrayList;
+//import java.util.List;
 import javax.ws.rs.core.Response;
 
 import org.collectionspace.services.client.CollectionSpaceClient;
@@ -41,7 +41,6 @@ import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterClass;
 
 /**
  * RoleServiceTest, carries out tests against a
@@ -52,16 +51,22 @@ import org.testng.annotations.AfterClass;
  */
 public class RoleServiceTest extends AbstractServiceTestImpl {
 
+    /** The logger. */
     private final Logger logger =
             LoggerFactory.getLogger(RoleServiceTest.class);
     // Instance variables specific to this test.
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
-    boolean addTenant = true;
+//    private List<String> allResourceIdsCreated = new ArrayList<String>();
+    /** The add tenant. */
+boolean addTenant = true;
     /*
      * This method is called only by the parent class, AbstractServiceTestImpl
      */
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     protected String getServicePathComponent() {
         return new RoleClient().getServicePathComponent();
@@ -85,6 +90,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
        throw new UnsupportedOperationException();
     }
     
+       /* (non-Javadoc)
+        * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
+        */
        @Test(dataProvider = "testName")
        @Override
     public void readPaginatedList(String testName) throws Exception {
@@ -95,6 +103,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
@@ -133,6 +144,12 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Creates the for unique role.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createForUniqueRole(String testName) throws Exception {
@@ -155,6 +172,12 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
     }
 
+    /**
+     * Creates the without role name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
     public void createWithoutRoleName(String testName) throws Exception {
@@ -178,6 +201,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     }
 
     //to not cause uniqueness violation for role, createList is removed
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -223,16 +249,25 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
@@ -242,6 +277,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"create"})
@@ -269,6 +307,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read"})
@@ -296,6 +337,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
@@ -326,6 +370,12 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Search role name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"createList", "read"})
     public void searchRoleName(String testName) throws Exception {
@@ -365,6 +415,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"read", "readList", "readNonExistent"})
@@ -407,21 +460,33 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
        //FIXME: Should this test really be empty?  If so, please comment accordingly.
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
@@ -456,6 +521,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"update"})
@@ -480,6 +548,9 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
     dependsOnMethods = {"delete"})
@@ -509,6 +580,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
     /**
      * Tests the code for manually submitting data that is used by several
      * of the methods above.
+     * @throws Exception 
      */
     @Test(dependsOnMethods = {"create", "read"})
     public void testSubmitRequest() throws Exception {
@@ -539,7 +611,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
      * @param roleName
      * @param description
      * @param useRoleName
-     * @return
+     * @return role
      */
     public Role createRoleInstance(String roleName,
             String description,
@@ -555,29 +627,13 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    @AfterClass(alwaysRun = true)
-    public void cleanUp() {
-        setupDelete("delete");
-        String noTest = System.getProperty("noTestCleanup");
-       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-       }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-        RoleClient client = new RoleClient();
-        for (String resourceId : allResourceIdsCreated) {
-            ClientResponse<Response> res = client.delete(resourceId);
-            int statusCode = res.getStatus();
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        }
-    }
-
+    /**
+     * Prints the list.
+     *
+     * @param testName the test name
+     * @param list the list
+     * @return the int
+     */
     private int printList(String testName, RolesList list) {
 
         int i = 0;
index 7755b48aad8830651d5e3bccf6795bf3811bf8c4..1aa2f03807b41846b56d0ba6ec527323e993f32c 100644 (file)
@@ -26,45 +26,52 @@ package org.collectionspace.services.client;
 import java.io.InputStream;\r
 import java.net.URL;\r
 import java.util.Properties;\r
+\r
+import javax.ws.rs.core.Response;\r
+\r
+//import javax.ws.rs.core.Response;\r
+\r
 import org.apache.commons.httpclient.HttpClient;\r
 import org.apache.commons.httpclient.UsernamePasswordCredentials;\r
-import org.apache.commons.httpclient.auth.AuthScope;\r
-//import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;\r
+import org.apache.commons.httpclient.auth.AuthScope; //import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;\r
 import org.collectionspace.services.jaxb.AbstractCommonList;\r
-import org.jboss.resteasy.client.ClientResponse;\r
-//import org.collectionspace.services.common.context.ServiceContext;\r
+import org.jboss.resteasy.client.ClientResponse; //import org.collectionspace.services.common.context.ServiceContext;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
 /**\r
- * BaseServiceClient is an abstract base client of all service clients\r
- * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684\r
+ * BaseServiceClient is an abstract base client of all service clients FIXME:\r
+ * http://issues.collectionspace.org/browse/CSPACE-1684\r
+ * @param <CommonListType> \r
+ * @param <ListType> \r
  */\r
-public abstract class AbstractServiceClientImpl implements CollectionSpaceClient {\r
-\r
-    /** The logger. */\r
-    protected final Logger logger = LoggerFactory.getLogger(AbstractServiceClientImpl.class);\r
-    \r
-    /**\r
-     * The character used to separate the words in a part label\r
-     */\r
-    public static final String PART_LABEL_SEPERATOR = "_";\r
-    \r
-    /** The Constant PART_COMMON_LABEL. */\r
-    public static final String PART_COMMON_LABEL = "common";\r
-    \r
-    /** The properties. */\r
-    private Properties properties = new Properties();\r
-    \r
-    /** The url. */\r
-    private URL url;\r
-    \r
-    /** The http client. */\r
-    private HttpClient httpClient;\r
+public abstract class AbstractServiceClientImpl implements\r
+       CollectionSpaceClient {\r
+\r
+       /** The logger. */\r
+       protected final Logger logger = LoggerFactory\r
+       .getLogger(AbstractServiceClientImpl.class);\r
+\r
+       /**\r
+        * The character used to separate the words in a part label\r
+        */\r
+       public static final String PART_LABEL_SEPERATOR = "_";\r
+\r
+       /** The Constant PART_COMMON_LABEL. */\r
+       public static final String PART_COMMON_LABEL = "common";\r
+\r
+       /** The properties. */\r
+       private Properties properties = new Properties();\r
+\r
+       /** The url. */\r
+       private URL url;\r
+\r
+       /** The http client. */\r
+       private HttpClient httpClient;\r
 \r
        /**\r
         * Gets the common part name.\r
-        *\r
+        * \r
         * @return the common part name\r
         */\r
        public String getCommonPartName() {\r
@@ -73,207 +80,246 @@ public abstract class AbstractServiceClientImpl implements CollectionSpaceClient
 \r
        /**\r
         * Gets the common part name.\r
-        *\r
-        * @param servicePathComponent the service path component\r
+        * \r
+        * @param servicePathComponent\r
+        *            the service path component\r
         * @return the common part name\r
         */\r
        public String getCommonPartName(String servicePathComponent) {\r
-               return servicePathComponent\r
-               + PART_LABEL_SEPERATOR\r
-               + PART_COMMON_LABEL;\r
+               return servicePathComponent + PART_LABEL_SEPERATOR + PART_COMMON_LABEL;\r
        }\r
 \r
        /**\r
         * Gets the service path component.\r
-        *\r
+        * \r
         * @return the service path component\r
         */\r
        abstract public String getServicePathComponent();\r
-    \r
-    /**\r
-     * Instantiates a new abstract service client impl.\r
-     */\r
-    protected AbstractServiceClientImpl() {\r
-        readProperties();\r
-        setupHttpClient();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#getProperty(java.lang.String)\r
-     */\r
-    @Override\r
-    public String getProperty(String propName) {\r
-        return properties.getProperty(propName);\r
-    }\r
 \r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#setProperty(java.lang.String, java.lang.String)\r
-     */\r
-    @Override\r
-    public void setProperty(String propName, String value) {\r
-        properties.setProperty(propName, value);\r
-    }\r
+       /**\r
+        * Instantiates a new abstract service client impl.\r
+        */\r
+       protected AbstractServiceClientImpl() {\r
+               readProperties();\r
+               setupHttpClient();\r
+       }\r
 \r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#removeProperty(java.lang.String)\r
-     */\r
-    @Override\r
-    public Object removeProperty(String propName) {\r
-        return properties.remove(propName);\r
-    }\r
-\r
-    /**\r
-     * Prints the properties.\r
-     */\r
-    public void printProperties() {\r
-        for(Object kobj : properties.keySet()){\r
-            String key = (String) kobj;\r
-            logger.trace("begin property name=" + key + " value=" + properties.get(key));\r
-        }\r
-    }\r
-    \r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#getBaseURL()\r
-     */\r
-    @Override\r
-    public String getBaseURL() {\r
-        return properties.getProperty(URL_PROPERTY);\r
-    }\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.collectionspace.services.client.CollectionSpaceClient#getProperty\r
+        * (java.lang.String)\r
+        */\r
+       @Override\r
+       public String getProperty(String propName) {\r
+               return properties.getProperty(propName);\r
+       }\r
 \r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#getHttpClient()\r
-     */\r
-    @Override\r
-    public HttpClient getHttpClient() {\r
-        return httpClient;\r
-    }\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.collectionspace.services.client.CollectionSpaceClient#setProperty\r
+        * (java.lang.String, java.lang.String)\r
+        */\r
+       @Override\r
+       public void setProperty(String propName, String value) {\r
+               properties.setProperty(propName, value);\r
+       }\r
 \r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#useAuth()\r
-     */\r
-    @Override\r
-    public boolean useAuth() {\r
-        String auth = properties.getProperty(AUTH_PROPERTY);\r
-        return Boolean.valueOf(auth);\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#useSSL()\r
-     */\r
-    @Override\r
-    public boolean useSSL() {\r
-        String ssl = properties.getProperty(SSL_PROPERTY);\r
-        return Boolean.valueOf(ssl);\r
-    }\r
-\r
-    /**\r
-     * readProperties reads properties from system class path as well\r
-     * as it overrides properties made available using command line\r
-     * @exception RuntimeException\r
-     */\r
-    private void readProperties() {\r
-\r
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();\r
-        InputStream is = null;\r
-        try{\r
-            is = cl.getResourceAsStream("collectionspace-client.properties");\r
-            properties.load(is);\r
-            if(logger.isDebugEnabled()){\r
-                printProperties();\r
-            }\r
-            String spec = System.getProperty(URL_PROPERTY);\r
-            if(spec != null && !"".equals(spec)){\r
-                properties.setProperty(URL_PROPERTY, spec);\r
-            }\r
-\r
-            spec = properties.getProperty(URL_PROPERTY);\r
-            url = new URL(spec);\r
-            if(logger.isInfoEnabled()){\r
-                logger.info("readProperties() using url=" + url);\r
-            }\r
-\r
-            String auth = System.getProperty(AUTH_PROPERTY);\r
-            if(auth != null && !"".equals(auth)){\r
-                properties.setProperty(AUTH_PROPERTY, auth);\r
-            }\r
-            String ssl = System.getProperty(SSL_PROPERTY);\r
-            if(ssl != null && !"".equals(ssl)){\r
-                properties.setProperty(AUTH_PROPERTY, ssl);\r
-            }\r
-            String user = System.getProperty(USER_PROPERTY);\r
-            if(user != null && !"".equals(user)){\r
-                properties.setProperty(USER_PROPERTY, user);\r
-            }\r
-            String password = System.getProperty(PASSWORD_PROPERTY);\r
-            if(password != null && !"".equals(password)){\r
-                properties.setProperty(PASSWORD_PROPERTY, password);\r
-            }\r
-            if(logger.isDebugEnabled()){\r
-                printProperties();\r
-            }\r
-        }catch(Exception e){\r
-            logger.debug("Caught exception while reading properties", e);\r
-            throw new RuntimeException(e);\r
-        }finally{\r
-            if(is != null){\r
-                try{\r
-                    is.close();\r
-                }catch(Exception e){\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * setupHttpClient sets up HTTP client for the service client\r
-     * the setup process relies on the following properties\r
-     * URL_PROPERTY\r
-     * USER_PROPERTY\r
-     * PASSWORD_PROPERTY\r
-     * AUTH_PROPERTY\r
-     * SSL_PROPERTY\r
-     */\r
-    @Override\r
-    public void setupHttpClient() {\r
-        this.httpClient = new HttpClient();\r
-        if(useAuth()){\r
-            String user = properties.getProperty(USER_PROPERTY);\r
-            String password = properties.getProperty(PASSWORD_PROPERTY);\r
-            if(logger.isInfoEnabled()){\r
-                logger.info("setupHttpClient() using url=" + url +\r
-                        " user=" + user + " password=" + password);\r
-            }\r
-\r
-            httpClient.getState().setCredentials(\r
-                    new AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM),\r
-                    new UsernamePasswordCredentials(user, password));\r
-            //JAXRS client library requires HTTP preemptive authentication\r
-            httpClient.getParams().setAuthenticationPreemptive(true);\r
-            if(logger.isInfoEnabled()){\r
-                logger.info("setupHttpClient: set preemptive authentication");\r
-            }\r
-        } else {\r
-            if(logger.isInfoEnabled()){\r
-                logger.info("setupHttpClient() : no auth mode!");\r
-            }\r
-        }\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#isServerSecure()\r
-     */\r
-    @Override\r
-    public boolean isServerSecure() {\r
-        return Boolean.getBoolean("cspace.server.secure");\r
-    }\r
-    \r
-    /* (non-Javadoc)\r
-     * @see org.collectionspace.services.client.CollectionSpaceClient#readList(java.lang.String, java.lang.String)\r
-     */\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.collectionspace.services.client.CollectionSpaceClient#removeProperty\r
+        * (java.lang.String)\r
+        */\r
+       @Override\r
+       public Object removeProperty(String propName) {\r
+               return properties.remove(propName);\r
+       }\r
+\r
+       /**\r
+        * Prints the properties.\r
+        */\r
+       public void printProperties() {\r
+               for (Object kobj : properties.keySet()) {\r
+                       String key = (String) kobj;\r
+                       logger.trace("begin property name=" + key + " value="\r
+                                       + properties.get(key));\r
+               }\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.collectionspace.services.client.CollectionSpaceClient#getBaseURL()\r
+        */\r
+       @Override\r
+       public String getBaseURL() {\r
+               return properties.getProperty(URL_PROPERTY);\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.collectionspace.services.client.CollectionSpaceClient#getHttpClient()\r
+        */\r
+       @Override\r
+       public HttpClient getHttpClient() {\r
+               return httpClient;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see org.collectionspace.services.client.CollectionSpaceClient#useAuth()\r
+        */\r
+       @Override\r
+       public boolean useAuth() {\r
+               String auth = properties.getProperty(AUTH_PROPERTY);\r
+               return Boolean.valueOf(auth);\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see org.collectionspace.services.client.CollectionSpaceClient#useSSL()\r
+        */\r
+       @Override\r
+       public boolean useSSL() {\r
+               String ssl = properties.getProperty(SSL_PROPERTY);\r
+               return Boolean.valueOf(ssl);\r
+       }\r
+\r
+       /**\r
+        * readProperties reads properties from system class path as well as it\r
+        * overrides properties made available using command line\r
+        * \r
+        * @exception RuntimeException\r
+        */\r
+       private void readProperties() {\r
+\r
+               ClassLoader cl = Thread.currentThread().getContextClassLoader();\r
+               InputStream is = null;\r
+               try {\r
+                       is = cl.getResourceAsStream("collectionspace-client.properties");\r
+                       properties.load(is);\r
+                       if (logger.isDebugEnabled()) {\r
+                               printProperties();\r
+                       }\r
+                       String spec = System.getProperty(URL_PROPERTY);\r
+                       if (spec != null && !"".equals(spec)) {\r
+                               properties.setProperty(URL_PROPERTY, spec);\r
+                       }\r
+\r
+                       spec = properties.getProperty(URL_PROPERTY);\r
+                       url = new URL(spec);\r
+                       if (logger.isInfoEnabled()) {\r
+                               logger.info("readProperties() using url=" + url);\r
+                       }\r
+\r
+                       String auth = System.getProperty(AUTH_PROPERTY);\r
+                       if (auth != null && !"".equals(auth)) {\r
+                               properties.setProperty(AUTH_PROPERTY, auth);\r
+                       }\r
+                       String ssl = System.getProperty(SSL_PROPERTY);\r
+                       if (ssl != null && !"".equals(ssl)) {\r
+                               properties.setProperty(AUTH_PROPERTY, ssl);\r
+                       }\r
+                       String user = System.getProperty(USER_PROPERTY);\r
+                       if (user != null && !"".equals(user)) {\r
+                               properties.setProperty(USER_PROPERTY, user);\r
+                       }\r
+                       String password = System.getProperty(PASSWORD_PROPERTY);\r
+                       if (password != null && !"".equals(password)) {\r
+                               properties.setProperty(PASSWORD_PROPERTY, password);\r
+                       }\r
+                       if (logger.isDebugEnabled()) {\r
+                               printProperties();\r
+                       }\r
+               } catch (Exception e) {\r
+                       logger.debug("Caught exception while reading properties", e);\r
+                       throw new RuntimeException(e);\r
+               } finally {\r
+                       if (is != null) {\r
+                               try {\r
+                                       is.close();\r
+                               } catch (Exception e) {\r
+                                       if (logger.isDebugEnabled() == true) {\r
+                                               e.printStackTrace();\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * setupHttpClient sets up HTTP client for the service client the setup\r
+        * process relies on the following properties URL_PROPERTY USER_PROPERTY\r
+        * PASSWORD_PROPERTY AUTH_PROPERTY SSL_PROPERTY\r
+        */\r
+       @Override\r
+       public void setupHttpClient() {\r
+               this.httpClient = new HttpClient();\r
+               if (useAuth()) {\r
+                       String user = properties.getProperty(USER_PROPERTY);\r
+                       String password = properties.getProperty(PASSWORD_PROPERTY);\r
+                       if (logger.isInfoEnabled()) {\r
+                               logger.info("setupHttpClient() using url=" + url + " user="\r
+                                               + user + " password=" + password);\r
+                       }\r
+\r
+                       httpClient.getState().setCredentials(\r
+                                       new AuthScope(url.getHost(), url.getPort(),\r
+                                                       AuthScope.ANY_REALM),\r
+                                                       new UsernamePasswordCredentials(user, password));\r
+                       // JAXRS client library requires HTTP preemptive authentication\r
+                       httpClient.getParams().setAuthenticationPreemptive(true);\r
+                       if (logger.isInfoEnabled()) {\r
+                               logger.info("setupHttpClient: set preemptive authentication");\r
+                       }\r
+               } else {\r
+                       if (logger.isInfoEnabled()) {\r
+                               logger.info("setupHttpClient() : no auth mode!");\r
+                       }\r
+               }\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.collectionspace.services.client.CollectionSpaceClient#isServerSecure\r
+        * ()\r
+        */\r
+       @Override\r
+       public boolean isServerSecure() {\r
+               return Boolean.getBoolean("cspace.server.secure");\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.collectionspace.services.client.CollectionSpaceClient#readList(java\r
+        * .lang.String, java.lang.String)\r
+        */\r
+       @Override\r
+       public ClientResponse<AbstractCommonList> readList(String pageSize,\r
+                       String pageNumber) {\r
+               return getProxy().readList(pageSize, pageNumber);\r
+       }\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.collectionspace.services.client.CollectionSpaceClient#delete(java.lang.String)\r
+        */\r
     @Override\r
-    public ClientResponse<AbstractCommonList> readList(String pageSize,\r
-               String pageNumber) {\r
-       return getProxy().readList(pageSize, pageNumber);\r
-    }\r
-    \r
+       public ClientResponse<Response> delete(String csid) {\r
+       // must override in children if you want behavior\r
+               throw new UnsupportedOperationException();\r
+       }       \r
 }\r
index 59c19888fd401e9f6f9537b20f7c0af236984453..82adaede4f8dbbdd4e37d5c0d9e18371b606def8 100644 (file)
@@ -22,6 +22,8 @@
  *  limitations under the License.
  */
 package org.collectionspace.services.client;
+import javax.ws.rs.core.Response;
+
 import org.apache.commons.httpclient.HttpClient;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.jboss.resteasy.client.ClientResponse;
@@ -118,7 +120,7 @@ public interface CollectionSpaceClient {
 
     /**
      * checks System property cspace.server.secure
-     * @return
+     * @return boolean
      */
     boolean isServerSecure();
     
@@ -130,6 +132,14 @@ public interface CollectionSpaceClient {
      * @return the client response
      */
     public ClientResponse<AbstractCommonList> readList(String pageSize,
-               String pageNumber);    
+               String pageNumber);
+    
+    /**
+     * Delete.
+     *
+     * @param csid the csid
+     * @return the client response
+     */
+    public ClientResponse<Response> delete(String csid);
 
 }
index 379a354975b73711ad57a97846e07752af341eff..8374ff20865c70647e7dd8d6ab39e13609e3588b 100644 (file)
 
 package org.collectionspace.services.client;
 
+import javax.ws.rs.core.Response;
+
+import org.jboss.resteasy.client.ClientResponse;
+
 /**
  * A CollectionObjectClient.
 
@@ -43,5 +47,9 @@ public class TestServiceClient extends AbstractServiceClientImpl {
        @Override
        public CollectionSpaceProxy getProxy() {
                throw new UnsupportedOperationException();
-       }  
+       }
+       
+       public ClientResponse<Response> delete(String csid) {
+               throw new UnsupportedOperationException();
+       }
 }
index 8d2dc3eb199846b9b979747d163f5710ff2b0655..7f2e8860a5c56a7a31d27efec92a924ba0da21dc 100644 (file)
@@ -25,6 +25,9 @@ package org.collectionspace.services.client.test;
 
 //import java.util.List;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.ws.rs.core.Response;
 
 import org.collectionspace.services.jaxb.AbstractCommonList;
@@ -34,6 +37,7 @@ import org.jboss.resteasy.client.ClientResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 /**
@@ -51,6 +55,9 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
        /** The Constant DEFAULT_LIST_SIZE. */
        static protected final int DEFAULT_LIST_SIZE = 10;
        static protected final int DEFAULT_PAGINATEDLIST_SIZE = 10;
+       
+       /* Use this to keep track of resources to delete */
+       protected List<String> allResourceIdsCreated = new ArrayList<String>(); 
 
 //    // Success outcomes
 //    /* (non-Javadoc)
@@ -242,21 +249,26 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
                        CollectionSpaceClient client,
                        long pageSize, long pageNumber) throws Exception {
                ClientResponse<AbstractCommonList> response =
-                       (ClientResponse<AbstractCommonList>)client.readList(Long.toString(pageSize),
-                                       Long.toString(pageNumber));
-               int statusCode = response.getStatus();
-
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if (getLogger().isDebugEnabled()) {
-                       getLogger().debug(testName + ": status = " + statusCode);
+                       client.readList(Long.toString(pageSize), Long.toString(pageNumber));
+               AbstractCommonList result = null;
+               try {
+                       int statusCode = response.getStatus();
+       
+                       // Check the status code of the response: does it match
+                       // the expected response(s)?
+                       if (getLogger().isDebugEnabled()) {
+                               getLogger().debug(testName + ": status = " + statusCode);
+                       }
+                       Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
+                                       invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
+                       Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+       
+                       result = this.getAbstractCommonList(response);
+               } finally {
+                       response.releaseConnection();
                }
-               Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
-                               invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
-               AbstractCommonList list = this.getAbstractCommonList(response);         
-               return list;
+               
+               return result;
        }
 
     /**
@@ -325,10 +337,10 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
         
         // Get the current total number of items.
         // If there are no items then create some
-        AbstractCommonList list = this.readList(testName, client, 1 /*pgSz*/, 0 /*pgNum*/);
+        AbstractCommonList list = (AbstractCommonList) this.readList(testName, client, 1 /*pgSz*/, 0 /*pgNum*/);
         if (list == null || list.getTotalItems() == 0) {
                this.createPaginatedList(testName, DEFAULT_PAGINATEDLIST_SIZE);
-               list = this.readList(testName, client, 1 /*pgSz*/, 0 /*pgNum*/);
+               list = (AbstractCommonList) this.readList(testName, client, 1 /*pgSz*/, 0 /*pgNum*/);
         }
 
         // Print out the current list size to be paginated
@@ -343,7 +355,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
         long pageSize = totalItems / 3; //create up to 3 pages to iterate over
         long pagesTotal = pageSize > 0 ? (totalItems / pageSize) : 0;
         for (int i = 0; i < pagesTotal; i++) {
-               list = this.readList(testName, client, pageSize, i);
+               list = (AbstractCommonList) this.readList(testName, client, pageSize, i);
                assertPaginationInfo(testName,
                                list,
                                i,                      //expected page number
@@ -355,7 +367,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
         // if there are any remainders be sure to paginate them as well
         long mod = totalItems % pageSize;
         if (mod != 0) {
-               list = this.readList(testName, client, pageSize, pagesTotal);
+               list = (AbstractCommonList) this.readList(testName, client, pageSize, pagesTotal);
                assertPaginationInfo(testName,
                                list, 
                                pagesTotal, //expected page number
@@ -489,6 +501,33 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
         // Expected status code: 400 Bad Request
        testSetup(Response.Status.BAD_REQUEST.getStatusCode(), ServiceRequestType.UPDATE, label);
     }
+    
+    /**
+     * 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(alwaysRun=true)
+    public void cleanUp() {
+        String noTest = System.getProperty("noTestCleanup");
+       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Skipping Cleanup phase ...");
+            }
+            return;
+       }
+        if (logger.isDebugEnabled()) {
+            logger.debug("Cleaning up temporary resources created for testing ...");
+        }
+        CollectionSpaceClient client = this.getClientInstance();
+        for (String resourceId : allResourceIdsCreated) {
+            // Note: Any non-success responses are ignored and not reported.
+            client.delete(resourceId).releaseConnection();
+        }
+    }    
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.ServiceTest#updateNonExistent(java.lang.String)
index 0f2f42ac0e436b0e6257a7af06c8ea8dd9be7f99..be29719c43a296de73199da9a822cce3e3ddfc5e 100644 (file)
@@ -31,7 +31,7 @@ import java.io.File;
 import java.io.InputStream;\r
 import java.io.StringWriter;\r
 import java.lang.reflect.Method;\r
-import java.util.ArrayList;\r
+//import java.util.ArrayList;\r
 import java.util.List;\r
 \r
 import javax.ws.rs.core.MultivaluedMap;\r
@@ -42,6 +42,8 @@ import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;\r
 import javax.xml.parsers.DocumentBuilderFactory;\r
 \r
+import org.apache.commons.httpclient.HttpMethodBase;\r
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;\r
 import org.apache.commons.httpclient.methods.DeleteMethod;\r
 import org.apache.commons.httpclient.methods.GetMethod;\r
 import org.apache.commons.httpclient.methods.PostMethod;\r
@@ -63,6 +65,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 /**\r
  * FIXME: http://issues.collectionspace.org/browse/CSPACE-1685\r
  * The Class BaseServiceTest.\r
+ * @param <CommonListType> \r
  */\r
 public abstract class BaseServiceTest {\r
 \r
@@ -228,21 +231,23 @@ public abstract class BaseServiceTest {
      */\r
     protected int submitRequest(String method, String url) {\r
         int statusCode = 0;\r
+        HttpMethodBase httpMethod = null;\r
         try {\r
             TestServiceClient client = new TestServiceClient();\r
             if (method.equals(javax.ws.rs.HttpMethod.DELETE)) {\r
-                DeleteMethod deleteMethod = new DeleteMethod(url);\r
-                statusCode = client.getHttpClient().executeMethod(deleteMethod);\r
+               httpMethod = new DeleteMethod(url);\r
             } else if (method.equals(javax.ws.rs.HttpMethod.GET)) {\r
-                GetMethod getMethod = new GetMethod(url);\r
-                statusCode = client.getHttpClient().executeMethod(getMethod);\r
-            } else {\r
-                // Do nothing - leave status code at default value.\r
+               httpMethod = new GetMethod(url);\r
+            }\r
+            if (httpMethod != null) {\r
+                statusCode = client.getHttpClient().executeMethod(httpMethod);\r
             }\r
         } catch (Exception e) {\r
             logger.error(\r
                     "Exception during HTTP " + method + " request to "\r
                     + url + ":", e);\r
+        } finally {\r
+               httpMethod.releaseConnection();\r
         }\r
         return statusCode;\r
     }\r
@@ -265,27 +270,26 @@ public abstract class BaseServiceTest {
     protected int submitRequest(String method, String url, String mediaType,\r
             String entityStr) {\r
         int statusCode = 0;\r
+        EntityEnclosingMethod httpMethod = null;\r
         try {\r
             TestServiceClient client = new TestServiceClient();\r
             if (method.equals(javax.ws.rs.HttpMethod.POST)) {\r
-                StringRequestEntity entityBody =\r
-                        new StringRequestEntity(mediaType, entityStr, NULL_CHARSET);\r
-                PostMethod postMethod = new PostMethod(url);\r
-                postMethod.setRequestEntity(entityBody);\r
-                statusCode = client.getHttpClient().executeMethod(postMethod);\r
+                httpMethod = new PostMethod(url);\r
             } else if (method.equals(javax.ws.rs.HttpMethod.PUT)) {\r
+                httpMethod = new PutMethod(url);\r
+            }\r
+            if (httpMethod != null) {\r
                 StringRequestEntity entityBody =\r
-                        new StringRequestEntity(mediaType, entityStr, NULL_CHARSET);\r
-                PutMethod putMethod = new PutMethod(url);\r
-                putMethod.setRequestEntity(entityBody);\r
-                statusCode = client.getHttpClient().executeMethod(putMethod);\r
-            } else {\r
-                // Do nothing - leave status code at default value.\r
+                    new StringRequestEntity(mediaType, entityStr, NULL_CHARSET);\r
+               httpMethod.setRequestEntity(entityBody);\r
+               statusCode = client.getHttpClient().executeMethod(httpMethod);\r
             }\r
         } catch (Exception e) {\r
             logger.error(\r
                     "Exception during HTTP " + method + " request to "\r
                     + url + ":", e);\r
+        } finally {\r
+               httpMethod.releaseConnection();\r
         }\r
         return statusCode;\r
     }\r
@@ -297,8 +301,8 @@ public abstract class BaseServiceTest {
      * @return the string\r
      */\r
     static protected String extractId(ClientResponse<Response> res) {\r
-        MultivaluedMap mvm = res.getMetadata();\r
-        String uri = (String) ((ArrayList) mvm.get("Location")).get(0);\r
+        MultivaluedMap<String, Object> mvm = res.getMetadata();\r
+        String uri = (String) ((List<Object>) mvm.get("Location")).get(0);\r
         if (logger.isDebugEnabled()) {\r
             logger.debug("extractId:uri=" + uri);\r
         }\r
@@ -338,7 +342,7 @@ public abstract class BaseServiceTest {
      * @return the object\r
      * @throws Exception the exception\r
      */\r
-    static protected Object extractPart(MultipartInput input, String label, Class clazz)\r
+    static protected Object extractPart(MultipartInput input, String label, Class<?> clazz)\r
             throws Exception {\r
         Object obj = null;\r
         String partLabel = "";\r
@@ -397,7 +401,7 @@ public abstract class BaseServiceTest {
      * @return the part object\r
      * @throws JAXBException the jAXB exception\r
      */\r
-    static protected Object getPartObject(String partStr, Class clazz)\r
+    static protected Object getPartObject(String partStr, Class<?> clazz)\r
             throws JAXBException {\r
         JAXBContext jc = JAXBContext.newInstance(clazz);\r
         ByteArrayInputStream bais = null;\r
@@ -411,6 +415,9 @@ public abstract class BaseServiceTest {
                 try {\r
                     bais.close();\r
                 } catch (Exception e) {\r
+                       if (logger.isDebugEnabled() == true) {\r
+                               e.printStackTrace();\r
+                       }\r
                 }\r
             }\r
         }\r
@@ -424,7 +431,7 @@ public abstract class BaseServiceTest {
      * @param clazz the clazz\r
      * @return the string\r
      */\r
-    static protected String objectAsXmlString(Object o, Class clazz) {\r
+    static protected String objectAsXmlString(Object o, Class<?> clazz) {\r
         StringWriter sw = new StringWriter();\r
         try {\r
             JAXBContext jc = JAXBContext.newInstance(clazz);\r
@@ -445,7 +452,7 @@ public abstract class BaseServiceTest {
      * @return\r
      * @throws Exception\r
      */\r
-    static protected Object getObjectFromFile(Class jaxbClass, String fileName)\r
+    static protected Object getObjectFromFile(Class<?> jaxbClass, String fileName)\r
             throws Exception {\r
 \r
         JAXBContext context = JAXBContext.newInstance(jaxbClass);\r
@@ -493,7 +500,7 @@ public abstract class BaseServiceTest {
      * @return\r
      * @throws Exception\r
      */\r
-    static protected Object getObjectFromStream(Class jaxbClass, InputStream is) throws Exception {\r
+    static protected Object getObjectFromStream(Class<?> jaxbClass, InputStream is) throws Exception {\r
         JAXBContext context = JAXBContext.newInstance(jaxbClass);\r
         Unmarshaller unmarshaller = context.createUnmarshaller();\r
         //note: setting schema to null will turn validator off\r
@@ -507,10 +514,10 @@ public abstract class BaseServiceTest {
      * @param map the map\r
      * @return the string\r
      */\r
-    protected String mapAsString(MultivaluedMap map) {\r
+    protected String mapAsString(MultivaluedMap<String, Object> map) {\r
         StringBuffer sb = new StringBuffer();\r
         for (Object entry : map.entrySet()) {\r
-            MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry;\r
+            MultivaluedMap.Entry<String, Object> mentry = (MultivaluedMap.Entry<String, Object>) entry;\r
             sb.append("    name=" + mentry.getKey());\r
             sb.append(" value=" + mentry.getValue() + "\n");\r
         }\r
index e778414a648315d06acfb891c35eabbc812c61ce..2958bca3dd7e092183564e78ed79aef3eb85127a 100644 (file)
@@ -45,6 +45,8 @@ public interface ServiceTest {
      * Tests creation of a new resource.
      *
      * Relied upon by 'read', 'update' and 'delete' tests, below.
+     * @param testName 
+     * @throws Exception 
      */
     public void create(String testName) throws Exception;
 
@@ -53,6 +55,8 @@ public interface ServiceTest {
      * calling create(), and relies on the latter's test assertion(s).
      *
      * Relied upon by 'read list' tests, below.
+     * @param testName 
+     * @throws Exception 
      */
     public void createList(String testName) throws Exception;
 
@@ -61,12 +65,16 @@ public interface ServiceTest {
     /**
      * Tests creation of a resource by submitting
      * an empty entity body (aka empty payload).
+     * @param testName 
+     * @throws Exception 
      */
     public void createWithEmptyEntityBody(String testName) throws Exception;
 
     /**
      * Tests creation of a resource by submitting
      * a representation with malformed XML data.
+     * @param testName 
+     * @throws Exception 
      */
     public void createWithMalformedXml(String testName) throws Exception;
 
@@ -74,6 +82,8 @@ public interface ServiceTest {
      * Tests creation of a resource by submitting
      * a representation in the wrong XML schema
      * (e.g. not matching the object's schema).
+     * @param testName 
+     * @throws Exception 
      */
     public void createWithWrongXmlSchema(String testName) throws Exception;
 
@@ -89,6 +99,8 @@ public interface ServiceTest {
 
     /**
      * Tests reading (i.e. retrieval) of a resource.
+     * @param testName 
+     * @throws Exception 
      */
     public void read(String testName) throws Exception;
 
@@ -98,6 +110,8 @@ public interface ServiceTest {
      * Tests reading (i.e. retrieval) of a non-existent
      * resource, whose resource identifier does not exist
      * at the specified URL.
+     * @param testName 
+     * @throws Exception 
      */
     public void readNonExistent(String testName) throws Exception;
 
@@ -111,6 +125,8 @@ public interface ServiceTest {
     /**
      * Tests reading (i.e. retrieval) of a list of
      * multiple resources.
+     * @param testName 
+     * @throws Exception 
      */
     public void readList(String testName) throws Exception;
 
@@ -133,6 +149,8 @@ public interface ServiceTest {
 
     /**
      * Tests updating the content of a resource.
+     * @param testName 
+     * @throws Exception 
      */
     public void update(String testName) throws Exception;
 
@@ -141,6 +159,8 @@ public interface ServiceTest {
     /**
      * Tests updating the content of a resource
      * by submitting an empty entity body (aka empty payload).
+     * @param testName 
+     * @throws Exception 
      */
     public void updateWithEmptyEntityBody(String testName) throws Exception;
 
@@ -148,6 +168,8 @@ public interface ServiceTest {
      * Tests updating the content of a resource
      * by submitting a representation with malformed
      * XML data.
+     * @param testName 
+     * @throws Exception 
      */
     public void updateWithMalformedXml(String testName) throws Exception;
 
@@ -155,12 +177,16 @@ public interface ServiceTest {
      * Tests updating the content of a resource
      * by submitting a representation in the wrong
      * XML schema (e.g. not matching the object's schema).
+     * @param testName 
+     * @throws Exception 
      */
     public void updateWithWrongXmlSchema(String testName) throws Exception;
 
     /**
      * Tests updating the content of a non-existent
      * resource, whose resource identifier does not exist.
+     * @param testName 
+     * @throws Exception 
      */
     public void updateNonExistent(String testName) throws Exception;
 
@@ -173,6 +199,8 @@ public interface ServiceTest {
 
     /**
      * Tests deleting a resource.
+     * @param testName 
+     * @throws Exception 
      */
     public void delete(String testName) throws Exception;
 
@@ -181,6 +209,8 @@ public interface ServiceTest {
     /**
      * Tests deleting a non-existent resource, whose resource
      * identifier does not exist at the specified URL.
+     * @param testName 
+     * @throws Exception 
      */
     public void deleteNonExistent(String testName) throws Exception;
 
index f83f37aa2594dee0f739c7b9f1101ec5d1420cd8..1869975e56a3e88cd1b66d813ae69807674349bf 100644 (file)
  */
 package org.collectionspace.services.client;
 
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
 
-import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 //import org.collectionspace.services.common.context.ServiceContext;
@@ -100,12 +94,11 @@ public class CollectionObjectClient extends AbstractServiceClientImpl {
 
     }
 
-    @Override
-    public ClientResponse<AbstractCommonList> readList(String pageSize,
-               String pageNumber) {
-        return collectionObjectProxy.readList(pageSize, pageNumber);
-
-    }
+//    @Override
+//    public ClientResponse<CollectionobjectsCommonList> readList(String pageSize,
+//             String pageNumber) {
+//        return collectionObjectProxy.readList(pageSize, pageNumber);
+//    }
     
     /**
      * Roundtrip.
@@ -147,7 +140,7 @@ public class CollectionObjectClient extends AbstractServiceClientImpl {
 
     /**
      * @param csid
-     * @return
+     * @return response
      * @see org.collectionspace.services.client.CollectionObjectProxy#getAuthorityRefs(java.lang.String)
      */
     public ClientResponse<AuthorityRefList> getAuthorityRefs(String csid) {
@@ -188,6 +181,7 @@ public class CollectionObjectClient extends AbstractServiceClientImpl {
      * @see org.collectionspace.services.client.CollectionObjectProxy#delete()
      * @return the client response< response>
      */
+    @Override
     public ClientResponse<Response> delete(String csid) {
         return collectionObjectProxy.delete(csid);
     }
index a454f2279ad626555a017939711543c948baabcd..b6e2941b09a3d4956e51def4c2778f18a25a5429 100644 (file)
@@ -35,15 +35,15 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
+//import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+//import javax.ws.rs.core.UriInfo;
 
-import org.collectionspace.services.client.IClientQueryParams;
+//import org.collectionspace.services.client.IClientQueryParams;
 import org.collectionspace.services.client.CollectionSpaceProxy;
 import org.collectionspace.services.common.query.IQueryManager;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.jaxb.AbstractCommonList;
+//import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
 
 import org.jboss.resteasy.client.ClientResponse;
@@ -68,6 +68,21 @@ public interface CollectionObjectProxy extends CollectionSpaceProxy {
     @GET
     @Produces({"application/xml"})
     ClientResponse<CollectionobjectsCommonList> readList();
+    
+//    /**
+//     * Read list.
+//     *
+//     * @param pageSize the page size
+//     * @param pageNumber the page number
+//     * @return the client response
+//     */
+//    @GET
+//    @Produces({"application/xml"})
+//    @Override
+//    ClientResponse<CollectionobjectsCommonList> readList(
+//             @QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) String pageSize,
+//             @QueryParam(IClientQueryParams.START_PAGE_PARAM) String pageNumber);
+    
 
     /**
      * Roundtrip.
index ac23ec85473c4db3e1b37539adb11de27a3e07fa..f0f9737e8ff094194770b0d831464f1a0717ea76 100644 (file)
@@ -61,22 +61,48 @@ import org.slf4j.LoggerFactory;
  */
 public class CollectionObjectAuthRefsTest extends BaseServiceTest {
 
+   /** The logger. */
    private final Logger logger =
        LoggerFactory.getLogger(CollectionObjectAuthRefsTest.class);
 
     // Instance variables specific to this test.
+    /** The SERVIC e_ pat h_ component. */
     final String SERVICE_PATH_COMPONENT = "collectionobjects";
+    
+    /** The PERSO n_ authorit y_ name. */
     final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
+    
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> collectionObjectIdsCreated = new ArrayList();
-    private List<String> personIdsCreated = new ArrayList();
+    
+    /** The collection object ids created. */
+    private List<String> collectionObjectIdsCreated = new ArrayList<String>();
+    
+    /** The person ids created. */
+    private List<String> personIdsCreated = new ArrayList<String>();
+    
+    /** The CREATE d_ status. */
     private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
+    
+    /** The O k_ status. */
     private int OK_STATUS = Response.Status.OK.getStatusCode();
+    
+    /** The person auth csid. */
     private String personAuthCSID = null; 
+    
+    /** The content organization ref name. */
     private String contentOrganizationRefName = null;
+    
+    /** The content people ref name. */
     private String contentPeopleRefName = null;
+    
+    /** The content person ref name. */
     private String contentPersonRefName = null;
+    
+    /** The inscriber ref name. */
     private String inscriberRefName = null;
+    
+    /** The NU m_ aut h_ ref s_ expected. */
     private final int NUM_AUTH_REFS_EXPECTED = 4;
 
     /* (non-Javadoc)
@@ -100,6 +126,12 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /**
+     * Creates the with auth refs.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
     public void createWithAuthRefs(String testName) throws Exception {
 
@@ -151,6 +183,9 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest {
         collectionObjectIdsCreated.add(extractId(res));
     }
     
+    /**
+     * Creates the person refs.
+     */
     protected void createPersonRefs(){
        String authRefName = 
                PersonAuthorityClientUtils.createPersonAuthRefName(PERSON_AUTHORITY_NAME, false);
@@ -182,6 +217,14 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest {
         personIdsCreated.add(createPerson("Ingrid", "Inscriber", inscriberRefName));
     }
     
+    /**
+     * Creates the person.
+     *
+     * @param firstName the first name
+     * @param surName the sur name
+     * @param refName the ref name
+     * @return the string
+     */
     protected String createPerson(String firstName, String surName, String refName ) {
         Map<String, String> personInfo = new HashMap<String,String>();
         personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
@@ -200,6 +243,12 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest {
     }
 
     // Success outcomes
+    /**
+     * Read and check auth refs.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"createWithAuthRefs"})
     public void readAndCheckAuthRefs(String testName) throws Exception {
@@ -290,26 +339,40 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest {
         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
         for (String resourceId : collectionObjectIdsCreated) {
             // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
+            collectionObjectClient.delete(resourceId).releaseConnection();
         }
         // Note: Any non-success response is ignored and not reported.
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Delete persons before PersonAuth
         for (String resourceId : personIdsCreated) {
             // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+            personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
         }
-        ClientResponse<Response> res = personAuthClient.delete(personAuthCSID);
+        personAuthClient.delete(personAuthCSID).releaseConnection();
     }
 
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     public String getServicePathComponent() {
         return SERVICE_PATH_COMPONENT;
     }
 
+   /**
+    * Creates the collection object instance.
+    *
+    * @param title the title
+    * @param objNum the obj num
+    * @param contentOrganization the content organization
+    * @param contentPeople the content people
+    * @param contentPerson the content person
+    * @param inscriber the inscriber
+    * @return the multipart output
+    */
    private MultipartOutput createCollectionObjectInstance(
                                String title,
                                String objNum,
index 5b645d0e1baaf27f0a38944487a02d0a7435613a..7ed609f177866c053c40cc62fbba290efb774801 100644 (file)
@@ -22,7 +22,6 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -42,7 +41,6 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
@@ -64,21 +62,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
     /** The known resource id. */
     private String knownResourceId = null;
     
-    /** The all resource ids created. */
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
-    
     /** The multivalue. */
     private boolean multivalue; //toggle
 
-    /**
-     * Gets the logger.
-     *
-     * @return the logger
-     */
-    private Logger getLogger() {
-       return this.logger;
-    }
-
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
      */
@@ -984,36 +970,6 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    // ---------------------------------------------------------------
-    // Cleanup of resources created during testing
-    // ---------------------------------------------------------------
-    /**
-     * 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(alwaysRun = true)
-    public void cleanUp() {
-        String noTest = System.getProperty("noTestCleanup");
-       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-       }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-       CollectionObjectClient client = new CollectionObjectClient();
-       for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
-    }
-
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
index 1c4862f89b4da4f3b816c9c5d2e473b1c405e6ab..7eb0247bea2b3f1fe90c2efd4338815c95f5c54d 100644 (file)
@@ -128,7 +128,7 @@ public class DocumentFilter {
         // Set the page size\r
         //\r
         String pageSizeStr = null;\r
-        List<String> list = queryParams.remove(IClientQueryParams.PAGE_SIZE_PARAM);\r
+        List<String> list = queryParams.remove(IClientQueryParams.PAGE_SIZE_PARAM);  //REM: Should we really be removing this param?\r
         if (list != null) {\r
             pageSizeStr = list.get(0);\r
         }\r
@@ -138,7 +138,7 @@ public class DocumentFilter {
         // Set the start page\r
         //\r
         String startPageStr = null;\r
-        list = queryParams.remove(IClientQueryParams.START_PAGE_PARAM);\r
+        list = queryParams.remove(IClientQueryParams.START_PAGE_PARAM);        //REM: Should we really be removing this param?\r
         if (list != null) {\r
             startPageStr = list.get(0);\r
         }\r
index eed72b171f39f942ba33993e9a3873aefaa01d95..b3456559da1da9ab833c5a47945e5c0af22c23f3 100644 (file)
@@ -61,7 +61,6 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
     // Instance variables specific to this test.
     final String SERVICE_PATH_COMPONENT = "contacts";
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList();
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -143,14 +142,17 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
     // See Issue CSPACE-401.
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty??
     }
 
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty??
     }
 
     /*
@@ -406,13 +408,21 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
     @Override
-    public void updateWithEmptyEntityBody(String testName) throws Exception{
+    public void updateWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty??
     }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty??
     }
+
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty??
     }
 
     /*
@@ -602,30 +612,6 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    // ---------------------------------------------------------------
-    // Cleanup of resources created during testing
-    // ---------------------------------------------------------------
-
-    /**
-     * 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(alwaysRun=true)
-    public void cleanUp() {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-        ContactClient client = new ContactClient();
-        for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
-    }
-
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
@@ -633,5 +619,4 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
     public String getServicePathComponent() {
         return SERVICE_PATH_COMPONENT;
     }
-
 }
index 9d42e934f94e12dec5e8d5ff59f3f4dbbb17790b..ac6b92fc63f1c086f1c07239ca9cebb7ef440264 100644 (file)
@@ -73,6 +73,9 @@ public class DimensionClient extends AbstractServiceClientImpl {
         setProxy();
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
+     */
     @Override
     public CollectionSpaceProxy getProxy() {
        return this.dimensionProxy;
@@ -140,9 +143,10 @@ public class DimensionClient extends AbstractServiceClientImpl {
 
     /**
      * @param csid
-     * @return
+     * @return response
      * @see org.collectionspace.services.client.DimensionProxy#deleteDimension(java.lang.Long)
      */
+    @Override
     public ClientResponse<Response> delete(String csid) {
         return dimensionProxy.delete(csid);
     }
index 2f195dcb6d893d9619e23b52357c1658bb63b422..32310fba83616ea62425ce799770526fbd9cb41c 100644 (file)
@@ -22,7 +22,7 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
+//import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -39,7 +39,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
+//import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
@@ -54,13 +54,16 @@ import org.slf4j.LoggerFactory;
  */
 public class DimensionServiceTest extends AbstractServiceTestImpl {
 
+   /** The logger. */
    private final Logger logger =
        LoggerFactory.getLogger(DimensionServiceTest.class);
 
     // Instance variables specific to this test.
+    /** The SERVIC e_ pat h_ component. */
     final String SERVICE_PATH_COMPONENT = "dimensions";
+    
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -83,6 +86,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
@@ -127,6 +133,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
         allResourceIdsCreated.add(extractId(res));
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create"})
@@ -139,16 +148,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -235,6 +256,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create"})
@@ -264,6 +288,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"read"})
@@ -291,6 +318,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"read"})
@@ -339,6 +369,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"read"})
@@ -402,14 +435,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception{
+       //Should this really be empty?
     }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -492,6 +539,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     }
      */
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"update", "testSubmitRequest"})
@@ -523,6 +573,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
@@ -547,6 +600,9 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"delete"})
@@ -598,45 +654,23 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    // ---------------------------------------------------------------
-    // Cleanup of resources created during testing
-    // ---------------------------------------------------------------
-
-    /**
-     * 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(alwaysRun=true)
-    public void cleanUp() {
-        String noTest = System.getProperty("noTestCleanup");
-       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-       }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-        DimensionClient client = new DimensionClient();
-        for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
-    }
-
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     public String getServicePathComponent() {
         return SERVICE_PATH_COMPONENT;
     }
 
+    /**
+     * Creates the dimension instance.
+     *
+     * @param identifier the identifier
+     * @return the multipart output
+     */
     private MultipartOutput createDimensionInstance(String identifier) {
         return createDimensionInstance(
                        "dimensionType-" + identifier,
@@ -644,6 +678,14 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
                 "entryDate-" + identifier);
     }
 
+    /**
+     * Creates the dimension instance.
+     *
+     * @param dimensionType the dimension type
+     * @param entryNumber the entry number
+     * @param entryDate the entry date
+     * @return the multipart output
+     */
     private MultipartOutput createDimensionInstance(String dimensionType, String entryNumber, String entryDate) {
         DimensionsCommon dimension = new DimensionsCommon();
         dimension.setDimension(dimensionType);
index 557706a0e8ff020a7e7edaccef53f10802361e0e..a653700561aad74b84dd6b6cc0795f3f953cc75a 100644 (file)
@@ -67,8 +67,8 @@ public class IntakeAuthRefsTest extends BaseServiceTest {
     final String SERVICE_PATH_COMPONENT = "intakes";
     final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
     private String knownResourceId = null;
-    private List<String> intakeIdsCreated = new ArrayList();
-    private List<String> personIdsCreated = new ArrayList();
+    private List<String> intakeIdsCreated = new ArrayList<String>();
+    private List<String> personIdsCreated = new ArrayList<String>();
     private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
     private int OK_STATUS = Response.Status.OK.getStatusCode();
     private String personAuthCSID = null; 
@@ -303,14 +303,14 @@ public class IntakeAuthRefsTest extends BaseServiceTest {
         IntakeClient intakeClient = new IntakeClient();
         // Note: Any non-success responses are ignored and not reported.
         for (String resourceId : intakeIdsCreated) {
-            ClientResponse<Response> res = intakeClient.delete(resourceId);
+            intakeClient.delete(resourceId).releaseConnection();
         }
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Delete persons before PersonAuth
         for (String resourceId : personIdsCreated) {
-            ClientResponse<Response> res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+            personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
         }
-        ClientResponse<Response> res = personAuthClient.delete(personAuthCSID);
+        personAuthClient.delete(personAuthCSID).releaseConnection();
     }
 
     // ---------------------------------------------------------------
index 11433935afbe4f1e8ec83670a111fde211b9e78b..51c7cbcf96f39183245091588be2943f053786c2 100644 (file)
@@ -22,7 +22,6 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -38,7 +37,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
+//import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
@@ -65,9 +64,6 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
     /** The known resource id. */
     private String knownResourceId = null;
     
-    /** The all resource ids created. */
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
-
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
      */
@@ -156,6 +152,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -163,6 +160,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -170,6 +168,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -440,7 +439,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
      */
     @Override
-    public void updateWithEmptyEntityBody(String testName) throws Exception{
+    public void updateWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
     
     /* (non-Javadoc)
@@ -448,6 +448,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
     
     /* (non-Javadoc)
@@ -455,6 +456,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -652,37 +654,6 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    // ---------------------------------------------------------------
-    // Cleanup of resources created during testing
-    // ---------------------------------------------------------------
-
-    /**
-     * 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(alwaysRun=true)
-    public void cleanUp() {
-        String noTest = System.getProperty("noTestCleanup");
-       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-       }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-        IntakeClient client = new IntakeClient();
-        for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
-    }
-
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
index 5ccf8709b55d80c75f4b6b7bbee0b9705e4c04e1..d23707081ee04bcc70d0d93c69e46425eb8bd842 100644 (file)
@@ -124,34 +124,37 @@ public class LoaninAuthRefsTest extends BaseServiceTest {
                 lendersAuthorizerRefName,
                 lendersContactRefName,
                 loanInContactRefName);
-        ClientResponse<Response> res = loaninClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        // Specifically:
-        // Does it fall within the set of valid status codes?
-        // Does it exactly match the expected status code?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Store the ID returned from the first resource created
-        // for additional tests below.
-        if (knownResourceId == null){
-            knownResourceId = extractId(res);
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": knownResourceId=" + knownResourceId);
-            }
+        ClientResponse<Response> response = loaninClient.create(multipart);
+        int statusCode = response.getStatus();
+        try {
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               //
+               // Specifically:
+               // Does it fall within the set of valid status codes?
+               // Does it exactly match the expected status code?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Store the ID returned from the first resource created
+               // for additional tests below.
+               if (knownResourceId == null){
+                   knownResourceId = extractId(response);
+                   if (logger.isDebugEnabled()) {
+                       logger.debug(testName + ": knownResourceId=" + knownResourceId);
+                   }
+               }
+               
+               // Store the IDs from every resource created by tests,
+               // so they can be deleted after tests have been run.
+               loaninIdsCreated.add(extractId(response));
+        } finally {
+               response.releaseConnection();
         }
-        
-        // Store the IDs from every resource created by tests,
-        // so they can be deleted after tests have been run.
-        loaninIdsCreated.add(extractId(res));
     }
     
     protected void createPersonRefs(){
@@ -307,7 +310,9 @@ public class LoaninAuthRefsTest extends BaseServiceTest {
         
         for (String resourceId : personIdsCreated) {
             // Note: Any non-success responses are ignored and not reported.
-               personAuthClient.deleteItem(personAuthCSID, resourceId);
+               ClientResponse<Response> response = 
+                       personAuthClient.deleteItem(personAuthCSID, resourceId); // alternative to personAuthClient.deleteItem().releaseConnection();
+               response.releaseConnection();
         }
         
         // Delete PersonAuthority resource(s).
@@ -315,10 +320,12 @@ public class LoaninAuthRefsTest extends BaseServiceTest {
         if (personAuthCSID != null) {
                personAuthClient.delete(personAuthCSID);
                // Delete Loans In resource(s).
-               LoaninClient loaninClient = new LoaninClient();
+               LoaninClient loaninClient = new LoaninClient();
+               ClientResponse<Response> response = null;
                for (String resourceId : loaninIdsCreated) {
                    // Note: Any non-success responses are ignored and not reported.
-                   loaninClient.delete(resourceId);
+                   response = loaninClient.delete(resourceId); // alternative to loaninClient.delete(resourceId).releaseConnection();
+                   response.releaseConnection();
                }
         }
     }
index 4b977b6fb5c187bf25cd02846c36a583d8e9e105..97ec963ed04a0a7950727fb82c289652b36a1647 100644 (file)
@@ -22,7 +22,7 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
+//import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -39,7 +39,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
+//import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
@@ -54,13 +54,16 @@ import org.slf4j.LoggerFactory;
  */
 public class LoaninServiceTest extends AbstractServiceTestImpl {
 
+   /** The logger. */
    private final Logger logger =
        LoggerFactory.getLogger(LoaninServiceTest.class);
 
     // Instance variables specific to this test.
+    /** The SERVIC e_ pat h_ component. */
     final String SERVICE_PATH_COMPONENT = "loansin";
+    
+    /** The known resource id. */
     private String knownResourceId = null;
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -83,6 +86,9 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
     public void create(String testName) throws Exception {
@@ -96,27 +102,33 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         LoaninClient client = new LoaninClient();
         String identifier = createIdentifier();
         MultipartOutput multipart = createLoaninInstance(identifier);
+        String newID = null;
         ClientResponse<Response> res = client.create(multipart);
-
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        // Specifically:
-        // Does it fall within the set of valid status codes?
-        // Does it exactly match the expected status code?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               //
+               // Specifically:
+               // Does it fall within the set of valid status codes?
+               // Does it exactly match the expected status code?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               newID = extractId(res);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null){
-            knownResourceId = extractId(res);
+            knownResourceId = newID;
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
             }
@@ -124,9 +136,12 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         
         // Store the IDs from every resource created by tests,
         // so they can be deleted after tests have been run.
-        allResourceIdsCreated.add(extractId(res));
+        allResourceIdsCreated.add(newID);
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create"})
@@ -139,16 +154,28 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -235,35 +262,46 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create"})
     public void read(String testName) throws Exception {
-
         // Perform setup.
         setupRead(testName);
 
         // Submit the request to the service and store the response.
+        MultipartInput input = null;
         LoaninClient client = new LoaninClient();
         ClientResponse<MultipartInput> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               input = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         LoansinCommon loanin = (LoansinCommon) extractPart(input,
                 client.getCommonPartName(), LoansinCommon.class);
         Assert.assertNotNull(loanin);
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"read"})
@@ -275,48 +313,60 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LoaninClient client = new LoaninClient();
         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     // ---------------------------------------------------------------
     // CRUD tests : READ_LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"createList", "read"})
     public void readList(String testName) throws Exception {
-
         // Perform setup.
         setupReadList(testName);
 
         // Submit the request to the service and store the response.
+        LoansinCommonList list = null;
         LoaninClient client = new LoaninClient();
         ClientResponse<LoansinCommonList> res = client.readList();
-        LoansinCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+               
+               list = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = false;
-        if(iterateThroughList && logger.isDebugEnabled()){
+        if (iterateThroughList && logger.isDebugEnabled()){
             List<LoansinCommonList.LoaninListItem> items =
                     list.getLoaninListItem();
             int i = 0;
@@ -330,7 +380,6 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
                 i++;
             }
         }
-
     }
 
     // Failure outcomes
@@ -339,6 +388,9 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"read"})
@@ -348,18 +400,24 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         setupUpdate(testName);
 
         // Retrieve the contents of a resource to update.
+        MultipartInput input = null;
         LoaninClient client = new LoaninClient();
         ClientResponse<MultipartInput> res =
-                client.read(knownResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got object to update with ID: " + knownResourceId);
+            client.read(knownResourceId);
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got object to update with ID: " + knownResourceId);
+               }
+               input = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         LoansinCommon loanin = (LoansinCommon) extractPart(input,
                 client.getCommonPartName(), LoansinCommon.class);
         Assert.assertNotNull(loanin);
@@ -377,17 +435,22 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         commonPart.getHeaders().add("label", client.getCommonPartName());
 
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+       
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-
-        input = (MultipartInput) res.getEntity();
+        
         LoansinCommon updatedLoanin =
                 (LoansinCommon) extractPart(input,
                         client.getCommonPartName(), LoansinCommon.class);
@@ -396,20 +459,33 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(updatedLoanin.getLoanReturnDate(),
                 loanin.getLoanReturnDate(),
                 "Data in updated object did not match submitted data.");
-
     }
 
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
-    public void updateWithEmptyEntityBody(String testName) throws Exception{
+    public void updateWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -492,6 +568,9 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
     }
      */
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"update", "testSubmitRequest"})
@@ -507,22 +586,29 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         MultipartOutput multipart = createLoaninInstance(NON_EXISTENT_ID);
         ClientResponse<MultipartInput> res =
                 client.update(NON_EXISTENT_ID, multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     // ---------------------------------------------------------------
     // CRUD tests : DELETE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
@@ -534,40 +620,50 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LoaninClient client = new LoaninClient();
         ClientResponse<Response> res = client.delete(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"delete"})
     public void deleteNonExistent(String testName) throws Exception {
-
         // Perform setup.
         setupDeleteNonExistent(testName);
 
         // Submit the request to the service and store the response.
         LoaninClient client = new LoaninClient();
         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     // ---------------------------------------------------------------
@@ -598,44 +694,36 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    // ---------------------------------------------------------------
-    // Cleanup of resources created during testing
-    // ---------------------------------------------------------------
-
-    /**
-     * 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(alwaysRun=true)
-    public void cleanUp() {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-       LoaninClient client = new LoaninClient();
-       for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
-    }
-
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     public String getServicePathComponent() {
         return SERVICE_PATH_COMPONENT;
     }
 
+    /**
+     * Creates the loanin instance.
+     *
+     * @param identifier the identifier
+     * @return the multipart output
+     */
     private MultipartOutput createLoaninInstance(String identifier) {
         return createLoaninInstance(
                 "loaninNumber-" + identifier,
                 "returnDate-" + identifier);
     }
 
+    /**
+     * Creates the loanin instance.
+     *
+     * @param loaninNumber the loanin number
+     * @param returnDate the return date
+     * @return the multipart output
+     */
     private MultipartOutput createLoaninInstance(String loaninNumber,
                String returnDate) {
         LoansinCommon loanin = new LoansinCommon();
index b19069700461a479186ba6494175547edf1293aa..212081a142f0216d5312e40e4ce00db63a929d94 100644 (file)
@@ -22,7 +22,6 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -39,7 +38,6 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.testng.Assert;
-import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 import org.slf4j.Logger;
@@ -65,9 +63,6 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
     /** The known resource id. */
     private String knownResourceId = null;
     
-    /** The all resource ids created. */
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
-
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
      */
@@ -156,6 +151,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -163,6 +159,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -170,6 +167,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -440,6 +438,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception{
+       //Should this really be empty?
     }
     
     /* (non-Javadoc)
@@ -447,6 +446,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
     
     /* (non-Javadoc)
@@ -454,6 +454,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /*
@@ -651,37 +652,6 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
 
     }
 
-    // ---------------------------------------------------------------
-    // Cleanup of resources created during testing
-    // ---------------------------------------------------------------
-
-    /**
-     * 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(alwaysRun=true)
-    public void cleanUp() {
-        String noTest = System.getProperty("noTestCleanup");
-       if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Skipping Cleanup phase ...");
-            }
-            return;
-       }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Cleaning up temporary resources created for testing ...");
-        }
-       LoanoutClient client = new LoanoutClient();
-       for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
-    }
-
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
index 449697f9d8a3ce3429158ad46d7f2c6d242ba859..caccb3523eb7ff59c095bc4ad8387206f658081a 100644 (file)
@@ -1,3 +1,29 @@
+/**    \r
+ * OrgAuthorityClientUtils.java\r
+ *\r
+ * {Purpose of This Class}\r
+ *\r
+ * {Other Notes Relating to This Class (Optional)}\r
+ *\r
+ * $LastChangedBy: $\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ *\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright Â© 2009 {Contributing Institution}\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ */\r
 package org.collectionspace.services.client;\r
 \r
 import java.util.ArrayList;\r
@@ -17,10 +43,23 @@ import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
+/**\r
+ * The Class OrgAuthorityClientUtils.\r
+ */\r
 public class OrgAuthorityClientUtils {\r
+    \r
+    /** The Constant logger. */\r
     private static final Logger logger =\r
         LoggerFactory.getLogger(OrgAuthorityClientUtils.class);\r
 \r
+    /**\r
+     * Creates the org authority instance.\r
+     *\r
+     * @param displayName the display name\r
+     * @param refName the ref name\r
+     * @param headerLabel the header label\r
+     * @return the multipart output\r
+     */\r
     public static MultipartOutput createOrgAuthorityInstance(\r
                String displayName, String refName, String headerLabel ) {\r
         OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();\r
@@ -39,6 +78,15 @@ public class OrgAuthorityClientUtils {
         return multipart;\r
     }\r
 \r
+    /**\r
+     * Creates the item in authority.\r
+     *\r
+     * @param vcsid the vcsid\r
+     * @param orgAuthorityRefName the org authority ref name\r
+     * @param orgInfo the org info\r
+     * @param client the client\r
+     * @return the string\r
+     */\r
     public static String createItemInAuthority(String vcsid, \r
                String orgAuthorityRefName, Map<String, String> orgInfo,\r
                OrgAuthorityClient client) {\r
@@ -58,31 +106,46 @@ public class OrgAuthorityClientUtils {
                                orgInfo.get(OrganizationJAXBSchema.SHORT_NAME ),                        \r
                                orgInfo.get(OrganizationJAXBSchema.FOUNDING_PLACE ));\r
        }\r
-       String refName = createOrganizationRefName( orgAuthorityRefName, displayName, true);\r
+       String refName = createOrganizationRefName(orgAuthorityRefName, displayName, true);\r
 \r
        if(logger.isDebugEnabled()){\r
                logger.debug("Import: Create Item: \""+displayName\r
                                +"\" in orgAuthority: \"" + orgAuthorityRefName +"\"");\r
        }\r
        MultipartOutput multipart =\r
-               createOrganizationInstance( vcsid, refName, orgInfo, client.getItemCommonPartName() );\r
+               createOrganizationInstance(vcsid, refName, orgInfo, client.getItemCommonPartName());\r
        ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
-\r
-       int statusCode = res.getStatus();\r
-\r
-       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
-               throw new RuntimeException("Could not create Item: \""+displayName\r
-                               +"\" in orgAuthority: \"" + orgAuthorityRefName\r
-                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       String result;\r
+       try {   \r
+               int statusCode = res.getStatus();\r
+       \r
+               if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+                       throw new RuntimeException("Could not create Item: \""+displayName\r
+                                       +"\" in orgAuthority: \"" + orgAuthorityRefName\r
+                                       +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+               }\r
+               if(statusCode != EXPECTED_STATUS_CODE) {\r
+                       throw new RuntimeException("Unexpected Status when creating Item: \""+ displayName\r
+                                       +"\" in orgAuthority: \"" + orgAuthorityRefName +"\", Status:"+ statusCode);\r
+               }\r
+       \r
+               result = extractId(res);\r
+       } finally {\r
+               res.releaseConnection();\r
        }\r
-       if(statusCode != EXPECTED_STATUS_CODE) {\r
-               throw new RuntimeException("Unexpected Status when creating Item: \""+displayName\r
-                               +"\" in orgAuthority: \"" + orgAuthorityRefName +"\", Status:"+ statusCode);\r
-       }\r
-\r
-       return extractId(res);\r
+       \r
+       return result;\r
     }\r
 \r
+    /**\r
+     * Creates the organization instance.\r
+     *\r
+     * @param inAuthority the in authority\r
+     * @param orgRefName the org ref name\r
+     * @param orgInfo the org info\r
+     * @param headerLabel the header label\r
+     * @return the multipart output\r
+     */\r
     public static MultipartOutput createOrganizationInstance(String inAuthority, \r
                String orgRefName, Map<String, String> orgInfo, String headerLabel){\r
         OrganizationsCommon organization = new OrganizationsCommon();\r
@@ -147,6 +210,12 @@ public class OrgAuthorityClientUtils {
                 requestType.validStatusCodesAsString();\r
     }\r
 \r
+    /**\r
+     * Extract id.\r
+     *\r
+     * @param res the res\r
+     * @return the string\r
+     */\r
     public static String extractId(ClientResponse<Response> res) {\r
         MultivaluedMap<String, Object> mvm = res.getMetadata();\r
         String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);\r
@@ -161,6 +230,13 @@ public class OrgAuthorityClientUtils {
         return id;\r
     }\r
     \r
+    /**\r
+     * Creates the org auth ref name.\r
+     *\r
+     * @param orgAuthorityName the org authority name\r
+     * @param withDisplaySuffix the with display suffix\r
+     * @return the string\r
+     */\r
     public static String createOrgAuthRefName(String orgAuthorityName, boolean withDisplaySuffix) {\r
        String refName = "urn:cspace:org.collectionspace.demo:orgauthority:name("\r
                        +orgAuthorityName+")";\r
@@ -169,6 +245,14 @@ public class OrgAuthorityClientUtils {
        return refName;\r
     }\r
 \r
+    /**\r
+     * Creates the organization ref name.\r
+     *\r
+     * @param orgAuthRefName the org auth ref name\r
+     * @param orgName the org name\r
+     * @param withDisplaySuffix the with display suffix\r
+     * @return the string\r
+     */\r
     public static String createOrganizationRefName(\r
                                                String orgAuthRefName, String orgName, boolean withDisplaySuffix) {\r
        String refName = orgAuthRefName+":organization:name("+orgName+")";\r
index 1a2ec608f61823598692281d27610ac834fd68d5..41933994248411cce94be1d58480978b994589f6 100644 (file)
@@ -60,23 +60,49 @@ import org.slf4j.LoggerFactory;
  */
 public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
 
+   /** The logger. */
    private final Logger logger =
        LoggerFactory.getLogger(OrgAuthorityAuthRefsTest.class);
 
     // Instance variables specific to this test.
+    /** The SERVIC e_ pat h_ component. */
     final String SERVICE_PATH_COMPONENT = "orgauthorities";
+    
+    /** The PERSO n_ authorit y_ name. */
     final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
+    
+    /** The known resource ref name. */
     private String knownResourceRefName = null;
+    
+    /** The known auth resource id. */
     private String knownAuthResourceId = null;
+    
+    /** The known item id. */
     private String knownItemId = null;
+    
+    /** The all resource ids created. */
     private List<String> allResourceIdsCreated = new ArrayList<String>();
+    
+    /** The all item resource ids created. */
     private Map<String, String> allItemResourceIdsCreated =
         new HashMap<String, String>();
-    private List<String> personIdsCreated = new ArrayList();
+    
+    /** The person ids created. */
+    private List<String> personIdsCreated = new ArrayList<String>();
+    
+    /** The CREATE d_ status. */
     private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
+    
+    /** The O k_ status. */
     private int OK_STATUS = Response.Status.OK.getStatusCode();
+    
+    /** The person auth csid. */
     private String personAuthCSID = null;
+    
+    /** The organization contact person ref name. */
     private String organizationContactPersonRefName = null;
+    
+    /** The NU m_ aut h_ ref s_ expected. */
     private final int NUM_AUTH_REFS_EXPECTED = 1;
 
     /* (non-Javadoc)
@@ -100,6 +126,12 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /**
+     * Creates the with auth refs.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
     public void createWithAuthRefs(String testName) throws Exception {
 
@@ -114,28 +146,31 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
             OrgAuthorityClientUtils.createOrgAuthRefName(displayName, createWithDisplayName);
         MultipartOutput multipart =
             OrgAuthorityClientUtils.createOrgAuthorityInstance(
-               displayName, knownResourceRefName, new OrgAuthorityClient().getCommonPartName());
+               displayName, knownResourceRefName, orgAuthClient.getCommonPartName());
 
         // Submit the request to the service and store the response.
         ClientResponse<Response> res = orgAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        // Specifically:
-        // Does it fall within the set of valid status codes?
-        // Does it exactly match the expected status code?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Store the IDs from every resource created by tests,
-        // so they can be deleted after tests have been run.
-        knownAuthResourceId = extractId(res);
+        try {
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               //
+               // Specifically:
+               // Does it fall within the set of valid status codes?
+               // Does it exactly match the expected status code?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                   invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Store the IDs from every resource created by tests,
+               // so they can be deleted after tests have been run.
+               knownAuthResourceId = extractId(res);
+        } finally {
+               res.releaseConnection();
+        }        
         allResourceIdsCreated.add(knownAuthResourceId);
 
         // Create all the person refs and entities
@@ -159,23 +194,15 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
         knownItemId = OrgAuthorityClientUtils.createItemInAuthority(
             knownAuthResourceId, knownResourceRefName, testOrgMap, orgAuthClient);
 
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
         // Store the IDs from every item created by tests,
         // so they can be deleted after tests have been run.
         allItemResourceIdsCreated.put(knownItemId, knownAuthResourceId);
-
     }
     
-    protected void createPersonRefs(){
-
+    /**
+     * Creates the person refs.
+     */
+    protected void createPersonRefs() {
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Create a temporary PersonAuthority resource, and its corresponding
         // refName by which it can be identified.
@@ -183,13 +210,17 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
            PersonAuthorityClientUtils.createPersonAuthRefName(PERSON_AUTHORITY_NAME, false);
        MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
            PERSON_AUTHORITY_NAME, authRefName, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, CREATED_STATUS);
-        personAuthCSID = extractId(res);
+        
+       ClientResponse<Response> res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();       
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                   invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, CREATED_STATUS);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.releaseConnection();
+        }
 
         // Create a temporary Person resource, and its corresponding refName
         // by which it can be identified.
@@ -199,6 +230,14 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
 
     }
     
+    /**
+     * Creates the person.
+     *
+     * @param firstName the first name
+     * @param surName the sur name
+     * @param refName the ref name
+     * @return the string
+     */
     protected String createPerson(String firstName, String surName, String refName ) {
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         Map<String, String> personInfo = new HashMap<String,String>();
@@ -207,16 +246,30 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
        MultipartOutput multipart = 
            PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
                refName, personInfo, personAuthClient.getItemCommonPartName());
-        ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, CREATED_STATUS);
-       return extractId(res);
+        
+       String result = null;
+       ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
+       try {
+               int statusCode = res.getStatus();
+       
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, CREATED_STATUS);
+               result = extractId(res);
+       } finally {
+               res.releaseConnection();
+       }
+       
+       return result;
     }
 
     // Success outcomes
+    /**
+     * Read and check auth refs.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"createWithAuthRefs"})
     public void readAndCheckAuthRefs(String testName) throws Exception {
@@ -310,14 +363,14 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
         }
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Delete Person resource(s) (before PersonAuthority resources).
-        ClientResponse<Response> res;
         for (String resourceId : personIdsCreated) {
             // Note: Any non-success responses are ignored and not reported.
-            res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+            personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
         }
         // Delete PersonAuthority resource(s).
         // Note: Any non-success response is ignored and not reported.
-        res = personAuthClient.delete(personAuthCSID);
+        personAuthClient.delete(personAuthCSID).releaseConnection();
+        
         String parentResourceId;
         String itemResourceId;
         OrgAuthorityClient client = new OrgAuthorityClient();
@@ -327,24 +380,34 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
             parentResourceId = entry.getValue();
             // Note: Any non-success responses from the delete operation
             // below are ignored and not reported.
-            res = client.deleteItem(parentResourceId, itemResourceId);
+            client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
         }
+        
         // Clean up parent resources.
         for (String resourceId : allResourceIdsCreated) {
             // Note: Any non-success responses from the delete operation
             // below are ignored and not reported.
-            res = client.delete(resourceId);
+            client.delete(resourceId).releaseConnection();
         }
     }
 
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     public String getServicePathComponent() {
         return SERVICE_PATH_COMPONENT;
     }
 
+    /**
+     * Creates the org authority instance.
+     *
+     * @param identifier the identifier
+     * @return the multipart output
+     */
     private MultipartOutput createOrgAuthorityInstance(String identifier) {
        String displayName = "displayName-" + identifier;
        String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true);
index db4d0ac4d7526469d5a150a48af64f132ae6e4e8..00a58f8f8f13306f34276a44cf52cd9dac997e5c 100644 (file)
@@ -22,7 +22,6 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -62,24 +61,49 @@ import org.testng.annotations.Test;
  */
 public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
 
+    /** The logger. */
     private final Logger logger =
         LoggerFactory.getLogger(OrgAuthorityServiceTest.class);
 
     // Instance variables specific to this test.
+    /** The SERVIC e_ pat h_ component. */
     final String SERVICE_PATH_COMPONENT = "orgauthorities";
+    
+    /** The ITE m_ servic e_ pat h_ component. */
     final String ITEM_SERVICE_PATH_COMPONENT = "items";
+    
+    /** The CONTAC t_ servic e_ pat h_ component. */
     final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
+    
+    /** The TES t_ or g_ shortname. */
     private final String TEST_ORG_SHORTNAME = "Test Org";
+    
+    /** The TES t_ or g_ foundin g_ place. */
     private final String TEST_ORG_FOUNDING_PLACE = "Anytown, USA";
+    
+    /** The known resource id. */
     private String knownResourceId = null;
+    
+    /** The known resource display name. */
     private String knownResourceDisplayName = null;
+    
+    /** The known resource ref name. */
     private String knownResourceRefName = null;
+    
+    /** The known item resource id. */
     private String knownItemResourceId = null;
+    
+    /** The known contact resource id. */
     private String knownContactResourceId = null;
+    
+    /** The n items to create in list. */
     private int nItemsToCreateInList = 3;
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
+    
+    /** The all item resource ids created. */
     private Map<String, String> allItemResourceIdsCreated =
         new HashMap<String, String>();
+    
+    /** The all contact resource ids created. */
     private Map<String, String> allContactResourceIdsCreated =
         new HashMap<String, String>();
     
@@ -104,6 +128,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"create"})
@@ -122,27 +149,34 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
        MultipartOutput multipart = 
            OrgAuthorityClientUtils.createOrgAuthorityInstance(
                displayName, refName, client.getCommonPartName());
-        ClientResponse<Response> res = client.create(multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        // Specifically:
-        // Does it fall within the set of valid status codes?
-        // Does it exactly match the expected status code?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        
+       String newID = null;
+       ClientResponse<Response> res = client.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               //
+               // Specifically:
+               // Does it fall within the set of valid status codes?
+               // Does it exactly match the expected status code?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Store the refname from the first resource created
+               // for additional tests below.
+               knownResourceRefName = refName;
+       
+               newID = OrgAuthorityClientUtils.extractId(res);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Store the refname from the first resource created
-        // for additional tests below.
-        knownResourceRefName = refName;
-
-        String newID = OrgAuthorityClientUtils.extractId(res);
+        
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null){
@@ -157,6 +191,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         allResourceIdsCreated.add(newID);
     }
 
+    /**
+     * Creates the item.
+     *
+     * @param testName the test name
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"create"}, dependsOnMethods = {"create"})
     public void createItem(String testName) {
@@ -164,6 +203,13 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
     }
 
+    /**
+     * Creates the item in authority.
+     *
+     * @param vcsid the vcsid
+     * @param authRefName the auth ref name
+     * @return the string
+     */
     private String createItemInAuthority(String vcsid, String authRefName) {
 
         final String testName = "createItemInAuthority";
@@ -201,6 +247,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         return newID;
     }
 
+    /**
+     * Creates the contact.
+     *
+     * @param testName the test name
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"create"}, dependsOnMethods = {"createItem"})
     public void createContact(String testName) {
@@ -208,6 +259,13 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         String newID = createContactInItem(knownResourceId, knownItemResourceId);
     }
 
+   /**
+    * Creates the contact in item.
+    *
+    * @param parentcsid the parentcsid
+    * @param itemcsid the itemcsid
+    * @return the string
+    */
    private String createContactInItem(String parentcsid, String itemcsid) {
 
         final String testName = "createContactInItem";
@@ -222,19 +280,25 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         MultipartOutput multipart =
             ContactClientUtils.createContactInstance(parentcsid,
             itemcsid, identifier, new ContactClient().getCommonPartName());
+        
+        String newID = null;
         ClientResponse<Response> res =
              client.createContact(parentcsid, itemcsid, multipart);
-        int statusCode = res.getStatus();
-        String newID = OrgAuthorityClientUtils.extractId(res);
+        try {
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+               newID = OrgAuthorityClientUtils.extractId(res);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Store the ID returned from the first contact resource created
         // for additional tests below.
@@ -257,16 +321,28 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
 
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+     */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
 /*
@@ -353,7 +429,10 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : CREATE LIST tests
     // ---------------------------------------------------------------
     // Success outcomes
-    @Override
+    /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+ */
+@Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"createList"}, dependsOnGroups = {"create"})
     public void createList(String testName) throws Exception {
@@ -362,6 +441,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Creates the item list.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"createList"}, dependsOnMethods = {"createList"})
     public void createItemList(String testName) throws Exception {
@@ -371,6 +456,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Creates the contact list.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"createList"}, dependsOnMethods = {"createItemList"})
     public void createContactList(String testName) throws Exception {
@@ -384,6 +475,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : READ tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnGroups = {"create"})
@@ -395,27 +489,37 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        //FIXME: remove the following try catch once Aron fixes signatures
         try {
-            MultipartInput input = (MultipartInput) res.getEntity();
-            OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
-                    client.getCommonPartName(), OrgauthoritiesCommon.class);
-            Assert.assertNotNull(orgAuthority);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+               //FIXME: remove the following try catch once Aron fixes signatures
+               try {
+                   MultipartInput input = (MultipartInput) res.getEntity();
+                   OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+                           client.getCommonPartName(), OrgauthoritiesCommon.class);
+                   Assert.assertNotNull(orgAuthority);
+               } catch (Exception e) {
+                   throw new RuntimeException(e);
+               }
+        } finally {
+               res.releaseConnection();
         }
     }
 
+    /**
+     * Read by name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
             groups = {"read"}, dependsOnGroups = {"create"})
         public void readByName(String testName) throws Exception {
@@ -426,24 +530,28 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        //FIXME: remove the following try catch once Aron fixes signatures
         try {
-            MultipartInput input = (MultipartInput) res.getEntity();
-            OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
-                    new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class);
-            Assert.assertNotNull(orgAuthority);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+               //FIXME: remove the following try catch once Aron fixes signatures
+               try {
+                   MultipartInput input = (MultipartInput) res.getEntity();
+                   OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+                           new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class);
+                   Assert.assertNotNull(orgAuthority);
+               } catch (Exception e) {
+                   throw new RuntimeException(e);
+               }
+        } finally {
+               res.releaseConnection();
         }
     }
 
@@ -479,7 +587,13 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     }
 */
 
-    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+    /**
+ * Read item.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnMethods = {"read"})
     public void readItem(String testName) throws Exception {
 
@@ -489,31 +603,41 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Check whether we've received a organization.
-        MultipartInput input = (MultipartInput) res.getEntity();
-        OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
-                client.getItemCommonPartName(), OrganizationsCommon.class);
-        Assert.assertNotNull(organization);
-        boolean showFull = true;
-        if(showFull && logger.isDebugEnabled()){
-            logger.debug(testName + ": returned payload:");
-            logger.debug(objectAsXmlString(organization,
-                    OrganizationsCommon.class));
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Check whether we've received a organization.
+               MultipartInput input = (MultipartInput) res.getEntity();
+               OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+                       client.getItemCommonPartName(), OrganizationsCommon.class);
+               Assert.assertNotNull(organization);
+               boolean showFull = true;
+               if(showFull && logger.isDebugEnabled()){
+                   logger.debug(testName + ": returned payload:");
+                   logger.debug(objectAsXmlString(organization,
+                           OrganizationsCommon.class));
+               }
+               Assert.assertEquals(organization.getInAuthority(), knownResourceId);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertEquals(organization.getInAuthority(), knownResourceId);
     }
 
+    /**
+     * Verify item display name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
             dependsOnMethods = {"readItem", "updateItem"})
     public void verifyItemDisplayName(String testName) throws Exception {
@@ -523,20 +647,26 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
+        MultipartInput input = null;
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Check whether organization has expected displayName.
+               input = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Check whether organization has expected displayName.
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
                 client.getItemCommonPartName(), OrganizationsCommon.class);
         Assert.assertNotNull(organization);
@@ -560,18 +690,23 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
+        
         OrganizationsCommon updatedOrganization =
                 (OrganizationsCommon) extractPart(input,
                         client.getItemCommonPartName(), OrganizationsCommon.class);
@@ -594,18 +729,23 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
+        
         updatedOrganization =
                 (OrganizationsCommon) extractPart(input,
                         client.getItemCommonPartName(), OrganizationsCommon.class);
@@ -620,6 +760,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
                 "Updated DisplayName (not computed) in Organization not stored.");
     }
 
+    /**
+     * Verify illegal item display name.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
             dependsOnMethods = {"verifyItemDisplayName"})
     public void verifyIllegalItemDisplayName(String testName) throws Exception {
@@ -666,6 +812,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Read contact.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnMethods = {"readItem"})
     public void readContact(String testName) throws Exception {
@@ -705,6 +857,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnMethods = {"read"})
@@ -728,6 +883,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Read item non existent.
+     *
+     * @param testName the test name
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnMethods = {"readItem"})
     public void readItemNonExistent(String testName) {
@@ -750,6 +910,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Read contact non existent.
+     *
+     * @param testName the test name
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnMethods = {"readContact"})
     public void readContactNonExistent(String testName) {
@@ -778,6 +943,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     // ---------------------------------------------------------------
     // Success outcomes
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"readList"}, dependsOnGroups = {"createList", "read"})
@@ -821,16 +989,28 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Read item list.
+     */
     @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
     public void readItemList() {
         readItemList(knownResourceId, null);
     }
 
+    /**
+     * Read item list by authority name.
+     */
     @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
     public void readItemListByAuthorityName() {
         readItemList(null, knownResourceDisplayName);
     }
 
+    /**
+     * Read item list.
+     *
+     * @param vcsid the vcsid
+     * @param name the name
+     */
     private void readItemList(String vcsid, String name) {
 
         final String testName = "readItemList";
@@ -896,11 +1076,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         }
     }
 
+    /**
+     * Read contact list.
+     */
     @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
     public void readContactList() {
         readContactList(knownResourceId, knownItemResourceId);
     }
 
+    /**
+     * Read contact list.
+     *
+     * @param parentcsid the parentcsid
+     * @param itemcsid the itemcsid
+     */
     private void readContactList(String parentcsid, String itemcsid) {
         final String testName = "readContactList";
 
@@ -962,6 +1151,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     // CRUD tests : UPDATE tests
     // ---------------------------------------------------------------
     // Success outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"update"}, dependsOnGroups = {"read", "readList"})
@@ -1023,6 +1215,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
                 "Data in updated object did not match submitted data.");
     }
 
+    /**
+     * Update item.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"update"}, dependsOnMethods = {"update"})
     public void updateItem(String testName) throws Exception {
@@ -1086,6 +1284,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
                 "Data in updated Organization did not match submitted data.");
     }
 
+    /**
+     * Update contact.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"update"}, dependsOnMethods = {"updateItem"})
     public void updateContact(String testName) throws Exception {
@@ -1152,16 +1356,28 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     // Failure outcomes
     // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+     */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+     */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+     */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
 /*
@@ -1244,7 +1460,10 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     }
 */
 
-    @Override
+    /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+ */
+@Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
     public void updateNonExistent(String testName) throws Exception {
@@ -1271,6 +1490,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Update non existent item.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
     public void updateNonExistentItem(String testName) throws Exception {
@@ -1303,6 +1528,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Update non existent contact.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"update"}, dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
     public void updateNonExistentContact(String testName) throws Exception {
@@ -1317,6 +1548,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     // Note: delete sub-resources in ascending hierarchical order,
     // before deleting their parents.
 
+    /**
+     * Delete contact.
+     *
+     * @param testName the test name
+     * @throws Exception the exception
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
     public void deleteContact(String testName) throws Exception {
@@ -1346,6 +1583,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+   /**
+    * Delete item.
+    *
+    * @param testName the test name
+    * @throws Exception the exception
+    */
    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"delete"}, dependsOnMethods = {"deleteContact"})
     public void deleteItem(String testName) throws Exception {
@@ -1373,6 +1616,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"delete"}, dependsOnMethods = {"deleteItem"})
@@ -1401,6 +1647,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     }
 
     // Failure outcomes
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+     */
     @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"delete"}, dependsOnMethods = {"delete"})
@@ -1424,6 +1673,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Delete non existent item.
+     *
+     * @param testName the test name
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"delete"}, dependsOnMethods = {"deleteItem"})
     public void deleteNonExistentItem(String testName) {
@@ -1446,6 +1700,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    /**
+     * Delete non existent contact.
+     *
+     * @param testName the test name
+     */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"delete"}, dependsOnMethods = {"deleteContact"})
     public void deleteNonExistentContact(String testName) {
@@ -1497,6 +1756,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
 
     }
 
+    /**
+     * Test item submit request.
+     */
     @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
     public void testItemSubmitRequest() {
 
@@ -1518,6 +1780,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
 
     }
 
+    /**
+     * Test contact submit request.
+     */
     @Test(dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
     public void testContactSubmitRequest() {
 
@@ -1555,6 +1820,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
      */
 
     @AfterClass(alwaysRun=true)
+    @Override
     public void cleanUp() {
         String noTest = System.getProperty("noTestCleanup");
        if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
@@ -1566,6 +1832,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         if (logger.isDebugEnabled()) {
             logger.debug("Cleaning up temporary resources created for testing ...");
         }
+        
         String parentResourceId;
         String itemResourceId;
         String contactResourceId;
@@ -1579,6 +1846,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
             // below are ignored and not reported.
             ClientResponse<Response> res =
                 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
+            res.releaseConnection();
         }
         // Clean up item resources.
         for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
@@ -1588,27 +1856,38 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
             // below are ignored and not reported.
             ClientResponse<Response> res =
                 client.deleteItem(parentResourceId, itemResourceId);
+            res.releaseConnection();
         }
         // Clean up parent resources.
-        for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses from the delete operation
-            // below are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
+        super.cleanUp();
+        
     }
 
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+     */
     @Override
     public String getServicePathComponent() {
         return SERVICE_PATH_COMPONENT;
     }
 
+    /**
+     * Gets the item service path component.
+     *
+     * @return the item service path component
+     */
     public String getItemServicePathComponent() {
         return ITEM_SERVICE_PATH_COMPONENT;
     }
 
+    /**
+     * Gets the contact service path component.
+     *
+     * @return the contact service path component
+     */
     public String getContactServicePathComponent() {
         return CONTACT_SERVICE_PATH_COMPONENT;
     }
@@ -1686,6 +1965,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
             itemResourceIdentifier) + "/" + contactResourceIdentifier;
     }
 
+    /**
+     * Creates the org authority instance.
+     *
+     * @param identifier the identifier
+     * @return the multipart output
+     */
     private MultipartOutput createOrgAuthorityInstance(String identifier) {
        String displayName = "displayName-" + identifier;
        String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true);
index 4c7f7d64916da4586a3594ba38a636858810192d..a9c46ab4eacd300f6f5bc27c4890b1e3e3b0641e 100644 (file)
@@ -56,6 +56,7 @@
             <artifactId>testng</artifactId>\r
             <version>5.6</version>\r
         </dependency>\r
+        <!-- RESTEasy -->\r
         <dependency>\r
             <groupId>org.jboss.resteasy</groupId>\r
             <artifactId>resteasy-jaxrs</artifactId>\r
@@ -75,6 +76,7 @@
             <groupId>org.jboss.resteasy</groupId>\r
             <artifactId>resteasy-multipart-provider</artifactId>\r
         </dependency>\r
+        \r
         <dependency>\r
             <groupId>commons-httpclient</groupId>\r
             <artifactId>commons-httpclient</artifactId>\r
index fb28b2979c69fa08360a569e8be56270a636f491..a627080480626fd405c7e199daad054088e06625 100644 (file)
@@ -1,3 +1,29 @@
+/**    \r
+ * PersonAuthorityClientUtils.java\r
+ *\r
+ * {Purpose of This Class}\r
+ *\r
+ * {Other Notes Relating to This Class (Optional)}\r
+ *\r
+ * $LastChangedBy: $\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ *\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright Â© 2009 {Contributing Institution}\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ */\r
 package org.collectionspace.services.client;\r
 \r
 import java.util.ArrayList;\r
@@ -19,10 +45,23 @@ import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
+/**\r
+ * The Class PersonAuthorityClientUtils.\r
+ */\r
 public class PersonAuthorityClientUtils {\r
+    \r
+    /** The Constant logger. */\r
     private static final Logger logger =\r
         LoggerFactory.getLogger(PersonAuthorityClientUtils.class);\r
 \r
+    /**\r
+     * Creates the person authority instance.\r
+     *\r
+     * @param displayName the display name\r
+     * @param refName the ref name\r
+     * @param headerLabel the header label\r
+     * @return the multipart output\r
+     */\r
     public static MultipartOutput createPersonAuthorityInstance(\r
                String displayName, String refName, String headerLabel ) {\r
         PersonauthoritiesCommon personAuthority = new PersonauthoritiesCommon();\r
@@ -41,6 +80,15 @@ public class PersonAuthorityClientUtils {
         return multipart;\r
     }\r
 \r
+    /**\r
+     * Creates the person instance.\r
+     *\r
+     * @param inAuthority the in authority\r
+     * @param personRefName the person ref name\r
+     * @param personInfo the person info\r
+     * @param headerLabel the header label\r
+     * @return the multipart output\r
+     */\r
     public static MultipartOutput createPersonInstance(String inAuthority, \r
                String personRefName, Map<String, String> personInfo, String headerLabel){\r
         PersonsCommon person = new PersonsCommon();\r
@@ -98,6 +146,15 @@ public class PersonAuthorityClientUtils {
         return multipart;\r
     }\r
     \r
+    /**\r
+     * Creates the item in authority.\r
+     *\r
+     * @param vcsid the vcsid\r
+     * @param personAuthorityRefName the person authority ref name\r
+     * @param personMap the person map\r
+     * @param client the client\r
+     * @return the string\r
+     */\r
     public static String createItemInAuthority(String vcsid, \r
                String personAuthorityRefName, Map<String,String> personMap,\r
                PersonAuthorityClient client ) {\r
@@ -132,23 +189,37 @@ public class PersonAuthorityClientUtils {
        MultipartOutput multipart = \r
                createPersonInstance( vcsid, refName,\r
                        personMap, client.getItemCommonPartName() );\r
+       \r
+       String result = null;\r
        ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
-\r
-       int statusCode = res.getStatus();\r
-\r
-       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
-               throw new RuntimeException("Could not create Item: \""+refName\r
-                               +"\" in personAuthority: \"" + personAuthorityRefName\r
-                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       try {\r
+               int statusCode = res.getStatus();\r
+       \r
+               if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+                       throw new RuntimeException("Could not create Item: \""+refName\r
+                                       +"\" in personAuthority: \"" + personAuthorityRefName\r
+                                       +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+               }\r
+               if(statusCode != EXPECTED_STATUS_CODE) {\r
+                       throw new RuntimeException("Unexpected Status when creating Item: \""+refName\r
+                                       +"\" in personAuthority: \"" + personAuthorityRefName +"\", Status:"+ statusCode);\r
+               }\r
+       \r
+               result = extractId(res);\r
+       } finally {\r
+               res.releaseConnection();\r
        }\r
-       if(statusCode != EXPECTED_STATUS_CODE) {\r
-               throw new RuntimeException("Unexpected Status when creating Item: \""+refName\r
-                               +"\" in personAuthority: \"" + personAuthorityRefName +"\", Status:"+ statusCode);\r
-       }\r
-\r
-       return extractId(res);\r
+       \r
+       return result;\r
     }\r
 \r
+    /**\r
+     * Creates the person auth ref name.\r
+     *\r
+     * @param personAuthorityName the person authority name\r
+     * @param withDisplaySuffix the with display suffix\r
+     * @return the string\r
+     */\r
     public static String createPersonAuthRefName(String personAuthorityName, boolean withDisplaySuffix) {\r
        String refName = "urn:cspace:org.collectionspace.demo:personauthority:name("\r
                        +personAuthorityName+")";\r
@@ -157,6 +228,14 @@ public class PersonAuthorityClientUtils {
        return refName;\r
     }\r
 \r
+    /**\r
+     * Creates the person ref name.\r
+     *\r
+     * @param personAuthRefName the person auth ref name\r
+     * @param personName the person name\r
+     * @param withDisplaySuffix the with display suffix\r
+     * @return the string\r
+     */\r
     public static String createPersonRefName(\r
                                                String personAuthRefName, String personName, boolean withDisplaySuffix) {\r
        String refName = personAuthRefName+":person:name("+personName+")";\r
@@ -165,6 +244,12 @@ public class PersonAuthorityClientUtils {
        return refName;\r
     }\r
 \r
+    /**\r
+     * Extract id.\r
+     *\r
+     * @param res the res\r
+     * @return the string\r
+     */\r
     public static String extractId(ClientResponse<Response> res) {\r
         MultivaluedMap<String, Object> mvm = res.getMetadata();\r
         String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);\r
@@ -208,7 +293,7 @@ public class PersonAuthorityClientUtils {
      * @param surName\r
      * @param birthDate\r
      * @param deathDate\r
-     * @return\r
+     * @return display name\r
      */\r
     public static String prepareDefaultDisplayName(\r
                String foreName, String middleName, String surName,\r
index 3006ad2c31987d0a56b388bdd2cf5b8125fa3ad1..ad22c3e71948272dcc710e1bdee716773f824f55 100644 (file)
@@ -22,7 +22,6 @@
  */
 package org.collectionspace.services.client.test;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -108,9 +107,6 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
     /** The n items to create in list. */
     private int nItemsToCreateInList = 3;
     
-    /** The all resource ids created. */
-    private List<String> allResourceIdsCreated = new ArrayList<String>();
-    
     /** The all item resource ids created. */
     private Map<String, String> allItemResourceIdsCreated =
         new HashMap<String, String>();
@@ -162,27 +158,32 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
        MultipartOutput multipart = 
             PersonAuthorityClientUtils.createPersonAuthorityInstance(
            displayName, fullRefName, client.getCommonPartName());
-        ClientResponse<Response> res = client.create(multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        // Specifically:
-        // Does it fall within the set of valid status codes?
-        // Does it exactly match the expected status code?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
+        
+       String newID = null;
+       ClientResponse<Response> res = client.create(multipart);
+       try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               //
+               // Specifically:
+               // Does it fall within the set of valid status codes?
+               // Does it exactly match the expected status code?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+       
+               newID = PersonAuthorityClientUtils.extractId(res);
+       } finally {
+               res.releaseConnection();
+       }
         // Store the refname from the first resource created
         // for additional tests below.
         knownResourceRefName = baseRefName;
-
-        String newID = PersonAuthorityClientUtils.extractId(res);
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null){
@@ -243,18 +244,24 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         MultipartOutput multipart = 
             PersonAuthorityClientUtils.createPersonInstance(vcsid, refName, johnWayneMap,
                 client.getItemCommonPartName() );
+
+        String newID = null;
         ClientResponse<Response> res = client.createItem(vcsid, multipart);
-        int statusCode = res.getStatus();
-        String newID = PersonAuthorityClientUtils.extractId(res);
+        try {
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+               newID = PersonAuthorityClientUtils.extractId(res);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Store the ID returned from the first item resource created
         // for additional tests below.
@@ -306,19 +313,25 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         MultipartOutput multipart =
             ContactClientUtils.createContactInstance(parentcsid,
             itemcsid, identifier, new ContactClient().getCommonPartName());
+        
+        String newID = null;
         ClientResponse<Response> res =
              client.createContact(parentcsid, itemcsid, multipart);
-        int statusCode = res.getStatus();
-        String newID = PersonAuthorityClientUtils.extractId(res);
+        try {
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+               newID = PersonAuthorityClientUtils.extractId(res);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Store the ID returned from the first contact resource created
         // for additional tests below.
@@ -346,6 +359,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -353,6 +367,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -360,6 +375,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void createWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
 /*
@@ -449,7 +465,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
     /* (non-Javadoc)
  * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
  */
-@Override
+    @Override
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"createList"}, dependsOnGroups = {"create"})
     public void createList(String testName) throws Exception {
@@ -506,24 +522,27 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<MultipartInput> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        //FIXME: remove the following try catch once Aron fixes signatures
         try {
-            MultipartInput input = (MultipartInput) res.getEntity();
-            PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
-                    client.getCommonPartName(), PersonauthoritiesCommon.class);
-            Assert.assertNotNull(personAuthority);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+               //FIXME: remove the following try catch once Aron fixes signatures
+               try {
+                   MultipartInput input = (MultipartInput) res.getEntity();
+                   PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
+                           client.getCommonPartName(), PersonauthoritiesCommon.class);
+                   Assert.assertNotNull(personAuthority);
+               } catch (Exception e) {
+                   throw new RuntimeException(e);
+               }
+        } finally {
+               res.releaseConnection();
         }
     }
 
@@ -537,30 +556,33 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
             groups = {"read"}, dependsOnGroups = {"create"})
         public void readByName(String testName) throws Exception {
 
-            // Perform setup.
+        // Perform setup.
         setupRead();
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        //FIXME: remove the following try catch once Aron fixes signatures
         try {
-            MultipartInput input = (MultipartInput) res.getEntity();
-            PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
-                    client.getCommonPartName(), PersonauthoritiesCommon.class);
-            Assert.assertNotNull(personAuthority);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+               //FIXME: remove the following try catch once Aron fixes signatures
+               try {
+                   MultipartInput input = (MultipartInput) res.getEntity();
+                   PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
+                           client.getCommonPartName(), PersonauthoritiesCommon.class);
+                   Assert.assertNotNull(personAuthority);
+               } catch (Exception e) {
+                   throw new RuntimeException(e);
+               }
+        } finally {
+               res.releaseConnection();
         }
     }
 
@@ -605,36 +627,38 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnMethods = {"read"})
     public void readItem(String testName) throws Exception {
-
         // Perform setup.
         setupRead(testName);
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Check whether we've received a person.
-        MultipartInput input = (MultipartInput) res.getEntity();
-        PersonsCommon person = (PersonsCommon) extractPart(input,
-                client.getItemCommonPartName(), PersonsCommon.class);
-        Assert.assertNotNull(person);
-        boolean showFull = true;
-        if(showFull && logger.isDebugEnabled()){
-            logger.debug(testName + ": returned payload:");
-            logger.debug(objectAsXmlString(person, PersonsCommon.class));
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Check whether we've received a person.
+               MultipartInput input = (MultipartInput) res.getEntity();
+               PersonsCommon person = (PersonsCommon) extractPart(input,
+                       client.getItemCommonPartName(), PersonsCommon.class);
+               Assert.assertNotNull(person);
+               boolean showFull = true;
+               if(showFull && logger.isDebugEnabled()){
+                   logger.debug(testName + ": returned payload:");
+                   logger.debug(objectAsXmlString(person, PersonsCommon.class));
+               }
+               Assert.assertEquals(person.getInAuthority(), knownResourceId);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertEquals(person.getInAuthority(), knownResourceId);
-
     }
 
     /**
@@ -646,26 +670,31 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         dependsOnMethods = {"readItem", "updateItem"})
     public void verifyItemDisplayName(String testName) throws Exception {
-
         // Perform setup.
         setupUpdate(testName);
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
+        MultipartInput input =null;
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Check whether person has expected displayName.
-        MultipartInput input = (MultipartInput) res.getEntity();
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Check whether person has expected displayName.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
+        }
+               
         PersonsCommon person = (PersonsCommon) extractPart(input,
                 client.getItemCommonPartName(), PersonsCommon.class);
         Assert.assertNotNull(person);
@@ -676,7 +705,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
                TEST_FORE_NAME, null, TEST_SUR_NAME,
                TEST_BIRTH_DATE, TEST_DEATH_DATE);
         Assert.assertNotNull(displayName, expectedDisplayName);
-        
+    
         // Update the shortName and verify the computed name is updated.
         person.setCsid(null);
         person.setDisplayNameComputed(true);
@@ -691,18 +720,23 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
+        
         PersonsCommon updatedPerson =
                 (PersonsCommon) extractPart(input,
                         client.getItemCommonPartName(), PersonsCommon.class);
@@ -725,18 +759,23 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
+        
         updatedPerson =
                 (PersonsCommon) extractPart(input,
                         client.getItemCommonPartName(), PersonsCommon.class);
@@ -766,20 +805,26 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
+        MultipartInput input = null;
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+       
+               // Check whether Person has expected displayName.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
-        // Check whether Person has expected displayName.
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         PersonsCommon person = (PersonsCommon) extractPart(input,
                 client.getItemCommonPartName(), PersonsCommon.class);
         Assert.assertNotNull(person);
@@ -792,15 +837,19 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
     
     /**
@@ -812,28 +861,33 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"read"}, dependsOnMethods = {"readItem"})
     public void readContact(String testName) throws Exception {
-
         // Perform setup.
         setupRead(testName);
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
+        MultipartInput input = null;
         ClientResponse<MultipartInput> res =
             client.readContact(knownResourceId, knownItemResourceId,
             knownContactResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Check whether we've received a contact.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Check whether we've received a contact.
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         ContactsCommon contact = (ContactsCommon) extractPart(input,
                 new ContactClient().getCommonPartName(), ContactsCommon.class);
         Assert.assertNotNull(contact);
@@ -862,16 +916,19 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     /**
@@ -889,16 +946,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     /**
@@ -917,16 +978,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<MultipartInput> res =
             client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     // ---------------------------------------------------------------
@@ -947,18 +1012,24 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
+        PersonauthoritiesCommonList list = null;
         ClientResponse<PersonauthoritiesCommonList> res = client.readList();
-        PersonauthoritiesCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               list = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = false;
@@ -1012,24 +1083,30 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
        // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<PersonsCommonList> res = null;
-        if(vcsid!= null) {
+        if (vcsid!= null) {
                res = client.readItemList(vcsid);
-        } else if(name!= null) {
+        } else if (name!= null) {
                res = client.readItemListForNamedAuthority(name);
         } else {
                Assert.fail("readItemList passed null csid and name!");
         }
-        PersonsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        PersonsCommonList list = null;
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+               list = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         List<PersonsCommonList.PersonListItem> items =
             list.getPersonListItem();
@@ -1089,20 +1166,26 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
+        ContactsCommonList list = null;
         ClientResponse<ContactsCommonList> res =
                 client.readContactList(parentcsid, itemcsid);
-        ContactsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               list = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        
         List<ContactsCommonList.ContactListItem> listitems =
             list.getContactListItem();
         int nItemsReturned = listitems.size();
@@ -1155,17 +1238,22 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Retrieve the contents of a resource to update.
         PersonAuthorityClient client = new PersonAuthorityClient();
-        ClientResponse<MultipartInput> res =
-                client.read(knownResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
+        MultipartInput input = null;
+        ClientResponse<MultipartInput> res = client.read(knownResourceId);
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
+               }
+               input = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
                 client.getCommonPartName(), PersonauthoritiesCommon.class);
         Assert.assertNotNull(personAuthority);
@@ -1183,18 +1271,23 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         OutputPart commonPart = output.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", client.getCommonPartName());
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
+        
         PersonauthoritiesCommon updatedPersonAuthority =
                 (PersonauthoritiesCommon) extractPart(input,
                         client.getCommonPartName(), PersonauthoritiesCommon.class);
@@ -1221,19 +1314,25 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Retrieve the contents of a resource to update.
         PersonAuthorityClient client = new PersonAuthorityClient();
+        MultipartInput input = null;
         ClientResponse<MultipartInput> res =
                 client.readItem(knownResourceId, knownItemResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got Person to update with ID: " +
-                knownItemResourceId +
-                " in PersonAuthority: " + knownResourceId );
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got Person to update with ID: " +
+                       knownItemResourceId +
+                       " in PersonAuthority: " + knownResourceId );
+               }
+               input = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         PersonsCommon person = (PersonsCommon) extractPart(input,
                 client.getItemCommonPartName(), PersonsCommon.class);
         Assert.assertNotNull(person);
@@ -1252,18 +1351,23 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         OutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
+        
         PersonsCommon updatedPerson =
                 (PersonsCommon) extractPart(input,
                         client.getItemCommonPartName(), PersonsCommon.class);
@@ -1284,26 +1388,31 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"update"}, dependsOnMethods = {"updateItem"})
     public void updateContact(String testName) throws Exception {
-
         // Perform setup.
         setupUpdate(testName);
 
         // Retrieve the contents of a resource to update.
         PersonAuthorityClient client = new PersonAuthorityClient();
+        MultipartInput input = null;
         ClientResponse<MultipartInput> res =
                 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got Contact to update with ID: " +
-                knownContactResourceId +
-                " in item: " + knownItemResourceId +
-                " in parent: " + knownResourceId );
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got Contact to update with ID: " +
+                       knownContactResourceId +
+                       " in item: " + knownItemResourceId +
+                       " in parent: " + knownResourceId );
+               }
+               input = res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        MultipartInput input = (MultipartInput) res.getEntity();
+        
         ContactsCommon contact = (ContactsCommon) extractPart(input,
                 new ContactClient().getCommonPartName(), ContactsCommon.class);
         Assert.assertNotNull(contact);
@@ -1321,18 +1430,22 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
         commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
         res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
         ContactsCommon updatedContact =
                 (ContactsCommon) extractPart(input,
                         new ContactClient().getCommonPartName(), ContactsCommon.class);
@@ -1352,6 +1465,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithEmptyEntityBody(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -1359,6 +1473,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithMalformedXml(String testName) throws Exception {
+       //Should this really be empty?
     }
 
     /* (non-Javadoc)
@@ -1366,6 +1481,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
     @Override
     public void updateWithWrongXmlSchema(String testName) throws Exception {
+       //Should this really be empty?
     }
 
 /*
@@ -1469,16 +1585,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
                                displayName, fullRefName, client.getCommonPartName());
         ClientResponse<MultipartInput> res =
                 client.update(NON_EXISTENT_ID, multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     /**
@@ -1508,16 +1628,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
                        client.getItemCommonPartName() );
         ClientResponse<MultipartInput> res =
                 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
     /**
@@ -1564,6 +1688,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         ClientResponse<Response> res =
             client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
         int statusCode = res.getStatus();
+        res.releaseConnection();
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -1597,6 +1722,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
         int statusCode = res.getStatus();
+        res.releaseConnection();
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -1627,6 +1753,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.delete(knownResourceId);
         int statusCode = res.getStatus();
+        res.releaseConnection();
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -1654,6 +1781,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
         int statusCode = res.getStatus();
+        res.releaseConnection();
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -1681,6 +1809,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
         int statusCode = res.getStatus();
+        res.releaseConnection();
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -1709,6 +1838,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         ClientResponse<Response> res =
             client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
         int statusCode = res.getStatus();
+        res.releaseConnection();
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -1812,6 +1942,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
      */
 
     @AfterClass(alwaysRun=true)
+    @Override
     public void cleanUp() {
         String noTest = System.getProperty("noTestCleanup");
        if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
@@ -1836,6 +1967,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
             // below are ignored and not reported.
             ClientResponse<Response> res =
                 client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
+            res.releaseConnection();
         }
         // Clean up item resources.
         for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
@@ -1845,13 +1977,10 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
             // below are ignored and not reported.
             ClientResponse<Response> res =
                 client.deleteItem(parentResourceId, itemResourceId);
+            res.releaseConnection();
         }
         // Clean up parent resources.
-        for (String resourceId : allResourceIdsCreated) {
-            // Note: Any non-success responses from the delete operation
-            // below are ignored and not reported.
-            ClientResponse<Response> res = client.delete(resourceId);
-        }
+        super.cleanUp();
     }
 
     // ---------------------------------------------------------------
index 13b28b703c39baf81a440387e1b3d4c1c6250c23..79dc82721ca75e61f3e87cfc5aaae731930632ff 100644 (file)
         <dependency>\r
             <groupId>org.slf4j</groupId>\r
             <artifactId>slf4j-api</artifactId>\r
-            <version>1.5.2</version>\r
         </dependency>\r
-        <!-- <dependency>\r
+        <dependency>\r
             <groupId>org.slf4j</groupId>\r
             <artifactId>slf4j-log4j12</artifactId>\r
-            <version>1.5.2</version>\r
-            </dependency> -->\r
-        <!-- CollectionSpace Dependencies -->\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.person.jaxb</artifactId>\r
index 1b6070ee28bdcf0f2c61fef6aa5a17a077133b94..a02ee7ab2cb376af4baafb635e7d5d47e1b3aaf2 100644 (file)
@@ -47,14 +47,14 @@ import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResou
 import org.collectionspace.services.common.ClientType;
 import org.collectionspace.services.common.ServiceMain;
 import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.context.MultipartServiceContext;
+//import org.collectionspace.services.common.authorityref.AuthorityRefList;
+//import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.MultipartServiceContextFactory;
-import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+//import org.collectionspace.services.common.context.MultipartServiceContextImpl;
 import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
-import org.collectionspace.services.common.document.DocumentException;
+//import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
@@ -62,14 +62,14 @@ import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.common.security.UnauthorizedException;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
-import org.collectionspace.services.common.vocabulary.RefNameUtils;
+//import org.collectionspace.services.common.vocabulary.RefNameUtils;
 import org.collectionspace.services.common.query.IQueryManager;
 import org.collectionspace.services.contact.ContactResource;
 import org.collectionspace.services.contact.ContactsCommon;
 import org.collectionspace.services.contact.ContactsCommonList;
 import org.collectionspace.services.contact.ContactJAXBSchema;
 import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+//import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.collectionspace.services.person.nuxeo.PersonDocumentModelHandler;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
@@ -265,7 +265,7 @@ public class PersonAuthorityResource extends
     @GET
     @Path("urn:cspace:name({specifier})")
     public MultipartOutput getPersonAuthorityByName(@PathParam("specifier") String specifier) {
-        String idValue = null;
+//REM:        String idValue = null;
         if (specifier == null) {
             logger.error("getPersonAuthority: missing name!");
             Response response = Response.status(Response.Status.BAD_REQUEST).entity(
@@ -325,6 +325,7 @@ public class PersonAuthorityResource extends
      * can be passed as a query param "type", and must match a configured type
      * for the service bindings. If not set, the type defaults to
      * ServiceBindingUtils.SERVICE_TYPE_PROCEDURE.
+     * @param parentcsid 
      * 
      * @param csid the parent csid
      * @param itemcsid the person csid
@@ -334,7 +335,7 @@ public class PersonAuthorityResource extends
      */
     @GET
     @Path("{csid}/items/{itemcsid}/refObjs")
-    @Produces("application/xml")
+    @Produces("application/xml") //FIXME: REM do this for CSPACE-1079 in Org authority.
     public AuthorityRefDocList getReferencingObjects(
             @PathParam("csid") String parentcsid,
             @PathParam("itemcsid") String itemcsid,
@@ -355,7 +356,7 @@ public class PersonAuthorityResource extends
         }
     try {
         // Note that we have to create the service context for the Items, not the main service
-        ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(getItemServiceName());
+        ServiceContext<MultipartInput, MultipartOutput> ctx = MultipartServiceContextFactory.get().createServiceContext(getItemServiceName());
         DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
         RepositoryClient repoClient = getRepositoryClient(ctx); 
         DocumentFilter myFilter = handler.createDocumentFilter();
@@ -463,16 +464,16 @@ public class PersonAuthorityResource extends
     public PersonauthoritiesCommonList getPersonAuthorityList(@Context UriInfo ui) {
         PersonauthoritiesCommonList personAuthorityObjectList = new PersonauthoritiesCommonList();
         try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
             MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
             DocumentHandler handler = createDocumentHandler(ctx);
-            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
-            myFilter.setPagination(queryParams); //FIXME
+//REM:            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+//REM:            myFilter.setPagination(queryParams); //FIXME
             String nameQ = queryParams.getFirst("refName");
             if (nameQ != null) {
-                myFilter.setWhereClause("personauthorities_common:refName='" + nameQ + "'");
+                handler.getDocumentFilter().setWhereClause("personauthorities_common:refName='" + nameQ + "'");
             }
-            handler.setDocumentFilter(myFilter);
+//REM:            handler.setDocumentFilter(myFilter);
             getRepositoryClient(ctx).getFiltered(ctx, handler);
             personAuthorityObjectList = (PersonauthoritiesCommonList) handler.getCommonPartList();
         } catch (UnauthorizedException ue) {
@@ -588,9 +589,15 @@ public class PersonAuthorityResource extends
 
     }
 
-    /*************************************************************************
+    /**
+     * ***********************************************************************
      * Person parts - this is a sub-resource of PersonAuthority
-     *************************************************************************/
+     * ***********************************************************************.
+     *
+     * @param parentcsid the parentcsid
+     * @param input the input
+     * @return the response
+     */    
     @POST
     @Path("{csid}/items")
     public Response createPerson(@PathParam("csid") String parentcsid, MultipartInput input) {
@@ -705,11 +712,11 @@ public class PersonAuthorityResource extends
                ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
                                queryParams);
             DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
-            myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
+//REM:            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+//REM:            myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
 
             // Add the where clause "persons_common:inAuthority='" + parentcsid + "'"
-            myFilter.setWhereClause(PersonJAXBSchema.PERSONS_COMMON + ":" +
+            handler.getDocumentFilter().setWhereClause(PersonJAXBSchema.PERSONS_COMMON + ":" +
                        PersonJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
             
             // AND persons_common:displayName LIKE '%partialTerm%'
@@ -719,10 +726,9 @@ public class PersonAuthorityResource extends
                        PersonJAXBSchema.DISPLAY_NAME +
                        " LIKE " +
                        "'%" + partialTerm + "%'";
-               myFilter.appendWhereClause(ptClause);
-            }
-            
-            handler.setDocumentFilter(myFilter);
+               handler.getDocumentFilter().appendWhereClause(ptClause);
+            }            
+//REM:            handler.setDocumentFilter(myFilter);
             getRepositoryClient(ctx).getFiltered(ctx, handler);
             personObjectList = (PersonsCommonList) handler.getCommonPartList();
         } catch (UnauthorizedException ue) {
@@ -771,11 +777,11 @@ public class PersonAuthorityResource extends
 
             ctx = createServiceContext(getItemServiceName(), queryParams);
             DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
-            myFilter.setPagination(queryParams); //FIXME
+//REM:            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+//REM:            myFilter.setPagination(queryParams); //FIXME
 
             // Add the where clause "persons_common:inAuthority='" + parentcsid + "'"
-            myFilter.setWhereClause(PersonJAXBSchema.PERSONS_COMMON + ":" +
+            handler.createDocumentFilter().setWhereClause(PersonJAXBSchema.PERSONS_COMMON + ":" +
                        PersonJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
             
             // AND persons_common:displayName LIKE '%partialTerm%'
@@ -785,10 +791,10 @@ public class PersonAuthorityResource extends
                        PersonJAXBSchema.DISPLAY_NAME +
                        " LIKE " +
                        "'%" + partialTerm + "%'";
-               myFilter.appendWhereClause(ptClause);
+               handler.createDocumentFilter().appendWhereClause(ptClause);
             }
             
-            handler.setDocumentFilter(myFilter);
+//REM:            handler.setDocumentFilter(myFilter);
             getRepositoryClient(ctx).getFiltered(ctx, handler);
             personObjectList = (PersonsCommonList) handler.getCommonPartList();
         } catch (UnauthorizedException ue) {
@@ -925,9 +931,16 @@ public class PersonAuthorityResource extends
 
     }
 
-    /*************************************************************************
+    /**
+     * ***********************************************************************
      * Contact parts - this is a sub-resource of Person (or "item")
-     *************************************************************************/
+     * ***********************************************************************.
+     *
+     * @param parentcsid the parentcsid
+     * @param itemcsid the itemcsid
+     * @param input the input
+     * @return the response
+     */
     @POST
     @Path("{parentcsid}/items/{itemcsid}/contacts")
     public Response createContact(
@@ -987,9 +1000,9 @@ public class PersonAuthorityResource extends
                ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(),
                                queryParams);
             DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
-            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
-            myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
-            myFilter.setWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":" +
+//REM:            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+//REM:            myFilter.setPagination(queryParams); //FIXME (this is unnecessary since it is already set by "createContactDocumentHandler" method
+            handler.createDocumentFilter().setWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":" +
                 ContactJAXBSchema.IN_AUTHORITY +
                 "='" + parentcsid + "'" +
                 " AND " +
@@ -997,7 +1010,7 @@ public class PersonAuthorityResource extends
                 ContactJAXBSchema.IN_ITEM +
                 "='" + itemcsid + "'" +
                 " AND ecm:isProxy = 0");
-            handler.setDocumentFilter(myFilter);
+//REM:            handler.setDocumentFilter(myFilter);
             getRepositoryClient(ctx).getFiltered(ctx, handler);
             contactObjectList = (ContactsCommonList) handler.getCommonPartList();
         } catch (UnauthorizedException ue) {
index 3915a6168d52d22ada0edf7aeda0027ab6680f51..aa6b6325610a7a22eba43f0f86694ae3b7420da2 100644 (file)
@@ -3,14 +3,14 @@
     <parent>\r
         <artifactId>org.collectionspace.services.main</artifactId>\r
         <groupId>org.collectionspace.services</groupId>\r
-        <version>1.0</version>\r
+        <version>0.7-SNAPSHOT</version>\r
     </parent>\r
+    \r
     <modelVersion>4.0.0</modelVersion>\r
     <groupId>org.collectionspace.services</groupId>\r
-    <version>1.0</version>\r
     <artifactId>org.collectionspace.services.query</artifactId>\r
-    <packaging>pom</packaging>\r
     <name>services.query</name>\r
+    <packaging>pom</packaging>\r
 \r
     <modules>\r
         <module>service</module>\r
index 830b2e951fb6c4e9b60926e549068d11d6cab1b2..25236060e72a1f2b0fe8f76ace6bf6e1c8a1ab41 100644 (file)
@@ -1,25 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
-\r
+<project xmlns="http://maven.apache.org/POM/4.0.0"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
     <parent>\r
-        <artifactId>org.collectionspace.services.query</artifactId>\r
         <groupId>org.collectionspace.services</groupId>\r
-        <version>1.0</version>\r
+        <artifactId>org.collectionspace.services.query</artifactId>\r
+        <version>0.7-SNAPSHOT</version>\r
     </parent>\r
     \r
     <modelVersion>4.0.0</modelVersion>\r
     <groupId>org.collectionspace.services</groupId>\r
     <artifactId>org.collectionspace.services.query.service</artifactId>\r
-    <packaging>jar</packaging>\r
-    <version>1.0</version>\r
     <name>services.query.service</name>\r
 \r
     <dependencies>\r
-        <dependency>\r
-            <groupId>org.collectionspace.services</groupId>\r
-            <artifactId>org.collectionspace.services.common</artifactId>\r
-            <version>1.0</version>\r
-        </dependency>\r
         <dependency>\r
             <groupId>org.slf4j</groupId>\r
             <artifactId>slf4j-api</artifactId>\r
             <artifactId>slf4j-log4j12</artifactId>\r
         </dependency>\r
         <dependency>\r
-            <groupId>junit</groupId>\r
-            <artifactId>junit</artifactId>\r
-            <version>4.1</version>\r
-            <scope>test</scope>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.common</artifactId>\r
+            <version>1.0</version>\r
         </dependency>\r
         <dependency>\r
             <groupId>org.testng</groupId>\r
             <artifactId>commons-logging</artifactId>\r
             <version>1.1</version>\r
         </dependency>\r
-      <!-- javax -->\r
 \r
+      <!-- javax -->\r
 \r
-        <dependency>\r
+<!--         <dependency>\r
             <groupId>javax.security</groupId>\r
             <artifactId>jaas</artifactId>\r
-            <version>1.0.01</version>\r
             <scope>provided</scope>\r
         </dependency>\r
-\r
         <dependency>\r
             <groupId>dom4j</groupId>\r
             <artifactId>dom4j</artifactId>\r
-            <version>1.6.1</version>\r
             <scope>provided</scope>\r
-        </dependency>\r
+        </dependency>  -->\r
         \r
         <!-- jboss -->\r
 \r
+        <dependency>\r
+            <groupId>org.jboss.resteasy</groupId>\r
+            <artifactId>jaxrs-api</artifactId>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.jboss.resteasy</groupId>\r
             <artifactId>resteasy-jaxrs</artifactId>\r
             <groupId>org.jboss.resteasy</groupId>\r
             <artifactId>resteasy-multipart-provider</artifactId>\r
         </dependency>\r
-        \r
-        <!-- nuxeo -->\r
-\r
-        <dependency>\r
-            <groupId>org.nuxeo.ecm.core</groupId>\r
-            <artifactId>nuxeo-core-api</artifactId>\r
-            <version>${nuxeo.version.1.5}</version>\r
-            <exclusions>\r
-                <exclusion>\r
-                    <artifactId>jboss-remoting</artifactId>\r
-                    <groupId>jboss</groupId>\r
-                </exclusion>\r
-            </exclusions>\r
-        </dependency>\r
-\r
-        <dependency>\r
-            <groupId>org.restlet</groupId>\r
-            <artifactId>org.restlet</artifactId>\r
-            <version>1.0.7</version>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>com.noelios.restlet</groupId>\r
-            <artifactId>com.noelios.restlet.ext.httpclient</artifactId>\r
-            <version>1.0.7</version>\r
-        </dependency>\r
-        <dependency>\r
-            <groupId>com.noelios.restlet</groupId>\r
-            <artifactId>com.noelios.restlet</artifactId>\r
-            <version>1.0.7</version>\r
-        </dependency>\r
-\r
     </dependencies>\r
     \r
     <build>\r
index 6b7ad0733d65ff37ebe9ee5b4a9ee3f2ab569dd3..ad6b3d2280d2aa89f0adc093babf3460156a9dc0 100644 (file)
@@ -36,8 +36,8 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;\r
 import javax.ws.rs.core.UriBuilder;\r
 import javax.ws.rs.core.UriInfo;\r
-import javax.xml.bind.JAXBContext;\r
-import javax.xml.bind.Marshaller;\r
+//import javax.xml.bind.JAXBContext;\r
+//import javax.xml.bind.Marshaller;\r
 \r
 import org.collectionspace.services.common.query.QueryManager;\r
 //import org.collectionspace.services.common.NuxeoClientType;\r