for(RelationsCommonList.RelationListItem listItem : relationListItems){
String foundCsid = listItem.getCsid();
- ClientResponse<String> multiPartResponse = null;
+ Response multiPartResponse = null;
try {
multiPartResponse = relationClient.read(foundCsid);
int responseStatus = multiPartResponse.getStatus();
Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
- PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
resultRelation = (RelationsCommon) extractPart(input,
relationClient.getCommonPartName(),
RelationsCommon.class);
RelationsCommon resultRelation = null;
for(RelationsCommonList.RelationListItem listItem : relationListItems){
String foundCsid = listItem.getCsid();
- ClientResponse<String> multiPartResponse = null;
+ Response multiPartResponse = null;
try {
multiPartResponse = relationClient.read(foundCsid);
int responseStatus = multiPartResponse.getStatus();
Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
- PoxPayloadIn input = new PoxPayloadIn(multiPartResponse.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)multiPartResponse.getEntity());
resultRelation = (RelationsCommon) extractPart(input,
relationClient.getCommonPartName(),
RelationsCommon.class);
import org.testng.Assert;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.util.HttpResponseCodes;
-
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.PayloadOutputPart;
try {
Assert.assertEquals(response.getStatus(), HttpResponseCodes.SC_OK);
} finally {
- response.releaseConnection();
+ response.close();
}
Date stopTime = new Date();
totalTime = totalTime + (stopTime.getTime() - startTime.getTime());
try {
coListItem = searchResults.getEntity();
} finally {
- searchResults.releaseConnection();
+ searchResults.close();
}
long time = stopTime.getTime() - startTime.getTime();
*/
private void readCollectionObject(CollectionObjectClient collectionObjectClient,
String resourceId) {
- ClientResponse<String> res = collectionObjectClient.read(resourceId);
- res.releaseConnection();
+ Response res = collectionObjectClient.read(resourceId);
+ res.close();
}
/**
*/
public void readCollectionObjects() {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
- ClientResponse<AbstractCommonList> response;
List<AbstractCommonList.ListItem> coListItems = null;
do {
- response = collectionObjectClient.readList(new Long(MAX_RECORDS),
+ Response res = collectionObjectClient.readList(new Long(MAX_RECORDS),
new Long(0));
try {
AbstractCommonList commonListElement =
- (AbstractCommonList) response.getEntity(AbstractCommonList.class);
+ (AbstractCommonList) res.readEntity(AbstractCommonList.class);
coListItems = commonListElement.getListItem();
} finally {
- response.releaseConnection();
+ res.close();
}
Date startTime = new Date();
*/
private void deleteCollectionObjects() {
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
- ClientResponse<AbstractCommonList> response;
List<AbstractCommonList.ListItem> coListItems = null;
do {
- response = collectionObjectClient.readList(new Long(MAX_RECORDS),
+ Response res = collectionObjectClient.readList(new Long(MAX_RECORDS),
new Long(0));
try {
AbstractCommonList commonListElement =
- (AbstractCommonList) response.getEntity(AbstractCommonList.class);
+ (AbstractCommonList) res.readEntity(AbstractCommonList.class);
coListItems = commonListElement.getListItem();
} finally {
- response.releaseConnection();
+ res.close();
}
Date startTime = new Date();
import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
+import java.lang.UnsupportedOperationException;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
import org.collectionspace.services.client.test.ServiceRequestType;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
protected String getServicePathComponent() {
return new AccountRoleClient().getServicePathComponent();
}
+
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<AccountRole> getEntityResponseType() {
+ return AccountRole.class;
+ }
/**
* Seed data.
protected Class<AccountRole> getCommonListType() {
return AccountRole.class;
}
+
+ @Override
+ protected long getSizeOfList(AccountRole list) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Method getSizeOfList() is not implemented because this service does not support lists.");
+ }
}
package org.collectionspace.services.account.client.test;
import java.util.List;
+
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ClientResponse;
import org.collectionspace.services.client.AccountClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.account.AccountsCommon;
import org.collectionspace.services.account.AccountsCommonList;
import org.collectionspace.services.account.AccountListItem;
-
import org.collectionspace.services.account.Status;
+import org.collectionspace.services.authorization.AccountRole;
import org.collectionspace.services.client.AccountFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
import org.collectionspace.services.client.test.ServiceRequestType;
-
import org.testng.Assert;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return AccountClient.SERVICE_NAME;
}
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<AccountsCommon> getEntityResponseType() {
+ return AccountsCommon.class;
+ }
+
/*
* This method is called only by the parent class, AbstractServiceTestImpl
*/
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AccountsCommonList getCommonList(
- ClientResponse<AccountsCommonList> response) {
+ protected AccountsCommonList getCommonList(Response response) {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
throw new UnsupportedOperationException();
}
"Data in updated object did not match submitted data.");
}
+ @Override
+ protected long getSizeOfList(AccountsCommonList list) {
+ return list.getTotalItems();
+ }
+
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
AcquisitionClient client = new AcquisitionClient();
// Submit the request to the service and store the response.
- ClientResponse<String> 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);
+ Response res = client.read(knownResourceId);
+ PoxPayloadIn input = 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ input = new PoxPayloadIn((String)res.getEntity());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+
AcquisitionsCommon acquisitionObject = (AcquisitionsCommon) extractPart(input,
client.getCommonPartName(), AcquisitionsCommon.class);
Assert.assertNotNull(acquisitionObject);
// Verify the number and contents of values in repeatable fields,
// as created in the instance record used for testing.
- List<String> acqSources =
- acquisitionObject.getAcquisitionSources().getAcquisitionSource();
+ List<String> acqSources = acquisitionObject.getAcquisitionSources().getAcquisitionSource();
Assert.assertTrue(acqSources.size() > 0);
Assert.assertNotNull(acqSources.get(0));
// Submit the request to the service and store the response.
AcquisitionClient client = new AcquisitionClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// Submit the request to the service and store the response.
AcquisitionClient client = new AcquisitionClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
try {
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
+ AbstractCommonList list = res.readEntity(this.getCommonListType());
// Optionally output additional data about list members for debugging.
if (logger.isTraceEnabled() == true){
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Retrieve the contents of a resource to update.
AcquisitionClient client = new AcquisitionClient();
- ClientResponse<String> res = client.read(knownResourceId);
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
+ Response res = client.read(knownResourceId);
+ PoxPayloadIn input = null;
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ input = new PoxPayloadIn((String)res.getEntity());
+ } finally {
+ res.close();
}
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
client.getCommonPartName(), AcquisitionsCommon.class);
commonPart.setLabel(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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ input = new PoxPayloadIn((String)res.getEntity());
+ AcquisitionsCommon updatedAcquisition =
+ (AcquisitionsCommon) extractPart(input,
+ client.getCommonPartName(), AcquisitionsCommon.class);
+ Assert.assertNotNull(updatedAcquisition);
+
+ Assert.assertEquals(updatedAcquisition.getAcquisitionReferenceNumber(),
+ acquisition.getAcquisitionReferenceNumber(),
+ "Data in updated object did not match submitted data.");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- input = new PoxPayloadIn(res.getEntity());
- AcquisitionsCommon updatedAcquisition =
- (AcquisitionsCommon) extractPart(input,
- client.getCommonPartName(), AcquisitionsCommon.class);
- Assert.assertNotNull(updatedAcquisition);
-
- Assert.assertEquals(updatedAcquisition.getAcquisitionReferenceNumber(),
- acquisition.getAcquisitionReferenceNumber(),
- "Data in updated object did not match submitted data.");
}
// The only relevant ID may be the one used in update(), below.
AcquisitionClient client = new AcquisitionClient();
PoxPayloadOut multipart = createAcquisitionInstance(NON_EXISTENT_ID);
- ClientResponse<String> 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);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
+ 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);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
AcquisitionClient client = new AcquisitionClient();
- ClientResponse<String> res = client.read(csid);
+ Response res = client.read(csid);
AcquisitionsCommon acquisition = null;
try {
// Check the status code of the response: does it match
// the expected response(s)?
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
if (logger.isDebugEnabled()) {
logger.debug(testName + ": Reading Common part ...");
Assert.assertNotNull(acquisition);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
protected String getServiceName() {
return PermissionClient.SERVICE_NAME; //Since we're a sub-resource of permission service return its name?
}
-
+
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<PermissionRole> getEntityResponseType() {
+ return PermissionRole.class;
+ }
+
/**
* Seed data.
*/
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected PermissionRole getCommonList(
- ClientResponse<PermissionRole> response) {
+ protected PermissionRole getCommonList(Response response) {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
throw new UnsupportedOperationException();
}
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
"org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
public void CRUDTests(String testName) {
// Do nothing. Simply here to for a TestNG execution order for our tests
- }
+ }
+
+ @Override
+ protected long getSizeOfList(PermissionRole list) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Method getSizeOfList() is not implemented because this service does not support lists.");
+ }
}
return new PermissionClient();
}
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<Permission> getEntityResponseType() {
+ return Permission.class;
+ }
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
*/
// TODO Auto-generated method stub
}
+
+ @Override
+ protected long getSizeOfList(PermissionsList list) {
+ // TODO Auto-generated method stub
+ return list.getPermission().size();
+ }
}
return TEST_ROLE_NAME + TEST_MARKER + now.toString();
}
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<PermissionRole> getEntityResponseType() {
+ return PermissionRole.class;
+ }
+
/**
* Seed data.
*/
return roleValues.get(getRoleName()).getRoleId();
}
+ @Override
+ protected long getSizeOfList(PermissionRole permRole) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Method getSizeOfList() is not implemented because this service does not support lists.");
+ }
+
/*
* For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
* refer to this method in their @Test annotation declarations.
return new RoleClient().getServicePathComponent();
}
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<Role> getEntityResponseType() {
+ return Role.class;
+ }
+
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
"org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
public void CRUDTests(String testName) {
// Do nothing. Simply here to for a TestNG execution order for our tests
- }
+ }
+
+ @Override
+ protected long getSizeOfList(RolesList list) {
+ return list.getRole().size();
+ }
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
/**
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
// Read the blob back to get the new dimension data
//
setupRead();
- ClientResponse<String> readResponse = client.read(blobCsid);
+ Response readResponse = client.read(blobCsid);
BlobsCommon blobsCommon = null;
try {
assertStatusCode(readResponse, testName);
Assert.assertNotNull(blobsCommon);
} finally {
if (readResponse != null) {
- readResponse.releaseConnection();
+ readResponse.close();
}
}
return getProxy().read(csid);
}
- public ClientResponse<CLT> readList() {
+ public Response readList() {
CollectionSpaceProxy<CLT> proxy = (CollectionSpaceProxy<CLT>)getProxy();
return proxy.readList();
}
@Override
- public ClientResponse<CLT> readIncludeDeleted(Boolean includeDeleted) {
+ public Response readIncludeDeleted(Boolean includeDeleted) {
CollectionSpacePoxProxy<CLT> proxy = getProxy();
return proxy.readIncludeDeleted(includeDeleted.toString());
}
}
@Override
- public ClientResponse<String> update(String csid, PoxPayloadOut xmlPayload) {
+ public Response update(String csid, PoxPayloadOut xmlPayload) {
return getProxy().update(csid, xmlPayload.getBytes());
}
* .lang.String, java.lang.String)
*/
@Override
- public ClientResponse<CLT> readList(Long pageSize,
+ public Response readList(Long pageSize,
Long pageNumber) {
return getProxy().readList(pageSize, pageNumber);
}
* .lang.String, java.lang.String)
*/
@Override
- public ClientResponse<CLT> readList(String sortBy, Long pageSize,
+ public Response readList(String sortBy, Long pageSize,
Long pageNumber) {
return getProxy().readList(sortBy, pageSize, pageNumber);
}
public Response read(String csid);
- public ClientResponse<RESPONSE_TYPE> update(String csid, REQUEST_TYPE payload);
+ public Response update(String csid, REQUEST_TYPE payload);
/**
* Read list.
* @param pageNumber the page number
* @return the client response
*/
- public ClientResponse<CLT> readList(
+ public Response readList(
Long pageSize,
Long pageNumber);
- public ClientResponse<CLT> readList();
+ public Response readList(); // Formally, ClientResponse<CLT>
/**
* Read list.
* @param pageNumber the page number
* @return the client response
*/
- public ClientResponse<CLT> readList(
+ public Response readList(
String sortBy,
Long pageSize,
Long pageNumber);
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.jaxb.AbstractCommonList;
public interface CollectionSpaceCommonListPoxProxy extends CollectionSpacePoxProxy<AbstractCommonList> {
@GET
- ClientResponse<AbstractCommonList> readList();
+ Response readList();
@Override
@GET
package org.collectionspace.services.client;
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.client.ClientResponse;
* Common service calls
*/
- public ClientResponse<String> readIncludeDeleted(String csid, Boolean includeDeleted);
+ public Response readIncludeDeleted(String csid, Boolean includeDeleted);
/*
* GET list with workflow 'deleted' state
*/
- public ClientResponse<LT> readIncludeDeleted(Boolean includeDeleted);
+ public Response readIncludeDeleted(Boolean includeDeleted);
public ClientResponse<LT> keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted);
// (U)pdate
@PUT
@Path("/{csid}")
- ClientResponse<String> update(@PathParam("csid") String csid, byte[] payload);
+ Response update(@PathParam("csid") String csid, byte[] payload);
// (L)ist non-deleted items
@GET
@Produces({ "application/xml" })
- ClientResponse<LT> readIncludeDeleted(
+ Response readIncludeDeleted(
@QueryParam(WorkflowClient.WORKFLOWSTATE_QUERY) String workflowState);
/**
@GET
@Produces({"application/xml"})
- ClientResponse<CLT> readList();
+ Response readList();
/**
* Read list.
*/
@GET
@Produces({"application/xml"})
- ClientResponse<CLT> readList(
+ Response readList(
@QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,
@QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber);
*/
@GET
@Produces({"application/xml"})
- ClientResponse<CLT> readList(
+ Response readList(
@QueryParam(IClientQueryParams.ORDER_BY_PARAM) String sortBy,
@QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,
@QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber);
// Submit the request to the service and store the response.
AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =
(AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
- ClientResponse<String> 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 + " read authority:" + knownResourceId + "/Item:"
- + knownItemResourceId + " status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
- AUTHORITY_ITEM_TYPE vitem = extractItemCommonPartValue(res);
- Assert.assertNotNull(vitem);
- // Try to Update with new parent vocab (use self, for test).
- Assert.assertEquals(client.getInAuthority(vitem), knownResourceId,
- "VocabularyItem inAuthority does not match knownResourceId.");
- client.setInAuthority(vitem, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
+ AUTHORITY_ITEM_TYPE vitem = 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 + " read authority:" + knownResourceId + "/Item:"
+ + knownItemResourceId + " status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+
+ vitem = extractItemCommonPartValue(res);
+ Assert.assertNotNull(vitem);
+ // Try to Update with new parent vocab (use self, for test).
+ Assert.assertEquals(client.getInAuthority(vitem), knownResourceId,
+ "VocabularyItem inAuthority does not match knownResourceId.");
+ client.setInAuthority(vitem, knownItemResourceId);
+ } finally {
+ res.close();
+ }
+
// Submit the updated resource to the service and store the response.
PoxPayloadOut output = this.createItemRequestTypeInstance(vitem);
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(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);
+
+ // Retrieve the updated resource and verify that the parent did not change
+ res = client.readItem(knownResourceId, knownItemResourceId);
+ AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);
+ Assert.assertNotNull(updatedVocabularyItem);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(client.getInAuthority(updatedVocabularyItem),
+ knownResourceId,
+ "VocabularyItem allowed update to the parent (inAuthority).");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Retrieve the updated resource and verify that the parent did not change
- res = client.readItem(knownResourceId, knownItemResourceId);
- AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);
- Assert.assertNotNull(updatedVocabularyItem);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(client.getInAuthority(updatedVocabularyItem),
- knownResourceId,
- "VocabularyItem allowed update to the parent (inAuthority).");
}
@Test(dataProvider = "testName",
// Submit the request to the service and store the response.
AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
ClientResponse<String> res = client.readByName(getKnowResourceIdentifier());
- 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ AUTHORITY_COMMON_TYPE commonPart = extractCommonPartValue(res);
+ Assert.assertNotNull(commonPart);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- AUTHORITY_COMMON_TYPE commonPart = extractCommonPartValue(res);
- Assert.assertNotNull(commonPart);
}
/**
* @return
* @throws Exception
*/
- public AUTHORITY_ITEM_TYPE extractItemCommonPartValue(ClientResponse<String> res) throws Exception {
+ public AUTHORITY_ITEM_TYPE extractItemCommonPartValue(Response res) throws Exception {
AUTHORITY_ITEM_TYPE result = null;
- AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
+ this.getClientInstance();
PayloadInputPart payloadInputPart = extractPart(res, client.getItemCommonPartName());
if (payloadInputPart != null) {
result = (AUTHORITY_ITEM_TYPE) payloadInputPart.getBody();
setupReadNonExistent();
// Submit the request to the service and store the response.
- AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
- ClientResponse<String> 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);
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
+ this.getClientInstance();
+ Response res = client.readItem(knownResourceId, NON_EXISTENT_ID);
+ 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);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
@Test(dataProvider = "testName",
// Submit the request to the service and store the response.
AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
- ClientResponse<String> 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);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
+ 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);
+
+ AUTHORITY_ITEM_TYPE itemCommonPart = extractItemCommonPartValue(res);
+ Assert.assertNotNull(itemCommonPart);
+ Assert.assertEquals(client.getInAuthority(itemCommonPart), knownResourceId);
+ verifyReadItemInstance(itemCommonPart);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- AUTHORITY_ITEM_TYPE itemCommonPart = extractItemCommonPartValue(res);
- Assert.assertNotNull(itemCommonPart);
- Assert.assertEquals(client.getInAuthority(itemCommonPart), knownResourceId);
- verifyReadItemInstance(itemCommonPart);
}
protected abstract void verifyReadItemInstance(AUTHORITY_ITEM_TYPE item) throws Exception;
setupDelete();
// Submit the request to the service and store the response.
- AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
+ AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
+ this.getClientInstance();
Response res = client.deleteItem(knownResourceId, knownItemResourceId);
int statusCode;
try {
// Retrieve the contents of a resource to update.
AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =
(AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
- ClientResponse<String> res =
- client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
try {
if (logger.isDebugEnabled()) {
logger.debug(testName + ": read status = " + res.getStatus());
+ objectAsXmlString(theUpdate));
}
} finally {
- res.releaseConnection();
+ res.close();
}
// Submit the updated resource to the service and store the response.
compareUpdatedItemInstances(theUpdate, updatedVocabularyItem);
} finally {
- res.releaseConnection();
+ res.close();
}
}
AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);
}
}
+
+ @Override
+ protected long getSizeOfList(CLT list) {
+ return list.getTotalItems();
+ }
+
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<String> getEntityResponseType() {
+ return String.class;
+ }
@Override
public CPT extractCommonPartValue(PoxPayloadOut payloadOut) throws Exception {
"Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");
return result;
- }
-
+ }
+
@Override
public PoxPayloadOut createRequestTypeInstance(CPT commonPartTypeInstance) {
PoxPayloadOut result = null;
if (getLogger().isDebugEnabled()) {
getLogger().debug("Reading part " + partLabel + " ...");
}
- PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(getEntityResponseType()));
PayloadInputPart payloadInputPart = input.getPart(partLabel);
Assert.assertNotNull(payloadInputPart,
"Part " + partLabel + " was unexpectedly null.");
package org.collectionspace.services.client.test;
import java.io.File;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.TypeVariable;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.workflow.WorkflowCommon;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.jboss.resteasy.client.ClientResponse;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.testng.Assert;
import org.testng.annotations.Test;
+import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
/**
return result;
}
- @Override
+ abstract public Class<RESPONSE_TYPE> getEntityResponseType();
+
+ @SuppressWarnings("unchecked")
+ @Override
@Test(dataProvider = "testName", dependsOnMethods = {"create"})
public void read(String testName) throws Exception {
// Perform setup.
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- RESPONSE_TYPE output = (RESPONSE_TYPE) res.getEntity();
- Assert.assertNotNull(output);
//
// Now compare with the expected field values
public CPT extractCommonPartValue(Response res) throws Exception {
CPT result = null;
- result = (CPT) res.getEntity();
+ result = (CPT) res.readEntity(getEntityResponseType());
return result;
}
// Submit the request to the service and store the response.
CollectionSpaceClient client = this.getClientInstance();
- ClientResponse<CLT> res = client.readList();
- CLT list = res.getEntity();
+ Response res = client.readList();
+ CLT list = res.readEntity(this.getCommonListType());
int statusCode = res.getStatus();
// Check the status code of the response: does it match
int result = 0;
while (trials < 30) {
CollectionSpacePoxClient client = this.assertPoxClient();
- ClientResponse<String> res = client.readIncludeDeleted(csid, Boolean.FALSE);
+ Response res = client.readIncludeDeleted(csid, Boolean.FALSE);
result = res.getStatus();
if (result == STATUS_NOT_FOUND) {
logger.info("Workflow transition to 'deleted' is complete");
result = 0;
while (trials < 30) {
CollectionSpacePoxClient client = this.assertPoxClient();
- ClientResponse<String> res = client.readIncludeDeleted(csid, Boolean.FALSE);
+ Response res = client.readIncludeDeleted(csid, Boolean.FALSE);
result = res.getStatus();
+ res.close();
if (result == STATUS_OK) {
logger.info("Workflow transition to 'project' is complete");
break;
// The only relevant ID may be the one used in update(), below.
CollectionSpaceClient client = this.getClientInstance();
REQUEST_TYPE multipart = createNonExistenceInstance(client.getCommonPartName(), NON_EXISTENT_ID);
- ClientResponse<String> 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);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
+ 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);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
long pageSize,
long pageNumber,
int expectedStatus) throws Exception {
- ClientResponse<CLT> response =
- client.readList(sortBy, pageSize, pageNumber);
+ Response response = client.readList(sortBy, pageSize, pageNumber);
CLT result = null;
try {
int statusCode = response.getStatus();
result = this.getCommonList(response);
} finally {
- response.releaseConnection();
+ response.close();
}
return result;
}
return (CollectionSpacePoxClient) clientCandidate;
}
+
+ /*
+ * Must be overridden for CTL param
+ */
+ abstract protected long getSizeOfList(CLT list);
+ /*
+ * Return the number of items including those soft-deleted.
+ */
protected long readIncludeDeleted(String testName, Boolean includeDeleted) {
long result = 0;
// Perform setup.
// Ask for a list of all resources filtered by the incoming 'includeDeleted' workflow param
//
CollectionSpacePoxClient client = assertPoxClient();
- ClientResponse<AbstractCommonList> res = client.readIncludeDeleted(includeDeleted);
+ Response res = client.readIncludeDeleted(includeDeleted);
try {
//
// Check the status code of the response: does it match
// the expected response(s)?
//
assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
+ CLT list = res.readEntity(getCommonListType());
//
// Now check that list size is correct
//
- result = list.getTotalItems();
+ result = getSizeOfList(list); //list.getTotalItems();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
return (Class<CLT>)AbstractCommonList.class;
}
- protected CLT getCommonList(
- ClientResponse<CLT> response) {
- return response.getEntity(getCommonListType());
+ protected CLT getCommonList(Response response) {
+ return response.readEntity(getCommonListType());
}
/**
* @param id the id
* @return the client response
*/
- private ClientResponse<String> updateRetrieve(String testName, String id) {
+ private Response updateRetrieve(String testName, String id) {
setupRead();
CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// the expected response(s)?
* @param id the id
* @return the client response
*/
- private ClientResponse<String> updateSend(String testName, String id,
+ private Response updateSend(String testName, String id,
CollectionobjectsCommon collectionObjectCommon) {
setupUpdate();
PoxPayloadOut output = new PoxPayloadOut(CollectionObjectClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(collectionObjectCommon, MediaType.APPLICATION_XML_TYPE);
CollectionObjectClient client = new CollectionObjectClient();
commonPart.setLabel(client.getCommonPartName());
- ClientResponse<String> res = client.update(knownResourceId, output);
+
+ Response res = client.update(knownResourceId, output);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// the expected response(s)?
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- return res;
+
+ return res; // Calling needs to make sure they call res.close();
}
// Failure outcomes
CollectionObjectClient client = new CollectionObjectClient();
PoxPayloadOut multipart =
createInstance(client.getCommonPartName(), NON_EXISTENT_ID);
- ClientResponse<String> 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);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
+ 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);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
/**
dependsOnMethods = {"CRUDTests"})
public void updateWithRequiredValuesNullOrEmpty(String testName) throws Exception {
// Read an existing record for updating.
- ClientResponse<String> res = updateRetrieve(testName, knownResourceId);
+ Response res = updateRetrieve(testName, knownResourceId);
CollectionobjectsCommon collectionObjectCommon = null;
try {
// Extract its common part.
// Submit the request to the service and store the response.
CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<String> res = client.read(csid);
+ Response res = client.read(csid);
CollectionobjectsCommon collectionObject = null;
try {
int statusCode = res.getStatus();
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
ConditioncheckClient client = new ConditioncheckClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
ConditioncheckClient client = new ConditioncheckClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AbstractCommonList list = null;
ConditioncheckClient client = new ConditioncheckClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
assertStatusCode(res, testName);
try {
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- list = res.getEntity();
+ list = res.readEntity(getCommonListType());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Retrieve the contents of a resource to update.
ConditioncheckClient client = new ConditioncheckClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// The only relevant ID may be the one used in update(), below.
ConditioncheckClient client = new ConditioncheckClient();
PoxPayloadOut multipart = createConditioncheckInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// @Override
// Submit the request to the service and store the response.
ContactClient client = new ContactClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
ContactsCommon contact = (ContactsCommon) extractPart(input,
client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
ContactClient client = new ContactClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
try {
assertStatusCode(res, testName);
- AbstractCommonList list = res.getEntity();
+ AbstractCommonList list = res.readEntity(getCommonListType());
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = false;
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// First read the object that will be updated
//
ContactClient client = new ContactClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
ContactsCommon contact = null;
try {
assertStatusCode(res, testName);
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
contact = (ContactsCommon) extractPart(input,
client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(contact);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
ContactsCommon updatedContact = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
updatedContact = (ContactsCommon) extractPart(input,
client.getCommonPartName(), ContactsCommon.class);
Assert.assertNotNull(updatedContact);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
ContactClient client = new ContactClient();
PoxPayloadOut multipart =
ContactClientUtils.createContactInstance(NON_EXISTENT_ID, client.getCommonPartName());
- ClientResponse<String> res =
+ Response 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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
*/
package org.collectionspace.services.client;
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.dimension.DimensionsCommonList;
import org.jboss.resteasy.client.ClientResponse;
* Proxied service calls
*/
- public ClientResponse<DimensionsCommonList> readList() {
+ public Response readList() {
DimensionProxy proxy = (DimensionProxy)getProxy();
return proxy.readList();
}
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.dimension.DimensionsCommonList;
public interface DimensionProxy extends CollectionSpacePoxProxy<DimensionsCommonList> {
@GET
@Produces({"application/xml"})
- ClientResponse<DimensionsCommonList> readList();
+ Response readList();
@Override
@GET
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
ExhibitionClient client = new ExhibitionClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
ExhibitionClient client = new ExhibitionClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AbstractCommonList list = null;
ExhibitionClient client = new ExhibitionClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
assertStatusCode(res, testName);
try {
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- list = res.getEntity();
+ list = res.readEntity(getCommonListType());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Retrieve the contents of a resource to update.
ExhibitionClient client = new ExhibitionClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// The only relevant ID may be the one used in update(), below.
ExhibitionClient client = new ExhibitionClient();
PoxPayloadOut multipart = createExhibitionInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
package org.collectionspace.services.client.test;
import java.util.List;
+
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.dom4j.Element;
-
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.IntakeClient;
import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.intake.CurrentLocationGroupList;
import org.collectionspace.services.intake.IntakesCommon;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
import org.testng.annotations.Test;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Retrieve the contents of a resource to update.
IntakeClient client = new IntakeClient();
- ClientResponse<String> res = client.read(knownResourceId);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
+ PoxPayloadIn input = null;
+ Response res = client.read(knownResourceId);
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ input = new PoxPayloadIn((String)res.getEntity());
+ } finally {
+ res.close();
}
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+
PayloadInputPart payloadInputPart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
Element coreAsElement = null;
if (payloadInputPart != null) {
// Create an output payload to send to the service, and add the common part
PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart corePart = output.addPart(
- COLLECTIONSPACE_CORE_SCHEMA, coreAsElement);
+ PayloadOutputPart corePart = output.addPart(COLLECTIONSPACE_CORE_SCHEMA, coreAsElement);
// Submit the request to the service and store the response.
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);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- input = new PoxPayloadIn(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(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ input = new PoxPayloadIn((String)res.getEntity());
+ } finally {
+ res.close();
+ }
+
PayloadInputPart updatedCorePart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
Element updatedCoreAsElement = null;
if (updatedCorePart != null) {
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
LoaninClient client = new LoaninClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
LoaninClient client = new LoaninClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AbstractCommonList list = null;
LoaninClient client = new LoaninClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
assertStatusCode(res, testName);
try {
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- list = res.getEntity();
+ list = res.readEntity(getCommonListType());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Retrieve the contents of a resource to update.
LoaninClient client = new LoaninClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// The only relevant ID may be the one used in update(), below.
LoaninClient client = new LoaninClient();
PoxPayloadOut multipart = createLoaninInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
LoanoutClient client = new LoanoutClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
LoansoutCommon loanoutCommon = null;
try {
assertStatusCode(res, testName);
// Get the common part of the response and verify that it is not null.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
Assert.assertNotNull(loanoutCommon);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
LoanoutClient client = new LoanoutClient();
- ClientResponse<String> 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);
+ Response res = client.read(NON_EXISTENT_ID);
+ 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);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
LoanoutClient client = new LoanoutClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
AbstractCommonList list = null;
try {
assertStatusCode(res, testName);
- list = res.getEntity();
+ list = res.readEntity(getCommonListType());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Optionally output additional data about list members for debugging.
// Retrieve the contents of a resource to update.
LoanoutClient client = new LoanoutClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
LoansoutCommon loanoutCommon = null;
try {
assertStatusCode(res, testName);
// Extract the common part from the response.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
loanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
Assert.assertNotNull(loanoutCommon);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
try {
assertStatusCode(res, testName);
// Extract the updated common part from the response.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
updatedLoanoutCommon = (LoansoutCommon) payloadInputPart.getBody();
Assert.assertNotNull(updatedLoanoutCommon);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// The only relevant ID may be the one used in update(), below.
LoanoutClient client = new LoanoutClient();
PoxPayloadOut multipart = createLoanoutInstance(NON_EXISTENT_ID);
- ClientResponse<String> 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);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
+ 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);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
}
// ---------------------------------------------------------------
import java.util.List;
import java.util.Map;
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.LocationJAXBSchema;
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.location.LocTermGroupList;
import org.collectionspace.services.location.LocationauthoritiesCommon;
import org.collectionspace.services.location.LocationsCommon;
-
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;
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
LocationsCommon location = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
location = (LocationsCommon) extractPart(input,
client.getItemCommonPartName(), LocationsCommon.class);
Assert.assertNotNull(location);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
list = res.getEntity();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
* @param media
* @return
*/
- public ClientResponse<String> update(String csid, PoxPayloadOut xmlPayload, String URI) {
+ public Response update(String csid, PoxPayloadOut xmlPayload, String URI) {
return getProxy().update(csid, xmlPayload.getBytes());
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
/**
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// Submit the request to the service and store the response.
MovementClient client = new MovementClient();
- ClientResponse<String> res = client.read(csid);
+ Response res = client.read(csid);
MovementsCommon movementCommon = null;
try {
assertStatusCode(res, testName);
// Extract and return the common part of the record.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
if (payloadInputPart != null) {
movementCommon = (MovementsCommon) payloadInputPart.getBody();
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
list = res.getEntity();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
public static String getOrgRefName(String inAuthority, String csid, OrgAuthorityClient client){
if(client==null)
client = new OrgAuthorityClient();
- ClientResponse<String> res = client.readItem(inAuthority, csid);
+ Response res = client.readItem(inAuthority, csid);
try {
int statusCode = res.getStatus();
if(!READ_REQ.isValidStatusCode(statusCode)
}
//FIXME: remove the following try catch once Aron fixes signatures
try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
OrganizationsCommon org =
(OrganizationsCommon) CollectionSpaceClientUtils.extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
throw new RuntimeException(e);
}
} finally {
- res.releaseConnection();
+ res.close();
}
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
}
// Submit the request to the service and store the response.
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
- ClientResponse<String> res = orgAuthClient.readItem(knownResourceId, knownItemResourceId);
+ Response res = orgAuthClient.readItem(knownResourceId, knownItemResourceId);
OrganizationsCommon organization = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
organization = (OrganizationsCommon) extractPart(input,
orgAuthClient.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
+
// Check one or more of the authority fields in the Organization item
Assert.assertEquals(organization.getContactNames().getContactName().get(0),
organizationContactPersonRefName1);
list = res2.getEntity();
} finally {
if (res2 != null) {
- res2.releaseConnection();
+ res2.close();
}
}
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res = null;
+ Response res = null;
if (CSID != null) {
res = client.read(CSID);
} else if (shortId != null) {
assertStatusCode(res, testName);
//FIXME: remove the following try catch once Aron fixes signatures
try {
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class);
if (logger.isDebugEnabled()) {
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res = null;
+ Response res = null;
if (authCSID != null) {
if (itemCSID != null) {
res = client.readItem(authCSID, itemCSID);
try {
assertStatusCode(res, testName);
// Check whether we've received a organization.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// First read our known resource.
//
OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
OrganizationsCommon organization = null;
try {
assertStatusCode(res, testName);
// Check whether organization has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
organization = (OrganizationsCommon) extractPart(input,
client.getItemCommonPartName(), OrganizationsCommon.class);
Assert.assertNotNull(organization);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
Assert.assertEquals(contact.getInItem(), knownItemResourceId);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
list = res.getEntity();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
list = res.getEntity();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertNotNull(contact);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
"Data in updated object did not match submitted data.");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
itemResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res =
- client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
- res.releaseConnection();
+ client.deleteContact(parentResourceId, itemResourceId, contactResourceId).close();
}
// Clean up item resources.
for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
private String getPartialTermCommon() {
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
@BeforeClass
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
setupRead();
- ClientResponse<String> res =
- client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
+ ClientResponse<String> res = client.readContact(knownResourceId, knownItemResourceId,
+ knownContactResourceId);
try {
assertStatusCode(res, testName);
if (logger.isDebugEnabled()) {
createPlaceInstance( placeAuthorityRefName,
placeMap, terms, client.getItemCommonPartName() );
String newID = null;
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
try {
int statusCode = res.getStatus();
}
newID = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return newID;
PoxPayloadOut multipart =
createPlaceInstance(commonPartXML, client.getItemCommonPartName());
String newID = null;
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
try {
int statusCode = res.getStatus();
}
newID = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return newID;
return refName;
}
- public static String extractId(ClientResponse<Response> res) {
+ public static String extractId(Response res) {
MultivaluedMap<String, Object> mvm = res.getMetadata();
String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
if(logger.isDebugEnabled()){
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.PlaceJAXBSchema;
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
// Submit the request to the service and store the response.
PlaceAuthorityClient client = new PlaceAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
PlacesCommon place= null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
place = (PlacesCommon) extractPart(input,
client.getItemCommonPartName(), PlacesCommon.class);
Assert.assertNotNull(place);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
list = res.getEntity();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
* getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
PublicItemClient client = new PublicItemClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
PublicItemClient client = new PublicItemClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AbstractCommonList list = null;
PublicItemClient client = new PublicItemClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
assertStatusCode(res, testName);
try {
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- list = res.getEntity();
+ list = res.readEntity(getCommonListType());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Retrieve the contents of a resource to update.
PublicItemClient client = new PublicItemClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// The only relevant ID may be the one used in update(), below.
PublicItemClient client = new PublicItemClient();
PoxPayloadOut multipart = createPublicItemInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
}
private String createPerson(String firstName, String surName, String shortId, String authRefName) {
+ String result = null;
+
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
Map<String, String> personInfo = new HashMap<String, String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
PoxPayloadOut multipart =
PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
authRefName, personInfo, null, personAuthClient.getItemCommonPartName());
- ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
- int statusCode = res.getStatus();
-
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, STATUS_CREATED);
- return extractId(res);
+ Response res = personAuthClient.createItem(personAuthCSID, multipart);
+ try {
+ int statusCode = res.getStatus();
+
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, STATUS_CREATED);
+ result = extractId(res);
+ } finally {
+ res.close();
+ }
+
+ return result;
}
@Test(dataProvider="testName",
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
throw new UnsupportedOperationException(); //Since this test does not support lists, this method is not needed.
}
createAccountInstance("barney", "barney08", "barney@dinoland.com",
accountClient.getTenantId(), false);
ClientResponse<Response> res = accountClient.create(account);
- int statusCode = res.getStatus();
-
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": barney status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- barneyAccountId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": barneyAccountId=" + barneyAccountId);
+ try {
+ int statusCode = res.getStatus();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": barney status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ barneyAccountId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": barneyAccountId=" + barneyAccountId);
+ }
+ } finally {
+ res.close();
}
- res.releaseConnection();
}
DimensionClient client = new DimensionClient();
//elmo allowed to read
client.setAuth(true, "elmo2010", true, "elmo2010", true);
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
client.getCommonPartName(), DimensionsCommon.class);
Assert.assertNotNull(dimension);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
DimensionClient client = new DimensionClient();
//lockedOut allowed to read
client.setAuth(true, "lockedOut", true, "lockedOut", true);
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
//
PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
- ClientResponse<String> res = client.update(knownResourceId, output);
+ Response res = client.update(knownResourceId, output);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
+ protected AbstractCommonList getCommonList(Response response) {
//FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
throw new UnsupportedOperationException();
}
// Submit the request to the service and store the response.
DimensionClient client = new DimensionClient();
client.setAuth(true, userName, true, userName, true);
- ClientResponse<String> res = client.read(id);
+ Response res = client.read(id);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
result = (DimensionsCommon) extractPart(input,
client.getCommonPartName(), DimensionsCommon.class);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
PoxPayloadOut output = new PoxPayloadOut(DimensionClient.SERVICE_PAYLOAD_NAME);
PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), dimension);
- ClientResponse<String> res = client.update(TENANT_RESOURCE_2, output);
+ Response res = client.update(TENANT_RESOURCE_2, output);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
@Override
- protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
public ServicegroupsCommon extractCommonPartValue(CollectionSpaceClient client,
- ClientResponse<String> res) throws Exception {
+ Response res) throws Exception {
ServicegroupsCommon result = null;
PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName());
return result;
}
- protected PayloadInputPart extractPart(ClientResponse<String> res, String partLabel)
+ protected PayloadInputPart extractPart(Response res, String partLabel)
throws Exception {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Reading part " + partLabel + " ...");
}
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
PayloadInputPart payloadInputPart = input.getPart(partLabel);
Assert.assertNotNull(payloadInputPart,
"Part " + partLabel + " was unexpectedly null.");
// Submit the request to the service and store the response.
CollectionSpaceClient client = this.getClientInstance();
- ClientResponse<String> res = client.read(readGroupName);
+ Response res = client.read(readGroupName);
int statusCode = res.getStatus();
// Check the status code of the response: does it match
// Submit the request to the service and store the response.
CollectionSpaceClient client = this.getClientInstance();
- ClientResponse<AbstractCommonList> res = client.readList();
- AbstractCommonList list = res.getEntity();
- int statusCode = res.getStatus();
+ Response res = client.readList();
+ AbstractCommonList list = res.readEntity(getCommonListType());
+ int statusCode;
+ try {
+ statusCode = res.getStatus();
+ } finally {
+ res.close();
+ }
+
// Check the status code of the response: does it match
// the expected response(s)?
AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);
}
}
-
-
}
createTaxonInstance(TaxonomyauthorityRefName,
taxonMap, terms, taxonAuthorGroupList, taxonCitationList, commonNameGroupList, client.getItemCommonPartName());
String newID = null;
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
try {
int statusCode = res.getStatus();
}
newID = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return newID;
PoxPayloadOut multipart =
createTaxonInstance(commonPartXML, client.getItemCommonPartName());
String newID = null;
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
try {
int statusCode = res.getStatus();
}
newID = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return newID;
return refName;
}
- public static String extractId(ClientResponse<Response> res) {
+ public static String extractId(Response res) {
MultivaluedMap<String, Object> mvm = res.getMetadata();
String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
if (logger.isDebugEnabled()) {
//
setupRead();
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
TaxonCommon taxon = null;
try {
assertStatusCode(res, testName);
// Check whether Taxonomy has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
taxon = (TaxonCommon) extractPart(input,
client.getItemCommonPartName(), TaxonCommon.class);
Assert.assertNotNull(taxon);
* @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
*/
@Override
- protected AbstractCommonList getCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(AbstractCommonList.class);
+ protected AbstractCommonList getCommonList(Response response) {
+ return response.readEntity(AbstractCommonList.class);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
ValuationcontrolClient client = new ValuationcontrolClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
ValuationcontrolClient client = new ValuationcontrolClient();
- ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
AbstractCommonList list = null;
ValuationcontrolClient client = new ValuationcontrolClient();
- ClientResponse<AbstractCommonList> res = client.readList();
+ Response res = client.readList();
assertStatusCode(res, testName);
try {
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- list = res.getEntity();
+ list = res.readEntity(getCommonListType());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Retrieve the contents of a resource to update.
ValuationcontrolClient client = new ValuationcontrolClient();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
PoxPayloadIn input = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
if (logger.isDebugEnabled()) {
logger.debug("got object to update with ID: " + knownResourceId);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// The only relevant ID may be the one used in update(), below.
ValuationcontrolClient client = new ValuationcontrolClient();
PoxPayloadOut multipart = createValuationcontrolInstance(NON_EXISTENT_ID);
- ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
+ Response res = client.update(NON_EXISTENT_ID, multipart);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
valuationcontrolCommon.setValueNote(getUTF8DataFragment());
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart =
- multipart.addPart(new ValuationcontrolClient().getCommonPartName(), valuationcontrolCommon);
+ PayloadOutputPart commonPart = multipart.addPart(new ValuationcontrolClient().getCommonPartName(),
+ valuationcontrolCommon);
if (logger.isDebugEnabled()) {
logger.debug("to be created, valuationcontrol common");
public static String createItemInVocabulary(String vcsid,
String vocabularyRefName, Map<String,String> itemMap,
VocabularyClient client ) {
+ String result = null;
+
// Expected status code: 201 Created
int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
// Type of service request being tested
}
PoxPayloadOut multipart = createVocabularyItemInstance(null, //vocabularyRefName,
itemMap, client.getItemCommonPartName());
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create Item: \"" + itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
- + "\" in personAuthority: \"" + vcsid //vocabularyRefName
- + "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating Item: \""+itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
- + "\" in vocabularyAuthority: \"" + vcsid /*vocabularyRefName*/ + "\", Status:" + statusCode);
+ Response res = client.createItem(vcsid, multipart);
+
+ try {
+ int statusCode = res.getStatus();
+
+ if (!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+ throw new RuntimeException("Could not create Item: \"" + itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
+ + "\" in personAuthority: \"" + vcsid //vocabularyRefName
+ + "\" " + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ }
+ if (statusCode != EXPECTED_STATUS_CODE) {
+ throw new RuntimeException("Unexpected Status when creating Item: \""+itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
+ + "\" in vocabularyAuthority: \"" + vcsid /*vocabularyRefName*/ + "\", Status:" + statusCode);
+ }
+ result = extractId(res);
+ } finally {
+ res.close();
}
- return extractId(res);
+ return result;
}
/**
requestType.validStatusCodesAsString();
}
- public static String extractId(ClientResponse<Response> res) {
+ public static String extractId(Response res) {
MultivaluedMap<String, Object> mvm = res.getMetadata();
String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
if(logger.isDebugEnabled()){
PoxPayloadOut multipart =
VocabularyClientUtils.createVocabularyItemInstance(null, //knownResourceRefName,
itemInfo, client.getItemCommonPartName());
- ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
+ Response res = client.createItem(knownResourceId, multipart);
try {
int statusCode = res.getStatus();
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
VocabularyClient client = new VocabularyClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
VocabularyitemsCommon vitem = null;
try {
assertStatusCode(res, testName);
// Check whether Person has expected displayName.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
vitem = (VocabularyitemsCommon) extractPart(input,
client.getItemCommonPartName(), VocabularyitemsCommon.class);
Assert.assertNotNull(vitem);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
createWorkInstance( workAuthorityRefName,
workMap, terms, client.getItemCommonPartName() );
String newID = null;
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
try {
int statusCode = res.getStatus();
}
newID = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return newID;
PoxPayloadOut multipart =
createWorkInstance(commonPartXML, client.getItemCommonPartName());
String newID = null;
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
try {
int statusCode = res.getStatus();
}
newID = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return newID;
return refName;
}
- public static String extractId(ClientResponse<Response> res) {
+ public static String extractId(Response res) {
MultivaluedMap<String, Object> mvm = res.getMetadata();
String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
if(logger.isDebugEnabled()){
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.WorkJAXBSchema;
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
* @throws Exception the exception
*/
@Test(dataProvider="testName")
- public void verifyIllegalItemDisplayName(String testName) throws Exception {
- // Perform setup for read.
- setupRead();
-
- // Submit the request to the service and store the response.
- WorkAuthorityClient client = new WorkAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
- WorksCommon work = null;
- try {
- assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
- work = (WorksCommon) extractPart(input,
- client.getItemCommonPartName(), WorksCommon.class);
- Assert.assertNotNull(work);
- } finally {
- if (res != null) {
- res.releaseConnection();
- }
- }
-
- //
- // Make an invalid UPDATE request, without a display name
- //
- WorkTermGroupList termList = work.getWorkTermGroupList();
- Assert.assertNotNull(termList);
- List<WorkTermGroup> terms = termList.getWorkTermGroup();
- Assert.assertNotNull(terms);
- Assert.assertTrue(terms.size() > 0);
- terms.get(0).setTermDisplayName(null);
- terms.get(0).setTermName(null);
-
- setupUpdateWithInvalidBody(); // we expect a failure
-
- // Submit the updated resource to the service and store the response.
- PoxPayloadOut output = new PoxPayloadOut(WorkAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
- PayloadOutputPart commonPart = output.addPart(client.getItemCommonPartName(), work);
- setupUpdateWithInvalidBody(); // we expected a failure here.
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- try {
- assertStatusCode(res, testName);
- } finally {
- if (res != null) {
- res.releaseConnection();
- }
- }
- }
+ public void verifyIllegalItemDisplayName(String testName) throws Exception {
+ // Perform setup for read.
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ WorkAuthorityClient client = new WorkAuthorityClient();
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
+ WorksCommon work = null;
+ try {
+ assertStatusCode(res, testName);
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
+ work = (WorksCommon) extractPart(input,
+ client.getItemCommonPartName(), WorksCommon.class);
+ Assert.assertNotNull(work);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+
+ //
+ // Make an invalid UPDATE request, without a display name
+ //
+ WorkTermGroupList termList = work.getWorkTermGroupList();
+ Assert.assertNotNull(termList);
+ List<WorkTermGroup> terms = termList.getWorkTermGroup();
+ Assert.assertNotNull(terms);
+ Assert.assertTrue(terms.size() > 0);
+ terms.get(0).setTermDisplayName(null);
+ terms.get(0).setTermName(null);
+
+ setupUpdateWithInvalidBody(); // we expect a failure
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(
+ WorkAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(
+ client.getItemCommonPartName(), work);
+ setupUpdateWithInvalidBody(); // we expected a failure here.
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ try {
+ assertStatusCode(res, testName);
+ } finally {
+ if (res != null) {
+ res.close();
+ }
+ }
+ }
/**
* Read item list.
list = res.getEntity();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}