// 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
}
@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
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;
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();
totalSearchResults = totalSearchResults
+ coListItem.getListItem().size();
}
+
if (logger.isDebugEnabled()) {
System.out.println("------------------------------------------------------------------------------");
System.out.println("Searched Objects: " + numberOfObjects);
}
@Override
- public ClientResponse<String> readIncludeDeleted(String csid, Boolean includeDeleted) {
+ public Response readIncludeDeleted(String csid, Boolean includeDeleted) {
return getProxy().readIncludeDeleted(csid, includeDeleted.toString());
}
@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());
}
}
@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);
}
* @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.
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
*/
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);
}
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;
// (R)ead
@GET
@Path("/{csid}")
- ClientResponse<String> readIncludeDeleted(
+ Response readIncludeDeleted(
@PathParam("csid") String csid,
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
*/
@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);
@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
// 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.");
// 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();
}
}
//
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();
}
}
//
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();
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
trials++;
result = list.getTotalItems();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
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;
}
//
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.");
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 {
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;
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();
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();
// 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();
// 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);
}
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
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)?
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 + "="
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
}
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
*/
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;
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());
Assert.assertNotNull(workflowsCommon);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}