]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1911: In client test framework, 'banner' signifying the start of a test can...
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 26 May 2010 04:09:38 +0000 (04:09 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 26 May 2010 04:09:38 +0000 (04:09 +0000)
services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java
services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java
services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java

index a64c61ee2aff87dd2bf6f1ffb334a453b08ad993..453ed93a97c7550b796620f869eec7c2bd5c2588 100644 (file)
@@ -482,7 +482,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
     @AfterClass(alwaysRun = true)
     @Override
     public void cleanUp() {
-        setupDelete("delete");
+        setupDelete("cleanUp");
 
         String noTest = System.getProperty("noTestCleanup");
        if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
@@ -529,7 +529,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
      * @return the string
      */
     private String createAccount(String userName, String email) {
-        setupCreate();
+        setupCreate("createAccount");
         AccountClient accClient = new AccountClient();
         AccountsCommon account = AccountFactory.createAccountInstance(
                 userName, userName, userName, email,
@@ -553,7 +553,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
      * @param accId the acc id
      */
     private void deleteAccount(String accId) {
-        setupDelete();
+        setupDelete("deleteAccount");
         AccountClient accClient = new AccountClient();
         ClientResponse<Response> res = accClient.delete(accId);
         int statusCode = res.getStatus();
@@ -577,7 +577,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
      * @return the string
      */
     private String createRole(String roleName) {
-        setupCreate();
+        setupCreate("createRole");
         RoleClient roleClient = new RoleClient();
 
         Role role = RoleFactory.createRoleInstance(roleName,
@@ -601,7 +601,7 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
      * @param roleId the role id
      */
     private void deleteRole(String roleId) {
-        setupDelete();
+        setupDelete("deleteRole");
         RoleClient roleClient = new RoleClient();
         ClientResponse<Response> res = roleClient.delete(roleId);
         int statusCode = res.getStatus();
index 91268ad99247818b29025bcc15a833ac88aa597a..123230c00e55d3f94d5814303f629bd9973ed28a 100644 (file)
@@ -992,7 +992,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
     dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
     public void updateWrongUser(String testName) throws Exception {
 
-        setupUpdate();
+        setupUpdate(testName);
 
         // Submit the request to the service and store the response.
         //
index 2471d408e73038ab7b0112927318c91dd564d2b6..c2121a31329b7c9493da35a849bc7097f49b024b 100644 (file)
@@ -472,7 +472,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
     @AfterClass(alwaysRun = true)
     @Override
     public void cleanUp() {
-        setupDelete("cleanup");
+        setupDelete("cleanUp");
         String noTest = System.getProperty("noTestCleanup");
        if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
             if (logger.isDebugEnabled()) {
@@ -518,7 +518,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
      * @return the string
      */
     private String createPermission(String resName, EffectType effect) {
-        setupCreate();
+        setupCreate("createPermission");
         PermissionClient permClient = new PermissionClient();
         List<PermissionAction> actions = PermissionFactory.createDefaultActions();
         Permission permission = PermissionFactory.createPermissionInstance(resName,
@@ -543,7 +543,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
      * @param permId the perm id
      */
     private void deletePermission(String permId) {
-        setupDelete();
+        setupDelete("deletePermission");
         PermissionClient permClient = new PermissionClient();
         ClientResponse<Response> res = permClient.delete(permId);
         int statusCode = res.getStatus();
@@ -568,7 +568,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
      * @return the string
      */
     private String createRole(String roleName) {
-        setupCreate();
+        setupCreate("createRole");
         RoleClient roleClient = new RoleClient();
 
         Role role = RoleFactory.createRoleInstance(roleName,
@@ -592,7 +592,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
      * @param roleId the role id
      */
     private void deleteRole(String roleId) {
-        setupDelete();
+        setupDelete("deleteRole");
         RoleClient roleClient = new RoleClient();
         ClientResponse<Response> res = roleClient.delete(roleId);
         int statusCode = res.getStatus();
index 2fd5e344cc2e48d196a224773a1037e420a015f0..c4dfb7efa576557daa1081fa3c8a545ad12c2237 100644 (file)
@@ -54,7 +54,10 @@ import org.testng.annotations.Test;
 public abstract class AbstractServiceTestImpl extends BaseServiceTest implements ServiceTest {
 
     /** The logger. */
-    protected final Logger logger = LoggerFactory.getLogger(AbstractServiceTestImpl.class);
+    private final Logger logger = LoggerFactory.getLogger(AbstractServiceTestImpl.class);
+
+    // A non-existent logger.
+    static private final Logger LOGGER_NULL = null;
 
     /** The Constant DEFAULT_LIST_SIZE. */
     static protected final int DEFAULT_LIST_SIZE = 10;
@@ -62,7 +65,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     /* Use this to keep track of resources to delete */
     protected List<String> allResourceIdsCreated = new ArrayList<String>();
-    
+
     /**
      * Gets the logger.
      *
@@ -88,20 +91,25 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     /**
      * Sets up create tests.
+     *
+     * @param testName The name of the test being run.
      */
-    protected void setupCreate() {
-        setupCreate("Create");
+    protected void setupCreate(String testName) {
+        setupCreate(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up create tests.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupCreate(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.CREATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     /* (non-Javadoc)
@@ -124,20 +132,25 @@ 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() {
-        setupCreateWithEmptyEntityBody("CreateWithEmptyEntityBody");
+    protected void setupCreateWithEmptyEntityBody(String testName) {
+        setupCreateWithEmptyEntityBody(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up create tests with empty entity body.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupCreateWithEmptyEntityBody(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.CREATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     /* (non-Javadoc)
@@ -148,20 +161,25 @@ 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() {
-        setupCreateWithMalformedXml("CreateWithMalformedXml");
+    protected void setupCreateWithMalformedXml(String testName) {
+        setupCreateWithMalformedXml(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up create tests with malformed xml.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupCreateWithMalformedXml(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.CREATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     /* (non-Javadoc)
@@ -172,20 +190,25 @@ 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() {
-        setupCreateWithWrongXmlSchema("CreateWithWrongXmlSchema");
+    protected void setupCreateWithWrongXmlSchema(String testName) {
+        setupCreateWithWrongXmlSchema(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up create tests with wrong xml schema.
      *
-     * @param label the new up create 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 label) {
+    protected void setupCreateWithWrongXmlSchema(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.CREATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // ---------------------------------------------------------------
@@ -202,20 +225,25 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     /**
      * Sets up read tests.
+     *
+     * @param testName The name of the test being run.
      */
-    protected void setupRead() {
-        setupRead("Read");
+    protected void setupRead(String testName) {
+        setupRead(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up read tests.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupRead(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.READ;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // Failure outcomes
@@ -228,20 +256,25 @@ 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() {
-        setupReadNonExistent("ReadNonExistent");
+    protected void setupReadNonExistent(String testName) {
+        setupReadNonExistent(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up read non existent tests.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupReadNonExistent(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.READ;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // ---------------------------------------------------------------
@@ -260,20 +293,25 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     /**
      * Sets up read list tests.
+     *
+     * @param testName The name of the test being run.
      */
-    protected void setupReadList() {
-        setupReadList("ReadList");
+    protected void setupReadList(String testName) {
+        setupReadList(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up read list tests.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupReadList(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.READ_LIST;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // Failure outcomes
@@ -294,20 +332,25 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     /**
      * Sets up update tests.
+     *
+     * @param testName The name of the test being run.
      */
-    protected void setupUpdate() {
-        setupUpdate("Update");
+    protected void setupUpdate(String testName) {
+        setupUpdate(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up update tests.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupUpdate(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.UPDATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // Failure outcomes
@@ -320,20 +363,25 @@ 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() {
-        setupUpdateWithEmptyEntityBody("UpdateWithEmptyEntityBody");
+    protected void setupUpdateWithEmptyEntityBody(String testName) {
+        setupUpdateWithEmptyEntityBody(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up update tests with an empty entity body.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupUpdateWithEmptyEntityBody(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.UPDATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     /* (non-Javadoc)
@@ -344,20 +392,25 @@ 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() {
-        setupUpdateWithMalformedXml("UpdateWithMalformedXml");
+    protected void setupUpdateWithMalformedXml(String testName) {
+        setupUpdateWithMalformedXml(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up update tests with malformed xml.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupUpdateWithMalformedXml(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.UPDATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     /* (non-Javadoc)
@@ -368,20 +421,25 @@ 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() {
-        setupUpdateWithWrongXmlSchema("UpdateWithWrongXmlSchema");
+    protected void setupUpdateWithWrongXmlSchema(String testName) {
+        setupUpdateWithWrongXmlSchema(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up update tests with wrong xml schema.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupUpdateWithWrongXmlSchema(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.UPDATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
     
     /* (non-Javadoc)
@@ -392,20 +450,25 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     /**
      * Sets up update non existent tests.
+     *
+     * @param testName The name of the test being run.
      */
-    protected void setupUpdateNonExistent() {
-        setupUpdateNonExistent("UpdateNonExistent");
+    protected void setupUpdateNonExistent(String testName) {
+        setupUpdateNonExistent(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up update non existent tests
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupUpdateNonExistent(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.UPDATE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // ---------------------------------------------------------------
@@ -422,20 +485,25 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     /**
      * Sets up delete tests.
+     *
+     * @param testName The name of the test being run.
      */
-    protected void setupDelete() {
-        setupDelete("Delete");
+    protected void setupDelete(String testName) {
+        setupDelete(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up delete tests.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupDelete(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.DELETE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // Failure outcomes
@@ -448,20 +516,25 @@ 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() {
-        setupDeleteNonExistent("DeleteNonExistent");
+    protected void setupDeleteNonExistent(String testName) {
+        setupDeleteNonExistent(testName, LOGGER_NULL);
     }
 
     /**
      * Sets up delete non existent tests.
      *
-     * @param label A label to be displayed prior to running this test.
+     * @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 label) {
+    protected void setupDeleteNonExistent(String testName, Logger testLogger) {
         EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode();
         REQUEST_TYPE = ServiceRequestType.DELETE;
-        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, label);
+        testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE, testName, testLogger);
     }
 
     // ---------------------------------------------------------------
index 98f826d4bfc07afcf1277d10bd46878e89226f95..256011ed1a8a314f6b19ea10f864eb280c3a7a06 100644 (file)
@@ -72,9 +72,9 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 public abstract class BaseServiceTest {\r
 \r
     //Maven's base directory -i.e., the one containing the current pom.xml\r
-    static protected final String MAVEN_BASEDIR_PROPERTY = "maven.basedir";\r
+    protected static final String MAVEN_BASEDIR_PROPERTY = "maven.basedir";\r
     /** The Constant logger. */\r
-    static protected final Logger logger = LoggerFactory.getLogger(BaseServiceTest.class);\r
+    private static final Logger logger = LoggerFactory.getLogger(BaseServiceTest.class);\r
     /** The Constant serviceClient. */\r
     protected static final TestServiceClient serviceClient = new TestServiceClient();\r
     /** The non-existent id. */\r
@@ -96,7 +96,10 @@ public abstract class BaseServiceTest {
 \r
     protected final static String BANNER_SEPARATOR_LINE =\r
         "===================================================";\r
-\r
+    protected final static String BANNER_PREFIX =\r
+        "\n" + BANNER_SEPARATOR_LINE + "\n";\r
+    protected final static String BANNER_SUFFIX =\r
+        "\n" + BANNER_SEPARATOR_LINE;\r
 \r
     /**\r
      * Instantiates a new base service test.\r
@@ -129,7 +132,6 @@ public abstract class BaseServiceTest {
      *\r
      * @param   m  The currently running test method.\r
      *\r
-     * @return  The name of the currently running test method.\r
      */\r
     @DataProvider(name = "testName")\r
     public static Object[][] testName(Method m) {\r
@@ -157,47 +159,77 @@ public abstract class BaseServiceTest {
         REQUEST_TYPE = ServiceRequestType.NON_EXISTENT;\r
     }\r
 \r
-\r
-        /**\r
-     * Initializes setup values for a given test.\r
+    /**\r
+     * Initializes setup values for a given test, and prints a banner\r
+     * identifying the test being run, using the local logger for this class.\r
      *\r
      * @param expectedStatusCode  A status code expected to be returned in the response.\r
      *\r
      * @param serviceRequestType  A type of service request (e.g. CREATE, DELETE).\r
+     *\r
+     * @param testName The name of the test being run.\r
      */\r
     protected void testSetup(\r
             int expectedStatusCode,\r
-            ServiceRequestType reqType) {\r
-        String testName = null;\r
-        testSetup(expectedStatusCode, reqType, testName);\r
+            ServiceRequestType reqType,\r
+            String testName) {\r
+        testSetup(expectedStatusCode, reqType, testName, null);\r
     }\r
 \r
     /**\r
-     * Initializes setup values for a given test.\r
+     * Initializes setup values for a given test, and prints a banner\r
+     * identifying the test being run, using a specified logger.\r
      *\r
      * @param expectedStatusCode  A status code expected to be returned in the response.\r
      *\r
      * @param serviceRequestType  A type of service request (e.g. CREATE, DELETE).\r
      *\r
      * @param testName The name of the test being run.\r
+     *\r
+     * @param testLogger An optional logger to use within the current base\r
+     *     class, when generating log statements related to that test.\r
+     *     If null, the logger of the current base class will be used.\r
      */\r
     protected void testSetup(\r
             int expectedStatusCode,\r
             ServiceRequestType reqType,\r
-            String testName) {\r
+            String testName,\r
+            Logger testLogger) {\r
+\r
+        testSetup(expectedStatusCode, reqType);\r
 \r
-        clearSetup();\r
-        EXPECTED_STATUS_CODE = expectedStatusCode;\r
-        REQUEST_TYPE = reqType;\r
-        \r
         // Print a banner identifying the test being run.\r
-        if ((testName != null) && (! testName.trim().isEmpty())) {\r
-            if (logger.isDebugEnabled()) {\r
-                logger.debug(testBanner(testName));\r
+        //\r
+        // If an optional logger has been provided, such as by a\r
+        // calling class, use that logger to print the banner.\r
+        if (testLogger != null) {\r
+            if (testLogger.isDebugEnabled()) {\r
+               testLogger.debug(testBanner(testName, testLogger));\r
+            }\r
+        // Otherwise, use this base class's logger to print the banner.\r
+        } else {\r
+            testLogger = logger;\r
+            if (testLogger.isDebugEnabled()) {\r
+                testLogger.debug(testBanner(testName));\r
             }\r
         }\r
     }\r
 \r
+    /**\r
+     * Initializes setup values for a given test.\r
+     *\r
+     * @param expectedStatusCode  A status code expected to be returned in the response.\r
+     *\r
+     * @param serviceRequestType  A type of service request (e.g. CREATE, DELETE).\r
+     */\r
+    protected void testSetup(\r
+            int expectedStatusCode,\r
+            ServiceRequestType reqType) {\r
+        clearSetup();\r
+        EXPECTED_STATUS_CODE = expectedStatusCode;\r
+        REQUEST_TYPE = reqType;\r
+    }\r
+\r
     /**\r
      * Returns an error message indicating that the status code returned by a\r
      * specific call to a service does not fall within a set of valid status\r
@@ -558,25 +590,68 @@ public abstract class BaseServiceTest {
      */\r
     protected static String testBanner(String testName) {\r
         testName = (testName == null || testName.trim().isEmpty()) ?\r
-            "Test = no test name specified" : " Test = " + testName;\r
+            " Test = no test name specified" : " Test = " + testName;\r
         return banner(testName);\r
     }\r
 \r
     /**\r
-     * Returns text inside a banner.\r
+     * Returns a test-specific banner.\r
      *\r
-     * @param label The label to be output inside a banner.\r
+     * @param testName The name of a test method.\r
+     *\r
+     * @param testLogger An optional logger to use within the current base\r
+     *     class, when generating log statements related to that test.\r
      *\r
-     * @return A banner.\r
+     * @return A test-specific banner.\r
+     */\r
+    protected static String testBanner(String testName, Logger testLogger) {\r
+        String testClass = testLogger.getName();\r
+        return testBanner(testName, testClass);\r
+    }\r
+\r
+    /**\r
+     * Returns a test-specific banner.\r
+     *\r
+     * @param testName The name of a test method.\r
+     *\r
+     * @param testClass The name of a test class.\r
+     *\r
+     * @return A test-specific banner.\r
+     */\r
+    protected static String testBanner(String testName, String testClass) {\r
+        testName = (testName == null || testName.trim().isEmpty()) ?\r
+            " Test = no test name specified" : " Test = " + testName;\r
+        testClass = (testClass == null || testClass.trim().isEmpty()) ?\r
+            "Class = no test class specified" : "Class = " + classNameFromPackageName(testClass);\r
+        String testLabel = testClass + "\n" + testName;\r
+        return banner(testLabel);\r
+    }\r
+\r
+    /**\r
+     * Returns a 'banner', consisting of a text label inside a pair of prefix\r
+     * and suffix strings.\r
+     *\r
+     * @param label The label to be output inside the banner.\r
+     *\r
+     * @return The banner.\r
      */\r
     protected static String banner(String label) {\r
         StringBuffer sb = new StringBuffer();\r
-        sb.append("\n");\r
-        sb.append(BANNER_SEPARATOR_LINE);\r
-        sb.append("\n");\r
-        sb.append(" " + label);\r
-        sb.append("\n");\r
-        sb.append(BANNER_SEPARATOR_LINE);\r
+        sb.append(BANNER_PREFIX);\r
+        sb.append(label);\r
+        sb.append(BANNER_SUFFIX);\r
         return sb.toString();\r
     }\r
+\r
+    protected static String classNameFromPackageName(String className) {\r
+        if (className == null || className.trim().isEmpty()) {\r
+            return className;\r
+        }\r
+        final char PKG_SEPARATOR = '.';\r
+        int pos = className.lastIndexOf(PKG_SEPARATOR) + 1;\r
+        if (pos > 0) {\r
+            className = className.substring(pos);\r
+        }\r
+        return className;\r
+    }\r
 }\r
index 83fd1e9fd76eb8e3fc6ef18f1e309b58c7779203..c7aa0dd04f6590fa9fd950be54bf426edc2bd6d4 100644 (file)
@@ -344,7 +344,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
     public void read(String testName) throws Exception {
 
         // Perform setup.
-        setupRead();
+        setupRead(testName);
         
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
@@ -381,7 +381,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         public void readByName(String testName) throws Exception {
 
             // Perform setup.
-        setupRead();
+        setupRead(testName);
 
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
index 00a58f8f8f13306f34276a44cf52cd9dac997e5c..da318a55ff8f5e6a3792a6a806df158094c770fc 100644 (file)
@@ -484,7 +484,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     public void read(String testName) throws Exception {
 
         // Perform setup.
-        setupRead();
+        setupRead(testName);
 
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
@@ -525,7 +525,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         public void readByName(String testName) throws Exception {
 
         // Perform setup.
-        setupRead();
+        setupRead(testName);
 
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
@@ -561,7 +561,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
     public void readByName(String testName) throws Exception {
 
         // Perform setup.
-        setupRead();
+        setupRead(testName);
 
         // Submit the request to the service and store the response.
         ClientResponse<MultipartInput> res = client.read(knownResourceId);
@@ -1978,4 +1978,4 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
                                displayName, refName, 
                                new OrgAuthorityClient().getCommonPartName());
     }
-}
\ No newline at end of file
+}
index 06cd8a5ca44b11ebe89b7d75214f2970073aeecd..e443935cf6dc1412b4dce40bc85b0e83fb941429 100644 (file)
@@ -69,7 +69,8 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
     final String TEST_PARTIAL_TERM_DISPLAY_NAME =
             TEST_PARTIAL_TERM_FORE_NAME + " " + TEST_PARTIAL_TERM_SUR_NAME;
 
-    // Non-existent test name for partial term matching
+    // Non-existent partial term name (first letters of each of the words
+    // in a pangram for the English alphabet).
     private static final String TEST_PARTIAL_TERM_NON_EXISTENT = "jlmbsoq";
 
     /** The known resource id. */
@@ -93,6 +94,10 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
     // The number of matches expected on each partial term.
     final int NUM_MATCHES_EXPECTED = 1;
 
+    // The minimum number of characters that must be included
+    // a partial term, in order to permit matching to occur.
+    final int PARTIAL_TERM_MIN_LENGTH = 1;
+
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
      */
@@ -122,6 +127,18 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
         return TEST_PARTIAL_TERM_NON_EXISTENT;
     }
 
+    private String getPartialTermMinimumLength() {
+        String partialTerm = getPartialTerm();
+        if (partialTerm == null || partialTerm.trim().isEmpty()) {
+            return partialTerm;
+        }
+        if (getPartialTerm().length() > PARTIAL_TERM_MIN_LENGTH) {
+            return partialTerm.substring(0, PARTIAL_TERM_MIN_LENGTH);
+        } else {
+          return partialTerm;
+        }
+    }
+
     @BeforeClass
     public void setup() {
         try {
@@ -143,13 +160,13 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
     // Success outcomes
 
     /**
-     * Read item list by partial term.
+     * Reads an item list by partial term.
      */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"readListByPartialTerm"})
     public void partialTermMatch(String testName) {
         if (logger.isDebugEnabled()) {
-            logger.debug(testBanner(testName));
+            logger.debug(testBanner(testName, logger));
         }
         int numMatchesFound = 0;
         String partialTerm = getPartialTerm();
@@ -165,36 +182,50 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
     }
 
     /**
-     * Read item list by partial term, where the match is case-insensitive.
-     * Tests by attempting a partial match on all-lowercase and all-uppercase
-     * variations of the partial term.
+     * Reads an item list by partial term, with a partial term that consists
+     * of an all-lowercase variation of the expected match, to test case-insensitive
+     * matching.
      */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
-    public void partialTermMatchCaseInsensitive(String testName) {
+    public void partialTermMatchCaseInsensitiveLowerCase(String testName) {
         if (logger.isDebugEnabled()) {
-            logger.debug(testBanner(testName));
+            logger.debug(testBanner(testName, logger));
         }
         int numMatchesFound = 0;
 
-        final String PARTIAL_TERM_LOWERCASE = getPartialTerm().toLowerCase();
+        final String partialTerm = getPartialTerm().toLowerCase();
         if (logger.isDebugEnabled()) {
-            logger.debug("Attempting match on partial term '" + PARTIAL_TERM_LOWERCASE + "' ...");
+            logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
         }
         numMatchesFound =
-            readItemListByPartialTerm(knownResourceId, PARTIAL_TERM_LOWERCASE);
+            readItemListByPartialTerm(knownResourceId, partialTerm);
                 if (logger.isDebugEnabled()) {
         logger.debug("Found " + numMatchesFound + " match(es), expected " +
                 NUM_MATCHES_EXPECTED + " match(es).");
         }
         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED);
+    }
 
-        final String PARTIAL_TERM_UPPERCASE = getPartialTerm().toUpperCase();
+    /**
+     * Reads an item list by partial term, with a partial term that consists
+     * of an all-uppercase variation of the expected match, to test case-insensitive
+     * matching.
+     */
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+        groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
+    public void partialTermMatchCaseInsensitiveUpperCase(String testName) {
+        if (logger.isDebugEnabled()) {
+            logger.debug(testBanner(testName, logger));
+        }
+        int numMatchesFound = 0;
+
+        final String partialTerm = getPartialTerm().toUpperCase();
         if (logger.isDebugEnabled()) {
-            logger.debug("Attempting match on partial term '" + PARTIAL_TERM_UPPERCASE + "' ...");
+            logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
         }
         numMatchesFound =
-            readItemListByPartialTerm(knownResourceId, PARTIAL_TERM_UPPERCASE);
+            readItemListByPartialTerm(knownResourceId, partialTerm);
         if (logger.isDebugEnabled()) {
             logger.debug("Found " + numMatchesFound + " match(es), expected " +
                 NUM_MATCHES_EXPECTED + " match(es).");
@@ -203,8 +234,32 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
     }
 
     /**
-     * Read item list by partial term, with at least one Unicode UTF-8 character
-     * (outside the USASCII range) in the partial term.
+     * Reads an item list by partial term, with a partial term that is of
+     * the minimum character length that may be expected to be matched.
+     */
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+        groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
+    public void partialTermMatchMinimumLength(String testName) {
+        if (logger.isDebugEnabled()) {
+            logger.debug(testBanner(testName, logger));
+        }
+        int numMatchesFound = 0;
+        String partialTerm = getPartialTermMinimumLength();
+        if (logger.isDebugEnabled()) {
+            logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
+        }
+        numMatchesFound = readItemListByPartialTerm(knownResourceId, partialTerm);
+        // Zero matches are expected on a non-existent term.
+        if (logger.isDebugEnabled()) {
+            logger.debug("Found " + numMatchesFound + " match(es), expected " +
+                NUM_MATCHES_EXPECTED + " match(es).");
+        }
+        Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED);
+    }
+
+    /**
+     * Reads an item list by partial term, with a partial term that contains
+     * at least one Unicode UTF-8 character (outside the USASCII range).
      */
     // FIXME: Test currently fails with a true UTF-8 String - need to investigate why.
     // Will be commented out for now until we get this working ...
@@ -213,7 +268,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
     public void partialTermMatchUTF8(String testName) {
         if (logger.isDebugEnabled()) {
-            logger.debug(testBanner(testName));
+            logger.debug(testBanner(testName, logger));
         }
         int numMatchesFound = 0;
         String partialTerm = getPartialTermUtf8();
@@ -233,14 +288,14 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
     // Failure outcomes
 
     /**
-     * Read item list by partial term, where the partial term is not
+     * Reads an item list by partial term, with a partial term that is not
      * expected to be matched by any term in any resource.
      */
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
     public void partialTermMatchOnNonexistentTerm(String testName) {
         if (logger.isDebugEnabled()) {
-            logger.debug(testBanner(testName));
+            logger.debug(testBanner(testName, logger));
         }
         int numMatchesFound = 0;
         int ZERO_MATCHES_EXPECTED = 0;
@@ -258,21 +313,20 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
     }
 
     /**
-     * Read item list by partial term.
+     * Reads an item list by partial term, given an authority and a term.
      *
-     * @param testName The name of the test which has invoked this method.
      * @param authorityCsid The CSID of the authority within which partial term matching
      *     will be performed.
      * @param partialTerm A partial term to match item resources.
      * @return The number of item resources matched by the partial term.
      */
-    private int readItemListByPartialTerm( String authorityCsid, String partialTerm) {
+    private int readItemListByPartialTerm(String authorityCsid, String partialTerm) {
 
         // Perform setup.
         int expectedStatusCode = Response.Status.OK.getStatusCode();
         ServiceRequestType requestType = ServiceRequestType.READ_LIST;
         String testName = "readItemListByPartialTerm";
-        testSetup(expectedStatusCode, requestType);
+        testSetup(expectedStatusCode, requestType, testName, logger);
 
        // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
@@ -362,6 +416,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
         return SERVICE_PATH_COMPONENT;
     }
 
+
     // ---------------------------------------------------------------
     // Utilities: setup routines for search tests
     // ---------------------------------------------------------------
@@ -372,7 +427,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
         int expectedStatusCode = Response.Status.CREATED.getStatusCode();
         ServiceRequestType requestType = ServiceRequestType.CREATE;
         String testName = "createPersonAuthority";
-        testSetup(expectedStatusCode, requestType, testName);
+        testSetup(expectedStatusCode, requestType, testName, logger);
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
index 257c299c1c14bf8287cc503a0550af9cab247e46..0b1da65d6179edf22179f78b8766b38a5c6007a0 100644 (file)
@@ -525,7 +525,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
     public void read(String testName) throws Exception {
 
         // Perform setup.
-        setupRead();
+        setupRead(testName);
         
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
@@ -565,7 +565,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         public void readByName(String testName) throws Exception {
 
         // Perform setup.
-        setupRead();
+        setupRead(testName);
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
index 73b7af6a9dbc9377377cbe962179bb63b57f8c2b..7fc7e720e9a3cd0085ada27c16bedcbdb01b776d 100644 (file)
@@ -291,7 +291,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
     public void read(String testName) throws Exception {
 
         // Perform setup.
-        setupRead();
+        setupRead(testName);
 
         // Submit the request to the service and store the response.
         VocabularyClient client = new VocabularyClient();
@@ -323,7 +323,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         public void readByName(String testName) throws Exception {
 
             // Perform setup.
-            setupRead();
+            setupRead(testName);
 
             // Submit the request to the service and store the response.
             ClientResponse<MultipartInput> res = client.read(knownResourceId);