* @param numberOfObjects The number of CollectionObject resources to create.
* @return A list of the resource IDs of the newly-created object resources.
*/
- public String[] createCollectionObjects(int numberOfObjects) {
-
- long identifier = 0;
- int i = 0;
-
- try {
- for (i = 0; i <= numberOfObjects; i++) {
- identifier = System.currentTimeMillis();
- coList[i] = createCollectionObject(identifier);
- if (logger.isDebugEnabled() == true) {
- logger.debug("Created CollectionObject #: " + i);
- }
- }
- } catch (AssertionError e) {
- if (logger.isDebugEnabled() == true) {
- logger.debug("FAILURE: Created " + i +
- " of " + numberOfObjects +
- " before failing.");
- }
- Assert.assertTrue(false);
- }
-
- return coList;
- }
+ public String[] createCollectionObjects(int numberOfObjects) {
+ long identifier = 0;
+ int i = 0;
+
+ try {
+ for (i = 0; i <= numberOfObjects; i++) {
+ identifier = System.currentTimeMillis();
+ coList[i] = createCollectionObject(identifier);
+ if (logger.isDebugEnabled() == true) {
+ logger.debug("Created CollectionObject #: " + i);
+ }
+ }
+ } catch (AssertionError e) {
+ if (logger.isDebugEnabled() == true) {
+ logger.debug("FAILURE: Created " + i + " of " + numberOfObjects
+ + " before failing.");
+ }
+ Assert.assertTrue(false);
+ }
+
+ return coList;
+ }
@AfterClass(alwaysRun=true)
public void cleanUp() {
-
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
String resourceId = "";
for (int i = 0; i < coList.length; i++) {
resourceId = coList[i];
- ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
+ collectionObjectClient.delete(resourceId).close();
if (logger.isDebugEnabled() == true) {
logger.debug("Deleted CollectionObject #: " + i);
}
- res.releaseConnection();
}
if (logger.isDebugEnabled()) {
for (int i = 0; i < coList.length; i++) {
resourceId = coList[i];
- ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
+ collectionObjectClient.delete(resourceId).close();;
if (logger.isDebugEnabled() == true) {
logger.debug("Deleted CollectionObject #: " + i);
}
- res.releaseConnection();
}
if (logger.isDebugEnabled()) {
for (int i = 0; i < coList.length; i++) {
resourceId = coList[i];
- ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
+ collectionObjectClient.delete(resourceId).close();
if (logger.isDebugEnabled() == true) {
logger.debug("Deleted CollectionObject #: " + i);
}
- res.releaseConnection();
}
if (logger.isDebugEnabled()) {
*/
private void deleteCollectionObject(CollectionObjectClient collectionObjectClient,
String resourceId) {
- ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
- res.releaseConnection();
+ collectionObjectClient.delete(resourceId).close();
}
/**
}
setupDelete();
- res = client.delete(toDelete.getAccount().get(0).getAccountId()); // delete form #2
+ Response deleteRes = client.delete(toDelete.getAccount().get(0).getAccountId()); // delete form #2
try {
- int statusCode = res.getStatus();
+ int statusCode = deleteRes.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ deleteRes.close();
}
}
testSetup(testExpectedStatusCode, testRequestType);
AccountRoleClient client = new AccountRoleClient();
- ClientResponse<Response> res = client.delete(prebuiltAdminCSID);
+ Response res = client.delete(prebuiltAdminCSID);
try {
int statusCode = res.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
private void deleteAccount(String accId) {
AccountClient accClient = new AccountClient();
setupDelete();
- ClientResponse<Response> res = accClient.delete(accId);
+ Response res = accClient.delete(accId);
try {
assertStatusCode(res, "DeleteAccount");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
private void deleteRole(String roleId) {
setupDelete();
RoleClient roleClient = new RoleClient();
- ClientResponse<Response> res = roleClient.delete(roleId);
+ Response res = roleClient.delete(roleId);
try {
assertStatusCode(res, "DeleteRole");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
term.setTermDisplayName(termName);
term.setTermName(termName);
personTerms.add(term);
+ String result = null;
+
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
+ PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
authRefName, personInfo, personTerms, 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;
}
// Success outcomes
// Submit the request to the service and store the response.
AcquisitionClient acquisitionClient = new AcquisitionClient();
- ClientResponse<String> res = acquisitionClient.read(knownResourceId);
+ Response res = acquisitionClient.read(knownResourceId);
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());
acquisition = (AcquisitionsCommon) extractPart(input,
acquisitionClient.getCommonPartName(), AcquisitionsCommon.class);
Assert.assertNotNull(acquisition);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
// Get the auth refs and check them
//
- ClientResponse<AuthorityRefList> res2 = acquisitionClient.getAuthorityRefs(knownResourceId);
+ res = acquisitionClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
- assertStatusCode(res2, testName);
- list = res2.getEntity();
+ assertStatusCode(res, testName);
+ list = (AuthorityRefList)res.getEntity();
Assert.assertNotNull(list);
} finally {
- if (res2 != null) {
- res2.releaseConnection();
+ if (res != null) {
+ res.close();
}
}
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
- if (logger.isDebugEnabled()){
+ if (logger.isDebugEnabled()) {
logger.debug("Expected " + NUM_AUTH_REFS_EXPECTED +
" authority references, found " + numAuthRefsFound);
}
AcquisitionClient acquisitionClient = new AcquisitionClient();
for (String resourceId : acquisitionIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- ClientResponse<Response> res = acquisitionClient.delete(resourceId);
- res.releaseConnection();
+ acquisitionClient.delete(resourceId).close();
}
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Delete persons before PersonAuth
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- ClientResponse<Response> res = personAuthClient.deleteItem(personAuthCSID, resourceId);
- res.releaseConnection();
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Note: Any non-success response is ignored and not reported.
- ClientResponse<Response> res = personAuthClient.delete(personAuthCSID);
- res.releaseConnection();
+ personAuthClient.delete(personAuthCSID).close();
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
AcquisitionClient client = new AcquisitionClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
+ Response res = client.delete(knownResourceId);
+ int statusCode;
+ try {
+ statusCode = res.getStatus();
+ } finally {
+ res.close();
+ }
// Check the status code of the response: does it match
// the expected response(s)?
// Submit the request to the service and store the response.
AcquisitionClient client = new AcquisitionClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
+ Response res = client.delete(NON_EXISTENT_ID);
+ int statusCode;
+ try {
+ statusCode = res.getStatus();
+ } finally {
+ res.close();
+ }
// Check the status code of the response: does it match
// the expected response(s)?
readResponse.releaseConnection();
}
- res = client.delete(toDelete.getPermission().get(0).getPermissionId());
+ Response deleteRes = client.delete(toDelete.getPermission().get(0).getPermissionId());
try {
- int statusCode = res.getStatus();
+ int statusCode = deleteRes.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ deleteRes.close();
}
}
}
setupDelete();
PermissionClient permClient = new PermissionClient();
- ClientResponse<Response> res = null;
+ Response res = permClient.delete(permId);
try {
- res = permClient.delete(permId);
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug("deletePermission: delete permission id="
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ res.close();
}
}
}
setupDelete();
RoleClient roleClient = new RoleClient();
- ClientResponse<Response> res = null;
+ Response res = roleClient.delete(roleId);
try {
- res = roleClient.delete(roleId);
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug("deleteRole: delete role id=" + roleId
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
RolePermissionClient client = new RolePermissionClient();
RoleValue rv = roleValues.get(getRoleName());
- ClientResponse<Response> delRes = null;
+ Response delRes = client.delete(rv.getRoleId());
try {
- delRes = client.delete(rv.getRoleId());
int statusCode = delRes.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (delRes != null) {
- delRes.releaseConnection();
+ delRes.close();
}
}
setupDelete();
PermissionClient permClient = new PermissionClient();
- ClientResponse<Response> res = null;
+ Response res = permClient.delete(permId);
try {
- res = permClient.delete(permId);
int statusCode = res.getStatus();
if (logger.isDebugEnabled()) {
logger.debug("deletePermission: delete permission id="
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
id = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
return id;
private void deleteRole(String roleId) {
setupDelete();
RoleClient roleClient = new RoleClient();
- ClientResponse<Response> res = null;
+ Response res = null;
try {
res = roleClient.delete(roleId);
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
- Role role = createRoleInstance(knownRoleName,
- "all users are required to be in this role",
+ Role role = createRoleInstance(knownRoleName, "All users are required to be in this role",
true);
ClientResponse<Response> res = client.create(role);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ try {
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ //
+ // Specifically:
+ // Does it fall within the set of valid status codes?
+ // Does it exactly match the expected status code?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ knownResourceId = extractId(res);
+ //allResourceIdsCreated.add(knownResourceId);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ }
+ } finally {
+ res.close();
}
}
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
ClientResponse<Role> res = client.read(verifyResourceId);
- 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);
+
+ Role output = (Role) res.getEntity();
+ Assert.assertNotNull(output);
+
+ //FIXME: Tenant ID of "1" should not be hard coded
+ String roleNameToVerify = "ROLE_" +
+ "1_" +
+ verifyRoleName.toUpperCase();
+ Assert.assertEquals(output.getRoleName(), roleNameToVerify,
+ "RoleName fix did not work!");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- Role output = (Role) res.getEntity();
- Assert.assertNotNull(output);
-
- //FIXME: Tenant ID of "1" should not be hard coded
- String roleNameToVerify = "ROLE_" +
- "1_" +
- verifyRoleName.toUpperCase();
- Assert.assertEquals(output.getRoleName(), roleNameToVerify,
- "RoleName fix did not work!");
}
// Failure outcomes
/* (non-Javadoc)
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
ClientResponse<Role> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ int statusCode = res.getStatus();
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(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);
}
// ---------------------------------------------------------------
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
RoleClient client = new RoleClient();
// Submit the request to the service and store the response.
ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
- int statusCode = res.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ // Check the status code of the response: does it match the expected response(s)?
+ int statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+
+ Role roleUpdated = (Role) res.getEntity();
+ Assert.assertNotNull(roleUpdated);
+
+ Assert.assertEquals(roleUpdated.getDescription(),
+ roleToUpdate.getDescription(),
+ "Data in updated object did not match submitted data.");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
-
- Role roleUpdated = (Role) res.getEntity();
- Assert.assertNotNull(roleUpdated);
-
- Assert.assertEquals(roleUpdated.getDescription(),
- roleToUpdate.getDescription(),
- "Data in updated object did not match submitted data.");
}
@Test(dataProvider = "testName",
dependsOnMethods = {"CRUDTests"})
public void verifyProtectionReadOnly(String testName) throws Exception {
-
+ // Setup to create a new role
setupCreate();
-
- // Submit the request to the service and store the response.
- RoleClient client = new RoleClient();
- Role role = createRoleInstance(knownRoleName+"_PT", "Just a temp", true);
+ Role role = createRoleInstance(knownRoleName+"_PT", "Just a temp", true);
role.setMetadataProtection(RoleClient.IMMUTABLE);
role.setPermsProtection(RoleClient.IMMUTABLE);
+ //
+ // Submit the create request to the service and store the response.
+ //
+ RoleClient client = new RoleClient();
ClientResponse<Response> res = client.create(role);
- int statusCode = res.getStatus();
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Store the ID returned from this create operation
- // for additional tests below.
- String testResourceId = extractId(res);
- allResourceIdsCreated.add(testResourceId);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": testResourceId=" + testResourceId);
+ String testResourceId = null;
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ testResourceId = extractId(res);
+ allResourceIdsCreated.add(testResourceId);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": testResourceId=" + testResourceId);
+ }
+ } finally {
+ res.close();
}
+
+ // Next, read back the role we just created.
setupRead();
-
// Submit the request to the service and store the response.
ClientResponse<Role> roleRes = client.read(testResourceId);
- statusCode = roleRes.getStatus();
-
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- Role roleRead = (Role) roleRes.getEntity();
- Assert.assertNotNull(roleRead);
- String mdProtection = roleRead.getMetadataProtection();
- String permsProtection = roleRead.getPermsProtection();
- if (logger.isTraceEnabled()) {
- logger.trace(testName + ": metadataProtection=" + mdProtection);
- logger.trace(testName + ": permsProtection=" + permsProtection);
+ try {
+ int statusCode = roleRes.getStatus();
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ Role roleRead = (Role) roleRes.getEntity();
+ Assert.assertNotNull(roleRead);
+ String mdProtection = roleRead.getMetadataProtection();
+ String permsProtection = roleRead.getPermsProtection();
+ if (logger.isTraceEnabled()) {
+ logger.trace(testName + ": metadataProtection=" + mdProtection);
+ logger.trace(testName + ": permsProtection=" + permsProtection);
+ }
+ Assert.assertFalse(role.getMetadataProtection().equals(mdProtection),
+ "Role allowed create to set the metadata protection flag.");
+ Assert.assertFalse(role.getPermsProtection().equals(permsProtection),
+ "Role allowed create to set the perms protection flag.");
+ } finally {
+ res.close();
}
- Assert.assertFalse(role.getMetadataProtection().equals(mdProtection),
- "Role allowed create to set the metadata protection flag.");
- Assert.assertFalse(role.getPermsProtection().equals(permsProtection),
- "Role allowed create to set the perms protection flag.");
-
+ // Finally, update the role with changes and verify
setupUpdate();
Role roleToUpdate = createRoleInstance(knownRoleName+"_PT", "Just a temp", true);
// Submit the request to the service and store the response.
roleRes = client.update(testResourceId, roleToUpdate);
- statusCode = roleRes.getStatus();
- // Check the status code of the response: does it match the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ // Check the status code of the response: does it match the expected response(s)?
+ int statusCode = roleRes.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+
+ Role roleUpdated = (Role) roleRes.getEntity();
+ Assert.assertNotNull(roleUpdated);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + "Updated role: ");
+ org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
+ logger.debug(objectAsXmlString(objectFactory.createRole(roleUpdated),
+ Role.class));
+ }
+
+ Assert.assertFalse(RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getMetadataProtection()),
+ "Role allowed update of the metadata protection flag.");
+ Assert.assertFalse(RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getPermsProtection()),
+ "Role allowed update of the perms protection flag.");
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
-
- Role roleUpdated = (Role) roleRes.getEntity();
- Assert.assertNotNull(roleUpdated);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + "Updated role: ");
- org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();
- logger.debug(objectAsXmlString(objectFactory.createRole(roleUpdated),
- Role.class));
- }
-
- Assert.assertFalse(
- RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getMetadataProtection()),
- "Role allowed update of the metadata protection flag.");
- Assert.assertFalse(
- RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getPermsProtection()),
- "Role allowed update of the perms protection flag.");
}
@Test(dataProvider = "testName",
RoleClient client = new RoleClient();
// Submit the request to the service and store the response.
ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
- 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, Response.Status.BAD_REQUEST.getStatusCode());
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
-
}
// Failure outcomes
true);
ClientResponse<Role> res =
client.update(NON_EXISTENT_ID, role);
- 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);
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
RoleClient client = new RoleClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.delete(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);
}
// ---------------------------------------------------------------
--- /dev/null
+package org.collectionspace.services.batch;
+
+import org.jboss.resteasy.specimpl.MultivaluedMapImpl;
+import org.jboss.resteasy.specimpl.PathSegmentImpl;
+import org.jboss.resteasy.util.Encode;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @version $Revision: 1 $
+ */
+public class UriInfoImpl implements UriInfo
+{
+ private String path;
+ private String encodedPath;
+ private MultivaluedMap<String, String> queryParameters;
+ private MultivaluedMap<String, String> encodedQueryParameters;
+ private MultivaluedMap<String, String> pathParameters;
+ private MultivaluedMap<String, String> encodedPathParameters;
+ private MultivaluedMap<String, PathSegment[]> pathParameterPathSegments;
+ private MultivaluedMap<String, PathSegment[]> encodedPathParameterPathSegments;
+
+ private List<PathSegment> pathSegments;
+ private List<PathSegment> encodedPathSegments;
+ private URI absolutePath;
+ private URI absolutePathWithQueryString;
+ private URI baseURI;
+ private List<String> matchedUris;
+ private List<String> encodedMatchedUris;
+ private List<Object> ancestors;
+
+
+ public UriInfoImpl(URI absolutePath, URI baseUri, String encodedPath, String queryString, List<PathSegment> encodedPathSegments)
+ {
+ /*
+ logger.info("**** URIINFO encodedPath: " + encodedPath);
+ for (PathSegment segment : encodedPathSegments)
+ {
+ logger.info(" Segment: " + segment.getPath());
+ }
+ */
+ this.encodedPath = encodedPath;
+ this.path = Encode.decodePath(encodedPath);
+ //System.out.println("path: " + path);
+ //System.out.println("encodedPath: " + encodedPath);
+
+ this.absolutePath = absolutePath;
+ this.encodedPathSegments = encodedPathSegments;
+ this.baseURI = baseUri;
+
+ extractParameters(queryString);
+ this.pathSegments = new ArrayList<PathSegment>(encodedPathSegments.size());
+ for (PathSegment segment : encodedPathSegments)
+ {
+ pathSegments.add(new PathSegmentImpl(((PathSegmentImpl) segment).getOriginal(), true));
+ }
+ if (queryString == null)
+ {
+ this.absolutePathWithQueryString = absolutePath;
+ }
+ else
+ {
+ this.absolutePathWithQueryString = URI.create(absolutePath.toString() + "?" + queryString);
+ }
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public String getPath(boolean decode)
+ {
+ if (decode) return getPath();
+ return encodedPath;
+ }
+
+ public List<PathSegment> getPathSegments()
+ {
+ return pathSegments;
+ }
+
+ public List<PathSegment> getPathSegments(boolean decode)
+ {
+ if (decode) return getPathSegments();
+ return encodedPathSegments;
+ }
+
+ public URI getRequestUri()
+ {
+ return absolutePathWithQueryString;
+ }
+
+ public UriBuilder getRequestUriBuilder()
+ {
+ return UriBuilder.fromUri(absolutePathWithQueryString);
+ }
+
+ public URI getAbsolutePath()
+ {
+ return absolutePath;
+ }
+
+ public UriBuilder getAbsolutePathBuilder()
+ {
+ return UriBuilder.fromUri(absolutePath);
+ }
+
+ public URI getBaseUri()
+ {
+ return baseURI;
+ }
+
+ public UriBuilder getBaseUriBuilder()
+ {
+ return UriBuilder.fromUri(baseURI);
+ }
+
+ public MultivaluedMap<String, String> getPathParameters()
+ {
+ if (pathParameters == null)
+ {
+ pathParameters = new MultivaluedMapImpl<String, String>();
+ }
+ return pathParameters;
+ }
+
+ public void addEncodedPathParameter(String name, String value)
+ {
+ getEncodedPathParameters().add(name, value);
+ String value1 = Encode.decodePath(value);
+ getPathParameters().add(name, value1);
+ }
+
+ private MultivaluedMap<String, String> getEncodedPathParameters()
+ {
+ if (encodedPathParameters == null)
+ {
+ encodedPathParameters = new MultivaluedMapImpl<String, String>();
+ }
+ return encodedPathParameters;
+ }
+
+ public MultivaluedMap<String, PathSegment[]> getEncodedPathParameterPathSegments()
+ {
+ if (encodedPathParameterPathSegments == null)
+ {
+ encodedPathParameterPathSegments = new MultivaluedMapImpl<String, PathSegment[]>();
+ }
+ return encodedPathParameterPathSegments;
+ }
+
+ public MultivaluedMap<String, PathSegment[]> getPathParameterPathSegments()
+ {
+ if (pathParameterPathSegments == null)
+ {
+ pathParameterPathSegments = new MultivaluedMapImpl<String, PathSegment[]>();
+ }
+ return pathParameterPathSegments;
+ }
+
+ public MultivaluedMap<String, String> getPathParameters(boolean decode)
+ {
+ if (decode) return getPathParameters();
+ return getEncodedPathParameters();
+ }
+
+ public MultivaluedMap<String, String> getQueryParameters()
+ {
+ if (queryParameters == null)
+ {
+ queryParameters = new MultivaluedMapImpl<String, String>();
+ }
+ return queryParameters;
+ }
+
+ protected MultivaluedMap<String, String> getEncodedQueryParameters()
+ {
+ if (encodedQueryParameters == null)
+ {
+ this.encodedQueryParameters = new MultivaluedMapImpl<String, String>();
+ }
+ return encodedQueryParameters;
+ }
+
+
+ public MultivaluedMap<String, String> getQueryParameters(boolean decode)
+ {
+ if (decode) return getQueryParameters();
+ else return getEncodedQueryParameters();
+ }
+
+ protected void extractParameters(String queryString)
+ {
+ if (queryString == null || queryString.equals("")) return;
+
+ String[] params = queryString.split("&");
+
+ for (String param : params)
+ {
+ if (param.indexOf('=') >= 0)
+ {
+ String[] nv = param.split("=", 2);
+ try
+ {
+ String name = URLDecoder.decode(nv[0], "UTF-8");
+ String val = nv.length > 1 ? nv[1] : "";
+ getEncodedQueryParameters().add(name, val);
+ getQueryParameters().add(name, URLDecoder.decode(val, "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else
+ {
+ try
+ {
+ String name = URLDecoder.decode(param, "UTF-8");
+ getEncodedQueryParameters().add(name, "");
+ getQueryParameters().add(name, "");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+
+ public List<String> getMatchedURIs(boolean decode)
+ {
+ if (decode)
+ {
+ if (matchedUris == null) matchedUris = new ArrayList<String>();
+ return matchedUris;
+ }
+ else
+ {
+ if (encodedMatchedUris == null) encodedMatchedUris = new ArrayList<String>();
+ return encodedMatchedUris;
+ }
+ }
+
+ public List<String> getMatchedURIs()
+ {
+ return getMatchedURIs(true);
+ }
+
+ public List<Object> getMatchedResources()
+ {
+ if (ancestors == null) ancestors = new ArrayList<Object>();
+ return ancestors;
+ }
+
+
+ public void pushCurrentResource(Object resource)
+ {
+ if (ancestors == null) ancestors = new ArrayList<Object>();
+ ancestors.add(0, resource);
+ }
+
+ public void popCurrentResource()
+ {
+ if (ancestors != null && ancestors.size() > 0)
+ {
+ ancestors.remove(0);
+ }
+ }
+
+ public void pushMatchedURI(String encoded, String decoded)
+ {
+ if (encodedMatchedUris == null) encodedMatchedUris = new ArrayList<String>();
+ encodedMatchedUris.add(0, encoded);
+
+ if (matchedUris == null) matchedUris = new ArrayList<String>();
+ matchedUris.add(0, decoded);
+ }
+
+ public void popMatchedURI()
+ {
+ if (encodedMatchedUris != null && encodedMatchedUris.size() > 0)
+ {
+ encodedMatchedUris.remove(0);
+ }
+ if (matchedUris != null && matchedUris.size() > 0)
+ {
+ matchedUris.remove(0);
+ }
+ }
+
+@Override
+public URI relativize(URI arg0) {
+ // TODO Auto-generated method stub
+ return null;
+}
+
+@Override
+public URI resolve(URI arg0) {
+ // TODO Auto-generated method stub
+ return null;
+}
+
+}
personTerms.add(term);
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
authRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
- ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
+ Response res = personAuthClient.createItem(personAuthCSID, multipart);
try {
assertStatusCode(res, "createPerson (not a surefire test)");
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
public void readAndCheckAuthRefs(String testName) throws Exception {
testSetup(STATUS_OK, ServiceRequestType.READ);
BlobClient blobClient = new BlobClient();
- ClientResponse<String> res = blobClient.read(knownResourceId);
+ Response res = blobClient.read(knownResourceId);
BlobsCommon blob = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
blob = (BlobsCommon) extractPart(input, blobClient.getCommonPartName(), BlobsCommon.class);
Assert.assertNotNull(blob);
logger.debug(objectAsXmlString(blob, BlobsCommon.class));
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertEquals(blob.getName(), blobName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = blobClient.getAuthorityRefs(knownResourceId);
+ res = blobClient.getAuthorityRefs(knownResourceId);
try {
- assertStatusCode(res2, testName);
- AuthorityRefList list = res2.getEntity();
+ assertStatusCode(res, testName);
+ AuthorityRefList list = (AuthorityRefList)res.getEntity();
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
int numAuthRefsFound = items.size();
logger.debug("Authority references, found " + numAuthRefsFound);
}
}
} finally {
- if (res2 != null) {
- res2.releaseConnection();
+ if (res != null) {
+ res.close();
}
}
}
PoxPayloadOut multipart =
createCitationInstance(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 createItemInAuthority(vcsid, commonPartXML, client );
}
- 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()){
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.delete(resourceId).releaseConnection();
+ client.delete(resourceId).close();
}
}
}
@Override
- public ClientResponse<String> read(String csid) {
+ public Response read(String csid) {
return getProxy().read(csid);
}
* @see org.collectionspace.services.client.AbstractServiceClientImpl#delete(java.lang.String)
*/
@Override
- public ClientResponse<Response> delete(String csid) {
+ public Response delete(String csid) {
return getProxy().delete(csid);
}
* @see org.collectionspace.services.client.BlobProxy#getAuthorityRefs(java.lang.String)
*/
@Override
- public ClientResponse<AuthorityRefList> getAuthorityRefs(String csid) {
+ public Response getAuthorityRefs(String csid) { // Response.getEntity returns AuthorityRefList type
return getProxy().getAuthorityRefs(csid);
}
void setInAuthority(AUTHORITY_ITEM_TYPE item, String inAuthorityCsid);
//(C)reate Item
- ClientResponse<Response> createItem(String vcsid, PoxPayloadOut poxPayloadOut);
+ Response createItem(String vcsid, PoxPayloadOut poxPayloadOut);
//(R)ead Item
- ClientResponse<String> readItem(String vcsid, String csid);
+ Response readItem(String vcsid, String csid);
//(R)ead Item
ClientResponse<String> readItem(String vcsid, String csid, Boolean includeDeleted);
ClientResponse<String> updateItem(String vcsid, String csid, PoxPayloadOut poxPayloadOut);
//(D)elete Item
- ClientResponse<Response> deleteItem(String vcsid, String csid);
+ Response deleteItem(String vcsid, String csid);
// Get a list of objects that
ClientResponse<AuthorityRefDocList> getReferencingObjects(
//(C)reate Item
@Override
- public ClientResponse<Response> createItem(String vcsid, PoxPayloadOut poxPayloadOut) {
+ public Response createItem(String vcsid, PoxPayloadOut poxPayloadOut) {
return getProxy().createItem(vcsid, poxPayloadOut.getBytes());
}
//(R)ead Item
@Override
- public ClientResponse<String> readItem(String vcsid, String csid) {
+ public Response readItem(String vcsid, String csid) {
return getProxy().readItem(vcsid, csid, INCLUDE_DELETE_TRUE);
}
//(D)elete Item
@Override
- public ClientResponse<Response> deleteItem(String vcsid, String csid) {
+ public Response deleteItem(String vcsid, String csid) {
return getProxy().deleteItem(vcsid, csid);
}
//(D)elete Item
@DELETE
@Path("/{vcsid}/items/{csid}")
- ClientResponse<Response> deleteItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid);
+ Response deleteItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid);
/**
* Get a list of objects that reference a given authority term.
public Response create(REQUEST_TYPE payload);
- public ClientResponse<RESPONSE_TYPE> read(String csid);
+ public Response read(String csid);
public ClientResponse<RESPONSE_TYPE> update(String csid, REQUEST_TYPE payload);
* @param csid the csid
* @return the authority refs
*/
- public ClientResponse<AuthorityRefList> getAuthorityRefs(String csid);
+ public Response getAuthorityRefs(String csid); // Response.getEntity returns AuthorityRefList type
/**
* Delete.
// (R)ead
@GET
@Path("/{csid}")
- ClientResponse<String> read(@PathParam("csid") String csid);
+ Response read(@PathParam("csid") String csid); // Returned entity type in response is String
// (R)ead
@GET
//(D)elete
@DELETE
@Path("/{csid}")
- ClientResponse<Response> delete(@PathParam("csid") String csid);
+ Response delete(@PathParam("csid") String csid);
// List Authority References
@GET
// Submit the request to the service and store the response.
AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
+ Response res = client.deleteItem(knownResourceId, knownItemResourceId);
+ int statusCode;
+ try {
+ statusCode = res.getStatus();
+ } finally {
+ res.close();
+ }
// Check the status code of the response: does it match
// the expected response(s)?
// Submit the request to the service and store the response.
AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
+ Response res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
+ int statusCode;
+ try {
+ statusCode = res.getStatus();
+ } finally {
+ res.close();
+ }
// Check the status code of the response: does it match
// the expected response(s)?
package org.collectionspace.services.client.test;
+import javax.ws.rs.core.Response;
+
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadInputPart;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
-
import org.jboss.resteasy.client.ClientResponse;
import org.testng.Assert;
extends AbstractServiceTestImpl<CLT, CPT, PoxPayloadOut, String> {
@Override
- public CPT extractCommonPartValue(ClientResponse<String> res) throws Exception {
+ public CPT extractCommonPartValue(Response res) throws Exception {
CPT result = null;
CollectionSpaceClient client = getClientInstance();
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<RESPONSE_TYPE> res = client.read(getKnowResourceId());
- 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(getKnowResourceId());
+ 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);
+
+ RESPONSE_TYPE output = (RESPONSE_TYPE) res.getEntity();
+ Assert.assertNotNull(output);
+
+ //
+ // Now compare with the expected field values
+ //
+ REQUEST_TYPE expectedResult = createInstance("read_test");
+ compareReadInstances(extractCommonPartValue(expectedResult), extractCommonPartValue(res));
+ } finally {
+ res.close();
}
- 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
- //
- REQUEST_TYPE expectedResult = createInstance("read_test");
- compareReadInstances(extractCommonPartValue(expectedResult), extractCommonPartValue(res));
}
@Override
// Submit the request to the service and store the response.
CollectionSpaceClient client = this.getClientInstance();
- ClientResponse<RESPONSE_TYPE> res = client.read(NON_EXISTENT_ID);
+ Response res = client.read(NON_EXISTENT_ID);
int statusCode = res.getStatus();
try {
// Check the status code of the response: does it match
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ res.close();
}
}
// protected abstract Class<CPT> getCommonPartTypeClass();
- public CPT extractCommonPartValue(ClientResponse<RESPONSE_TYPE> res) throws Exception {
+ public CPT extractCommonPartValue(Response res) throws Exception {
CPT result = null;
result = (CPT) res.getEntity();
return result;
// Retrieve the contents of a resource to update.
CollectionSpaceClient client = this.getClientInstance();
- ClientResponse<RESPONSE_TYPE> res = client.read(getKnowResourceId());
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Got object to update with CSID= " + getKnowResourceId());
+ Response res = client.read(getKnowResourceId());
+ CPT commonPartObject = null;
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Got object to update with CSID= " + getKnowResourceId());
+ }
+
+ commonPartObject = this.extractCommonPartValue(res);
+ Assert.assertNotNull(commonPartObject);
+ } finally {
+ res.close();
}
-
- CPT commonPartObject = this.extractCommonPartValue(res);
- Assert.assertNotNull(commonPartObject);
+
CPT theUpdate = updateInstance(commonPartObject);
if (logger.isDebugEnabled()) {
logger.debug("\n\nTo be updated fields: CSID = " + getKnowResourceId() + "\n"
// Submit the request to the service and store the response.
REQUEST_TYPE output = this.createRequestTypeInstance(theUpdate);
res = client.update(getKnowResourceId(), 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);
+ CPT updatedCommonPartObject = 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);
+
+ updatedCommonPartObject = this.extractCommonPartValue(res);
+ Assert.assertNotNull(updatedCommonPartObject);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- CPT updatedCommonPartObject = this.extractCommonPartValue(res);
- Assert.assertNotNull(updatedCommonPartObject);
compareUpdatedInstances(theUpdate, updatedCommonPartObject);
}
AuthorityClient client = (AuthorityClient) getClientInstance();
String identifier = createIdentifier();
PoxPayloadOut multipart = createItemInstance(parentCsid, identifier);
- ClientResponse<Response> res = client.createItem(parentCsid, multipart);
-
- int statusCode = res.getStatus();
- Assert.assertEquals(statusCode, STATUS_CREATED);
-
- result = extractId(res);
- allResourceItemIdsCreated.put(result, parentCsid);
+ Response res = client.createItem(parentCsid, multipart);
+ try {
+ int statusCode = res.getStatus();
+ Assert.assertEquals(statusCode, STATUS_CREATED);
+
+ result = extractId(res);
+ allResourceItemIdsCreated.put(result, parentCsid);
+ } finally {
+ res.close();
+ }
return result;
}
String itemResourceId = entry.getKey();
String authorityResourceId = entry.getValue();
// Note: Any non-success responses are ignored and not reported.
- authorityClient.deleteItem(authorityResourceId, itemResourceId).releaseConnection();
+ authorityClient.deleteItem(authorityResourceId, itemResourceId).close();
}
}
//
+ "\r\n ownerRefName: "+ownerRefName
+ "\r\n fieldCollectionSourceRefName: "+fieldCollectionSourceRefName
+ "\r\n fieldCollectorRefName: "+fieldCollectorRefName;
- StringBuffer buff = new StringBuffer();
return result;
}
* @return the CSID of the newly-created person record
*/
protected String createPerson(String firstName, String surName, String shortIdentifier ) {
+ String result = null;
+
Map<String, String> personInfo = new HashMap<String,String>();
personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
term.setTermName(termName);
personTerms.add(term);
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
+ PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
personAuthRefName, personInfo, personTerms, 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;
}
/**
* @return the CSID of the newly-created organization record
*/
protected String createOrganization(String shortName, String foundingPlace, String shortIdentifier ) {
+ String result = null;
+
Map<String, String> orgInfo = new HashMap<String,String>();
orgInfo.put(OrganizationJAXBSchema.FOUNDING_PLACE, foundingPlace);
orgInfo.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortIdentifier);
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
PoxPayloadOut multipart =
OrgAuthorityClientUtils.createOrganizationInstance(orgAuthRefName, orgInfo, orgTerms, orgAuthClient.getItemCommonPartName());
- ClientResponse<Response> res = orgAuthClient.createItem(orgAuthCSID, multipart);
- int statusCode = res.getStatus();
-
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, STATUS_CREATED);
- return extractId(res);
+ Response res = orgAuthClient.createItem(orgAuthCSID, 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;
}
/**
// First read the object
//
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
- ClientResponse<String> res = collectionObjectClient.read(knownResourceId);
+ Response res = collectionObjectClient.read(knownResourceId);
CollectionobjectsCommon collectionObject = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
collectionObject = (CollectionobjectsCommon) extractPart(input,
collectionObjectClient.getCommonPartName(), CollectionobjectsCommon.class);
Assert.assertNotNull(collectionObject);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
// Next, get all of the auth refs and check that the expected number is returned
//
- ClientResponse<AuthorityRefList> res2 = collectionObjectClient.getAuthorityRefs(knownResourceId);
+ res = collectionObjectClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
- assertStatusCode(res2, testName);
- list = res2.getEntity();
+ assertStatusCode(res, testName);
+ list = (AuthorityRefList)res.getEntity();
} finally {
- if (res2 != null) {
- res2.releaseConnection();
+ if (res != null) {
+ res.close();
}
}
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
for (String resourceId : collectionObjectIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- collectionObjectClient.delete(resourceId).releaseConnection();
+ collectionObjectClient.delete(resourceId).close();
}
// Note: Any non-success response is ignored and not reported.
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Delete persons before PersonAuth
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
- personAuthClient.delete(personAuthCSID).releaseConnection();
+ personAuthClient.delete(personAuthCSID).close();
// Note: Any non-success response is ignored and not reported.
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
// Delete organizations before OrgAuth
for (String resourceId : orgIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- orgAuthClient.deleteItem(orgAuthCSID, resourceId).releaseConnection();
+ orgAuthClient.deleteItem(orgAuthCSID, resourceId).close();
}
- orgAuthClient.delete(orgAuthCSID).releaseConnection();
+ orgAuthClient.delete(orgAuthCSID).close();
}
// ---------------------------------------------------------------
CollectionObjectJAXBSchema.DISTINGUISHING_FEATURES;
String propertyValue = theKeyword;
ClientResponse<AbstractCommonList> res = doAdvancedSearch(propertyName, propertyValue, "=");
- 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);
+
+ // Verify that the number of resources matched by the search
+ // is identical to the expected result
+ long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
+ long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+ Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Verify that the number of resources matched by the search
- // is identical to the expected result
- long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
- long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
- Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
}
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, groups = { "oneKeyword" })
// Send the search request and receive a response
ClientResponse<AbstractCommonList> res = doSearch(KEYWORD);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Verify that the number of resources matched by the search
+ // is identical to the expected result
+ long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
+ long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+ Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Verify that the number of resources matched by the search
- // is identical to the expected result
- long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
- long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
- Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
}
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
// Send the search request and receive a response
ClientResponse<AbstractCommonList> res = doSearch(TWO_KEYWORDS);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Verify that the number of resources matched by the search
+ // is identical to the expected result
+ long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
+ long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+ Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Verify that the number of resources matched by the search
- // is identical to the expected result
- long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
- long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
- Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
// Search using a single term
// Send the search request and receive a response
res = doSearch(TWO_KEYWORDS.get(0));
- statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Verify that the number of resources matched by the search
+ // is identical to the expected result
+ long NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
+ long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+ Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Verify that the number of resources matched by the search
- // is identical to the expected result
- NUM_MATCHES_EXPECTED = numKeywordRetrievableResources;
- numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
- Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
-
}
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
// Send the search request and receive a response
ClientResponse<AbstractCommonList> res = doSearch(NON_EXISTENT_KEYWORD);
- int statusCode = res.getStatus();
+ int statusCode;
+ try {
+ 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);
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+ // Verify that the number of resources matched by the search
+ // is identical to the expected result
+ long NUM_MATCHES_EXPECTED = 0;
+ long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
+ Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Verify that the number of resources matched by the search
- // is identical to the expected result
- long NUM_MATCHES_EXPECTED = 0;
- long numMatched = getNumMatched(res, NUM_MATCHES_EXPECTED, testName);
- Assert.assertEquals(numMatched, NUM_MATCHES_EXPECTED);
-
}
// ---------------------------------------------------------------
CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- collectionObjectClient.delete(resourceId).releaseConnection();
+ collectionObjectClient.delete(resourceId).close();
}
}
}
PoxPayloadOut multipart = new PoxPayloadOut(
CollectionObjectClient.SERVICE_PAYLOAD_NAME);
- PayloadOutputPart commonPart = multipart.addPart(collectionObject,
- MediaType.APPLICATION_XML_TYPE);
+ PayloadOutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
commonPart.setLabel(new CollectionObjectClient().getCommonPartName());
+
return multipart;
}
String whereClause = propertyName + operator +
"'" + propertyValue + "'";
CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<AbstractCommonList> res = client
- .advancedSearchIncludeDeleted(whereClause, false); // NOT_INCLUDING_DELETED_RESOURCES
+ ClientResponse<AbstractCommonList> res = client.advancedSearchIncludeDeleted(whereClause, false); // NOT_INCLUDING_DELETED_RESOURCES
+
return res;
}
if(logger.isDebugEnabled()){
logger.debug("got object to update with ID: " + knownResourceId);
}
+
return res;
}
// Extract its common part.
collectionObjectCommon = extractCommonPartValue(res);
} finally {
- res.releaseConnection();
+ res.close();
}
// Update the common part with invalid content, by setting a value to
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
} finally {
- res.releaseConnection();
+ res.close();
}
}
// Submit the request to the service and store the response.
CollectionObjectClient client = new CollectionObjectClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ Response res = client.delete(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
- res.releaseConnection();
+ res.close();
}
}
* @throws Exception the exception
*/
private String createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception {
-
// Perform setup.
setupCreate();
// Submit the request to the service and store the response.
CollectionObjectClient client = new CollectionObjectClient();
ClientResponse<String> res = client.read(csid);
- 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);
+ CollectionobjectsCommon collectionObject = 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);
+
+ // Extract the common part.
+ collectionObject = extractCommonPartValue(res);
+ Assert.assertNotNull(collectionObject);
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, testExpectedStatusCode);
-
- // Extract the common part.
- CollectionobjectsCommon collectionObject = extractCommonPartValue(res);
- Assert.assertNotNull(collectionObject);
return collectionObject;
}
PoxPayloadOut multipart =
createConceptInstance(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 createItemInAuthority(vcsid, commonPartXML, client );
}
- 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()){
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.delete(resourceId).releaseConnection();
+ client.delete(resourceId).close();
}
}
}
protected 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);
term.setTermDisplayName(termName);
term.setTermName(termName);
personTerms.add(term);
- PoxPayloadOut multipart =
- PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
+ PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
authRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
- ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
- int statusCode = res.getStatus();
+
+ 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();
+ }
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- Assert.assertEquals(statusCode, STATUS_CREATED);
- return extractId(res);
+ return result;
}
// Success outcomes
// Submit the request to the service and store the response.
ConditioncheckClient conditioncheckClient = new ConditioncheckClient();
- ClientResponse<String> res = conditioncheckClient.read(knownResourceId);
+ Response res = conditioncheckClient.read(knownResourceId);
ConditionchecksCommon conditioncheckCommon = 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());
conditioncheckCommon = (ConditionchecksCommon) extractPart(input,
conditioncheckClient.getCommonPartName(), ConditionchecksCommon.class);
Assert.assertNotNull(conditioncheckCommon);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
Assert.assertEquals(conditioncheckCommon.getConditionChecker(), conditionCheckerRefName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = conditioncheckClient.getAuthorityRefs(knownResourceId);
+ Response res2 = conditioncheckClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = res2.getEntity();
+ list = (AuthorityRefList)res2.getEntity();
Assert.assertNotNull(list);
} finally {
if (res2 != null) {
- res2.releaseConnection();
+ res2.close();
}
}
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- ClientResponse<Response> response =
- personAuthClient.deleteItem(personAuthCSID, resourceId); // alternative to personAuthClient.deleteItem().releaseConnection();
- response.releaseConnection();
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
personAuthClient.delete(personAuthCSID);
// Delete Condition Checks resource(s).
ConditioncheckClient conditioncheckClient = new ConditioncheckClient();
- ClientResponse<Response> response = null;
for (String resourceId : conditioncheckIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- response = conditioncheckClient.delete(resourceId); // alternative to conditioncheckClient.delete(resourceId).releaseConnection();
- response.releaseConnection();
+ conditioncheckClient.delete(resourceId).close();
}
}
}
// Submit the request to the service and store the response.
ConditioncheckClient client = new ConditioncheckClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
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.
ConditioncheckClient client = new ConditioncheckClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ Response res = client.delete(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.
ContactClient client = new ContactClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.delete(knownResourceId);
+ 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);
}
// Failure outcomes
// Submit the request to the service and store the response.
ContactClient client = new ContactClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.delete(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.
ExhibitionClient client = new ExhibitionClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
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.
ExhibitionClient client = new ExhibitionClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ Response res = client.delete(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
}
protected 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, personTerms, 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;
}
// Success outcomes
// Submit the request to the service and store the response.
IntakeClient intakeClient = new IntakeClient();
- ClientResponse<String> res = intakeClient.read(knownResourceId);
+ Response res = intakeClient.read(knownResourceId);
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
IntakesCommon intake = (IntakesCommon) extractPart(input,
intakeClient.getCommonPartName(), IntakesCommon.class);
Assert.assertNotNull(intake);
Assert.assertEquals(intake.getInsurers().getInsurer().get(0), insurerRefName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = intakeClient.getAuthorityRefs(knownResourceId);
+ res = intakeClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
- assertStatusCode(res2, testName);
- list = res2.getEntity();
+ assertStatusCode(res, testName);
+ list = (AuthorityRefList)res.getEntity();
} finally {
- if (res2 != null) {
- res2.releaseConnection();
+ if (res != null) {
+ res.close();
}
}
IntakeClient intakeClient = new IntakeClient();
// Note: Any non-success responses are ignored and not reported.
for (String resourceId : intakeIdsCreated) {
- intakeClient.delete(resourceId).releaseConnection();
+ intakeClient.delete(resourceId).close();
}
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
// Delete persons before PersonAuth
for (String resourceId : personIdsCreated) {
- personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
- personAuthClient.delete(personAuthCSID).releaseConnection();
+ personAuthClient.delete(personAuthCSID).close();
}
// ---------------------------------------------------------------
OrgAuthorityClientUtils.createOrganizationInstance(null, //orgAuthRefName
orgInfo, orgTerms, orgAuthClient.getItemCommonPartName());
- ClientResponse<Response> res = orgAuthClient.createItem(orgAuthCSID, multipart);
+ Response res = orgAuthClient.createItem(orgAuthCSID, multipart);
int statusCode = res.getStatus();
Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
// Get the auth ref docs and check them
OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
- ClientResponse<AuthorityRefDocList> refDocListResp =
- orgAuthClient.getReferencingObjects(orgAuthCSID, currentOwnerOrgCSID);
+ Response refDocListResp = orgAuthClient.getReferencingObjects(orgAuthCSID, currentOwnerOrgCSID);
AuthorityRefDocList list = null;
try {
assertStatusCode(refDocListResp, testName);
- list = refDocListResp.getEntity();
+ list = (AuthorityRefDocList)refDocListResp.getEntity();
Assert.assertNotNull(list);
} finally {
if (refDocListResp != null) {
- refDocListResp.releaseConnection();
+ refDocListResp.close();
}
}
IntakeClient intakeClient = new IntakeClient();
// Note: Any non-success responses are ignored and not reported.
for (String resourceId : intakeIdsCreated) {
- ClientResponse<Response> res = intakeClient.delete(resourceId);
- res.releaseConnection();
+ intakeClient.delete(resourceId).close();
}
// Delete persons before PersonAuth
OrgAuthorityClient personAuthClient = new OrgAuthorityClient();
for (String resourceId : orgIdsCreated) {
- ClientResponse<Response> res = personAuthClient.deleteItem(orgAuthCSID, resourceId);
- res.releaseConnection();
+ personAuthClient.deleteItem(orgAuthCSID, resourceId).close();
}
if (orgAuthCSID != null) {
- personAuthClient.delete(orgAuthCSID).releaseConnection();
+ personAuthClient.delete(orgAuthCSID).close();
}
}
}
protected 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, personTerms, 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;
}
// Success outcomes
list = res.getEntity();
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
IntakeClient intakeClient = new IntakeClient();
// Note: Any non-success responses are ignored and not reported.
for (String resourceId : intakeIdsCreated) {
- ClientResponse<Response> res = intakeClient.delete(resourceId);
- res.releaseConnection();
+ intakeClient.delete(resourceId).close();
}
// Delete persons before PersonAuth
PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
for (String resourceId : personIdsCreated) {
- ClientResponse<Response> res = personAuthClient.deleteItem(personAuthCSID, resourceId);
- res.releaseConnection();
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
if (personAuthCSID != null) {
- personAuthClient.delete(personAuthCSID).releaseConnection();
+ personAuthClient.delete(personAuthCSID).close();
}
}
}
protected 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, personTerms, 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;
}
// Success outcomes
// Submit the request to the service and store the response.
LoaninClient loaninClient = new LoaninClient();
- ClientResponse<String> res = loaninClient.read(knownResourceId);
+ Response res = loaninClient.read(knownResourceId);
LoansinCommon loaninCommon = 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());
loaninCommon = (LoansinCommon) extractPart(input,
loaninClient.getCommonPartName(), LoansinCommon.class);
Assert.assertNotNull(loaninCommon);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
Assert.assertEquals(loaninCommon.getBorrowersAuthorizer(), borrowersAuthorizerRefName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = loaninClient.getAuthorityRefs(knownResourceId);
+ Response res2 = loaninClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = res2.getEntity();
+ list = (AuthorityRefList)res2.getEntity();
Assert.assertNotNull(list);
} finally {
if (res2 != null) {
- res2.releaseConnection();
+ res2.close();
}
}
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- ClientResponse<Response> response =
- personAuthClient.deleteItem(personAuthCSID, resourceId); // alternative to personAuthClient.deleteItem().releaseConnection();
- response.releaseConnection();
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
personAuthClient.delete(personAuthCSID);
// Delete Loans In resource(s).
LoaninClient loaninClient = new LoaninClient();
- ClientResponse<Response> response = null;
for (String resourceId : loaninIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- response = loaninClient.delete(resourceId); // alternative to loaninClient.delete(resourceId).releaseConnection();
- response.releaseConnection();
+ loaninClient.delete(resourceId).close();
}
}
}
// Submit the request to the service and store the response.
LoaninClient client = new LoaninClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
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.
LoaninClient client = new LoaninClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ Response res = client.delete(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
}
protected 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, personTerms, 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;
}
// Success outcomes
// Submit the request to the service and store the response.
LoanoutClient loanoutClient = new LoanoutClient();
- ClientResponse<String> res = loanoutClient.read(knownResourceId);
+ Response res = loanoutClient.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());
loanoutCommon = (LoansoutCommon) extractPart(input,
loanoutClient.getCommonPartName(), LoansoutCommon.class);
Assert.assertNotNull(loanoutCommon);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertEquals(loanoutCommon.getLendersContact(), lendersContactRefName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = loanoutClient.getAuthorityRefs(knownResourceId);
+ Response res2 = loanoutClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = res2.getEntity();
+ list = (AuthorityRefList)res2.getEntity();
} finally {
if (res2 != null) {
- res2.releaseConnection();
+ res2.close();
}
}
// Submit the request to the service and store the response.
LoanoutClient client = new LoanoutClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.delete(knownResourceId);
+ 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);
}
// Failure outcomes
// Submit the request to the service and store the response.
LoanoutClient client = new LoanoutClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": status = " + statusCode);
+ Response res = client.delete(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);
}
// ---------------------------------------------------------------
createLocationInstance( locationAuthorityRefName,
locationMap, 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 =
createLocationInstance(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()){
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.delete(resourceId).releaseConnection();
+ client.delete(resourceId).close();
}
}
personTerms.add(term);
PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(
personAuthCSID, authRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
- ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
+ Response res = personAuthClient.createItem(personAuthCSID, multipart);
try {
assertStatusCode(res, "createPerson (not a surefire test)");
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
testSetup(STATUS_OK, ServiceRequestType.READ);
MediaClient mediaClient = new MediaClient();
- ClientResponse<String> res = mediaClient.read(knownResourceId);
+ Response res = mediaClient.read(knownResourceId);
PoxPayloadIn input = null;
MediaCommon media = null;
try {
assertStatusCode(res, testName);
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
media = (MediaCommon) extractPart(input, mediaClient.getCommonPartName(), MediaCommon.class);
Assert.assertNotNull(media);
logger.debug(objectAsXmlString(media, MediaCommon.class));
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertEquals(media.getTitle(), title);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = mediaClient.getAuthorityRefs(knownResourceId);
+ Response res2 = mediaClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = res2.getEntity();
+ list = (AuthorityRefList)res2.getEntity();
} finally {
if (res2 != null) {
- res2.releaseConnection();
+ res2.close();
}
}
// Submit the request to the service and store the response.
MovementClient movementClient = new MovementClient();
- ClientResponse<String> res = movementClient.read(knownResourceId);
+ Response res = movementClient.read(knownResourceId);
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(movementClient.getCommonPartName());
if (payloadInputPart != null) {
movementCommon = (MovementsCommon) payloadInputPart.getBody();
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
// Check a couple of fields
Assert.assertEquals(movementCommon.getMovementContact(), movementContactRefName);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = movementClient.getAuthorityRefs(knownResourceId);
+ Response res2 = movementClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = res2.getEntity();
+ list = (AuthorityRefList)res2.getEntity();
} finally {
if (res2 != null) {
- res2.releaseConnection();
+ res2.close();
}
}
MovementClient movementClient = new MovementClient();
for (String resourceId : movementIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- movementClient.delete(resourceId).releaseConnection();
+ movementClient.delete(resourceId).close();
}
}
PoxPayloadOut multipart =
PersonAuthorityClientUtils.createPersonInstance(personAuthCSID,
authRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
- ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
+ Response res = personAuthClient.createItem(personAuthCSID, multipart);
try {
assertStatusCode(res, "createPerson (not a surefire test)");
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
public void readAndCheckAuthRefs(String testName) throws Exception {
testSetup(STATUS_OK, ServiceRequestType.READ);
ObjectExitClient objectexitClient = new ObjectExitClient();
- ClientResponse<String> res = objectexitClient.read(knownResourceId);
+ Response res = objectexitClient.read(knownResourceId);
ObjectexitCommon objectexit = null;
try {
assertStatusCode(res, testName);
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
objectexit = (ObjectexitCommon) extractPart(input, objectexitClient.getCommonPartName(), ObjectexitCommon.class);
Assert.assertNotNull(objectexit);
logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
Assert.assertEquals(objectexit.getExitNumber(), exitNumber);
// Get the auth refs and check them
- ClientResponse<AuthorityRefList> res2 = objectexitClient.getAuthorityRefs(knownResourceId);
+ Response res2 = objectexitClient.getAuthorityRefs(knownResourceId);
AuthorityRefList list = null;
try {
assertStatusCode(res2, testName);
- list = res2.getEntity();
+ list = (AuthorityRefList)res2.getEntity();
} finally {
if (res2 != null) {
- res2.releaseConnection();
+ res2.close();
}
}
List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
public static String getAuthorityRefName(String csid, OrgAuthorityClient client){
if(client==null)
client = new OrgAuthorityClient();
- ClientResponse<String> res = client.read(csid);
+ Response res = client.read(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());
OrgauthoritiesCommon orgAuthority =
(OrgauthoritiesCommon) CollectionSpaceClientUtils.extractPart(input,
client.getCommonPartName(), OrgauthoritiesCommon.class);
throw new RuntimeException(e);
}
} finally {
- res.releaseConnection();
+ res.close();
}
}
createOrganizationInstance(orgAuthorityRefName,
orgInfo, terms, orgRepeatablesInfo, client.getItemCommonPartName());
- ClientResponse<Response> res = client.createItem(inAuthority, multipart);
+ Response res = client.createItem(inAuthority, multipart);
String result;
try {
int statusCode = res.getStatus();
result = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return result;
* @param res the res
* @return the string
*/
- 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()){
null, personInfo, personTerms, personAuthClient.getItemCommonPartName());
String result = null;
- ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
+ Response res = personAuthClient.createItem(personAuthCSID, multipart);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, STATUS_CREATED);
result = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return result;
// Delete Person resource(s) (before PersonAuthority resources).
for (String resourceId : personIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- personAuthClient.deleteItem(personAuthCSID, resourceId).releaseConnection();
+ personAuthClient.deleteItem(personAuthCSID, resourceId).close();
}
// Delete PersonAuthority resource(s).
// Note: Any non-success response is ignored and not reported.
if(personAuthCSID!=null) {
- personAuthClient.delete(personAuthCSID).releaseConnection();
+ personAuthClient.delete(personAuthCSID).close();
}
String parentResourceId;
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.delete(resourceId).releaseConnection();
+ client.delete(resourceId).close();
}
}
}
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res =
- client.deleteItem(parentResourceId, itemResourceId);
- res.releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
super.cleanUp();
if (client == null) {
client = new PersonAuthorityClient();
}
- ClientResponse<String> res = client.read(csid);
+ Response res = client.read(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());
PersonauthoritiesCommon personAuthority =
(PersonauthoritiesCommon) CollectionSpaceClientUtils.extractPart(input,
client.getCommonPartName(), PersonauthoritiesCommon.class);
throw new RuntimeException(e);
}
} finally {
- res.releaseConnection();
+ res.close();
}
}
if ( client == null) {
client = new PersonAuthorityClient();
}
- 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());
PersonsCommon person =
(PersonsCommon) CollectionSpaceClientUtils.extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
throw new RuntimeException(e);
}
} finally {
- res.releaseConnection();
+ res.close();
}
}
personMap, terms, personRepeatablesMap, client.getItemCommonPartName());
String result = null;
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
try {
int statusCode = res.getStatus();
result = extractId(res);
} finally {
- res.releaseConnection();
+ res.close();
}
return result;
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res =
- client.deleteItem(parentResourceId, itemResourceId);
- res.releaseConnection();
+ Response res = client.deleteItem(parentResourceId, itemResourceId);
+ res.close();
}
// Clean up authority resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses are ignored and not reported.
- client.delete(resourceId).releaseConnection();
+ client.delete(resourceId).close();
}
}
partialTermPersonMap, partialTerms, partialTermRepeatablesMap, client.getItemCommonPartName() );
String newID = null;
- ClientResponse<Response> res = client.createItem(authorityCsid, multipart);
+ Response res = client.createItem(authorityCsid, multipart);
try {
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
personMap, terms, personRepeatablesMap, client.getItemCommonPartName() );
String newID = null;
- ClientResponse<Response> res = client.createItem(authId, multipart);
+ Response res = client.createItem(authId, multipart);
try {
assertStatusCode(res, "createItem");
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
PersonAuthorityClient client = new PersonAuthorityClient();
// Clean up item resources.
for (String itemId : allItemIdsCreated) {
- client.deleteItem(authId, itemId).releaseConnection();
+ client.deleteItem(authId, itemId).close();
}
- client.delete(authId).releaseConnection();
+ client.delete(authId).close();
}
PersonAuthorityClientUtils.createPersonInstance(vcsid, null /*authRefName*/, itemFieldProperties,
terms, itemRepeatableFieldProperties, client.getItemCommonPartName());
setupCreate();
- ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ Response res = client.createItem(vcsid, multipart);
String newID = null;
try {
assertStatusCode(res, testName);
newID = PersonAuthorityClientUtils.extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName());
// Send the request and receive a response
- ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
+ Response res = client.createItem(knownResourceId, multipart);
// Check the status code of the response: does it match
// the expected response(s)?
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
protected void readInternal(String testName, String CSID, String shortId) {
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<String> res = null;
+ Response res = null;
setupRead();
if (CSID != null) {
res = client.read(CSID);
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());
PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
client.getCommonPartName(), PersonauthoritiesCommon.class);
Assert.assertNotNull(personAuthority);
}
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
setupRead();
- ClientResponse<String> res = null;
+ Response res = null;
if (authCSID != null) {
if (itemCSID != null) {
res = client.readItem(authCSID, itemCSID);
} else {
Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
}
+
try {
assertStatusCode(res, testName);
// Check whether we've received a person.
- PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ PoxPayloadIn input = new PoxPayloadIn((String)res.getEntity());
PersonsCommon person = (PersonsCommon) extractPart(input,
client.getItemCommonPartName(), PersonsCommon.class);
Assert.assertNotNull(person);
Assert.assertNotNull(groups.get(0));
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
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();
}
}
//
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
setupRead();
- ClientResponse<String> res = client.read(knownResourceId);
+ Response res = client.read(knownResourceId);
try {
assertStatusCode(res, testName);
if (logger.isDebugEnabled()) {
logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
}
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
try {
assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
PersonAuthorityClient client = new PersonAuthorityClient();
PoxPayloadIn input = null;
setupRead();
- ClientResponse<String> res =
- client.readItem(knownResourceId, knownItemResourceId);
+ Response res = client.readItem(knownResourceId, knownItemResourceId);
try {
assertStatusCode(res, testName);
if (logger.isDebugEnabled()) {
+ knownItemResourceId
+ " in PersonAuthority: " + knownResourceId);
}
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
try {
assertStatusCode(res, testName);
// Retrieve the updated resource and verify that its contents exist.
- input = new PoxPayloadIn(res.getEntity());
+ input = new PoxPayloadIn((String)res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
input = new PoxPayloadIn(res.getEntity());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
input = new PoxPayloadIn(res.getEntity());;
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
ContactsCommon updatedContact = (ContactsCommon) extractPart(input,
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// below are ignored and not reported.
ClientResponse<Response> res =
client.deleteContact(parentResourceId, itemResourceId, contactResourceId);
- res.releaseConnection();
+ res.close();
}
// Clean up item resources.
for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res =
- client.deleteItem(parentResourceId, itemResourceId);
- res.releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
super.cleanUp();
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.delete(resourceId).releaseConnection();
+ client.delete(resourceId).close();
}
}
// Submit the request to the service and store the response.
PublicItemClient client = new PublicItemClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
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.
PublicItemClient client = new PublicItemClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ Response res = client.delete(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
AccountClient accountClient = new AccountClient();
// accountClient.setAuth(true, "test", true, "test", true);
// Submit the request to the service and store the response.
- ClientResponse<Response> res = accountClient.delete(barneyAccountId);
- int statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": barney status = " + statusCode);
+
+ Response res = accountClient.delete(barneyAccountId);
+ int statusCode;
+ try {
+ statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": barney status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
-
+
res = accountClient.delete(georgeAccountId);
- statusCode = res.getStatus();
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": george status = " + statusCode);
+ try {
+ statusCode = res.getStatus();
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": george status = " + statusCode);
+ }
+ Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(testRequestType, statusCode));
+ } finally {
+ res.close();
}
- Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(testRequestType, statusCode));
- res.releaseConnection();
}
// ---------------------------------------------------------------
//
// Try to make a DELETE request
//
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
DimensionClient client = new DimensionClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
try {
assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
private void deletePermission(String permId) {
setupDelete();
PermissionClient permClient = new PermissionClient();
- ClientResponse<Response> res = permClient.delete(permId);
+ Response res = permClient.delete(permId);
try {
assertStatusCode(res, "DeletePermission");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
private void deleteRole(String roleId) {
setupDelete();
RoleClient roleClient = new RoleClient();
- ClientResponse<Response> res = roleClient.delete(roleId);
+ Response res = roleClient.delete(roleId);
try {
assertStatusCode(res, "DeleteRole");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
private void deleteAccount(String accId) {
setupDelete();
AccountClient accClient = new AccountClient();
- ClientResponse<Response> res = accClient.delete(accId);
+ Response res = accClient.delete(accId);
try {
assertStatusCode(res, "DeleteAccount");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
AccountRoleClient client = new AccountRoleClient();
AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
av, rvs, true, true);
- ClientResponse<Response> res = client.delete(av.getAccountId());
+ Response res = client.delete(av.getAccountId());
try {
assertStatusCode(res, "DeleteAccountRole");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
PermissionRoleClient client = new PermissionRoleClient();
PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
pv, rvls, true, true);
- ClientResponse<Response> res = client.delete(pv.getPermissionId());
+ Response res = client.delete(pv.getPermissionId());
try {
assertStatusCode(res, "DeletePermissionRole");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
// Submit the request to the service and store the response.
DimensionClient client = new DimensionClient();
client.setAuth(true, userName, true, userName, true);
- ClientResponse<Response> res = client.delete(id);
+ Response res = client.delete(id);
try {
result = assertStatusCode(res, testName);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
DimensionClient client = new DimensionClient();
//TENANT_2_USER of TENANT_2 is not allowed to delete the resource of TENANT_1
client.setAuth(true, TENANT_2_USER, true, TENANT_2_USER, true);
- ClientResponse<Response> res = client.delete(TENANT_RESOURCE_1);
+ Response res = client.delete(TENANT_RESOURCE_1);
try {
int statusCode = res.getStatus();
// Check the status code of the response: does it match
Assert.assertEquals(statusCode, Response.Status.NOT_FOUND.getStatusCode());
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
PermissionClient permClient = new PermissionClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
permClient.setAuth(true, ui.userName, true, ui.password, true);
- ClientResponse<Response> res = permClient.delete(permId);
+ Response res = permClient.delete(permId);
try {
assertStatusCode(res, "DeletePermission");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
RoleClient roleClient = new RoleClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
roleClient.setAuth(true, ui.userName, true, ui.password, true);
- ClientResponse<Response> res = roleClient.delete(roleId);
+ Response res = roleClient.delete(roleId);
try {
assertStatusCode(res, "DeleteRole");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
AccountClient accClient = new AccountClient();
UserInfo ui = tenantAdminUsers.get(tenantId);
accClient.setAuth(true, ui.userName, true, ui.password, true);
- ClientResponse<Response> res = accClient.delete(accId);
+ Response res = accClient.delete(accId);
try {
assertStatusCode(res, "DeleteAccount");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
client.setAuth(true, ui.userName, true, ui.password, true);
AccountRole accRole = AccountRoleFactory.createAccountRoleInstance(
av, rvs, true, true);
- ClientResponse<Response> res = client.delete(av.getAccountId());
+ Response res = client.delete(av.getAccountId());
try {
assertStatusCode(res, "DeleteAccountRole");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
result = extractId(res);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
client.setAuth(true, ui.userName, true, ui.password, true);
PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
pv, rvls, true, true);
- ClientResponse<Response> res = client.delete(pv.getPermissionId());
+ Response res = client.delete(pv.getPermissionId());
try {
assertStatusCode(res, "DeletePermissionRole");
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
Assert.assertNotNull(taxon);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
//
try {
assertStatusCode(res, testName);
} finally {
- res.releaseConnection();
+ res.close();
}
}
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
- List<AbstractCommonList.ListItem> items =
- list.getListItem();
+ List<AbstractCommonList.ListItem> items = list.getListItem();
int nItemsReturned = items.size();
// There will be 'nItemsToCreateInList'
// items created by the createItemList test,
AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
} finally {
- res.releaseConnection();
+ res.close();
}
}
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res =
- client.deleteItem(parentResourceId, itemResourceId);
- res.releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
+
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- ClientResponse<Response> res = client.delete(resourceId);
- res.releaseConnection();
+ client.delete(resourceId).close();
}
}
String identifier) {
String shortId = identifier;
String displayName = "displayName-" + shortId;
- String baseRefName =
- TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
- PoxPayloadOut multipart =
- TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
+ String baseRefName = TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
+ PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
displayName, shortId, commonPartName);
return multipart;
}
// Submit the request to the service and store the response.
ValuationcontrolClient client = new ValuationcontrolClient();
- ClientResponse<Response> res = client.delete(knownResourceId);
+ Response res = client.delete(knownResourceId);
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.
ValuationcontrolClient client = new ValuationcontrolClient();
- ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ Response res = client.delete(NON_EXISTENT_ID);
try {
int statusCode = res.getStatus();
Assert.assertEquals(statusCode, testExpectedStatusCode);
} finally {
if (res != null) {
- res.releaseConnection();
+ res.close();
}
}
}
parentResourceId = entry.getValue();
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.deleteItem(parentResourceId, itemResourceId).releaseConnection();
+ client.deleteItem(parentResourceId, itemResourceId).close();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
- client.delete(resourceId).releaseConnection();
+ client.delete(resourceId).close();
}
}