From: Aron Roberts Date: Fri, 28 May 2010 23:52:22 +0000 (+0000) Subject: CSPACE-1911: 'Banners' output between Services client tests now properly show calling... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=faa79fa800fa72a78d327a4c0880a949291a8546;p=tmp%2Fjakarta-migration.git CSPACE-1911: 'Banners' output between Services client tests now properly show calling class and line number in their log statements. Banner generation is now separated from test setup (e.g. specifying expected status code, valid status codes), in the client test framework, and each can be used independently. Formerly banners were output as an undocumented side effect of test setup; while that was convenient, it was not good practice. --- diff --git a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java index 453ed93a9..e18c9ab33 100644 --- a/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java +++ b/services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java @@ -64,8 +64,9 @@ import org.testng.annotations.BeforeClass; public class AccountRoleServiceTest extends AbstractServiceTestImpl { /** The Constant logger. */ - static private final Logger logger = - LoggerFactory.getLogger(AccountRoleServiceTest.class); + private final static String CLASS_NAME = AccountRoleServiceTest.class.getName(); + private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; @@ -172,10 +173,13 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + testBanner(testName, CLASS_NAME); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. AccountValue pv = accValues.get("acc-role-user1"); @@ -255,8 +259,12 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + testBanner(testName, CLASS_NAME); + } + // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. AccountRoleClient client = new AccountRoleClient(); @@ -288,8 +296,12 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + testBanner(testName, CLASS_NAME); + } + // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. AccountRoleClient client = new AccountRoleClient(); @@ -387,8 +399,13 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"}) public void delete(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + testBanner(testName, CLASS_NAME); + } + // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. AccountRoleClient client = new AccountRoleClient(); @@ -482,7 +499,8 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { @AfterClass(alwaysRun = true) @Override public void cleanUp() { - setupDelete("cleanUp"); + + setupDelete(); String noTest = System.getProperty("noTestCleanup"); if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { @@ -529,7 +547,13 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { * @return the string */ private String createAccount(String userName, String email) { - setupCreate("createAccount"); + + if (logger.isDebugEnabled()) { + testBanner("createAccount"); + } + + setupCreate(); + AccountClient accClient = new AccountClient(); AccountsCommon account = AccountFactory.createAccountInstance( userName, userName, userName, email, @@ -553,7 +577,13 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { * @param accId the acc id */ private void deleteAccount(String accId) { - setupDelete("deleteAccount"); + + if (logger.isDebugEnabled()) { + testBanner("deleteAccount"); + } + + setupDelete(); + AccountClient accClient = new AccountClient(); ClientResponse res = accClient.delete(accId); int statusCode = res.getStatus(); @@ -577,7 +607,10 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { * @return the string */ private String createRole(String roleName) { - setupCreate("createRole"); + if (logger.isDebugEnabled()) { + testBanner("createRole"); + } + setupCreate(); RoleClient roleClient = new RoleClient(); Role role = RoleFactory.createRoleInstance(roleName, @@ -601,7 +634,10 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl { * @param roleId the role id */ private void deleteRole(String roleId) { - setupDelete("deleteRole"); + if (logger.isDebugEnabled()) { + testBanner("deleteRole"); + } + setupDelete(); RoleClient roleClient = new RoleClient(); ClientResponse res = roleClient.delete(roleId); int statusCode = res.getStatus(); 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 123230c00..94ed4c9a6 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 @@ -54,8 +54,9 @@ import org.testng.annotations.AfterClass; public class AccountServiceTest extends AbstractServiceTestImpl { /** The Constant logger. */ - static private final Logger logger = - LoggerFactory.getLogger(AccountServiceTest.class); + private final String CLASS_NAME = AccountServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; @@ -112,10 +113,13 @@ public class AccountServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -156,7 +160,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createForUniqueUser(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -183,7 +190,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithInvalidTenant(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -212,7 +222,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithoutUser(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -240,7 +253,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithInvalidEmail(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -268,7 +284,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithoutScreenName(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -296,7 +315,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithInvalidPassword(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -324,7 +346,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithMostInvalid(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account = @@ -351,7 +376,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createList(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. AccountsCommon account1 = createAccountInstance("curious", "curious", "hithere08", "curious@george.com", @@ -426,8 +454,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -456,8 +487,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -486,8 +520,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -521,8 +558,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void searchScreenName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -557,8 +597,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void searchUserId(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -593,8 +636,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void searchEmail(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -629,8 +675,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void searchScreenNameEmail(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -669,8 +718,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read", "readList", "readNonExistent"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); AccountClient client = new AccountClient(); ClientResponse res = client.read(knownResourceId); @@ -727,8 +779,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update"}) public void updatePassword(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); AccountClient client = new AccountClient(); ClientResponse res = client.read(knownResourceId); @@ -786,8 +841,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update"}) public void updatePasswordWithoutUser(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); AccountsCommon accountToUpdate = new AccountsCommon(); accountToUpdate.setCsid(knownResourceId); @@ -824,8 +882,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update"}) public void updateInvalidPassword(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); AccountClient client = new AccountClient(); ClientResponse res = client.read(knownResourceId); if (logger.isDebugEnabled()) { @@ -874,8 +935,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"updatePasswordWithoutUser"}) public void deactivate(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); AccountClient client = new AccountClient(); ClientResponse res = client.read(knownResourceId); @@ -957,8 +1021,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // @@ -992,7 +1059,10 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"}) public void updateWrongUser(String testName) throws Exception { - setupUpdate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupUpdate(); // Submit the request to the service and store the response. // @@ -1044,8 +1114,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"testSubmitRequest", "updateWrongUser"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -1071,8 +1144,11 @@ public class AccountServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. AccountClient client = new AccountClient(); @@ -1100,8 +1176,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { @Test(dependsOnMethods = {"create", "read"}) public void testSubmitRequest() throws Exception { - // Expected status code: 200 OK - final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); + setupRead(); // Submit the request to the service and store the response. String method = ServiceRequestType.READ.httpMethodName(); @@ -1114,7 +1189,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl { logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode); } - Assert.assertEquals(statusCode, EXPECTED_STATUS); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } 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 d89c2630a..b8103304b 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 @@ -61,8 +61,8 @@ import org.slf4j.LoggerFactory; */ public class AcquisitionAuthRefsTest extends BaseServiceTest { - private final Logger logger = - LoggerFactory.getLogger(AcquisitionAuthRefsTest.class); + private final String CLASS_NAME = AcquisitionAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "acquisitions"; @@ -104,7 +104,12 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -200,9 +205,13 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest { dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); - + testSetup(STATUS_OK, ServiceRequestType.READ); + // Submit the request to the service and store the response. AcquisitionClient acquisitionClient = new AcquisitionClient(); ClientResponse res = acquisitionClient.read(knownResourceId); 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 d00cead9f..81cc31267 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 @@ -54,8 +54,8 @@ import org.slf4j.LoggerFactory; public class AcquisitionServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(AcquisitionServiceTest.class); + private final String CLASS_NAME = AcquisitionServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. /** The known resource id. */ @@ -89,10 +89,14 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -175,49 +179,57 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithWrongXmlSchema() throws Exception { + public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + setupCreateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -233,8 +245,12 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup. - setupRead(testName); + setupRead(); AcquisitionClient client = new AcquisitionClient(); @@ -267,8 +283,12 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. AcquisitionClient client = new AcquisitionClient(); @@ -297,8 +317,12 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. AcquisitionClient client = new AcquisitionClient(); @@ -355,8 +379,12 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. AcquisitionClient client = new AcquisitionClient(); @@ -442,50 +470,58 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - (testName + ": url=" + url + " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + setupUpdateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + (testName + ": url=" + url + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, dependsOnMethods = {"create", "testSubmitRequest"}) - public void createWithEmptyEntityBody() throws Exception { + public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + setupCreateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -493,48 +529,56 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -546,8 +590,12 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -580,8 +628,12 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "read", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. AcquisitionClient client = new AcquisitionClient(); @@ -607,8 +659,12 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; + // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. AcquisitionClient client = new AcquisitionClient(); @@ -631,13 +687,14 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { /** * Tests the code for manually submitting data that is used by several * of the methods above. + * * @throws Exception */ @Test(dependsOnMethods = {"create", "read"}) public void testSubmitRequest() throws Exception { - // Expected status code: 200 OK - final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); + // Perform setup. + setupRead(); // Submit the request to the service and store the response. String method = ServiceRequestType.READ.httpMethodName(); @@ -650,7 +707,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode); } - Assert.assertEquals(statusCode, EXPECTED_STATUS); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @@ -694,3 +751,4 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { return multipart; } } + 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 5aae52668..00e3d0421 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 @@ -65,8 +65,9 @@ import org.testng.annotations.BeforeClass; public class PermissionRoleServiceTest extends AbstractServiceTestImpl { /** The Constant logger. */ - static private final Logger logger = - LoggerFactory.getLogger(PermissionRoleServiceTest.class); + private final static String CLASS_NAME = PermissionRoleServiceTest.class.getName(); + private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; @@ -169,10 +170,14 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. PermissionValue pv = permValues.get(TEST_SERVICE_NAME + TEST_MARKER); @@ -255,8 +260,11 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. PermissionRoleClient client = new PermissionRoleClient(); @@ -293,8 +301,11 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. PermissionRoleClient client = new PermissionRoleClient(); @@ -397,8 +408,11 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. PermissionRoleClient client = new PermissionRoleClient(); @@ -497,7 +511,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { @AfterClass(alwaysRun = true) @Override public void cleanUp() { - setupDelete("cleanUp"); + setupDelete(); String noTest = System.getProperty("noTestCleanup"); if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { if (logger.isDebugEnabled()) { @@ -543,7 +557,10 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { * @return the string */ private String createPermission(String resName, EffectType effect) { - setupCreate("createPermission"); + if (logger.isDebugEnabled()) { + logger.debug(testBanner("createPermission")); + } + setupCreate(); PermissionClient permClient = new PermissionClient(); List actions = PermissionFactory.createDefaultActions(); Permission permission = PermissionFactory.createPermissionInstance(resName, @@ -577,7 +594,10 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { * @param permId the perm id */ private void deletePermission(String permId) { - setupDelete("deletePermission"); + if (logger.isDebugEnabled()) { + logger.debug(testBanner("deletePermission")); + } + setupDelete(); PermissionClient permClient = new PermissionClient(); ClientResponse res = null; try { @@ -603,7 +623,10 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { * @return the string */ private String createRole(String roleName) { - setupCreate("createRole"); + if (logger.isDebugEnabled()) { + logger.debug(testBanner("createRole")); + } + setupCreate(); RoleClient roleClient = new RoleClient(); Role role = RoleFactory.createRoleInstance(roleName, @@ -634,7 +657,10 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl { * @param roleId the role id */ private void deleteRole(String roleId) { - setupDelete("deleteRole"); + if (logger.isDebugEnabled()) { + logger.debug(testBanner("deleteRole")); + } + setupDelete(); RoleClient roleClient = new RoleClient(); ClientResponse res = null; try { 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 8cfb9964c..e70def7c7 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,8 +55,9 @@ import org.slf4j.LoggerFactory; public class PermissionServiceTest extends AbstractServiceTestImpl { /** The Constant logger. */ - static private final Logger logger = - LoggerFactory.getLogger(PermissionServiceTest.class); + private final static String CLASS_NAME = PermissionServiceTest.class.getName(); + private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; @@ -113,10 +114,13 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. List actions = PermissionFactory.createDefaultActions(); @@ -162,7 +166,10 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithoutResourceName(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. List actions = PermissionFactory.createDefaultActions(); @@ -194,7 +201,10 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createList(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. List actions = PermissionFactory.createDefaultActions(); Permission permission1 = createPermissionInstance("test-objects", @@ -280,8 +290,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. PermissionClient client = new PermissionClient(); @@ -310,8 +323,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. PermissionClient client = new PermissionClient(); @@ -340,8 +356,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. PermissionClient client = new PermissionClient(); @@ -375,8 +394,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void searchResourceName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. PermissionClient client = new PermissionClient(); @@ -418,8 +440,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read", "readList", "readNonExistent"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); Permission permToUpdate = new Permission(); permToUpdate.setCsid(knownResourceId); @@ -457,7 +482,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { public void updateNotAllowed(String testName) throws Exception { // Perform setup. - setupUpdate(testName); + setupUpdate(); Permission permToUpdate = new Permission(); permToUpdate.setCsid(knownResourceId); @@ -492,8 +517,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"updateNotAllowed"}) public void updateActions(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); Permission permToUpdate = new Permission(); permToUpdate.setCsid(knownResourceId); @@ -572,8 +600,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"readNonExistent", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // @@ -614,8 +645,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"updateActions", "testSubmitRequest"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. PermissionClient client = new PermissionClient(); @@ -641,8 +675,11 @@ public class PermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. PermissionClient client = new PermissionClient(); diff --git a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java index 893005232..f40dc0c36 100644 --- a/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java +++ b/services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java @@ -65,8 +65,9 @@ import org.testng.annotations.BeforeClass; public class RolePermissionServiceTest extends AbstractServiceTestImpl { /** The Constant logger. */ - static private final Logger logger = - LoggerFactory.getLogger(RolePermissionServiceTest.class); + private final static String CLASS_NAME = RolePermissionServiceTest.class.getName(); + private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; @@ -156,10 +157,13 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. RoleValue rv = roleValues.get(TEST_ROLE_NAME + TEST_MARKER); @@ -242,8 +246,11 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. RolePermissionClient client = new RolePermissionClient(); @@ -279,8 +286,11 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. RolePermissionClient client = new RolePermissionClient(); @@ -384,8 +394,11 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + }; // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. RolePermissionClient client = new RolePermissionClient(); @@ -483,7 +496,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { @AfterClass(alwaysRun = true) @Override public void cleanUp() { - setupDelete("cleanUp"); + setupDelete(); String noTest = System.getProperty("noTestCleanup"); if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { if (logger.isDebugEnabled()) { @@ -529,7 +542,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { * @return the string */ private String createPermission(String resName, EffectType effect) { - setupCreate("createPermission"); + setupCreate(); PermissionClient permClient = new PermissionClient(); List actions = PermissionFactory.createDefaultActions(); Permission permission = PermissionFactory.createPermissionInstance(resName, @@ -562,7 +575,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { * @param permId the perm id */ private void deletePermission(String permId) { - setupDelete("deletePermission"); + setupDelete(); PermissionClient permClient = new PermissionClient(); ClientResponse res = null; @@ -591,7 +604,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { * @return the string */ private String createRole(String roleName) { - setupCreate("createRole"); + setupCreate(); RoleClient roleClient = new RoleClient(); Role role = RoleFactory.createRoleInstance(roleName, @@ -623,7 +636,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl { * @param roleId the role id */ private void deleteRole(String roleId) { - setupDelete("deleteRole"); + setupDelete(); RoleClient roleClient = new RoleClient(); ClientResponse res = null; try { 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 abaceb776..9818eda81 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,8 +52,9 @@ import org.slf4j.LoggerFactory; public class RoleServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(RoleServiceTest.class); + private final static String CLASS_NAME = RoleServiceTest.class.getName(); + private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; @@ -113,10 +114,13 @@ public class RoleServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -157,7 +161,10 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createForUniqueRole(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -185,7 +192,10 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createWithoutRoleName(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -212,7 +222,10 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createList(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -291,8 +304,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -317,7 +333,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { public void readToVerify(String testName) throws Exception { // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -350,8 +366,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -380,8 +399,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -415,8 +437,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void searchRoleName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -458,8 +483,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read", "readList", "readNonExistent"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); Role roleToUpdate = new Role(); roleToUpdate.setCsid(knownResourceId); @@ -498,7 +526,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl { public void updateNotAllowed(String testName) throws Exception { // Perform setup. - setupUpdate(testName); + setupUpdate(); Role roleToUpdate = new Role(); roleToUpdate.setCsid(knownResourceId); @@ -558,8 +586,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"readNonExistent", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // @@ -595,8 +626,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"updateNotAllowed", "testSubmitRequest"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); @@ -622,8 +656,11 @@ public class RoleServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. RoleClient client = new RoleClient(); diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java index c4dfb7efa..812120425 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java @@ -26,8 +26,6 @@ package org.collectionspace.services.client.test; import java.util.ArrayList; import java.util.List; -import javax.ws.rs.core.Response; - import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.client.CollectionSpaceClient; import org.jboss.resteasy.client.ClientResponse; @@ -91,25 +89,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up create tests. - * - * @param testName The name of the test being run. - */ - protected void setupCreate(String testName) { - setupCreate(testName, LOGGER_NULL); - } - - /** - * Sets up create tests. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupCreate(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode(); + protected void setupCreate() { + EXPECTED_STATUS_CODE = STATUS_CREATED; REQUEST_TYPE = ServiceRequestType.CREATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } /* (non-Javadoc) @@ -132,25 +116,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up create tests with empty entity body. - * - * @param testName The name of the test being run. - */ - protected void setupCreateWithEmptyEntityBody(String testName) { - setupCreateWithEmptyEntityBody(testName, LOGGER_NULL); - } - - /** - * Sets up create tests with empty entity body. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupCreateWithEmptyEntityBody(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); + protected void setupCreateWithEmptyEntityBody() { + EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST; REQUEST_TYPE = ServiceRequestType.CREATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } /* (non-Javadoc) @@ -161,25 +131,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up create tests with malformed xml. - * - * @param testName The name of the test being run. - */ - protected void setupCreateWithMalformedXml(String testName) { - setupCreateWithMalformedXml(testName, LOGGER_NULL); - } - - /** - * Sets up create tests with malformed xml. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupCreateWithMalformedXml(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); + protected void setupCreateWithMalformedXml() { + EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST; REQUEST_TYPE = ServiceRequestType.CREATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } /* (non-Javadoc) @@ -190,25 +146,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up create tests with wrong xml schema. - * - * @param testName The name of the test being run. - */ - protected void setupCreateWithWrongXmlSchema(String testName) { - setupCreateWithWrongXmlSchema(testName, LOGGER_NULL); - } - - /** - * Sets up create tests with wrong xml schema. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupCreateWithWrongXmlSchema(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); + protected void setupCreateWithWrongXmlSchema() { + EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST; REQUEST_TYPE = ServiceRequestType.CREATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // --------------------------------------------------------------- @@ -225,25 +167,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up read tests. - * - * @param testName The name of the test being run. - */ - protected void setupRead(String testName) { - setupRead(testName, LOGGER_NULL); - } - - /** - * Sets up read tests. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupRead(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); + protected void setupRead() { + EXPECTED_STATUS_CODE = STATUS_OK; REQUEST_TYPE = ServiceRequestType.READ; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // Failure outcomes @@ -256,25 +184,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up read non existent tests. - * - * @param testName The name of the test being run. - */ - protected void setupReadNonExistent(String testName) { - setupReadNonExistent(testName, LOGGER_NULL); - } - - /** - * Sets up read non existent tests. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupReadNonExistent(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode(); + protected void setupReadNonExistent() { + EXPECTED_STATUS_CODE = STATUS_NOT_FOUND; REQUEST_TYPE = ServiceRequestType.READ; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // --------------------------------------------------------------- @@ -293,25 +207,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up read list tests. - * - * @param testName The name of the test being run. */ - protected void setupReadList(String testName) { - setupReadList(testName, LOGGER_NULL); - } - - /** - * Sets up read list tests. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. - */ - protected void setupReadList(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); + protected void setupReadList() { + EXPECTED_STATUS_CODE = STATUS_OK; REQUEST_TYPE = ServiceRequestType.READ_LIST; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // Failure outcomes @@ -332,25 +232,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up update tests. - * - * @param testName The name of the test being run. - */ - protected void setupUpdate(String testName) { - setupUpdate(testName, LOGGER_NULL); - } - - /** - * Sets up update tests. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupUpdate(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); + protected void setupUpdate() { + EXPECTED_STATUS_CODE = STATUS_OK; REQUEST_TYPE = ServiceRequestType.UPDATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // Failure outcomes @@ -363,25 +249,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up update tests with an empty entity body. - * - * @param testName The name of the test being run. - */ - protected void setupUpdateWithEmptyEntityBody(String testName) { - setupUpdateWithEmptyEntityBody(testName, LOGGER_NULL); - } - - /** - * Sets up update tests with an empty entity body. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupUpdateWithEmptyEntityBody(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); + protected void setupUpdateWithEmptyEntityBody() { + EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST; REQUEST_TYPE = ServiceRequestType.UPDATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } /* (non-Javadoc) @@ -392,25 +264,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up update tests with malformed xml. - * - * @param testName The name of the test being run. - */ - protected void setupUpdateWithMalformedXml(String testName) { - setupUpdateWithMalformedXml(testName, LOGGER_NULL); - } - - /** - * Sets up update tests with malformed xml. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupUpdateWithMalformedXml(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); + protected void setupUpdateWithMalformedXml() { + EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST; REQUEST_TYPE = ServiceRequestType.UPDATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } /* (non-Javadoc) @@ -421,25 +279,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up update tests with wrong xml schema. - * - * @param testName The name of the test being run. */ - protected void setupUpdateWithWrongXmlSchema(String testName) { - setupUpdateWithWrongXmlSchema(testName, LOGGER_NULL); - } - - /** - * Sets up update tests with wrong xml schema. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. - */ - protected void setupUpdateWithWrongXmlSchema(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode(); + protected void setupUpdateWithWrongXmlSchema() { + EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST; REQUEST_TYPE = ServiceRequestType.UPDATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } /* (non-Javadoc) @@ -448,27 +292,14 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements @Override public abstract void updateNonExistent(String testName) throws Exception; - /** - * Sets up update non existent tests. - * - * @param testName The name of the test being run. - */ - protected void setupUpdateNonExistent(String testName) { - setupUpdateNonExistent(testName, LOGGER_NULL); - } /** * Sets up update non existent tests - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupUpdateNonExistent(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode(); + protected void setupUpdateNonExistent() { + EXPECTED_STATUS_CODE = STATUS_NOT_FOUND; REQUEST_TYPE = ServiceRequestType.UPDATE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // --------------------------------------------------------------- @@ -485,25 +316,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up delete tests. - * - * @param testName The name of the test being run. */ - protected void setupDelete(String testName) { - setupDelete(testName, LOGGER_NULL); - } - - /** - * Sets up delete tests. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. - */ - protected void setupDelete(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode(); + protected void setupDelete() { + EXPECTED_STATUS_CODE = STATUS_OK; REQUEST_TYPE = ServiceRequestType.DELETE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // Failure outcomes @@ -516,25 +333,11 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements /** * Sets up delete non existent tests. - * - * @param testName The name of the test being run. - */ - protected void setupDeleteNonExistent(String testName) { - setupDeleteNonExistent(testName, LOGGER_NULL); - } - - /** - * Sets up delete non existent tests. - * - * @param testName The name of the test being run. - * - * @param testLogger The logger to use within the current base class, - * when generating log statements related to that test. */ - protected void setupDeleteNonExistent(String testName, Logger testLogger) { - EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode(); + protected void setupDeleteNonExistent() { + EXPECTED_STATUS_CODE = STATUS_NOT_FOUND; REQUEST_TYPE = ServiceRequestType.DELETE; - testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger); + testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE); } // --------------------------------------------------------------- @@ -669,7 +472,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements dependsOnMethods = {"leafCreate"}) */ public void readPaginatedList(String testName) throws Exception { // Perform setup. - setupReadList(testName); + setupReadList(); CollectionSpaceClient client = this.getClientInstance(); // Get the current total number of items. diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java index 256011ed1..920b63351 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java @@ -89,17 +89,26 @@ public abstract class BaseServiceTest { protected static final String MALFORMED_XML_DATA = XML_DECLARATION + "wrong schema contentswrong schema contents"; /** The null charset. */ - final String NULL_CHARSET = null; + private static final String NULL_CHARSET = null; - protected final static String BANNER_SEPARATOR_LINE = + private static final String BANNER_SEPARATOR_LINE = "==================================================="; - protected final static String BANNER_PREFIX = + private static final String BANNER_PREFIX = "\n" + BANNER_SEPARATOR_LINE + "\n"; - protected final static String BANNER_SUFFIX = + private static final String BANNER_SUFFIX = "\n" + BANNER_SEPARATOR_LINE; + + protected static final int STATUS_BAD_REQUEST = + Response.Status.BAD_REQUEST.getStatusCode(); + protected static final int STATUS_CREATED = + Response.Status.CREATED.getStatusCode(); + protected static final int STATUS_NOT_FOUND = + Response.Status.NOT_FOUND.getStatusCode(); + protected static final int STATUS_OK = + Response.Status.OK.getStatusCode(); /** * Instantiates a new base service test. @@ -160,67 +169,12 @@ public abstract class BaseServiceTest { } /** - * Initializes setup values for a given test, and prints a banner + * Initializes setup values for a given test. Returns a banner * identifying the test being run, using the local logger for this class. * * @param expectedStatusCode A status code expected to be returned in the response. * * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). - * - * @param testName The name of the test being run. - */ - protected void testSetup( - int expectedStatusCode, - ServiceRequestType reqType, - String testName) { - testSetup(expectedStatusCode, reqType, testName, null); - } - - /** - * Initializes setup values for a given test, and prints a banner - * identifying the test being run, using a specified logger. - * - * @param expectedStatusCode A status code expected to be returned in the response. - * - * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). - * - * @param testName The name of the test being run. - * - * @param testLogger An optional logger to use within the current base - * class, when generating log statements related to that test. - * If null, the logger of the current base class will be used. - */ - protected void testSetup( - int expectedStatusCode, - ServiceRequestType reqType, - String testName, - Logger testLogger) { - - testSetup(expectedStatusCode, reqType); - - // Print a banner identifying the test being run. - // - // If an optional logger has been provided, such as by a - // calling class, use that logger to print the banner. - if (testLogger != null) { - if (testLogger.isDebugEnabled()) { - testLogger.debug(testBanner(testName, testLogger)); - } - // Otherwise, use this base class's logger to print the banner. - } else { - testLogger = logger; - if (testLogger.isDebugEnabled()) { - testLogger.debug(testBanner(testName)); - } - } - } - - /** - * Initializes setup values for a given test. - * - * @param expectedStatusCode A status code expected to be returned in the response. - * - * @param serviceRequestType A type of service request (e.g. CREATE, DELETE). */ protected void testSetup( int expectedStatusCode, @@ -582,7 +536,7 @@ public abstract class BaseServiceTest { } /** - * Returns label text inside a test-specific banner. + * Returns a test-specific banner. * * @param testName The name of a test method. * @@ -594,21 +548,6 @@ public abstract class BaseServiceTest { return banner(testName); } - /** - * Returns a test-specific banner. - * - * @param testName The name of a test method. - * - * @param testLogger An optional logger to use within the current base - * class, when generating log statements related to that test. - * - * @return A test-specific banner. - */ - protected static String testBanner(String testName, Logger testLogger) { - String testClass = testLogger.getName(); - return testBanner(testName, testClass); - } - /** * Returns a test-specific banner. * 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 f0f9737e8..d5b42d419 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 @@ -62,14 +62,14 @@ import org.slf4j.LoggerFactory; public class CollectionObjectAuthRefsTest extends BaseServiceTest { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(CollectionObjectAuthRefsTest.class); + private final String CLASS_NAME = CollectionObjectAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. - /** The SERVIC e_ pat h_ component. */ + /** The service path component. */ final String SERVICE_PATH_COMPONENT = "collectionobjects"; - /** The PERSO n_ authorit y_ name. */ + /** The person authority name. */ final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; /** The known resource id. */ @@ -81,12 +81,6 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { /** The person ids created. */ private List personIdsCreated = new ArrayList(); - /** The CREATE d_ status. */ - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - - /** The O k_ status. */ - private int OK_STATUS = Response.Status.OK.getStatusCode(); - /** The person auth csid. */ private String personAuthCSID = null; @@ -102,7 +96,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { /** The inscriber ref name. */ private String inscriberRefName = null; - /** The NU m_ aut h_ ref s_ expected. */ + /** The number of authority references expected. */ private final int NUM_AUTH_REFS_EXPECTED = 4; /* (non-Javadoc) @@ -135,7 +129,10 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -197,7 +194,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); contentOrganizationRefName = PersonAuthorityClientUtils.createPersonRefName( @@ -238,7 +235,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); return extractId(res); } @@ -253,8 +250,11 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest { dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Submit the request to the service and store the response. CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); 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 64e8c70b3..0e1e8c350 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 @@ -59,8 +59,9 @@ import org.slf4j.LoggerFactory; public class CollectionObjectServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(CollectionObjectServiceTest.class); + private final String CLASS_NAME = CollectionObjectServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The known resource id. */ private String knownResourceId = null; @@ -104,10 +105,13 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); @@ -284,7 +288,6 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { @Override @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void createWithMalformedXml(String testName) throws Exception { - setupCreate(testName); } /* (non-Javadoc) @@ -303,25 +306,28 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throwsException { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -329,25 +335,28 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -355,25 +364,28 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -393,7 +405,10 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { */ @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void createWithRequiredValuesNullOrEmpty(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Build a payload with invalid content, by omitting a // field (objectNumber) which must be present, and in which @@ -457,8 +472,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); @@ -502,8 +520,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); @@ -533,8 +554,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); @@ -585,8 +609,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Read an existing resource that will be updated. ClientResponse res = updateRetrieve(testName, knownResourceId); @@ -714,25 +741,28 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -740,25 +770,28 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml() throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - final String entity = MALFORMED_XML_DATA; - String mediaType = MediaType.APPLICATION_XML; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + final String entity = MALFORMED_XML_DATA; + String mediaType = MediaType.APPLICATION_XML; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -766,25 +799,28 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(String testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -796,8 +832,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // @@ -838,8 +877,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read"}) public void updateWithRequiredValuesNullOrEmpty(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); if (logger.isDebugEnabled()) { logger.debug(testName + " got object to update with ID: " + knownResourceId); } @@ -888,8 +931,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); @@ -915,8 +961,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. CollectionObjectClient client = new CollectionObjectClient(); @@ -1154,10 +1203,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { * @throws Exception the exception */ private String createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception { - // Perform setup, such as initializing the type of service request - // (e.g. CREATE, DELETE), its valid and expected status codes, and - // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + + // Perform setup. + setupCreate(); MultipartOutput multipart = null; diff --git a/services/common-test/src/test/java/org/collectionspace/services/client/test/ServiceLayerTest.java b/services/common-test/src/test/java/org/collectionspace/services/client/test/ServiceLayerTest.java index ba7024111..6b8f8b45d 100644 --- a/services/common-test/src/test/java/org/collectionspace/services/client/test/ServiceLayerTest.java +++ b/services/common-test/src/test/java/org/collectionspace/services/client/test/ServiceLayerTest.java @@ -49,7 +49,9 @@ import org.testng.annotations.Test; */ public class ServiceLayerTest { - final Logger logger = LoggerFactory.getLogger(ServiceTest.class); + private final String CLASS_NAME = ServiceLayerTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + private TestServiceClient serviceClient = new TestServiceClient(); private HttpClient httpClient = serviceClient.getHttpClient(); @@ -73,6 +75,10 @@ public class ServiceLayerTest { @Test public void servicesExist() { + + if (logger.isDebugEnabled()) { + logger.debug(BaseServiceTest.testBanner("servicesExist", CLASS_NAME)); + } //use ID service that should always be present in a working service layer String url = serviceClient.getBaseURL() + "idgenerators"; OptionsMethod method = new OptionsMethod(url); @@ -98,6 +104,9 @@ public class ServiceLayerTest { @Test public void methodNotAllowed() { + if (logger.isDebugEnabled()) { + logger.debug(BaseServiceTest.testBanner("methodNotAllowed", CLASS_NAME)); + } // Delete is not allowed on the root URL of the id service String url = serviceClient.getBaseURL() + "idgenerators"; DeleteMethod method = new DeleteMethod(url); @@ -122,6 +131,9 @@ public class ServiceLayerTest { @Test public void nonexistentService() { + if (logger.isDebugEnabled()) { + logger.debug(BaseServiceTest.testBanner("nonexistentService", CLASS_NAME)); + } String url = serviceClient.getBaseURL() + "nonexistent-service"; GetMethod method = new GetMethod(url); try { @@ -145,6 +157,9 @@ public class ServiceLayerTest { // @Test public void serviceSecure() { + if (logger.isDebugEnabled()) { + logger.debug(BaseServiceTest.testBanner("serviceSecure", CLASS_NAME)); + } String url = serviceClient.getBaseURL() + "collectionobjects"; GetMethod method = new GetMethod(url); // This vanilla HTTP client does not contain credentials or any other @@ -174,6 +189,9 @@ public class ServiceLayerTest { @Test public void traceSupported() { + if (logger.isDebugEnabled()) { + logger.debug(BaseServiceTest.testBanner("traceSupported", CLASS_NAME)); + } String url = serviceClient.getBaseURL() + "collectionobjects"; TraceMethod method = new TraceMethod(url); try { @@ -202,6 +220,9 @@ public class ServiceLayerTest { @Test public void headSupported() { + if (logger.isDebugEnabled()) { + logger.debug(BaseServiceTest.testBanner("headSupported", CLASS_NAME)); + } String url = serviceClient.getBaseURL() + "intakes"; HeadMethod method = new HeadMethod(url); try { 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 b3456559d..c5475391b 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 @@ -55,8 +55,8 @@ import org.slf4j.LoggerFactory; */ public class ContactServiceTest extends AbstractServiceTestImpl { - private final Logger logger = - LoggerFactory.getLogger(ContactServiceTest.class); + private final String CLASS_NAME = ContactServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "contacts"; @@ -87,10 +87,13 @@ public class ContactServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. ContactClient client = new ContactClient(); @@ -161,25 +164,28 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(testName, logger); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -187,25 +193,28 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -213,25 +222,28 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(testName, logger); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -244,8 +256,11 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. ContactClient client = new ContactClient(); @@ -273,8 +288,11 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. ContactClient client = new ContactClient(); @@ -300,8 +318,11 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. ContactClient client = new ContactClient(); @@ -348,8 +369,11 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Submit the request to the service and store the response. ContactClient client = new ContactClient(); @@ -431,25 +455,28 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -457,25 +484,28 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -483,25 +513,28 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(testName, logger); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -510,8 +543,11 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -542,8 +578,11 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. ContactClient client = new ContactClient(); @@ -566,8 +605,11 @@ public class ContactServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. ContactClient client = new ContactClient(); 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 39105d7f6..9ed5bdbfd 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,8 +56,9 @@ import org.slf4j.LoggerFactory; public class DimensionServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(DimensionServiceTest.class); + private final String CLASS_NAME = DimensionServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. /** The SERVIC e_ pat h_ component. */ final String SERVICE_PATH_COMPONENT = "dimensions"; @@ -92,10 +93,13 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -178,25 +182,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(testName, logger); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -204,25 +211,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -230,25 +240,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ // --------------------------------------------------------------- @@ -263,8 +276,11 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -295,8 +311,11 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -325,8 +344,11 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -376,8 +398,11 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. DimensionClient client = new DimensionClient(); @@ -464,25 +489,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -490,25 +518,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(testName, logger); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -516,25 +547,28 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(testName, logger); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -546,8 +580,11 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -581,8 +618,11 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -608,8 +648,11 @@ public class DimensionServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); 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 a65370056..44bfb8314 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 @@ -60,8 +60,8 @@ import org.slf4j.LoggerFactory; */ public class IntakeAuthRefsTest extends BaseServiceTest { - private final Logger logger = - LoggerFactory.getLogger(IntakeAuthRefsTest.class); + private final String CLASS_NAME = IntakeAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "intakes"; @@ -69,8 +69,6 @@ public class IntakeAuthRefsTest extends BaseServiceTest { private String knownResourceId = null; private List intakeIdsCreated = new ArrayList(); private List personIdsCreated = new ArrayList(); - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - private int OK_STATUS = Response.Status.OK.getStatusCode(); private String personAuthCSID = null; private String currentOwnerRefName = null; private String depositorRefName = null; @@ -104,7 +102,10 @@ public class IntakeAuthRefsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -165,7 +166,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); currentOwnerRefName = PersonAuthorityClientUtils.createPersonRefName( @@ -208,7 +209,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); return extractId(res); } @@ -217,8 +218,11 @@ public class IntakeAuthRefsTest extends BaseServiceTest { dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Submit the request to the service and store the response. IntakeClient intakeClient = new IntakeClient(); 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 51c7cbcf9..f4be1b5f1 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 @@ -54,11 +54,11 @@ import org.slf4j.LoggerFactory; public class IntakeServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(IntakeServiceTest.class); + private final String CLASS_NAME = IntakeServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. - /** The SERVIC e_ pat h_ component. */ + /** The service path component. */ final String SERVICE_PATH_COMPONENT = "intakes"; /** The known resource id. */ @@ -92,10 +92,13 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); @@ -177,25 +180,28 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -203,25 +209,28 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -229,25 +238,28 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(testName, logger); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -263,8 +275,11 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); @@ -295,8 +310,11 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); @@ -325,8 +343,11 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); @@ -376,8 +397,11 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. IntakeClient client = new IntakeClient(); @@ -465,25 +489,28 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -491,25 +518,28 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -517,25 +547,28 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -547,8 +580,11 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -581,8 +617,11 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); @@ -608,8 +647,11 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. IntakeClient client = new IntakeClient(); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java index 4c7be741e..7a4ecf7bb 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java @@ -61,8 +61,8 @@ import org.slf4j.LoggerFactory; */ public class OrganizationAuthRefDocsTest extends BaseServiceTest { - private final Logger logger = - LoggerFactory.getLogger(OrganizationAuthRefDocsTest.class); + private final String CLASS_NAME = OrganizationAuthRefDocsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "intakes"; @@ -70,8 +70,6 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { private String knownIntakeId = null; private List intakeIdsCreated = new ArrayList(); private List orgIdsCreated = new ArrayList(); - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - private int OK_STATUS = Response.Status.OK.getStatusCode(); private String orgAuthCSID = null; private String currentOwnerOrgCSID = null; private String currentOwnerRefName = null; @@ -106,7 +104,10 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createIntakeWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -173,7 +174,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); orgAuthCSID = extractId(res); currentOwnerRefName = OrgAuthorityClientUtils.createOrganizationRefName( @@ -217,7 +218,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); return extractId(res); } @@ -226,8 +227,11 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest { dependsOnMethods = {"createIntakeWithAuthRefs"}) public void readAndCheckAuthRefDocs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Get the auth ref docs and check them OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java index d327824e2..ae955825e 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java @@ -61,8 +61,8 @@ import org.slf4j.LoggerFactory; */ public class PersonAuthRefDocsTest extends BaseServiceTest { - private final Logger logger = - LoggerFactory.getLogger(PersonAuthRefDocsTest.class); + private final String CLASS_NAME = PersonAuthRefDocsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "intakes"; @@ -70,8 +70,6 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { private String knownIntakeId = null; private List intakeIdsCreated = new ArrayList(); private List personIdsCreated = new ArrayList(); - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - private int OK_STATUS = Response.Status.OK.getStatusCode(); private String personAuthCSID = null; private String currentOwnerPersonCSID = null; private String currentOwnerRefName = null; @@ -106,7 +104,10 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createIntakeWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -173,7 +174,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); currentOwnerRefName = PersonAuthorityClientUtils.createPersonRefName( @@ -217,7 +218,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); return extractId(res); } @@ -226,8 +227,11 @@ public class PersonAuthRefDocsTest extends BaseServiceTest { dependsOnMethods = {"createIntakeWithAuthRefs"}) public void readAndCheckAuthRefDocs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Get the auth ref docs and check them PersonAuthorityClient personAuthClient = new PersonAuthorityClient(); 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 5b8fa9c38..3c80b2478 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 @@ -62,17 +62,15 @@ import org.slf4j.LoggerFactory; */ public class LoaninAuthRefsTest extends BaseServiceTest { - private final Logger logger = - LoggerFactory.getLogger(LoaninAuthRefsTest.class); - + private final String CLASS_NAME = LoaninAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "loansin"; final String PERSON_AUTHORITY_NAME = "TestPersonAuth"; private String knownResourceId = null; private List loaninIdsCreated = new ArrayList(); private List personIdsCreated = new ArrayList(); - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - private int OK_STATUS = Response.Status.OK.getStatusCode(); private String personAuthCSID = null; private String lendersAuthorizerRefName = null; private String lendersContactRefName = null; @@ -105,7 +103,10 @@ public class LoaninAuthRefsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -171,7 +172,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); // Create temporary Person resources, and their corresponding refNames @@ -207,7 +208,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); return extractId(res); } @@ -216,8 +217,11 @@ public class LoaninAuthRefsTest extends BaseServiceTest { dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Submit the request to the service and store the response. LoaninClient loaninClient = new LoaninClient(); 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 2b79afaea..29fcb4a3b 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 @@ -55,11 +55,11 @@ import org.slf4j.LoggerFactory; public class LoaninServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(LoaninServiceTest.class); + private final String CLASS_NAME = LoaninServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. - /** The SERVIC e_ pat h_ component. */ + /** The service path component. */ final String SERVICE_PATH_COMPONENT = "loansin"; /** The known resource id. */ @@ -93,10 +93,13 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); @@ -184,25 +187,28 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -210,25 +216,28 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(testName, logger); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -236,25 +245,28 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(testName, logger); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -269,8 +281,12 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. MultipartInput input = null; @@ -307,8 +323,11 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); @@ -340,8 +359,12 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. LoansinCommonList list = null; @@ -396,8 +419,11 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. MultipartInput input = null; @@ -494,25 +520,28 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -520,25 +549,28 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -546,25 +578,28 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -576,8 +611,11 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -614,8 +652,11 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); @@ -644,8 +685,12 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. LoaninClient client = new LoaninClient(); diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java index c7cdde9f9..6b95b3ad3 100644 --- a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java +++ b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java @@ -62,8 +62,8 @@ import org.slf4j.LoggerFactory; */ public class LoanoutAuthRefsTest extends BaseServiceTest { - private final Logger logger = - LoggerFactory.getLogger(LoanoutAuthRefsTest.class); + private final String CLASS_NAME = LoanoutAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "loansout"; @@ -71,8 +71,6 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { private String knownResourceId = null; private List loanoutIdsCreated = new ArrayList(); private List personIdsCreated = new ArrayList(); - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - private int OK_STATUS = Response.Status.OK.getStatusCode(); private String personAuthCSID = null; private String borrowersContactRefName = null; private String lendersAuthorizerRefName = null; @@ -107,7 +105,10 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -170,7 +171,7 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); // Create temporary Person resources, and their corresponding refNames @@ -201,7 +202,7 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); return extractId(res); } @@ -210,8 +211,11 @@ public class LoanoutAuthRefsTest extends BaseServiceTest { dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Submit the request to the service and store the response. LoanoutClient loanoutClient = new LoanoutClient(); diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java index a951341e5..22d065384 100644 --- a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java +++ b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java @@ -53,11 +53,11 @@ import org.slf4j.LoggerFactory; public class LoanoutServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(LoanoutServiceTest.class); + private final String CLASS_NAME = LoanoutServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. - /** The SERVIC e_ pat h_ component. */ + /** The service path component. */ final String SERVICE_PATH_COMPONENT = "loansout"; /** The known resource id. */ @@ -91,10 +91,13 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. LoanoutClient client = new LoanoutClient(); @@ -176,25 +179,28 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -202,25 +208,28 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -228,25 +237,28 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -262,8 +274,11 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. LoanoutClient client = new LoanoutClient(); @@ -294,8 +309,11 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. LoanoutClient client = new LoanoutClient(); @@ -324,8 +342,11 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. LoanoutClient client = new LoanoutClient(); @@ -375,8 +396,11 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. LoanoutClient client = new LoanoutClient(); @@ -463,25 +487,28 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -489,25 +516,28 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -515,25 +545,28 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -545,8 +578,11 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -579,8 +615,11 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. LoanoutClient client = new LoanoutClient(); @@ -606,8 +645,11 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. LoanoutClient client = new LoanoutClient(); diff --git a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java index c7aa0dd04..34759a91f 100644 --- a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java +++ b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java @@ -62,17 +62,18 @@ import org.testng.annotations.Test; public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(LocationAuthorityServiceTest.class); + private final String CLASS_NAME = LocationAuthorityServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. + /** The SERVICE path component. */ final String SERVICE_PATH_COMPONENT = "locationauthorities"; - /** The ITEM servicE path component. */ + /** The ITEM service path component. */ final String ITEM_SERVICE_PATH_COMPONENT = "items"; - /** The CONTACT servicE path component. */ + /** The CONTACT service path component. */ final String CONTACT_SERVICE_PATH_COMPONENT = "contacts"; /** The TEST name. */ @@ -152,10 +153,13 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"create"}) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -209,7 +213,10 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"create"}, dependsOnMethods = {"create"}) public void createItem(String testName) { - setupCreate(testName); + if(logger.isDebugEnabled()){ + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); String newID = createItemInAuthority(knownResourceId, knownResourceRefName); } @@ -224,7 +231,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { final String testName = "createItemInAuthority"; if(logger.isDebugEnabled()){ - logger.debug(testName + ":..."); + logger.debug(testBanner(testName, CLASS_NAME)); } // Submit the request to the service and store the response. @@ -343,8 +350,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnGroups = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -380,8 +390,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnGroups = {"create"}) public void readByName(String testName) throws Exception { - // Perform setup. - setupRead(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupRead(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -418,8 +431,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"read"}) public void readItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -459,8 +475,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"readItem", "updateItem"}) public void verifyItemDisplayName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -569,8 +588,12 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"verifyItemDisplayName"}) public void verifyIllegalItemDisplayName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateWithWrongXmlSchema(testName); + // FIXME: create a setup configuration for this operation. + setupUpdateWithWrongXmlSchema(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -621,8 +644,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"read"}) public void readNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -648,8 +674,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"readItem"}) public void readItemNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -680,8 +709,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"readList"}, dependsOnGroups = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -723,6 +755,10 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { */ @Test(groups = {"readList"}, dependsOnMethods = {"readList"}) public void readItemList() { + String testName = "readItemList"; + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } readItemList(knownResourceId, null); } @@ -731,6 +767,10 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { */ @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"}) public void readItemListByAuthorityName() { + String testName = "readItemListByAuthorityName"; + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } readItemList(null, knownResourceDisplayName); } @@ -742,12 +782,12 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { */ private void readItemList(String vcsid, String name) { - final String testName = "readItemList"; + String testName = "readItemList"; // Perform setup. - setupReadList(testName); + setupReadList(); - // Submit the request to the service and store the response. + // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); ClientResponse res = null; if(vcsid!= null) { @@ -821,8 +861,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnGroups = {"read", "readList"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -887,8 +930,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update"}) public void updateItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -978,8 +1024,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID(s) used when creating the request payload may be arbitrary. @@ -1013,8 +1062,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"}) public void updateNonExistentItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -1061,8 +1113,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"}) public void deleteItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId + @@ -1092,8 +1147,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId); @@ -1123,8 +1181,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); @@ -1150,8 +1211,11 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void deleteNonExistentItem(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java index 442c928dd..a58dc1a6b 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java @@ -62,8 +62,8 @@ import org.slf4j.LoggerFactory; */ public class MovementAuthRefsTest extends BaseServiceTest { - private final Logger logger = - LoggerFactory.getLogger(MovementAuthRefsTest.class); + private final String CLASS_NAME = MovementAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "movements"; @@ -71,8 +71,6 @@ public class MovementAuthRefsTest extends BaseServiceTest { private String knownResourceId = null; private List movementIdsCreated = new ArrayList(); private List personIdsCreated = new ArrayList(); - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - private int OK_STATUS = Response.Status.OK.getStatusCode(); private String personAuthCSID = null; private String movementContactRefName = null; @@ -105,7 +103,10 @@ public class MovementAuthRefsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Submit the request to the service and store the response. String identifier = createIdentifier(); @@ -166,7 +167,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); // Create temporary Person resources, and their corresponding refNames @@ -189,7 +190,7 @@ public class MovementAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); return extractId(res); } @@ -198,8 +199,11 @@ public class MovementAuthRefsTest extends BaseServiceTest { dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Submit the request to the service and store the response. MovementClient movementClient = new MovementClient(); diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java index 01854c2af..ff4a9994b 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java @@ -54,8 +54,8 @@ import org.slf4j.LoggerFactory; public class MovementServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(MovementServiceTest.class); + private final String CLASS_NAME = MovementServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. /** The service path component. */ @@ -92,10 +92,13 @@ public class MovementServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. MovementClient client = new MovementClient(); @@ -177,25 +180,28 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -203,25 +209,28 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -229,25 +238,28 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -263,8 +275,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. MovementClient client = new MovementClient(); @@ -295,8 +310,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. MovementClient client = new MovementClient(); @@ -325,8 +343,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. MovementClient client = new MovementClient(); @@ -376,8 +397,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. MovementClient client = new MovementClient(); @@ -464,25 +488,28 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -490,25 +517,28 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -516,25 +546,28 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -546,8 +579,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -580,8 +616,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. MovementClient client = new MovementClient(); @@ -607,8 +646,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. MovementClient client = new MovementClient(); @@ -687,8 +729,14 @@ public class MovementServiceTest extends AbstractServiceTestImpl { private MultipartOutput createMovementInstance(String movementReferenceNumber, String locationDate) { MovementsCommon movement = new MovementsCommon(); - movement.setMovementReferenceNumber(movementReferenceNumber); + // FIXME: Values of currentLocation, normalLocation, + // and movementContact should be refNames. + movement.setCurrentLocation("currentLocation value"); + movement.setCurrentLocationFitness("currentLocationFitness value"); + movement.setCurrentLocationNote("currentLocationNote value"); movement.setLocationDate(locationDate); + movement.setNormalLocation("normalLocation value"); + movement.setMovementContact("movementContact value"); MovementMethodsList movementMethodsList = new MovementMethodsList(); List methods = movementMethodsList.getMovementMethod(); // @TODO Use properly formatted refNames for representative movement @@ -697,6 +745,11 @@ public class MovementServiceTest extends AbstractServiceTestImpl { methods.add("First Movement Method-" + identifier); methods.add("Second Movement Method-" + identifier); movement.setMovementMethods(movementMethodsList); + movement.setMovementNote("movementNote value"); + movement.setMovementReferenceNumber(movementReferenceNumber); + movement.setPlannedRemovalDate("plannedRemovalDate value"); + movement.setRemovalDate("removalDate value"); + movement.setReasonForMove("reasonForMove value"); MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(movement, MediaType.APPLICATION_XML_TYPE); diff --git a/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java b/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java index e610d00db..427bf6fab 100644 --- a/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java +++ b/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java @@ -55,8 +55,8 @@ import org.slf4j.LoggerFactory; */ public class NoteServiceTest extends AbstractServiceTestImpl { - private final Logger logger = - LoggerFactory.getLogger(NoteServiceTest.class); + private final String CLASS_NAME = NoteServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "notes"; @@ -87,10 +87,13 @@ public class NoteServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. NoteClient client = new NoteClient(); @@ -166,8 +169,11 @@ public class NoteServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. NoteClient client = new NoteClient(); @@ -195,8 +201,11 @@ public class NoteServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. NoteClient client = new NoteClient(); @@ -222,8 +231,11 @@ public class NoteServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. NoteClient client = new NoteClient(); @@ -270,8 +282,11 @@ public class NoteServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Submit the request to the service and store the response. NoteClient client = new NoteClient(); @@ -352,8 +367,11 @@ public class NoteServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -384,8 +402,11 @@ public class NoteServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. NoteClient client = new NoteClient(); @@ -407,9 +428,12 @@ public class NoteServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { - + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. NoteClient client = new NoteClient(); diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java index 419339942..d9404fd9b 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java @@ -61,8 +61,8 @@ import org.slf4j.LoggerFactory; public class OrgAuthorityAuthRefsTest extends BaseServiceTest { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(OrgAuthorityAuthRefsTest.class); + private final String CLASS_NAME = OrgAuthorityAuthRefsTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. /** The SERVIC e_ pat h_ component. */ @@ -90,19 +90,13 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { /** The person ids created. */ private List personIdsCreated = new ArrayList(); - /** The CREATE d_ status. */ - private int CREATED_STATUS = Response.Status.CREATED.getStatusCode(); - - /** The O k_ status. */ - private int OK_STATUS = Response.Status.OK.getStatusCode(); - /** The person auth csid. */ private String personAuthCSID = null; /** The organization contact person ref name. */ private String organizationContactPersonRefName = null; - /** The NU m_ aut h_ ref s_ expected. */ + /** The number of authorityreferences expected. */ private final int NUM_AUTH_REFS_EXPECTED = 1; /* (non-Javadoc) @@ -135,7 +129,10 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void createWithAuthRefs(String testName) throws Exception { - testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + testSetup(STATUS_CREATED, ServiceRequestType.CREATE); // Create a new Organization Authority resource. OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); @@ -216,7 +213,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { int statusCode = res.getStatus(); Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); personAuthCSID = extractId(res); } finally { res.releaseConnection(); @@ -254,7 +251,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, CREATED_STATUS); + Assert.assertEquals(statusCode, STATUS_CREATED); result = extractId(res); } finally { res.releaseConnection(); @@ -274,8 +271,11 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest { dependsOnMethods = {"createWithAuthRefs"}) public void readAndCheckAuthRefs(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - testSetup(OK_STATUS, ServiceRequestType.READ,testName); + testSetup(STATUS_OK, ServiceRequestType.READ); // Submit the request to the service and store the response. OrgAuthorityClient orgAuthClient = new OrgAuthorityClient(); 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 da318a55f..f5d384b60 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 @@ -62,23 +62,23 @@ import org.testng.annotations.Test; public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(OrgAuthorityServiceTest.class); + private final String CLASS_NAME = OrgAuthorityServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. - /** The SERVIC e_ pat h_ component. */ + /** The service path component. */ final String SERVICE_PATH_COMPONENT = "orgauthorities"; - /** The ITE m_ servic e_ pat h_ component. */ + /** The item service path component. */ final String ITEM_SERVICE_PATH_COMPONENT = "items"; - /** The CONTAC t_ servic e_ pat h_ component. */ + /** The contact service path component. */ final String CONTACT_SERVICE_PATH_COMPONENT = "contacts"; - /** The TES t_ or g_ shortname. */ + /** The test organization shortname. */ private final String TEST_ORG_SHORTNAME = "Test Org"; - /** The TES t_ or g_ foundin g_ place. */ + /** The test organization founding place. */ private final String TEST_ORG_FOUNDING_PLACE = "Anytown, USA"; /** The known resource id. */ @@ -136,10 +136,13 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"create"}) public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -199,7 +202,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"create"}, dependsOnMethods = {"create"}) public void createItem(String testName) { - setupCreate(testName); + setupCreate(); String newID = createItemInAuthority(knownResourceId, knownResourceRefName); } @@ -255,7 +258,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"create"}, dependsOnMethods = {"createItem"}) public void createContact(String testName) { - setupCreate(testName); + setupCreate(); String newID = createContactInItem(knownResourceId, knownItemResourceId); } @@ -269,10 +272,10 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { private String createContactInItem(String parentcsid, String itemcsid) { final String testName = "createContactInItem"; - setupCreate(testName); - if(logger.isDebugEnabled()){ - logger.debug(testName + ":..."); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); } + setupCreate(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -351,51 +354,57 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()) { - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()) { + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -403,25 +412,28 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -483,8 +495,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnGroups = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -524,8 +539,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnGroups = {"create"}) public void readByName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -560,8 +578,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"read"}) public void readByName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. ClientResponse res = client.read(knownResourceId); @@ -597,8 +618,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"read"}) public void readItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -642,8 +666,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"readItem", "updateItem"}) public void verifyItemDisplayName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -770,8 +797,12 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"verifyItemDisplayName"}) public void verifyIllegalItemDisplayName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateWithWrongXmlSchema(testName); + testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE); + // setupUpdateWithWrongXmlSchema(testName, logger); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -822,8 +853,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"readItem"}) public void readContact(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -865,8 +899,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"read"}) public void readNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -892,8 +929,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"readItem"}) public void readItemNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -919,8 +959,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"readContact"}) public void readContactNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -951,8 +994,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"readList"}, dependsOnGroups = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1015,8 +1061,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { final String testName = "readItemList"; + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1093,8 +1142,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { private void readContactList(String parentcsid, String itemcsid) { final String testName = "readContactList"; + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1159,8 +1211,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnGroups = {"read", "readList"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1225,8 +1280,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update"}) public void updateItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1294,8 +1352,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"updateItem"}) public void updateContact(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1386,25 +1447,28 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -1412,51 +1476,54 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - } + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); - @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, - groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) - public void updateWithWrongXmlSchema(String testName) throws Exception { + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("updateWithWrongXmlSchema: url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) + public void updateWithWrongXmlSchema(String testName) throws Exception { + + // Perform setup. + setupUpdateWithWrongXmlSchema(testName, logger); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("updateWithWrongXmlSchema: url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -1468,8 +1535,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -1500,8 +1570,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"}) public void updateNonExistentItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID(s) used when creating the request payload may be arbitrary. @@ -1558,8 +1631,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"}) public void deleteContact(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId + @@ -1593,8 +1669,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteContact"}) public void deleteItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId + @@ -1624,8 +1703,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId); @@ -1655,8 +1737,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1682,8 +1767,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void deleteNonExistentItem(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); @@ -1709,8 +1797,11 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteContact"}) public void deleteNonExistentContact(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java index e443935cf..869795cf6 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java @@ -52,8 +52,9 @@ import org.testng.annotations.Test; */ public class PersonAuthoritySearchTest extends BaseServiceTest { - static final Logger logger = LoggerFactory.getLogger(PersonAuthoritySearchTest.class); - + private final String CLASS_NAME = PersonAuthoritySearchTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + /** The service path component. */ final String SERVICE_PATH_COMPONENT = "personauthorities"; @@ -166,7 +167,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { groups = {"readListByPartialTerm"}) public void partialTermMatch(String testName) { if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, logger)); + logger.debug(testBanner(testName, CLASS_NAME)); } int numMatchesFound = 0; String partialTerm = getPartialTerm(); @@ -190,7 +191,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"}) public void partialTermMatchCaseInsensitiveLowerCase(String testName) { if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, logger)); + logger.debug(testBanner(testName, CLASS_NAME)); } int numMatchesFound = 0; @@ -216,7 +217,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"}) public void partialTermMatchCaseInsensitiveUpperCase(String testName) { if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, logger)); + logger.debug(testBanner(testName, CLASS_NAME)); } int numMatchesFound = 0; @@ -241,7 +242,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"}) public void partialTermMatchMinimumLength(String testName) { if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, logger)); + logger.debug(testBanner(testName, CLASS_NAME)); } int numMatchesFound = 0; String partialTerm = getPartialTermMinimumLength(); @@ -268,7 +269,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"}) public void partialTermMatchUTF8(String testName) { if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, logger)); + logger.debug(testBanner(testName, CLASS_NAME)); } int numMatchesFound = 0; String partialTerm = getPartialTermUtf8(); @@ -295,7 +296,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"}) public void partialTermMatchOnNonexistentTerm(String testName) { if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, logger)); + logger.debug(testBanner(testName, CLASS_NAME)); } int numMatchesFound = 0; int ZERO_MATCHES_EXPECTED = 0; @@ -322,13 +323,14 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { */ private int readItemListByPartialTerm(String authorityCsid, String partialTerm) { + String testName = "readItemListByPartialTerm"; + // Perform setup. int expectedStatusCode = Response.Status.OK.getStatusCode(); ServiceRequestType requestType = ServiceRequestType.READ_LIST; - String testName = "readItemListByPartialTerm"; - testSetup(expectedStatusCode, requestType, testName, logger); + testSetup(expectedStatusCode, requestType); - // Submit the request to the service and store the response. + // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); ClientResponse res = null; if (authorityCsid != null) { @@ -423,11 +425,12 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { public void createAuthority() throws Exception { + String testName = "createAuthority"; + // Perform setup. int expectedStatusCode = Response.Status.CREATED.getStatusCode(); ServiceRequestType requestType = ServiceRequestType.CREATE; - String testName = "createPersonAuthority"; - testSetup(expectedStatusCode, requestType, testName, logger); + testSetup(expectedStatusCode, requestType); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -443,6 +446,11 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { ClientResponse res = client.create(multipart); try { int statusCode = res.getStatus(); + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": status = " + statusCode); + } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE); @@ -473,11 +481,12 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { */ private void createItemInAuthorityForPartialTermMatch(String authorityCsid, String authRefName) throws Exception { + + String testName = "createItemInAuthorityForPartialTermMatch"; int expectedStatusCode = Response.Status.CREATED.getStatusCode(); ServiceRequestType requestType = ServiceRequestType.CREATE; - String testName = "createItemInAuthorityForPartialTermMatch"; - testSetup(expectedStatusCode, requestType, testName); + testSetup(expectedStatusCode, requestType); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); 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 0b1da65d6..ebcb15414 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 @@ -61,8 +61,8 @@ import org.testng.annotations.Test; public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(PersonAuthorityServiceTest.class); + private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. /** The service path component. */ @@ -146,11 +146,14 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"create"}) public void create(String testName) throws Exception { - + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -209,7 +212,10 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"create"}, dependsOnMethods = {"create"}) public void createItem(String testName) { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); String newID = createItemInAuthority(knownResourceId, knownResourceRefName); } @@ -296,7 +302,10 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"create"}, dependsOnMethods = {"createItem"}) public void createContact(String testName) { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); String newID = createContactInItem(knownResourceId, knownItemResourceId); } @@ -310,10 +319,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { private String createContactInItem(String parentcsid, String itemcsid) { final String testName = "createContactInItem"; - setupCreate(testName); if(logger.isDebugEnabled()){ logger.debug(testName + ":..."); } + + setupCreate(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -392,25 +402,28 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()) { - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()) { + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -418,25 +431,28 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -444,25 +460,28 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"create"}, dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -477,6 +496,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"createList"}, dependsOnGroups = {"create"}) public void createList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } for (int i = 0; i < nItemsToCreateInList; i++) { create(testName); } @@ -491,6 +513,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"createList"}, dependsOnMethods = {"createList"}) public void createItemList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Add items to the initially-created, known parent record. for (int j = 0; j < nItemsToCreateInList; j++) { createItem(testName); @@ -524,8 +549,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnGroups = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -564,8 +592,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnGroups = {"create"}) public void readByName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -599,6 +630,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"read"}) public void readByName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. setupRead(); @@ -635,8 +669,12 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"read"}, dependsOnMethods = {"read"}) public void readItem(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -678,8 +716,12 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, dependsOnMethods = {"readItem", "updateItem"}) public void verifyItemDisplayName(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -808,8 +850,12 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"verifyItemDisplayName"}) public void verifyIllegalItemDisplayName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateWithWrongXmlSchema(testName); + testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE); + // setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -869,8 +915,12 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"read"}, dependsOnMethods = {"readItem"}) public void readContact(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -918,8 +968,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"read"}) public void readNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -948,8 +1001,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"readItem"}) public void readItemNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -979,8 +1035,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"read"}, dependsOnMethods = {"readContact"}) public void readContactNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1015,8 +1074,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"readList"}, dependsOnGroups = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1086,7 +1148,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { final String testName = "readItemList"; // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1170,7 +1232,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { final String testName = "readContactList"; // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1242,8 +1304,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnGroups = {"read", "readList", "readListByPartialTerm"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1318,8 +1383,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update"}) public void updateItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1407,8 +1475,12 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, groups = {"update"}, dependsOnMethods = {"updateItem"}) public void updateContact(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1509,25 +1581,28 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(testName, logger); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -1535,25 +1610,28 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -1561,25 +1639,28 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("updateWithWrongXmlSchema: url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("updateWithWrongXmlSchema: url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -1591,14 +1672,17 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // 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. PersonAuthorityClient client = new PersonAuthorityClient(); - String displayName = "displayName-NON_EXISTENT_ID"; + String displayName = "displayName-NON_EXISTENT_ID"; String fullRefName = PersonAuthorityClientUtils.createPersonAuthRefName(displayName, true); MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( displayName, fullRefName, client.getCommonPartName()); @@ -1630,8 +1714,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"}) public void updateNonExistentItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -1693,8 +1780,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"}) public void deleteContact(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId + @@ -1729,8 +1819,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteContact"}) public void deleteItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId + @@ -1761,8 +1854,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); if(logger.isDebugEnabled()){ logger.debug("parentcsid =" + knownResourceId); @@ -1793,8 +1889,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1821,8 +1920,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteItem"}) public void deleteNonExistentItem(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); @@ -1849,8 +1951,11 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { groups = {"delete"}, dependsOnMethods = {"deleteContact"}) public void deleteNonExistentContact(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); 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 8f82cc420..b06af7614 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 @@ -54,10 +54,10 @@ import org.slf4j.LoggerFactory; public class RelationServiceTest extends AbstractServiceTestImpl { /** The logger. */ - private final Logger logger = - LoggerFactory.getLogger(RelationServiceTest.class); + private final String CLASS_NAME = RelationServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); - /** The SERVIC e_ pat h_ component. */ + /** The SERVICE path component. */ final String SERVICE_PATH_COMPONENT = "relations"; /** The known resource id. */ @@ -91,10 +91,13 @@ public class RelationServiceTest extends AbstractServiceTestImpl { @Override public void create(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. RelationClient client = new RelationClient(); @@ -174,25 +177,28 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -200,25 +206,28 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -226,25 +235,28 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -260,8 +272,11 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. RelationClient client = new RelationClient(); @@ -294,8 +309,11 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. RelationClient client = new RelationClient(); @@ -324,8 +342,11 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. RelationClient client = new RelationClient(); @@ -375,8 +396,11 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve an existing resource that we can update. RelationClient client = new RelationClient(); @@ -471,25 +495,28 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -497,25 +524,28 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from abstract base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from abstract base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -523,25 +553,28 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; // Constant from abstract base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; // Constant from abstract base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -553,8 +586,11 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -587,8 +623,11 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. RelationClient client = new RelationClient(); @@ -614,8 +653,11 @@ public class RelationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. RelationClient client = new RelationClient(); @@ -653,8 +695,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { @Test(dependsOnMethods = {"create", "read"}) public void testSubmitRequest() { - // Expected status code: 200 OK - final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); + setupRead(); // Submit the request to the service and store the response. String method = ServiceRequestType.READ.httpMethodName(); @@ -667,7 +708,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl { logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode); } - Assert.assertEquals(statusCode, EXPECTED_STATUS); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } // --------------------------------------------------------------- diff --git a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java index 72bc9429a..9e3d0b1bf 100644 --- a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java +++ b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java @@ -62,9 +62,11 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { private String knownResourceId = null; private String barneyAccountId = null; //active private String georgeAccountId = null; //inactive + /** The logger. */ - final Logger logger = LoggerFactory.getLogger(AuthenticationServiceTest.class); - + private final String CLASS_NAME = AuthenticationServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTest#getServicePathComponent() */ @@ -100,10 +102,15 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void createActiveAccount(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); + AccountClient accountClient = new AccountClient(); accountClient.setAuth(true, "test", true, "test", true); @@ -132,10 +139,13 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void createInactiveAccount(String testName) throws Exception { - // Perform setup, such as initializing the type of service request - // (e.g. CREATE, DELETE), its valid and expected status codes, and - // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreate(); + AccountClient accountClient = new AccountClient(); accountClient.setAuth(true, "test", true, "test", true); @@ -160,7 +170,7 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { } res.releaseConnection(); //deactivate - setupUpdate(testName); + setupUpdate(); account.setStatus(Status.INACTIVE); if (logger.isDebugEnabled()) { logger.debug(testName + ":updated object"); @@ -189,7 +199,10 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createActiveAccount"}) @Override public void create(String testName) { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(true, "barney", true, "barney08", true); String identifier = BaseServiceTest.createIdentifier(); @@ -214,7 +227,10 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createActiveAccount"}) public void createWithoutAuthn(String testName) { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(false, "test", true, "test", true); String identifier = BaseServiceTest.createIdentifier(); @@ -233,7 +249,9 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dependsOnMethods = {"createInactiveAccount"}) public void createWithInactiveAccount(String testName) { - banner(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName)); + } CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(true, "george", true, "george08", true); String identifier = BaseServiceTest.createIdentifier(); @@ -255,7 +273,9 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { */ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"}) public void createWithoutPassword(String testName) { - banner(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName)); + } CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(true, "test", true, "", false); String identifier = BaseServiceTest.createIdentifier(); @@ -274,7 +294,9 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { */ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"}) public void createWithUnknownUser(String testName) { - banner(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName)); + } CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(true, "foo", true, "bar", true); String identifier = BaseServiceTest.createIdentifier(); @@ -293,7 +315,9 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { */ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"}) public void createWithIncorrectPassword(String testName) { - banner(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName)); + } CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(true, "test", true, "bar", true); String identifier = BaseServiceTest.createIdentifier(); @@ -312,7 +336,9 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { */ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"}) public void createWithIncorrectUserPassword(String testName) { - banner(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName)); + } CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(true, "foo", true, "bar", true); String identifier = BaseServiceTest.createIdentifier(); @@ -332,7 +358,9 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { */ @Test(dataProvider = "testName", dependsOnMethods = {"createActiveAccount"}) public void createWithoutTenant(String testName) { - banner(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName)); + } CollectionObjectClient collectionObjectClient = new CollectionObjectClient(); collectionObjectClient.setAuth(true, "babybop", true, "babybop09", true); String identifier = BaseServiceTest.createIdentifier(); @@ -354,7 +382,7 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"}) public void delete(String testName) { - setupDelete(testName); + setupDelete(); } @@ -362,8 +390,11 @@ public class AuthenticationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "createWithInactiveAccount"}) public void deleteAccounts(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); AccountClient accountClient = new AccountClient(); accountClient.setAuth(true, "test", true, "test", true); // Submit the request to the service and store the response. diff --git a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java index fa9242a64..c537834f6 100644 --- a/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java +++ b/services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java @@ -88,8 +88,9 @@ import org.testng.annotations.BeforeClass; */ public class AuthorizationServiceTest extends AbstractServiceTestImpl { - static private final Logger logger = - LoggerFactory.getLogger(AuthorizationServiceTest.class); + private final String CLASS_NAME = AuthorizationServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + // Instance variables specific to this test. private String knownResourceId = null; private List allResourceIdsCreated = new ArrayList(); @@ -242,7 +243,10 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { @Override @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { - setupCreate(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupCreate(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -302,8 +306,11 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -334,7 +341,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { public void readNonExistent(String testName) throws Exception { // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); } // --------------------------------------------------------------- @@ -345,7 +352,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { - setupReadList(testName); + setupReadList(); } // Failure outcomes @@ -358,14 +365,18 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read", "readList", "readNonExistent"}) public void update(String testName) throws Exception { - setupUpdate(testName); + setupUpdate(); } @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"read", "readList", "readNonExistent"}) public void updateNotAllowed(String testName) throws Exception { - setupUpdate(testName); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + setupUpdate(); DimensionClient client = new DimensionClient(); @@ -421,8 +432,12 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"updateNotAllowed"}) public void deleteNotAllowed(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -446,8 +461,12 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"deleteNotAllowed"}) public void delete(String testName) throws Exception { + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. DimensionClient client = new DimensionClient(); @@ -491,7 +510,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- @AfterClass(alwaysRun = true) public void cleanUp() { - setupDelete("cleanup"); + setupDelete(); String noTest = System.getProperty("noTestCleanup"); if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { if (logger.isDebugEnabled()) { @@ -521,7 +540,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { private String createPermission(String resName, List actions, EffectType effect) { - setupCreate("createPermission"); + setupCreate(); PermissionClient permClient = new PermissionClient(); Permission permission = PermissionFactory.createPermissionInstance(resName, "default permissions for " + resName, @@ -540,7 +559,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { } private void deletePermission(String permId) { - setupDelete("deletePermission"); + setupDelete(); PermissionClient permClient = new PermissionClient(); ClientResponse res = permClient.delete(permId); int statusCode = res.getStatus(); @@ -555,7 +574,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { } private String createRole(String roleName) { - setupCreate("createRole"); + setupCreate(); RoleClient roleClient = new RoleClient(); Role role = RoleFactory.createRoleInstance(roleName, @@ -574,7 +593,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { } private void deleteRole(String roleId) { - setupDelete("deleteRole"); + setupDelete(); RoleClient roleClient = new RoleClient(); ClientResponse res = roleClient.delete(roleId); int statusCode = res.getStatus(); @@ -589,7 +608,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { } private String createAccount(String userName, String email) { - setupCreate("createAccount"); + setupCreate(); AccountClient accClient = new AccountClient(); AccountsCommon account = AccountFactory.createAccountInstance( userName, userName, userName, email, @@ -608,7 +627,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { } private void deleteAccount(String accId) { - setupDelete("deleteAccount"); + setupDelete(); AccountClient accClient = new AccountClient(); ClientResponse res = accClient.delete(accId); int statusCode = res.getStatus(); @@ -624,7 +643,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { private String createAccountRole(AccountValue av, Collection rvs) { - setupCreate("createAccountRole"); + setupCreate(); // Submit the request to the service and store the response. AccountRole accRole = AccountRoleFactory.createAccountRoleInstance( @@ -645,7 +664,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { private void deleteAccountRole(String screenName) { // Perform setup. - setupDelete("deleteAccountRole"); + setupDelete(); // Submit the request to the service and store the response. AccountRoleClient client = new AccountRoleClient(); @@ -666,7 +685,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { private String createPermissionRole(PermissionValue pv, Collection rvs) { - setupCreate("createPermissionRole"); + setupCreate(); List rvls = new ArrayList(); rvls.addAll(rvs); PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance( @@ -688,7 +707,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl { private void deletePermissionRole(String permId) { // Perform setup. - setupDelete("deletePermissionRole"); + setupDelete(); // Submit the request to the service and store the response. PermissionRoleClient client = new PermissionRoleClient(); 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 7fc7e720e..befc9d016 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 @@ -58,8 +58,8 @@ import org.testng.annotations.Test; */ public class VocabularyServiceTest extends AbstractServiceTestImpl { - private final Logger logger = - LoggerFactory.getLogger(VocabularyServiceTest.class); + private final String CLASS_NAME = VocabularyServiceTest.class.getName(); + private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); // Instance variables specific to this test. final String SERVICE_PATH_COMPONENT = "vocabularies"; @@ -101,11 +101,14 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) public void create(String testName) throws Exception { - + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup, such as initializing the type of service request // (e.g. CREATE, DELETE), its valid and expected status codes, and // its associated HTTP method name (e.g. POST, DELETE). - setupCreate(testName); + setupCreate(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -148,8 +151,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void createItem(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupCreate(testName); + setupCreate(); VocabularyClient client = new VocabularyClient(); HashMap itemInfo = new HashMap(); @@ -207,25 +213,28 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupCreateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()) { - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithEmptyEntityBody(testName, CLASS_NAME); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()) { + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -233,25 +242,28 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupCreateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -259,25 +271,28 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupCreateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -290,8 +305,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create"}) public void read(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -322,39 +340,45 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readByName(String testName) throws Exception { - // Perform setup. - setupRead(testName); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupRead(); - // Submit the request to the service and store the response. - ClientResponse res = client.read(knownResourceId); - int statusCode = res.getStatus(); + // Submit the request to the service and store the response. + ClientResponse res = client.read(knownResourceId); + int statusCode = res.getStatus(); - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": status = " + statusCode); - } - 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(); - VocabulariesCommon vocabulary = (VocabulariesCommon) extractPart(input, - client.getCommonPartName(), VocabulariesCommon.class); - Assert.assertNotNull(vocabulary); - } catch (Exception e) { - throw new RuntimeException(e); - } + // 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(); + VocabulariesCommon vocabulary = (VocabulariesCommon) extractPart(input, + client.getCommonPartName(), VocabulariesCommon.class); + Assert.assertNotNull(vocabulary); + } catch (Exception e) { + throw new RuntimeException(e); + } + } */ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, dependsOnMethods = {"createItem", "read"}) public void readItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupRead(testName); + setupRead(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -383,8 +407,12 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"updateItem"}) public void verifyIllegalItemDisplayName(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateWithWrongXmlSchema(testName); + testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE); + // setupUpdateWithWrongXmlSchema(testName); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -449,8 +477,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void readNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -471,8 +502,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"readItem", "readNonExistent"}) public void readItemNonExistent(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadNonExistent(testName); + setupReadNonExistent(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -498,8 +532,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -546,7 +583,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { final String testName = "readItemList"; // Perform setup. - setupReadList(testName); + setupReadList(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -601,8 +638,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"read"}) public void update(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. VocabularyClient client = new VocabularyClient(); @@ -661,8 +701,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"readItem", "update"}) public void updateItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdate(testName); + setupUpdate(); // Retrieve the contents of a resource to update. VocabularyClient client = new VocabularyClient(); @@ -740,25 +783,28 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - // Perform setup. - setupUpdateWithEmptyEntityBody(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -766,25 +812,28 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - // Perform setup. - setupUpdateWithMalformedXml(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } @Override @@ -792,25 +841,28 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - // Perform setup. - setupUpdateWithWrongXmlSchema(testName); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("updateWithWrongXmlSchema: url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("updateWithWrongXmlSchema: url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -820,8 +872,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -849,8 +904,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"updateItem", "testItemSubmitRequest"}) public void updateNonExistentItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupUpdateNonExistent(testName); + setupUpdateNonExistent(); // Submit the request to the service and store the response. // Note: The ID used in this 'create' call may be arbitrary. @@ -885,8 +943,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -908,8 +969,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { "updateItem", "verifyIllegalItemDisplayName"}) public void deleteItem(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDelete(testName); + setupDelete(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -932,8 +996,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -954,8 +1021,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { dependsOnMethods = {"deleteItem"}) public void deleteNonExistentItem(String testName) { + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } // Perform setup. - setupDeleteNonExistent(testName); + setupDeleteNonExistent(); // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); @@ -983,8 +1053,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { public void testSubmitRequest() { // Expected status code: 200 OK - final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); - + setupRead(); + // Submit the request to the service and store the response. String method = ServiceRequestType.READ.httpMethodName(); String url = getResourceURL(knownResourceId); @@ -996,7 +1066,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { logger.debug("testSubmitRequest: url=" + url + " status=" + statusCode); } - Assert.assertEquals(statusCode, EXPECTED_STATUS); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); }