]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6770: More changes for RESTEasy client framework upgrade from 2.x to 3.0
authorremillet <remillet@yahoo.com>
Fri, 7 Aug 2015 23:53:42 +0000 (16:53 -0700)
committerremillet <remillet@yahoo.com>
Fri, 7 Aug 2015 23:53:42 +0000 (16:53 -0700)
services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java
services/client/src/main/java/org/collectionspace/services/client/AbstractPoxServiceClientImpl.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/CollectionSpacePoxClient.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpacePoxProxy.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceProxy.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectSearchTest.java
services/workflow/client/src/test/java/org/collectionspace/services/client/test/WorkflowServiceTest.java

index 58829438036cc8f6c9176d5008e6172f46a2f6e6..6e8c33e3be580f127ab0f074b063b3e504668db3 100644 (file)
@@ -187,7 +187,8 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            // Now lock the dimension record.
            
                @SuppressWarnings("unused")
-               ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
+               Response workflowResponse = dimensionClient.updateWorkflowWithTransition(
+                               dimensionCsid1, WorkflowClient.WORKFLOWTRANSITION_LOCK);
            System.out.println("Locked dimension record with CSID=" + dimensionCsid1);
            
            // Finally, try to delete the relationship
@@ -367,7 +368,9 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            }
            
            @SuppressWarnings("unused")
-               ClientResponse<String> workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid, WorkflowClient.WORKFLOWTRANSITION_LOCK);
+           Response workflowResponse = dimensionClient.updateWorkflowWithTransition(dimensionCsid, 
+                               WorkflowClient.WORKFLOWTRANSITION_LOCK);
+           workflowResponse.close();
            System.out.println("Locked dimension record with CSID=" + dimensionCsid);
            
            // Lastly, relate the two entities, by creating a new relation object
index b610d8c898edc6fbf319f1bf74f3cdf9ac1757b8..415d9a0b4e150c811bf0e997b6c6fd18d1cb901d 100644 (file)
@@ -116,7 +116,7 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
     private void searchCollectionObjects(int numberOfObjects) {
         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
         Random randomGenerator = new Random(System.currentTimeMillis());
-        ClientResponse<AbstractCommonList> searchResults;
+        Response searchResultsResponse;
 
         long totalTime = 0;
         long totalSearchResults = 0;
@@ -129,15 +129,16 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
             for (int i = 0; i < MAX_SEARCHES; i++) {
                 //sandwich the call with timestamps
                 Date startTime = new Date();
-                searchResults = collectionObjectClient.keywordSearchIncludeDeleted(keywords, NOT_INCLUDING_DELETED_RESOURCES);
+                searchResultsResponse = collectionObjectClient.keywordSearchIncludeDeleted(keywords, 
+                               NOT_INCLUDING_DELETED_RESOURCES);
                 Date stopTime = new Date();
 
                 //extract the result list and release the ClientResponse
                 AbstractCommonList coListItem = null;
                 try {
-                    coListItem = searchResults.getEntity();
+                    coListItem = searchResultsResponse.readEntity(AbstractCommonList.class);
                 } finally {
-                    searchResults.close();
+                       searchResultsResponse.close();
                 }
 
                 long time = stopTime.getTime() - startTime.getTime();
@@ -146,6 +147,7 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                 totalSearchResults = totalSearchResults
                         + coListItem.getListItem().size();
             }
+            
             if (logger.isDebugEnabled()) {
                 System.out.println("------------------------------------------------------------------------------");
                 System.out.println("Searched Objects: " + numberOfObjects);
index cdd26cd35d35b93e787715455f27e9165f4dd4ad..42fdf7e1d62be4c696aad0b888b9aa632d23f338 100644 (file)
@@ -35,7 +35,7 @@ public abstract class AbstractPoxServiceClientImpl<CLT extends AbstractCommonLis
     }
     
     @Override
-       public ClientResponse<String> readIncludeDeleted(String csid, Boolean includeDeleted) {
+       public Response readIncludeDeleted(String csid, Boolean includeDeleted) {
         return getProxy().readIncludeDeleted(csid, includeDeleted.toString());
     }
 
@@ -46,13 +46,13 @@ public abstract class AbstractPoxServiceClientImpl<CLT extends AbstractCommonLis
     
 
     @Override
-    public ClientResponse<CLT> keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted) {
+    public Response keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted) {
         CollectionSpacePoxProxy<CLT> proxy = getProxy();
         return proxy.keywordSearchIncludeDeleted(keywords, includeDeleted.toString());
     }
 
     @Override
-    public ClientResponse<CLT> advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted) {
+    public Response advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted) {
         CollectionSpacePoxProxy<CLT> proxy = getProxy();
         return proxy.advancedSearchIncludeDeleted(whereClause, includeDeleted.toString());
     }
