]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1911: Minoir formatting changes to test banner in BaseServiceTest, intended...
authorAron Roberts <aron@socrates.berkeley.edu>
Tue, 25 May 2010 00:48:02 +0000 (00:48 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Tue, 25 May 2010 00:48:02 +0000 (00:48 +0000)
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java

index 5d50a7394edd8287b156806b9994571f31fe5f7f..2fd5e344cc2e48d196a224773a1037e420a015f0 100644 (file)
@@ -38,7 +38,7 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.Test;
 
 /**
- * AbstractServiceTest.
+ * AbstractServiceTestImpl
  *
  * Abstract base class for client tests of entity and relation services.
  * Abstract methods are provided for a set of CRUD + List tests to be invoked.
index cb055a641d7c3f8627f89328ccf593677c94ced9..98f826d4bfc07afcf1277d10bd46878e89226f95 100644 (file)
@@ -94,6 +94,9 @@ public abstract class BaseServiceTest {
     /** The null charset. */\r
     final String NULL_CHARSET = null;\r
 \r
+    protected final static String BANNER_SEPARATOR_LINE =\r
+        "===================================================";\r
+\r
 \r
     /**\r
      * Instantiates a new base service test.\r
@@ -154,6 +157,21 @@ public abstract class BaseServiceTest {
         REQUEST_TYPE = ServiceRequestType.NON_EXISTENT;\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
+        String testName = null;\r
+        testSetup(expectedStatusCode, reqType, testName);\r
+    }\r
+\r
     /**\r
      * Initializes setup values for a given test.\r
      *\r
@@ -173,8 +191,10 @@ public abstract class BaseServiceTest {
         REQUEST_TYPE = reqType;\r
         \r
         // Print a banner identifying the test being run.\r
-        if (logger.isDebugEnabled()) {\r
-            testBanner(testName);\r
+        if ((testName != null) && (! testName.trim().isEmpty())) {\r
+            if (logger.isDebugEnabled()) {\r
+                logger.debug(testBanner(testName));\r
+            }\r
         }\r
     }\r
 \r
@@ -530,25 +550,33 @@ public abstract class BaseServiceTest {
     }\r
 \r
     /**\r
-     * Print label text inside a test-specific banner.\r
+     * Returns label text inside a test-specific banner.\r
      *\r
      * @param testName The name of a test method.\r
+     *\r
+     * @return A test-specific banner.\r
      */\r
-    protected static void testBanner(String testName) {\r
-        testName = (testName == null) ? "Test = no test name specified" : " Test = " + testName;\r
-        banner(testName);\r
+    protected static String testBanner(String testName) {\r
+        testName = (testName == null || testName.trim().isEmpty()) ?\r
+            "Test = no test name specified" : " Test = " + testName;\r
+        return banner(testName);\r
     }\r
 \r
     /**\r
-     * Print label text inside a banner.\r
+     * Returns text inside a banner.\r
      *\r
-     * @param label The label to be printed inside a banner.\r
+     * @param label The label to be output inside a banner.\r
+     *\r
+     * @return A banner.\r
      */\r
-    protected static void banner(String label) {\r
-        if (logger.isDebugEnabled()) {\r
-            logger.debug("===================================================");\r
-            logger.debug(" " + label);\r
-            logger.debug("===================================================");\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
+        return sb.toString();\r
     }\r
 }\r