From 81e3b11e0642661158c7a10916c9859ec4e7e1e6 Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Thu, 15 Apr 2010 03:47:45 +0000 Subject: [PATCH] CSPACE-901: Initialize HTTPClient-based clients only within test methods annotated with TestNG's @Test, not at the class level. This issue has led at least once to test failures, not just warnings, and needed to be addressed at this time. --- .../client/test/AccountServiceTest.java | 59 ++++++++---- .../client/test/AcquisitionAuthRefsTest.java | 15 ++- .../client/test/AcquisitionServiceTest.java | 22 +++-- .../test/PermissionRoleServiceTest.java | 10 +- .../client/test/PermissionServiceTest.java | 19 +++- .../client/test/RoleServiceTest.java | 20 +++- .../test/CollectionObjectAuthRefsTest.java | 12 ++- .../test/CollectionObjectServiceTest.java | 19 +++- .../client/test/ContactServiceTest.java | 14 ++- .../client/test/DimensionServiceTest.java | 17 ++-- .../client/test/IntakeAuthRefsTest.java | 24 +++-- .../client/test/IntakeServiceTest.java | 16 +++- .../client/test/LoaninAuthRefsTest.java | 12 ++- .../client/test/LoaninServiceTest.java | 18 ++-- .../client/test/OrgAuthorityServiceTest.java | 94 +++++++++++------- .../test/PersonAuthorityServiceTest.java | 95 ++++++++++++------- .../client/test/RelationServiceTest.java | 12 ++- .../client/test/VocabularyServiceTest.java | 29 ++++-- 18 files changed, 348 insertions(+), 159 deletions(-) diff --git a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java index beb92420a..a42427af9 100644 --- a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java +++ b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java @@ -56,7 +56,6 @@ public class AccountServiceTest extends AbstractServiceTestImpl { private final Logger logger = LoggerFactory.getLogger(AccountServiceTest.class); // Instance variables specific to this test. - private AccountClient client = new AccountClient(); private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); boolean addTenant = true; @@ -66,7 +65,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { @Override protected String getServicePathComponent() { - return client.getServicePathComponent(); + return new AccountClient().getServicePathComponent(); } // --------------------------------------------------------------- @@ -86,6 +85,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("barney", "barney", "hithere08", "barney@dinoland.com", true, false, true, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); @@ -120,6 +120,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("barney1", "barney", "hithere08", "barney@dinoland.com", true, false, true, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); @@ -141,6 +142,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("barney", "otherUser", "hithere08", "barney@dinoland.com", true, false, true, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); @@ -162,6 +164,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com", true, true, true, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); // Does it exactly match the expected status code? @@ -184,6 +187,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com", true, false, false, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); // Does it exactly match the expected status code? @@ -205,6 +209,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("babybop", "babybop", "hithere08", "babybop.dinoland.com", true, false, true, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); // Does it exactly match the expected status code? @@ -226,6 +231,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com", false, false, true, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); // Does it exactly match the expected status code? @@ -247,6 +253,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account = createAccountInstance("babybop", "babybop", "hithere08", "babybop/dinoland.com", false, true, false, false); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account); int statusCode = res.getStatus(); // Does it exactly match the expected status code? @@ -269,6 +276,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { AccountsCommon account1 = createAccountInstance("curious", "curious", "hithere08", "curious@george.com", true, false, true, true); + AccountClient client = new AccountClient(); ClientResponse res = client.create(account1); int statusCode = res.getStatus(); Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -327,6 +335,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + AccountClient client = new AccountClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -353,6 +362,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + AccountClient client = new AccountClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -379,6 +389,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + AccountClient client = new AccountClient(); ClientResponse res = client.readList(); AccountsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -407,7 +418,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. - ClientResponse res = client.readSearchList("tom", null, null); + AccountClient client = new AccountClient(); + ClientResponse res = + client.readSearchList("tom", null, null); AccountsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -435,7 +448,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. - ClientResponse res = client.readSearchList(null, "tom", null); + AccountClient client = new AccountClient(); + ClientResponse res = + client.readSearchList(null, "tom", null); AccountsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -463,7 +478,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. - ClientResponse res = client.readSearchList(null, null, "dinoland"); + AccountClient client = new AccountClient(); + ClientResponse res = + client.readSearchList(null, null, "dinoland"); AccountsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -491,7 +508,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. - ClientResponse res = client.readSearchList("tom", null, "jerry"); + AccountClient client = new AccountClient(); + ClientResponse res = + client.readSearchList("tom", null, "jerry"); AccountsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -525,9 +544,8 @@ public class AccountServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); - - ClientResponse res = - client.read(knownResourceId); + AccountClient client = new AccountClient(); + ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { logger.debug(testName + ": read status = " + res.getStatus()); } @@ -575,8 +593,8 @@ public class AccountServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); - ClientResponse res = - client.read(knownResourceId); + AccountClient client = new AccountClient(); + ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { logger.debug(testName + ": read status = " + res.getStatus()); } @@ -624,8 +642,8 @@ public class AccountServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); - ClientResponse res = - client.read(knownResourceId); + AccountClient client = new AccountClient(); + ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { logger.debug(testName + ": read status = " + res.getStatus()); } @@ -667,8 +685,8 @@ public class AccountServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); - ClientResponse res = - client.read(knownResourceId); + AccountClient client = new AccountClient(); + ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { logger.debug(testName + ": read status = " + res.getStatus()); } @@ -737,11 +755,12 @@ public class AccountServiceTest extends AbstractServiceTestImpl { // // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in updateAccount(), below. + AccountClient client = new AccountClient(); AccountsCommon account = createAccountInstance("simba", "simba", "tiger", "simba@lionking.com", true, false, true, true); ClientResponse res = - client.update(NON_EXISTENT_ID, account); + client.update(NON_EXISTENT_ID, account); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -759,12 +778,13 @@ public class AccountServiceTest extends AbstractServiceTestImpl { public void updateWrongUser(String testName) throws Exception { setupUpdate(); + // Submit the request to the service and store the response. // // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in updateAccount(), below. - ClientResponse res = - client.read(knownResourceId); + AccountClient client = new AccountClient(); + ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { logger.debug(testName + ": read status = " + res.getStatus()); } @@ -810,6 +830,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + AccountClient client = new AccountClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -833,6 +854,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + AccountClient client = new AccountClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -950,6 +972,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + AccountClient client = new AccountClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java index 43aabc68e..69c628760 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java @@ -63,8 +63,6 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { LoggerFactory.getLogger(AcquisitionAuthRefsTest.class); // Instance variables specific to this test. - private AcquisitionClient acquisitionClient = new AcquisitionClient(); - private PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); final String SERVICE_PATH_COMPONENT = "acquisitions"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private String knownResourceId = null; @@ -101,6 +99,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { acquisitionFundingSourceRefName, fieldCollectorRefName ); + AcquisitionClient acquisitionClient = new AcquisitionClient(); ClientResponse res = acquisitionClient.create(multipart); int statusCode = res.getStatus(); @@ -135,6 +134,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { protected void createPersonRefs(){ String authRefName = PersonAuthorityClientUtils.createPersonAuthRefName(PERSON_AUTHORITY_NAME, false); + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( PERSON_AUTHORITY_NAME, authRefName, personAuthClient.getCommonPartName()); ClientResponse res = personAuthClient.create(multipart); @@ -163,6 +163,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { Map personInfo = new HashMap(); personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); personInfo.put(PersonJAXBSchema.SUR_NAME, surName); + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, refName, personInfo, personAuthClient.getItemCommonPartName()); @@ -184,6 +185,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { testSetup(OK_STATUS, ServiceRequestType.READ,testName); // Submit the request to the service and store the response. + AcquisitionClient acquisitionClient = new AcquisitionClient(); ClientResponse res = acquisitionClient.read(knownResourceId); int statusCode = res.getStatus(); @@ -205,7 +207,8 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { Assert.assertEquals(acquisition.getFieldCollector(), fieldCollectorRefName); // Get the auth refs and check them - ClientResponse res2 = acquisitionClient.getAuthorityRefs(knownResourceId); + ClientResponse res2 = + acquisitionClient.getAuthorityRefs(knownResourceId); statusCode = res2.getStatus(); if(logger.isDebugEnabled()){ @@ -252,13 +255,18 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { */ // @AfterClass(alwaysRun=true) public void cleanUp() { + if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + + AcquisitionClient acquisitionClient = new AcquisitionClient(); // Note: Any non-success responses are ignored and not reported. for (String resourceId : acquisitionIdsCreated) { ClientResponse res = acquisitionClient.delete(resourceId); } + + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Delete persons before PersonAuth for (String resourceId : personIdsCreated) { ClientResponse res = personAuthClient.deleteItem(personAuthCSID, resourceId); @@ -287,6 +295,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); + AcquisitionClient acquisitionClient = new AcquisitionClient(); commonPart.getHeaders().add("label", acquisitionClient.getCommonPartName()); if(logger.isDebugEnabled()){ diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java index 8ff593edd..cda330726 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java @@ -57,7 +57,6 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(AcquisitionServiceTest.class); // Instance variables specific to this test. - private AcquisitionClient client = new AcquisitionClient(); private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); @@ -77,6 +76,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. String identifier = createIdentifier(); + AcquisitionClient client = new AcquisitionClient(); MultipartOutput multipart = createAcquisitionInstance(identifier); ClientResponse res = client.create(multipart); @@ -197,6 +197,8 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Perform setup. setupRead(testName); + AcquisitionClient client = new AcquisitionClient(); + // Submit the request to the service and store the response. ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -227,6 +229,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + AcquisitionClient client = new AcquisitionClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -253,6 +256,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + AcquisitionClient client = new AcquisitionClient(); ClientResponse res = client.readList(); AcquisitionsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -301,8 +305,9 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); - ClientResponse res = - client.read(knownResourceId); + // Retrieve the contents of a resource to update. + AcquisitionClient client = new AcquisitionClient(); + ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ logger.debug(testName + ": read status = " + res.getStatus()); } @@ -312,6 +317,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { logger.debug("got object to update with ID: " + knownResourceId); } MultipartInput input = (MultipartInput) res.getEntity(); + AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input, client.getCommonPartName(), AcquisitionsCommon.class); Assert.assertNotNull(acquisition); @@ -478,9 +484,10 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. + AcquisitionClient client = new AcquisitionClient(); MultipartOutput multipart = createAcquisitionInstance(NON_EXISTENT_ID); ClientResponse res = - client.update(NON_EXISTENT_ID, multipart); + client.update(NON_EXISTENT_ID, multipart); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -506,6 +513,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + AcquisitionClient client = new AcquisitionClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -529,6 +537,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + AcquisitionClient client = new AcquisitionClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -587,6 +596,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + AcquisitionClient client = new AcquisitionClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); @@ -598,7 +608,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- @Override public String getServicePathComponent() { - return client.getServicePathComponent(); + return new AcquisitionClient().getServicePathComponent(); } @@ -614,7 +624,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(acquisition, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + commonPart.getHeaders().add("label", new AcquisitionClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, acquisition common"); diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java index 5db336dc7..99358d097 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java @@ -59,7 +59,6 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { private final Logger logger = LoggerFactory.getLogger(PermissionRoleServiceTest.class); // Instance variables specific to this test. - private PermissionRoleClient client = new PermissionRoleClient(); private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); private Hashtable permIds = new Hashtable(); @@ -70,7 +69,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { @Override protected String getServicePathComponent() { - return client.getServicePathComponent(); + return new PermissionRoleClient().getServicePathComponent(); } @BeforeClass(alwaysRun = true) @@ -107,6 +106,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. PermissionRole permRole = createPermissionRoleInstance(permIds.get("accounts"), roleIds.values().toArray(new String[0]), true, true); + PermissionRoleClient client = new PermissionRoleClient(); ClientResponse res = client.create(permIds.get("accounts"), permRole); int statusCode = res.getStatus(); @@ -134,6 +134,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + PermissionRoleClient client = new PermissionRoleClient(); PermissionRole permRole = createPermissionRoleInstance(permIds.get("collectionobjects"), roleIds.values().toArray(new String[0]), true, true); ClientResponse res = client.create(permIds.get("collectionobjects"), permRole); @@ -184,6 +185,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + PermissionRoleClient client = new PermissionRoleClient(); ClientResponse res = client.read(permIds.get("accounts"), "123"); int statusCode = res.getStatus(); @@ -209,6 +211,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + PermissionRoleClient client = new PermissionRoleClient(); ClientResponse res = client.read(NON_EXISTENT_ID, "123"); int statusCode = res.getStatus(); @@ -278,6 +281,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + PermissionRoleClient client = new PermissionRoleClient(); ClientResponse res = client.delete(permIds.get("accounts"), "123"); int statusCode = res.getStatus(); @@ -301,6 +305,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + PermissionRoleClient client = new PermissionRoleClient(); ClientResponse res = client.delete(NON_EXISTENT_ID, "123"); int statusCode = res.getStatus(); @@ -388,6 +393,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + PermissionRoleClient client = new PermissionRoleClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId, "123"); diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java index 486e4f381..ecd22aed9 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java @@ -55,7 +55,6 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { static private final Logger logger = LoggerFactory.getLogger(PermissionServiceTest.class); // Instance variables specific to this test. - private PermissionClient client = new PermissionClient(); private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); boolean addTenant = true; @@ -65,7 +64,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { @Override protected String getServicePathComponent() { - return client.getServicePathComponent(); + return new PermissionClient().getServicePathComponent(); } // --------------------------------------------------------------- @@ -90,6 +89,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { true, true, true); + PermissionClient client = new PermissionClient(); ClientResponse res = client.create(permission); int statusCode = res.getStatus(); @@ -129,6 +129,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { false, true, true); + PermissionClient client = new PermissionClient(); ClientResponse res = client.create(permission); int statusCode = res.getStatus(); // Does it exactly match the expected status code? @@ -156,6 +157,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { true, true, true); + PermissionClient client = new PermissionClient(); ClientResponse res = client.create(permission1); int statusCode = res.getStatus(); Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -220,6 +222,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + PermissionClient client = new PermissionClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -246,6 +249,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + PermissionClient client = new PermissionClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -272,6 +276,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + PermissionClient client = new PermissionClient(); ClientResponse res = client.readList(); PermissionsList list = res.getEntity(); int statusCode = res.getStatus(); @@ -300,6 +305,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + PermissionClient client = new PermissionClient(); ClientResponse res = client.readSearchList("acquisition"); PermissionsList list = res.getEntity(); int statusCode = res.getStatus(); @@ -338,7 +344,8 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); - + // Retrieve the contents of a resource to update. + PermissionClient client = new PermissionClient(); ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { @@ -408,6 +415,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { // // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in updatePermission(), below. + PermissionClient client = new PermissionClient(); List actions = getDefaultActions(); Permission permission = createPermissionInstance("acquisitions", "default permissions for acquisitions", @@ -443,6 +451,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + PermissionClient client = new PermissionClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -466,6 +475,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + PermissionClient client = new PermissionClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -543,7 +553,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("to be created, permission common"); - logger.debug(objectAsXmlString(permission, Permission.class)); + logger.debug(objectAsXmlString(permission, Permission.class)); } return permission; } @@ -579,6 +589,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + PermissionClient client = new PermissionClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java index 6616b18b6..bb609762f 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java @@ -52,7 +52,6 @@ public class RoleServiceTest extends AbstractServiceTestImpl { static private final Logger logger = LoggerFactory.getLogger(RoleServiceTest.class); // Instance variables specific to this test. - private RoleClient client = new RoleClient(); private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); boolean addTenant = true; @@ -62,7 +61,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { @Override protected String getServicePathComponent() { - return client.getServicePathComponent(); + return new RoleClient().getServicePathComponent(); } // --------------------------------------------------------------- @@ -79,6 +78,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); Role role = createRoleInstance("ROLE_USERS_TEST", "all users are required to be in this role", true); @@ -113,6 +113,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); Role role = createRoleInstance("ROLE_USERS", "role users", true); @@ -134,6 +135,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); Role role = createRoleInstance("ROLE_USERS", "role for users", false); @@ -155,8 +157,10 @@ public class RoleServiceTest extends AbstractServiceTestImpl { public void createList(String testName) throws Exception { setupCreate(testName); + // Submit the request to the service and store the response. - Role role1 = createRoleInstance("ROLE_COLLECTIONS_MANGER_TEST", + RoleClient client = new RoleClient(); + Role role1 = createRoleInstance("ROLE_COLLECTIONS_MANGER_TEST", "collection manager", true); ClientResponse res = client.create(role1); @@ -217,6 +221,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -243,6 +248,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -269,6 +275,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); ClientResponse res = client.readList(); RolesList list = res.getEntity(); int statusCode = res.getStatus(); @@ -297,6 +304,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); ClientResponse res = client.readSearchList("movingImage"); RolesList list = res.getEntity(); int statusCode = res.getStatus(); @@ -335,7 +343,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); - + RoleClient client = new RoleClient(); ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { @@ -405,6 +413,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { // // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in updateRole(), below. + RoleClient client = new RoleClient(); Role role = createRoleInstance("ROLE_XXX", "xxx", true); @@ -435,6 +444,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -458,6 +468,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + RoleClient client = new RoleClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -532,6 +543,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + RoleClient client = new RoleClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java index 970bbbe03..479484d7b 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java @@ -63,8 +63,6 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { LoggerFactory.getLogger(CollectionObjectAuthRefsTest.class); // Instance variables specific to this test. - private CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); - private PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); final String SERVICE_PATH_COMPONENT = "collectionobjects"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private String knownResourceId = null; @@ -94,6 +92,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { // Create all the person refs and entities createPersonRefs(); + CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); MultipartOutput multipart = createCollectionObjectInstance( "Obj Title", "ObjNum-1234", @@ -136,6 +135,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { protected void createPersonRefs(){ String authRefName = PersonAuthorityClientUtils.createPersonAuthRefName(PERSON_AUTHORITY_NAME, false); + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( PERSON_AUTHORITY_NAME, authRefName, personAuthClient.getCommonPartName()); ClientResponse res = personAuthClient.create(multipart); @@ -167,6 +167,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { Map personInfo = new HashMap(); personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); personInfo.put(PersonJAXBSchema.SUR_NAME, surName); + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, refName, personInfo, personAuthClient.getItemCommonPartName()); @@ -188,6 +189,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { testSetup(OK_STATUS, ServiceRequestType.READ,testName); // Submit the request to the service and store the response. + CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); ClientResponse res = collectionObjectClient.read(knownResourceId); int statusCode = res.getStatus(); @@ -259,10 +261,12 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } - // Note: Any non-success responses are ignored and not reported. + CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); + // Note: Any non-success responses are ignored and not reported. for (String resourceId : collectionObjectIdsCreated) { ClientResponse res = collectionObjectClient.delete(resourceId); } + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Delete persons before PersonAuth for (String resourceId : personIdsCreated) { ClientResponse res = personAuthClient.deleteItem(personAuthCSID, resourceId); @@ -295,7 +299,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName()); + commonPart.getHeaders().add("label", new CollectionObjectClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, collectionObject common"); diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index b9f7bcd80..77ecb4746 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -56,7 +56,6 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { private final Logger logger = LoggerFactory.getLogger(CollectionObjectServiceTest.class); // Instance variables specific to this test. - private CollectionObjectClient client = new CollectionObjectClient(); private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); private boolean multivalue; //toggle @@ -66,7 +65,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { */ @Override protected String getServicePathComponent() { - return client.getServicePathComponent(); + return new CollectionObjectClient().getServicePathComponent(); } // --------------------------------------------------------------- @@ -83,6 +82,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + CollectionObjectClient client = new CollectionObjectClient(); String identifier = createIdentifier(); MultipartOutput multipart = createCollectionObjectInstance(client.getCommonPartName(), identifier); @@ -325,6 +325,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { collectionObject.setObjectName("some name"); // Submit the request to the service and store the response. + CollectionObjectClient client = new CollectionObjectClient(); MultipartOutput multipart = createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null); ClientResponse res = client.create(multipart); @@ -378,6 +379,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + CollectionObjectClient client = new CollectionObjectClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -419,6 +421,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + CollectionObjectClient client = new CollectionObjectClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -445,6 +448,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + CollectionObjectClient client = new CollectionObjectClient(); ClientResponse res = client.readList(); CollectionobjectsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -496,6 +500,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { ClientResponse res = updateRetrieve(testName, knownResourceId); // Extract its common part. + CollectionObjectClient client = new CollectionObjectClient(); MultipartInput input = (MultipartInput) res.getEntity(); CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input, @@ -536,6 +541,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { private ClientResponse updateRetrieve(String testName, String id) { final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); + CollectionObjectClient client = new CollectionObjectClient(); ClientResponse res = client.read(id); if (logger.isDebugEnabled()) { logger.debug("read in updateRetrieve for " + testName + " status = " + res.getStatus()); @@ -551,6 +557,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { CollectionobjectsCommon collectionObject) { MultipartOutput output = new MultipartOutput(); OutputPart commonPart = output.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); + CollectionObjectClient client = new CollectionObjectClient(); commonPart.getHeaders().add("label", client.getCommonPartName()); ClientResponse res = client.update(knownResourceId, output); return res; @@ -677,6 +684,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in updateCollectionObject(), below. + CollectionObjectClient client = new CollectionObjectClient(); MultipartOutput multipart = createCollectionObjectInstance(client.getCommonPartName(), NON_EXISTENT_ID); @@ -719,6 +727,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { // Read an existing record for updating. ClientResponse res = updateRetrieve(testName, knownResourceId); + CollectionObjectClient client = new CollectionObjectClient(); MultipartInput input = (MultipartInput) res.getEntity(); CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input, @@ -760,6 +769,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + CollectionObjectClient client = new CollectionObjectClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -783,6 +793,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + CollectionObjectClient client = new CollectionObjectClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -845,7 +856,8 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } - for (String resourceId : allResourceIdsCreated) { + CollectionObjectClient client = new CollectionObjectClient(); + for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); } @@ -986,6 +998,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { MultipartOutput multipart = null; + CollectionObjectClient client = new CollectionObjectClient(); if (useJaxb) { multipart = createCollectionObjectInstanceFromXml(testName, client.getCommonPartName(), fileName); diff --git a/services/contact/client/src/test/java/org/collectionspace/services/client/test/ContactServiceTest.java b/services/contact/client/src/test/java/org/collectionspace/services/client/test/ContactServiceTest.java index 17ab7ffc8..c6316ad9d 100644 --- a/services/contact/client/src/test/java/org/collectionspace/services/client/test/ContactServiceTest.java +++ b/services/contact/client/src/test/java/org/collectionspace/services/client/test/ContactServiceTest.java @@ -57,7 +57,6 @@ public class ContactServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(ContactServiceTest.class); // Instance variables specific to this test. - private ContactClient client = new ContactClient(); final String SERVICE_PATH_COMPONENT = "contacts"; private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); @@ -76,8 +75,8 @@ public class ContactServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + ContactClient client = new ContactClient(); String identifier = createIdentifier(); - MultipartOutput multipart = ContactClientUtils.createContactInstance(identifier, client.getCommonPartName()); ClientResponse res = client.create(multipart); @@ -228,6 +227,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + ContactClient client = new ContactClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -256,6 +256,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + ContactClient client = new ContactClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -282,6 +283,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + ContactClient client = new ContactClient(); ClientResponse res = client.readList(); ContactsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -328,6 +330,8 @@ public class ContactServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Submit the request to the service and store the response. + ContactClient client = new ContactClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -483,8 +487,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. - - // The only relevant ID may be the one used in update(), below. + ContactClient client = new ContactClient(); MultipartOutput multipart = ContactClientUtils.createContactInstance(NON_EXISTENT_ID, client.getCommonPartName()); ClientResponse res = @@ -514,6 +517,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + ContactClient client = new ContactClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -537,6 +541,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + ContactClient client = new ContactClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -595,6 +600,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + ContactClient client = new ContactClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); diff --git a/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java b/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java index 6c8ba6023..575a9e758 100644 --- a/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java +++ b/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java @@ -56,7 +56,6 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(DimensionServiceTest.class); // Instance variables specific to this test. - private DimensionClient client = new DimensionClient(); final String SERVICE_PATH_COMPONENT = "dimensions"; private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); @@ -75,8 +74,8 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + DimensionClient client = new DimensionClient(); String identifier = createIdentifier(); - MultipartOutput multipart = createDimensionInstance(identifier); ClientResponse res = client.create(multipart); @@ -226,6 +225,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + DimensionClient client = new DimensionClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -254,6 +254,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + DimensionClient client = new DimensionClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -280,6 +281,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + DimensionClient client = new DimensionClient(); ClientResponse res = client.readList(); DimensionsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -326,6 +328,8 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + DimensionClient client = new DimensionClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -341,7 +345,6 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { client.getCommonPartName(), DimensionsCommon.class); Assert.assertNotNull(dimension); - // Update the content of this resource. // Update the content of this resource. dimension.setValue("updated-" + dimension.getValue()); dimension.setValueDate("updated-" + dimension.getValueDate()); @@ -481,8 +484,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. - - // The only relevant ID may be the one used in update(), below. + DimensionClient client = new DimensionClient(); MultipartOutput multipart = createDimensionInstance(NON_EXISTENT_ID); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); @@ -511,6 +513,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + DimensionClient client = new DimensionClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -534,6 +537,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + DimensionClient client = new DimensionClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -592,6 +596,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + DimensionClient client = new DimensionClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); @@ -621,7 +626,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(dimension, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + commonPart.getHeaders().add("label", new DimensionClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, dimension common"); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java index 6efbcc25d..2eebbc8d5 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java @@ -63,8 +63,6 @@ public class IntakeAuthRefsTest extends BaseServiceTest { LoggerFactory.getLogger(IntakeAuthRefsTest.class); // Instance variables specific to this test. - private IntakeClient intakeClient = new IntakeClient(); - private PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); final String SERVICE_PATH_COMPONENT = "intakes"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private String knownResourceId = null; @@ -96,16 +94,17 @@ public class IntakeAuthRefsTest extends BaseServiceTest { // Create all the person refs and entities createPersonRefs(); + // Submit the request to the service and store the response. + IntakeClient intakeClient = new IntakeClient(); MultipartOutput multipart = createIntakeInstance( "entryNumber-" + identifier, "entryDate-" + identifier, - currentOwnerRefName, - depositorRefName, - conditionCheckAssesorRefName, - insurerRefName, - fieldCollectorRefName, - valuerRefName ); - + currentOwnerRefName, + depositorRefName, + conditionCheckAssesorRefName, + insurerRefName, + fieldCollectorRefName, + valuerRefName ); ClientResponse res = intakeClient.create(multipart); int statusCode = res.getStatus(); @@ -138,6 +137,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { } protected void createPersonRefs(){ + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); String authRefName = PersonAuthorityClientUtils.createPersonAuthRefName(PERSON_AUTHORITY_NAME, false); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( @@ -178,6 +178,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { } protected String createPerson(String firstName, String surName, String refName ) { + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); Map personInfo = new HashMap(); personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); personInfo.put(PersonJAXBSchema.SUR_NAME, surName); @@ -202,6 +203,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { testSetup(OK_STATUS, ServiceRequestType.READ,testName); // Submit the request to the service and store the response. + IntakeClient intakeClient = new IntakeClient(); ClientResponse res = intakeClient.read(knownResourceId); int statusCode = res.getStatus(); @@ -273,10 +275,12 @@ public class IntakeAuthRefsTest extends BaseServiceTest { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + IntakeClient intakeClient = new IntakeClient(); // Note: Any non-success responses are ignored and not reported. for (String resourceId : intakeIdsCreated) { ClientResponse res = intakeClient.delete(resourceId); } + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Delete persons before PersonAuth for (String resourceId : personIdsCreated) { ClientResponse res = personAuthClient.deleteItem(personAuthCSID, resourceId); @@ -312,7 +316,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", intakeClient.getCommonPartName()); + commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, intake common"); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index cc7403d82..c46cd9cbb 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -56,7 +56,6 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(IntakeServiceTest.class); // Instance variables specific to this test. - private IntakeClient client = new IntakeClient(); final String SERVICE_PATH_COMPONENT = "intakes"; private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); @@ -75,8 +74,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + IntakeClient client = new IntakeClient(); String identifier = createIdentifier(); - MultipartOutput multipart = createIntakeInstance(identifier); ClientResponse res = client.create(multipart); @@ -226,6 +225,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + IntakeClient client = new IntakeClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -254,6 +254,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + IntakeClient client = new IntakeClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -280,6 +281,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + IntakeClient client = new IntakeClient(); ClientResponse res = client.readList(); IntakesCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -326,6 +328,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + IntakeClient client = new IntakeClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -481,8 +485,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. - - // The only relevant ID may be the one used in update(), below. + IntakeClient client = new IntakeClient(); MultipartOutput multipart = createIntakeInstance(NON_EXISTENT_ID); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); @@ -511,6 +514,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + IntakeClient client = new IntakeClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -534,6 +538,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + IntakeClient client = new IntakeClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -592,6 +597,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + IntakeClient client = new IntakeClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); @@ -623,7 +629,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, intake common"); diff --git a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java index 7485d5a11..c5d1c82e9 100644 --- a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java +++ b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java @@ -64,8 +64,6 @@ public class LoaninAuthRefsTest extends BaseServiceTest { LoggerFactory.getLogger(LoaninAuthRefsTest.class); // Instance variables specific to this test. - private LoaninClient loaninClient = new LoaninClient(); - private PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); final String SERVICE_PATH_COMPONENT = "loansin"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private String knownResourceId = null; @@ -100,15 +98,14 @@ public class LoaninAuthRefsTest extends BaseServiceTest { // // One or more fields in this resource will be PersonAuthority // references, and will refer to Person resources by their refNames. + LoaninClient loaninClient = new LoaninClient(); MultipartOutput multipart = createLoaninInstance( "loanInNumber-" + identifier, "returnDate-" + identifier, lendersAuthorizerRefName, lendersContactRefName, loanInContactRefName); - ClientResponse res = loaninClient.create(multipart); - int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -140,6 +137,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { protected void createPersonRefs(){ + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Create a temporary PersonAuthority resource, and its corresponding // refName by which it can be identified. String authRefName = @@ -175,6 +173,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { } protected String createPerson(String firstName, String surName, String refName ) { + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); Map personInfo = new HashMap(); personInfo.put(PersonJAXBSchema.FORE_NAME, firstName); personInfo.put(PersonJAXBSchema.SUR_NAME, surName); @@ -199,6 +198,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { testSetup(OK_STATUS, ServiceRequestType.READ,testName); // Submit the request to the service and store the response. + LoaninClient loaninClient = new LoaninClient(); ClientResponse res = loaninClient.read(knownResourceId); int statusCode = res.getStatus(); @@ -278,6 +278,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { } // Note: Any non-success responses are ignored and not reported. + PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); // Delete Person resource(s) (before PersonAuthority resources). ClientResponse res; for (String resourceId : personIdsCreated) { @@ -286,6 +287,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { // Delete PersonAuthority resource(s). res = personAuthClient.delete(personAuthCSID); // Delete Loans In resource(s). + LoaninClient loaninClient = new LoaninClient(); for (String resourceId : loaninIdsCreated) { res = loaninClient.delete(resourceId); } @@ -313,7 +315,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(loanin, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", loaninClient.getCommonPartName()); + commonPart.getHeaders().add("label", new LoaninClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, loanin common"); diff --git a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java index 9455f0c79..4a72a4d00 100644 --- a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java +++ b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java @@ -58,7 +58,6 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(LoaninServiceTest.class); // Instance variables specific to this test. - private LoaninClient client = new LoaninClient(); final String SERVICE_PATH_COMPONENT = "loansin"; private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); @@ -77,8 +76,8 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + LoaninClient client = new LoaninClient(); String identifier = createIdentifier(); - MultipartOutput multipart = createLoaninInstance(identifier); ClientResponse res = client.create(multipart); @@ -228,6 +227,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + LoaninClient client = new LoaninClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -256,6 +256,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + LoaninClient client = new LoaninClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -282,6 +283,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + LoaninClient client = new LoaninClient(); ClientResponse res = client.readList(); LoansinCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -328,6 +330,8 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + LoaninClient client = new LoaninClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -482,8 +486,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. - - // The only relevant ID may be the one used in update(), below. + LoaninClient client = new LoaninClient(); MultipartOutput multipart = createLoaninInstance(NON_EXISTENT_ID); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); @@ -512,6 +515,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + LoaninClient client = new LoaninClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -535,6 +539,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + LoaninClient client = new LoaninClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -593,7 +598,8 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } - for (String resourceId : allResourceIdsCreated) { + LoaninClient client = new LoaninClient(); + for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); } @@ -628,7 +634,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(loanin, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + commonPart.getHeaders().add("label", new LoaninClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, loanin common"); diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java index 32d6d6a38..81872dd76 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java @@ -64,8 +64,6 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(OrgAuthorityServiceTest.class); // Instance variables specific to this test. - private OrgAuthorityClient client = new OrgAuthorityClient(); - private ContactClient contactClient = new ContactClient(); final String SERVICE_PATH_COMPONENT = "orgauthorities"; final String ITEM_SERVICE_PATH_COMPONENT = "items"; final String CONTACT_SERVICE_PATH_COMPONENT = "contacts"; @@ -98,6 +96,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); String identifier = createIdentifier(); String displayName = "displayName-" + identifier; String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true); @@ -154,6 +153,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); String identifier = createIdentifier(); String refName = OrgAuthorityClientUtils.createOrganizationRefName(knownResourceRefName, identifier, true); Map testOrgMap = new HashMap(); @@ -198,10 +198,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); String identifier = createIdentifier(); MultipartOutput multipart = ContactClientUtils.createContactInstance(parentcsid, - itemcsid, identifier, contactClient.getCommonPartName()); + itemcsid, identifier, new ContactClient().getCommonPartName()); ClientResponse res = client.createContact(parentcsid, itemcsid, multipart); int statusCode = res.getStatus(); @@ -373,6 +374,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupRead(); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -399,31 +401,32 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnGroups = {"create"}) public void readByName(String testName) throws Exception { - // Perform setup. - setupRead(); - - // Submit the request to the service and store the response. - ClientResponse res = client.readByName(knownResourceDisplayName); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - //FIXME: remove the following try catch once Aron fixes signatures - try { - MultipartInput input = (MultipartInput) res.getEntity(); - OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input, - client.getCommonPartName(), OrgauthoritiesCommon.class); - Assert.assertNotNull(orgAuthority); - } catch (Exception e) { - throw new RuntimeException(e); - } + // Perform setup. + setupRead(); + + // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); + ClientResponse res = client.readByName(knownResourceDisplayName); + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + //FIXME: remove the following try catch once Aron fixes signatures + try { + MultipartInput input = (MultipartInput) res.getEntity(); + OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input, + new OrgAuthorityClient().getCommonPartName(), OrgauthoritiesCommon.class); + Assert.assertNotNull(orgAuthority); + } catch (Exception e) { + throw new RuntimeException(e); } + } /* @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, @@ -465,6 +468,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -499,6 +503,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupUpdate(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -604,6 +609,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -649,6 +655,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId); @@ -666,7 +673,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Check whether we've received a contact. MultipartInput input = (MultipartInput) res.getEntity(); ContactsCommon contact = (ContactsCommon) extractPart(input, - contactClient.getCommonPartName(), ContactsCommon.class); + new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(contact); boolean showFull = true; if(showFull && logger.isDebugEnabled()){ @@ -688,6 +695,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -709,6 +717,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -730,6 +739,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -758,6 +768,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readList(); OrgauthoritiesCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -809,13 +820,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = null; - if(vcsid!= null) { - // Submit the request to the service and store the response. res = client.readItemList(vcsid); } else if(name!= null) { - // Submit the request to the service and store the response. res = client.readItemListForNamedAuthority(name); } else { Assert.fail("readItemList passed null csid and name!"); @@ -880,6 +889,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readContactList(parentcsid, itemcsid); ContactsCommonList list = res.getEntity(); @@ -942,6 +952,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupUpdate(testName); // Retrieve the contents of a resource to update. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -1000,6 +1011,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); if(logger.isDebugEnabled()){ @@ -1061,6 +1074,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId); if(logger.isDebugEnabled()){ @@ -1076,7 +1091,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } MultipartInput input = (MultipartInput) res.getEntity(); ContactsCommon contact = (ContactsCommon) extractPart(input, - contactClient.getCommonPartName(), ContactsCommon.class); + new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(contact); // Update the contents of this resource. @@ -1090,7 +1105,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the updated resource to the service and store the response. MultipartOutput output = new MultipartOutput(); OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", contactClient.getCommonPartName()); + commonPart.getHeaders().add("label", new ContactClient().getCommonPartName()); res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output); int statusCode = res.getStatus(); @@ -1106,7 +1121,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { input = (MultipartInput) res.getEntity(); ContactsCommon updatedContact = (ContactsCommon) extractPart(input, - contactClient.getCommonPartName(), ContactsCommon.class); + new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(updatedContact); // Verify that the updated resource received the correct data. @@ -1221,6 +1236,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. + OrgAuthorityClient client = new OrgAuthorityClient(); MultipartOutput multipart = createOrgAuthorityInstance(NON_EXISTENT_ID); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); @@ -1246,6 +1262,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID(s) used when creating the request payload may be arbitrary. // The only relevant ID may be the one used in update(), below. + OrgAuthorityClient client = new OrgAuthorityClient(); Map nonexOrgMap = new HashMap(); nonexOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, "Non-existent"); String refName = OrgAuthorityClientUtils.createOrganizationRefName(knownResourceRefName, NON_EXISTENT_ID, true); @@ -1295,6 +1312,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId); int statusCode = res.getStatus(); @@ -1322,6 +1340,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.deleteItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -1348,6 +1367,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -1371,6 +1391,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -1392,6 +1413,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.deleteItem(knownResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -1413,6 +1435,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + OrgAuthorityClient client = new OrgAuthorityClient(); ClientResponse res = client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -1522,6 +1545,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { String contactResourceId; // Clean up contact resources. parentResourceId = knownResourceId; + OrgAuthorityClient client = new OrgAuthorityClient(); for (Map.Entry entry : allContactResourceIdsCreated.entrySet()) { contactResourceId = entry.getKey(); itemResourceId = entry.getValue(); @@ -1641,6 +1665,6 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { String refName = OrgAuthorityClientUtils.createOrgAuthRefName(displayName, true); return OrgAuthorityClientUtils.createOrgAuthorityInstance( displayName, refName, - client.getCommonPartName()); + new OrgAuthorityClient().getCommonPartName()); } } \ No newline at end of file diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index 828d5683a..b9db66bfd 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -63,8 +63,6 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(PersonAuthorityServiceTest.class); // Instance variables specific to this test. - private PersonAuthorityClient client = new PersonAuthorityClient(); - private ContactClient contactClient = new ContactClient(); final String SERVICE_PATH_COMPONENT = "personauthorities"; final String ITEM_SERVICE_PATH_COMPONENT = "items"; final String CONTACT_SERVICE_PATH_COMPONENT = "contacts"; @@ -101,6 +99,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); String identifier = createIdentifier(); String displayName = "displayName-" + identifier; String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, false); @@ -158,6 +157,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); String identifier = createIdentifier(); String refName = PersonAuthorityClientUtils.createPersonRefName(authRefName, "John Wayne", true); Map johnWayneMap = new HashMap(); @@ -222,10 +222,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); String identifier = createIdentifier(); MultipartOutput multipart = ContactClientUtils.createContactInstance(parentcsid, - itemcsid, identifier, contactClient.getCommonPartName()); + itemcsid, identifier, new ContactClient().getCommonPartName()); ClientResponse res = client.createContact(parentcsid, itemcsid, multipart); int statusCode = res.getStatus(); @@ -397,6 +398,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupRead(); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -424,30 +426,31 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { public void readByName(String testName) throws Exception { // Perform setup. - setupRead(); - - // Submit the request to the service and store the response. - ClientResponse res = client.readByName(knownResourceDisplayName); - int statusCode = res.getStatus(); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - //FIXME: remove the following try catch once Aron fixes signatures - try { - MultipartInput input = (MultipartInput) res.getEntity(); - PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input, - client.getCommonPartName(), PersonauthoritiesCommon.class); - Assert.assertNotNull(personAuthority); - } catch (Exception e) { - throw new RuntimeException(e); - } + setupRead(); + + // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); + ClientResponse res = client.readByName(knownResourceDisplayName); + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + //FIXME: remove the following try catch once Aron fixes signatures + try { + MultipartInput input = (MultipartInput) res.getEntity(); + PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input, + client.getCommonPartName(), PersonauthoritiesCommon.class); + Assert.assertNotNull(personAuthority); + } catch (Exception e) { + throw new RuntimeException(e); } + } /* @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, @@ -489,6 +492,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -523,6 +527,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupUpdate(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -630,6 +635,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -675,6 +681,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId); @@ -692,7 +699,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { // Check whether we've received a contact. MultipartInput input = (MultipartInput) res.getEntity(); ContactsCommon contact = (ContactsCommon) extractPart(input, - contactClient.getCommonPartName(), ContactsCommon.class); + new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(contact); boolean showFull = true; if(showFull && logger.isDebugEnabled()){ @@ -714,6 +721,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -735,6 +743,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -756,6 +765,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -784,6 +794,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readList(); PersonauthoritiesCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -833,13 +844,12 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { // Perform setup. setupReadList(testName); + // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = null; - if(vcsid!= null) { - // Submit the request to the service and store the response. res = client.readItemList(vcsid); } else if(name!= null) { - // Submit the request to the service and store the response. res = client.readItemListForNamedAuthority(name); } else { Assert.fail("readItemList passed null csid and name!"); @@ -904,6 +914,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readContactList(parentcsid, itemcsid); ContactsCommonList list = res.getEntity(); @@ -966,6 +977,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupUpdate(testName); // Retrieve the contents of a resource to update. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -1024,6 +1036,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); if(logger.isDebugEnabled()){ @@ -1085,6 +1099,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId); if(logger.isDebugEnabled()){ @@ -1100,7 +1116,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { } MultipartInput input = (MultipartInput) res.getEntity(); ContactsCommon contact = (ContactsCommon) extractPart(input, - contactClient.getCommonPartName(), ContactsCommon.class); + new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(contact); // Update the contents of this resource. @@ -1114,7 +1130,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the updated resource to the service and store the response. MultipartOutput output = new MultipartOutput(); OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", contactClient.getCommonPartName()); + commonPart.getHeaders().add("label", new ContactClient().getCommonPartName()); res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output); int statusCode = res.getStatus(); @@ -1130,7 +1146,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { input = (MultipartInput) res.getEntity(); ContactsCommon updatedContact = (ContactsCommon) extractPart(input, - contactClient.getCommonPartName(), ContactsCommon.class); + new ContactClient().getCommonPartName(), ContactsCommon.class); Assert.assertNotNull(updatedContact); // Verify that the updated resource received the correct data. @@ -1245,7 +1261,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID(s) used when creating the request payload may be arbitrary. // The only relevant ID may be the one used in update(), below. - String displayName = "displayName-NON_EXISTENT_ID"; + PersonAuthorityClient client = new PersonAuthorityClient(); + String displayName = "displayName-NON_EXISTENT_ID"; String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( displayName, fullRefName, client.getCommonPartName()); @@ -1273,8 +1290,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. - - // The only relevant ID may be the one used in update(), below. + PersonAuthorityClient client = new PersonAuthorityClient(); Map nonexMap = new HashMap(); nonexMap.put(PersonJAXBSchema.FORE_NAME, "John"); nonexMap.put(PersonJAXBSchema.SUR_NAME, "Wayne"); @@ -1325,6 +1341,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId); int statusCode = res.getStatus(); @@ -1352,6 +1369,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.deleteItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -1378,6 +1396,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { } // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -1401,6 +1420,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -1422,6 +1442,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.deleteItem(knownResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -1443,6 +1464,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -1551,6 +1573,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { String itemResourceId; String contactResourceId; // Clean up contact resources. + PersonAuthorityClient client = new PersonAuthorityClient(); parentResourceId = knownResourceId; for (Map.Entry entry : allContactResourceIdsCreated.entrySet()) { contactResourceId = entry.getKey(); diff --git a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java index a763fc206..d99c453e0 100644 --- a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java +++ b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java @@ -56,7 +56,6 @@ public class RelationServiceTest extends AbstractServiceTestImpl { private final Logger logger = LoggerFactory.getLogger(RelationServiceTest.class); - private RelationClient client = new RelationClient(); final String SERVICE_PATH_COMPONENT = "relations"; private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); @@ -75,6 +74,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + RelationClient client = new RelationClient(); String identifier = createIdentifier(); MultipartOutput multipart = createRelationInstance(identifier); ClientResponse res = client.create(multipart); @@ -220,6 +220,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + RelationClient client = new RelationClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -250,6 +251,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + RelationClient client = new RelationClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -276,6 +278,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + RelationClient client = new RelationClient(); ClientResponse res = client.readList(); RelationsCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -323,6 +326,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { setupUpdate(testName); // Retrieve an existing resource that we can update. + RelationClient client = new RelationClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -484,6 +488,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. + RelationClient client = new RelationClient(); MultipartOutput multipart = createRelationInstance(NON_EXISTENT_ID); ClientResponse res = client.update(NON_EXISTENT_ID, multipart); @@ -512,6 +517,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + RelationClient client = new RelationClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -535,6 +541,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + RelationClient client = new RelationClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -600,6 +607,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } + RelationClient client = new RelationClient(); for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. ClientResponse res = client.delete(resourceId); @@ -621,7 +629,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE); - commonPart.getHeaders().add("label", client.getCommonPartName()); + commonPart.getHeaders().add("label", new RelationClient().getCommonPartName()); if(logger.isDebugEnabled()){ logger.debug("to be created, relation common"); logger.debug(objectAsXmlString(relation, RelationsCommon.class)); diff --git a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java index b6d04b567..0e8d60e36 100644 --- a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java +++ b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java @@ -60,7 +60,6 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { LoggerFactory.getLogger(VocabularyServiceTest.class); // Instance variables specific to this test. - private VocabularyClient client = new VocabularyClient(); final String SERVICE_PATH_COMPONENT = "vocabularies"; final String ITEM_SERVICE_PATH_COMPONENT = "items"; private String knownResourceId = null; @@ -90,6 +89,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupCreate(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); String identifier = createIdentifier(); String displayName = "displayName-" + identifier; String refName = VocabularyClientUtils.createVocabularyRefName(displayName, false); @@ -128,12 +128,16 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, dependsOnMethods = {"create"}) public void createItem(String testName) { + + // Perform setup. setupCreate(testName); + VocabularyClient client = new VocabularyClient(); HashMap itemInfo = new HashMap(); itemInfo.put(VocabularyItemJAXBSchema.DISPLAY_NAME, createIdentifier()); String newID = VocabularyClientUtils.createItemInVocabulary(knownResourceId, knownResourceRefName, itemInfo, client); + // Store the ID returned from the first item resource created // for additional tests below. if (knownItemResourceId == null){ @@ -271,6 +275,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupRead(); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.read(knownResourceId); int statusCode = res.getStatus(); @@ -333,6 +338,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupRead(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -362,6 +368,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -427,6 +434,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.read(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -448,6 +456,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupReadNonExistent(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.readItem(knownResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -474,6 +483,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.readList(); VocabulariesCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -520,6 +530,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupReadList(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.readItemList(vcsid); VocabularyitemsCommonList list = res.getEntity(); @@ -575,6 +586,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupUpdate(testName); // Retrieve the contents of a resource to update. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.read(knownResourceId); if(logger.isDebugEnabled()){ @@ -633,6 +645,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { // Perform setup. setupUpdate(testName); + // Retrieve the contents of a resource to update. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.readItem(knownResourceId, knownItemResourceId); if(logger.isDebugEnabled()){ @@ -793,8 +807,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. - - // The only relevant ID may be the one used in update(), below. + VocabularyClient client = new VocabularyClient(); String displayName = "displayName-" + NON_EXISTENT_ID; String refName = VocabularyClientUtils.createVocabularyRefName(displayName, false); MultipartOutput multipart = VocabularyClientUtils.createEnumerationInstance( @@ -823,8 +836,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. // The only relevant ID may be the one used in update(), below. - - // The only relevant ID may be the one used in update(), below. + VocabularyClient client = new VocabularyClient(); HashMap itemInfo = new HashMap(); itemInfo.put(VocabularyItemJAXBSchema.DISPLAY_NAME, "nonex"); MultipartOutput multipart = @@ -858,6 +870,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.delete(knownResourceId); int statusCode = res.getStatus(); @@ -880,6 +893,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupDelete(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.deleteItem(knownResourceId, knownItemResourceId); int statusCode = res.getStatus(); @@ -903,6 +917,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.delete(NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -924,6 +939,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { setupDeleteNonExistent(testName); // Submit the request to the service and store the response. + VocabularyClient client = new VocabularyClient(); ClientResponse res = client.deleteItem(knownResourceId, NON_EXISTENT_ID); int statusCode = res.getStatus(); @@ -1004,9 +1020,10 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } - // Clean up vocabulary item resources. + VocabularyClient client = new VocabularyClient(); String vocabularyResourceId; String vocabularyItemResourceId; + // Clean up vocabulary item resources. for (Map.Entry entry : allResourceItemIdsCreated.entrySet()) { vocabularyItemResourceId = entry.getKey(); vocabularyResourceId = entry.getValue(); -- 2.47.3