index 8304dfc89ec4d48d9734757d7a10e47bd0b387c3..64d8da7a83a4bbb51b578de8b6027e7a79e9ad6a 100644 (file)
@@ -528,12 +528,12 @@ public abstract class AbstractServiceClientImpl<CLT, REQUEST_PT, RESPONSE_PT, P
     }
     
     @Override
-       public ClientResponse<String> getWorkflow(String csid) {
+       public Response getWorkflow(String csid) {
        return getProxy().getWorkflow(csid);
     }
     
     @Override
-       public ClientResponse<String> updateWorkflowWithTransition(String csid, String workflowTransition) {
+       public Response updateWorkflowWithTransition(String csid, String workflowTransition) {
        return getProxy().updateWorkflowWithTransition(csid, workflowTransition);
     }        
     
index 298751101c7fcd202062a8486ff3d6198fecdd93..4f932c041a97dc32a6f276d741835399dc0ed1e0 100644 (file)
@@ -216,9 +216,9 @@ public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P exten
      * @param csid the csid of the entity
      * @return the workflow
      */
-    public ClientResponse<String> getWorkflow(String csid);
+    public Response getWorkflow(String csid);
     
-       public ClientResponse<String> updateWorkflowWithTransition(String csid, String workflowTransition);
+       public Response updateWorkflowWithTransition(String csid, String workflowTransition);
     
     /**
      * Gets the authority refs.
index 0efbfb9c242d335668e36cfa388b11c8c85e6eae..e7830f39215bb7ca8ccc0391cae3bd55492a9406 100644 (file)
@@ -3,7 +3,7 @@ package org.collectionspace.services.client;
 import javax.ws.rs.core.Response;
 
 import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.jboss.resteasy.client.ClientResponse;
+//import org.jboss.resteasy.client.ClientResponse;
 
 /*
  * <LT> = List type
@@ -23,7 +23,7 @@ public interface CollectionSpacePoxClient<LT extends AbstractCommonList, P exten
      */
     public Response readIncludeDeleted(Boolean includeDeleted);
 
-    public ClientResponse<LT> keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted);
+    public Response keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted);
     
-    public ClientResponse<LT> advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted);
+    public Response advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted);
 }
index 3f17a9f20bcccdf00ef5c8f21b62bc52174b6a31..df0321a100e851ade56b1cd9f9b21751b376be6d 100644 (file)
@@ -8,7 +8,7 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
+//import org.jboss.resteasy.client.ClientResponse;
 
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.jaxb.AbstractCommonList;
@@ -28,7 +28,7 @@ public interface CollectionSpacePoxProxy<LT extends AbstractCommonList> extends
        // (R)ead
        @GET
        @Path("/{csid}")
