]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-360,CSPACE-384: More minor code cleanup, including adding missing annotations...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 27 Aug 2009 00:11:09 +0000 (00:11 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 27 Aug 2009 00:11:09 +0000 (00:11 +0000)
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/AbstractServiceTest.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java

index dd9d18cf214170cae51b6e55e5c5407bac2fb2be..ed763da4707123ad72019aa46b9349a13f6d7b9a 100644 (file)
@@ -62,15 +62,21 @@ public abstract class AbstractServiceTest implements ServiceTest {
 
     final Logger logger = LoggerFactory.getLogger(AbstractServiceTest.class);
 
-    // Currently used for performing several negative (failure) tests.
+    // An HTTP client, used for performing several negative (failure) tests.
     //
-    // @TODO To be replaced with RESTeasy's ClientRequest, per Issue CSPACE-386.
+    // @TODO To be replaced with RESTeasy's ClientRequest (a higher-level API
+    // that is based on HttpClient), per Issue CSPACE-386.
     protected HttpClient httpClient = new HttpClient();
 
-    // Used (only) to obtain the base service URL.
-    private final TestServiceClient serviceClient = new TestServiceClient();
+    // A base-level client, used (only) to obtain the base service URL.
+    private static final TestServiceClient serviceClient = new TestServiceClient();
 
-    // The status code expected to be returned by a test method (where relevant).
+    // A resource identifier believed to be non-existent in actual use,
+    // used when testing service calls that reference non-existent resources.
+    protected final String NON_EXISTENT_ID = createNonExistentIdentifier();
+
+    // The HTTP status code expected to be returned in the response,
+    // from a request made to a service (where relevant).
     int EXPECTED_STATUS_CODE = 0;
     
     // The generic type of service request being tested (e.g. CREATE, UPDATE, DELETE).
@@ -79,7 +85,6 @@ public abstract class AbstractServiceTest implements ServiceTest {
     // such as the set of valid status codes that may be returned.
     ServiceRequestType REQUEST_TYPE = ServiceRequestType.NON_EXISTENT;
 
-
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
@@ -345,12 +350,14 @@ public abstract class AbstractServiceTest implements ServiceTest {
             contents = "";
         }
         StringRequestEntity entity = null;
-        final String XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
+        final String XML_DECLARATION =
+          "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
         final String XML_CONTENT_TYPE=MediaType.APPLICATION_XML;
         final String UTF8_CHARSET_NAME = "UTF-8";
         try {
             entity =
-                new StringRequestEntity(XML_DECLARATION + contents, XML_CONTENT_TYPE, UTF8_CHARSET_NAME);
+                new StringRequestEntity(
+                  XML_DECLARATION + contents, XML_CONTENT_TYPE, UTF8_CHARSET_NAME);
         } catch (UnsupportedEncodingException e) {
             logger.error("Unsupported character encoding error: ", e);
         }
index b690bce9738d9f09f470980e20a116afdd5a01fb..a96b7b55b3d54fe4650ea5f961f6174e4d2a24cb 100644 (file)
@@ -53,9 +53,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
 
     // Instance variables specific to this test.
     private CollectionObjectClient client = new CollectionObjectClient();
-
-    // Instance variables common to all entity service test classes.
-    private final String NON_EXISTENT_ID = createNonExistentIdentifier();
+    final String SERVICE_PATH_COMPONENT = "collectionobjects";
     private String knownObjectId = null;
  
     // ---------------------------------------------------------------
@@ -70,7 +68,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
 
         // Perform setup, such as initializing the type of service request
         // and its valid and expected status codes.
-        super.setupCreate();
+        setupCreate();
 
         // Submit the request to the service and store the response.
         String identifier = createIdentifier();
@@ -112,7 +110,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     public void createWithMalformedXml() {
     
         // Perform setup.
-        super.setupCreateWithMalformedXml();
+        setupCreateWithMalformedXml();
 
         // Submit the request to the service and store the response.
         String url = getServiceRootURL();
@@ -134,7 +132,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     public void createWithWrongXmlSchema() {
     
         // Perform setup.
-        super.setupCreateWithWrongXmlSchema();
+        setupCreateWithWrongXmlSchema();
      
         // Submit the request to the service and store the response.
         String url = getServiceRootURL();
@@ -161,7 +159,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     public void read() {
     
         // Perform setup.
-        super.setupRead();
+        setupRead();
 
         // Submit the request to the service and store the response.
         ClientResponse<CollectionObject> res = 
@@ -180,7 +178,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     public void readNonExistent() {
 
         // Perform setup.
-        super.setupReadNonExistent();
+        setupReadNonExistent();
         
         // Submit the request to the service and store the response.
         ClientResponse<CollectionObject> res = 
@@ -206,7 +204,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     public void readList() {
     
         // Perform setup.
-        super.setupReadList();
+        setupReadList();
 
         // Submit the request to the service and store the response.
         ClientResponse<CollectionObjectList> res = client.getCollectionObjectList();
@@ -251,7 +249,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     public void update() {
     
         // Perform setup.
-        super.setupUpdate();
+        setupUpdate();
 
         // Retrieve an existing resource that we can update.
         ClientResponse<CollectionObject> res = 
@@ -289,7 +287,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     public void updateWithMalformedXml() {
 
         // Perform setup.
-        super.setupUpdateWithMalformedXml();
+        setupUpdateWithMalformedXml();
 
         // Submit the request to the service and store the response.
         String url = getResourceURL(knownObjectId);
@@ -306,11 +304,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    @Override
     @Test(dependsOnMethods = {"create", "testSubmitRequest"}) // , "createWithMalformedXml"})
     public void updateWithWrongXmlSchema() {
     
         // Perform setup.
-        super.setupUpdateWithWrongXmlSchema();
+        setupUpdateWithWrongXmlSchema();
         
         // Submit the request to the service and store the response.
         String url = getResourceURL(knownObjectId);
@@ -326,11 +325,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     }
 
+    @Override
     @Test(dependsOnMethods = {"update"})
     public void updateNonExistent() {
 
         // Perform setup.
-        super.setupUpdateNonExistent();
+        setupUpdateNonExistent();
 
         // Submit the request to the service and store the response.
         // Note: The ID used in this 'create' call may be arbitrary.
@@ -354,12 +354,13 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
 
     // Success outcomes
 
+    @Override
     @Test(dependsOnMethods = 
         {"create", "read", "testSubmitRequest", "update"})
     public void delete() {
 
         // Perform setup.
-        super.setupDelete();
+        setupDelete();
 
         // Submit the request to the service and store the response.
         ClientResponse<Response> res = client.deleteCollectionObject(knownObjectId);
@@ -374,11 +375,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
+    @Override
     @Test(dependsOnMethods = {"delete"})
     public void deleteNonExistent() {
 
         // Perform setup.
-        super.setupDeleteNonExistent();
+        setupDeleteNonExistent();
 
         // Submit the request to the service and store the response.
         ClientResponse<Response> res =
@@ -421,6 +423,14 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     // ---------------------------------------------------------------
     // Utility methods used by tests above
     // ---------------------------------------------------------------
+
+    @Override
+    public String getServicePathComponent() {
+        // @TODO Determine if it is possible to obtain this value programmatically.
+        // We set this in an annotation in the CollectionObjectProxy interface, for instance.
+        // We also set service-specific constants in each service module.
+        return SERVICE_PATH_COMPONENT;
+    }
     
     private CollectionObject createCollectionObject(String identifier) {
         CollectionObject collectionObject = createCollectionObject("objectNumber-" + identifier,
@@ -435,13 +445,5 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
         return collectionObject;
     }
     
-    @Override
-    public String getServicePathComponent() {
-        // @TODO Determine if it is possible to obtain this value programmatically.
-        // We set this in an annotation in the CollectionObjectProxy interface, for instance.
-        // We also set service-specific constants in each service module.
-        final String SERVICE_PATH_COMPONENT = "collectionobjects";
-        return SERVICE_PATH_COMPONENT;
-    }
     
 }