-       ClientResponse<String> readIncludeDeleted(
+       Response readIncludeDeleted(
                        @PathParam("csid") String csid,
                        @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
 
@@ -53,13 +53,13 @@ public interface CollectionSpacePoxProxy<LT extends AbstractCommonList> extends
         */
        @GET
        @Produces({ "application/xml" })
-       ClientResponse<LT> keywordSearchIncludeDeleted(
+       Response keywordSearchIncludeDeleted(
                        @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
                        @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
 
        @GET
        @Produces({ "application/xml" })
-       ClientResponse<LT> advancedSearchIncludeDeleted(
+       Response advancedSearchIncludeDeleted(
                        @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_AS) String whereClause,
                        @QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
 
index 0532b507a5a9d09fae9fb9116abe8f70383fb57e..6fa4eebd9e0e760ce96cc271dcb2e6a46026093e 100644 (file)
@@ -62,13 +62,13 @@ public interface CollectionSpaceProxy<CLT> {
     @Produces({"application/xml"})
     @Consumes({"application/xml"})    
     @Path("{csid}" + WorkflowClient.SERVICE_PATH)
-    ClientResponse<String> getWorkflow(@PathParam("csid") String csid);
+    Response getWorkflow(@PathParam("csid") String csid);
     
     @PUT
     @Produces({"application/xml"})
     @Consumes({"application/xml"})    
     @Path("{csid}" + WorkflowClient.SERVICE_PATH + "/" + "{transition}")
-    ClientResponse<String> updateWorkflowWithTransition(@PathParam("csid") String csid, @PathParam("transition") String transition);
+    Response updateWorkflowWithTransition(@PathParam("csid") String csid, @PathParam("transition") String transition);
     
     /*
      * (R)read List operations
index 8c1e9b02ef8042eb8c87d1d3ed13e3554de6b5c7..de2e72d0ab97ddacbf7e31eb94f6d57da6c58cc8 100644 (file)
@@ -671,26 +671,35 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
             // Search for the newly-created records, excluding the soft deleted record.
             //
             // Send the search request and receive a response
-            ClientResponse<AbstractCommonList> res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.FALSE);
-            int result = res.getStatus();
-            Assert.assertEquals(result, STATUS_OK);
-
-            AbstractCommonList list = res.getEntity();
-            long itemsMatchedBySearch = list.getTotalItems();
-            Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE - 1,
-                    "The number of items marked for delete is not correct.");
+            Response res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.FALSE);
+            try {
+                   int result = res.getStatus();
+                   Assert.assertEquals(result, STATUS_OK);
+       
+                   CLT list = res.readEntity(getCommonListType());
+                   long itemsMatchedBySearch = this.getSizeOfList(list); //list.getTotalItems();
+                   Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE - 1,
+                           "The number of items marked for delete is not correct.");
+            } finally {
+               res.close();
+            }
+            
             //
             // Search for the newly-created records, including the soft deleted record.
             //
             // Send the search request and receive a response
             res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.TRUE);
-            result = res.getStatus();
-            Assert.assertEquals(result, STATUS_OK);
-
-            list = res.getEntity();
-            itemsMatchedBySearch = list.getTotalItems();
-            Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE,
-                    "Deleted item was not returned in list results, even though it was requested to be included.");
+            try {
+                   int result = res.getStatus();
+                   Assert.assertEquals(result, STATUS_OK);
+       
+                   CLT list = res.readEntity(getCommonListType());
+                   long itemsMatchedBySearch = this.getSizeOfList(list); //list.getTotalItems();
+                   Assert.assertEquals(itemsMatchedBySearch, OBJECTS_TO_CREATE,
+                           "Deleted item was not returned in list results, even though it was requested to be included.");
+            } finally {
+               res.close();
+            }
 
         } catch (UnsupportedOperationException e) {
             logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method.  No workflow tests performed.");
@@ -881,17 +890,17 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
         // Read the existing object
         //
         CollectionSpaceClient client = this.getClientInstance();
-        ClientResponse<String> res = client.getWorkflow(resourceId);
+        Response res = client.getWorkflow(resourceId);
         WorkflowCommon workflowCommons = null;
         try {
                assertStatusCode(res, testName);
                logger.debug("Got object to update life cycle state with ID: " + resourceId);
-               PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+               PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(String.class));
                workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
                Assert.assertNotNull(workflowCommons);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
         //
@@ -908,12 +917,12 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
         res = client.updateWorkflowWithTransition(resourceId, workflowTransition);
         try {
                assertStatusCode(res, testName);
-               PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+               PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(String.class));
                updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
                Assert.assertNotNull(updatedWorkflowCommons);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
         //
@@ -925,7 +934,7 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
                try {
                        assertStatusCode(res, testName);
                        logger.debug("Got workflow state of updated object with ID: " + resourceId);
-                       PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+                       PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(String.class));
                        updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
                        Assert.assertNotNull(workflowCommons);
                        String currentWorkflowState = updatedWorkflowCommons.getCurrentLifeCycleState();
@@ -935,7 +944,7 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
                        }
                } finally {
                        if (res != null) {
-                    res.releaseConnection();
+                    res.close();
                 }
                }
                trials++;
@@ -1017,7 +1026,7 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
                result = list.getTotalItems();
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
         
@@ -1037,12 +1046,15 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
         CollectionSpaceClient client = getClientInstance();
         REQUEST_TYPE payload = createInstance(identifier);
         Response res = client.create(payload);
-
-        int statusCode = res.getStatus();
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-
-        result = extractId(res);
-        allResourceIdsCreated.add(result);
+        try {
+               int statusCode = res.getStatus();
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+       
+               result = extractId(res);
+               allResourceIdsCreated.add(result);
+        } finally {
+               res.close();
+        }
 
         return result;
     }
@@ -1135,9 +1147,12 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
                 //
                 AuthorityClient client = (AuthorityClient) this.getClientInstance();
                 ClientResponse<String> res = client.readItem(parentCsid, csid, Boolean.FALSE);
-
-                int result = res.getStatus();
-                Assert.assertEquals(result, STATUS_NOT_FOUND);
+                try {
+                       int result = res.getStatus();
+                       Assert.assertEquals(result, STATUS_NOT_FOUND);
+                } finally {
+                       res.close();
+                }
 
             } catch (UnsupportedOperationException e) {
                 logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method.  No workflow tests performed.");
@@ -1179,7 +1194,7 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
         WorkflowCommon updatedWorkflowCommons = null;
         try {
                assertStatusCode(res, testName);
-               PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+               PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
                updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
                Assert.assertNotNull(updatedWorkflowCommons);
         } finally {
index b133d33ddfe5ccb63dbcd7aa4c0f201c75e3e25b..3db8d7b76909fcafa11b523599f9b6bb4a7d97d1 100644 (file)
@@ -37,7 +37,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
-import org.jboss.resteasy.client.ClientResponse;
+//import org.jboss.resteasy.client.ClientResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -164,7 +164,7 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                String propertyName = CollectionObjectClient.SERVICE_COMMON_PART_NAME + ":" +
                        CollectionObjectJAXBSchema.DISTINGUISHING_FEATURES;
                String propertyValue = theKeyword;
-               ClientResponse<AbstractCommonList> res = doAdvancedSearch(propertyName, propertyValue, "=");
+               Response res = doAdvancedSearch(propertyName, propertyValue, "=");
                try {
                        int statusCode = res.getStatus();
        
@@ -202,7 +202,7 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                testSetup(STATUS_OK, ServiceRequestType.SEARCH);
 
                // Send the search request and receive a response
-               ClientResponse<AbstractCommonList> res = doSearch(KEYWORD);
+               Response res = doSearch(KEYWORD);
                try {
                        int statusCode = res.getStatus();
        
@@ -245,7 +245,7 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                // Search using both terms
 
                // Send the search request and receive a response
-               ClientResponse<AbstractCommonList> res = doSearch(TWO_KEYWORDS);
+               Response res = doSearch(TWO_KEYWORDS);
                try {
                        int statusCode = res.getStatus();
        
@@ -313,44 +313,52 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                // Search using both terms
 
                // Send the search request and receive a response
-               ClientResponse<AbstractCommonList> res = doSearch(TWO_MORE_KEYWORDS);
-               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);
+               Response res = doSearch(TWO_MORE_KEYWORDS);
+               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(testRequestType.isValidStatusCode(statusCode),
+                                       invalidStatusCodeMessage(testRequestType, statusCode));
+                       Assert.assertEquals(statusCode, testExpectedStatusCode);
+       
+                       // Verify that the number of resources matched by the search
+                       // is identical to the expected result
+                       long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
+                       long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+                       Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+               } finally {
+                       res.close();
                }
-               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                               invalidStatusCodeMessage(testRequestType, statusCode));
-               Assert.assertEquals(statusCode, testExpectedStatusCode);
-
-               // Verify that the number of resources matched by the search
-               // is identical to the expected result
-               long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
-               long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
-               Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
 
                // Search using a single term
 
                // Send the search request and receive a response
                res = doSearch(TWO_MORE_KEYWORDS.get(0));
-               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(testRequestType.isValidStatusCode(statusCode),
+                                       invalidStatusCodeMessage(testRequestType, statusCode));
+                       Assert.assertEquals(statusCode, testExpectedStatusCode);
+       
+                       // Verify that the number of resources matched by the search
+                       // is identical to the expected result
+                       long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
+                       long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+                       Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+               } finally {
+                       res.close();
                }
-               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                               invalidStatusCodeMessage(testRequestType, statusCode));
-               Assert.assertEquals(statusCode, testExpectedStatusCode);
-
-               // Verify that the number of resources matched by the search
-               // is identical to the expected result
-               NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
-               numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
-               Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
 
        }
 
@@ -380,23 +388,27 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                testSetup(STATUS_OK, ServiceRequestType.SEARCH);
 
                // Send the search request and receive a response
-               ClientResponse<AbstractCommonList> res = doSearch(UTF8_KEYWORD);
-               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);
+               Response res = doSearch(UTF8_KEYWORD);
+               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(testRequestType.isValidStatusCode(statusCode),
+                                       invalidStatusCodeMessage(testRequestType, statusCode));
+                       Assert.assertEquals(statusCode, testExpectedStatusCode);
+       
+                       // Verify that the number of resources matched by the search
+                       // is identical to the expected result
+                       long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
+                       long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+                       Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+               } finally {
+                       res.close();
                }
-               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                               invalidStatusCodeMessage(testRequestType, statusCode));
-               Assert.assertEquals(statusCode, testExpectedStatusCode);
-
-               // Verify that the number of resources matched by the search
-               // is identical to the expected result
-               long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
-               long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
-               Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
        }
 
        // Failure outcomes
@@ -408,10 +420,9 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                testSetup(STATUS_OK, ServiceRequestType.SEARCH);
 
                // Send the search request and receive a response
-               ClientResponse<AbstractCommonList> res = doSearch(NON_EXISTENT_KEYWORD);
-               int statusCode;
+               Response res = doSearch(NON_EXISTENT_KEYWORD);
                try {
-                       statusCode = res.getStatus();
+                       int statusCode = res.getStatus();
 
                        // Check the status code of the response: does it match
                        // the expected response(s)?
@@ -533,12 +544,12 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                return sb.toString();
        }
 
-       private ClientResponse<AbstractCommonList> doSearch(List<String> keywords) {
+       private Response doSearch(List<String> keywords) {
                String searchParamValue = listToString(keywords, KEYWORD_SEPARATOR);
                return doSearch(searchParamValue);
        }
 
-       private ClientResponse<AbstractCommonList> doAdvancedSearch(
+       private Response doAdvancedSearch(
                        String propertyName, String propertyValue, String operator) {
                if (logger.isDebugEnabled()) {
                        logger.debug("Searching on property: " + propertyName + "="
@@ -547,12 +558,12 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                String whereClause = propertyName + operator +
                        "'" + propertyValue + "'";
                CollectionObjectClient client = new CollectionObjectClient();
-               ClientResponse<AbstractCommonList> res = client.advancedSearchIncludeDeleted(whereClause, false); // NOT_INCLUDING_DELETED_RESOURCES
+               Response res = client.advancedSearchIncludeDeleted(whereClause, false); // NOT_INCLUDING_DELETED_RESOURCES
        
                return res;
        }
 
-       private ClientResponse<AbstractCommonList> doSearch(String keyword) {
+       private Response doSearch(String keyword) {
                String searchParamValue = keyword;
                if (logger.isDebugEnabled()) {
                        logger.debug("Searching on keyword(s): " + searchParamValue
@@ -560,16 +571,13 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                }
                CollectionObjectClient client = new CollectionObjectClient();
                final boolean NOT_INCLUDING_DELETED_RESOURCES = false;
-               ClientResponse<AbstractCommonList> res = client
-                               .keywordSearchIncludeDeleted(searchParamValue,
+               Response res = client.keywordSearchIncludeDeleted(searchParamValue,
                                                NOT_INCLUDING_DELETED_RESOURCES);
                return res;
        }
 
-       private long getNumMatched(ClientResponse<AbstractCommonList> res,
-                       long numExpectedMatches, String testName) {
-               AbstractCommonList list = (AbstractCommonList) res
-                               .getEntity(AbstractCommonList.class);
+       private long getNumMatched(Response res, long numExpectedMatches, String testName) {
+               AbstractCommonList list = (AbstractCommonList) res.readEntity(AbstractCommonList.class);
                long numMatched = list.getTotalItems();
                if (logger.isDebugEnabled()) {
                        logger.debug("Keyword search matched " + numMatched
index 44f115c505ca97be98d2fc1b7271981b6e9056fe..47b67d9f8c3b508fe7a75f3cd86606b04a8f991d 100644 (file)
  */
 package org.collectionspace.services.client.test;
 
+import javax.ws.rs.core.Response;
+
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
-
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.workflow.WorkflowCommon;
 import org.collectionspace.services.client.DimensionClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.dimension.DimensionsCommon;
-
 import org.jboss.resteasy.client.ClientResponse;
-
 import org.testng.Assert;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,10 +80,10 @@ public class WorkflowServiceTest extends AbstractPoxServiceTestImpl<AbstractComm
     public void read(String testName) throws Exception {
         setupRead();
         DimensionClient client = new DimensionClient();
-        ClientResponse<String> res = client.getWorkflow(knownResourceId);
+        Response res = client.getWorkflow(knownResourceId);
         try {
                assertStatusCode(res, testName);
-               PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+               PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
                WorkflowCommon workflowsCommon = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
                if (logger.isDebugEnabled() == true) {
                        logger.debug("Workflow payload is: " + input.getXmlPayload());
@@ -93,7 +91,7 @@ public class WorkflowServiceTest extends AbstractPoxServiceTestImpl<AbstractComm
                Assert.assertNotNull(workflowsCommon);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
     }