]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-424: Remove unneeded, now failing createNull() test from client test framework...
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 9 Sep 2009 23:13:46 +0000 (23:13 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 9 Sep 2009 23:13:46 +0000 (23:13 +0000)
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/test/ServiceTest.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java
services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java

index 1e379820f5a106d1e272387aa73f5fc0cd08ecf8..e4e42d5d3ecb601b68a17da9d99dae2db87877ba 100644 (file)
@@ -83,7 +83,6 @@ public abstract class AbstractServiceTest implements ServiceTest {
       XML_DECLARATION +
       "<wrong_schema>wrong schema contents</wrong_schema>";
 
-
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
@@ -108,12 +107,6 @@ public abstract class AbstractServiceTest implements ServiceTest {
 
     // Failure outcomes
 
-    @Override
-    public void createNull() {
-    }
-    
-    // No setup required for createNull()
-
     @Override
     public abstract void createWithMalformedXml();
 
@@ -335,8 +328,17 @@ public abstract class AbstractServiceTest implements ServiceTest {
         return getServiceRootURL() + "/" + resourceIdentifier;
     }
 
-    // @TODO Add Javadoc comments to all methods requiring them, below.
-
+    /**
+     * Submits an HTTP request to a specified URL, and returns the
+     * status code of the response.  Currently accepts GET and DELETE
+     * requests.
+     *
+     * @param  method  An HTTP method.
+     *
+     * @param  url     A String representation of a URL.
+     *
+     * @return The status code received in the HTTP response.
+     */
     protected int submitRequest(String method, String url) {
         int statusCode = 0;
         try {
@@ -358,28 +360,47 @@ public abstract class AbstractServiceTest implements ServiceTest {
         return statusCode;
    }
 
-    protected int submitRequest(String method, String url, String entityStr) {
+    /**
+     * Submits an HTTP request to a specified URL, with the submitted
+     * entity body, and returns the status code of the response.
+     * Currently accepts POST and PUT requests.
+     *
+     * @param  method  An HTTP method.
+     *
+     * @param  url     A String representation of a URL.
+     *
+     * @param  mediaType  The media type of the entity body to be submitted.
+     *
+     * @param  entity     The contents of the entity body to be submitted.
+     *
+     * @return The status code received in the HTTP response.
+     */
+    protected int submitRequest(String method, String url,
+        String mediaType, String entityStr) {
         int statusCode = 0;
         try {
             ClientRequest request = new ClientRequest(url);
-            request.body(MediaType.APPLICATION_XML, entityStr);
+            request.body(mediaType, entityStr);
             if (method.equals(javax.ws.rs.HttpMethod.POST)) {
-                ClientResponse res = request.post();
+                ClientResponse res = request.post(java.lang.String.class);
                 statusCode = res.getStatus(); 
             } else if (method.equals(javax.ws.rs.HttpMethod.PUT)) {
-                ClientResponse res = request.put();
+                ClientResponse res = request.put(java.lang.String.class);
                 statusCode = res.getStatus(); 
             } else {
                 // Do nothing - leave status code at default value.
             }
         } catch (Exception e) {
             logger.error( 
-              "Exception during HTTP " + method + " request to " + url + " :",
+              "Exception during HTTP " + method + " request to " + url + ":",
               e);
         }
         return statusCode;
     } 
 
+    // @TODO Add Javadoc comments to all methods requiring them, below.
+
+
     protected String extractId(ClientResponse<Response> res) {
         MultivaluedMap mvm = res.getMetadata();
         String uri = (String) ((ArrayList) mvm.get("Location")).get(0);
index 751fbf520088bb130a3024c8b8d19b4d9836b171..beebd5bffd08fab3f9823fb4243a33f50e8e6939 100644 (file)
@@ -52,12 +52,6 @@ public interface ServiceTest {
 
     // Failure outcomes
 
-    /**
-     * Tests creation of a null resource via the
-     * Java Client Library. 
-     */
-    public void createNull();
-
     /**
      * Tests creation of a resource by submitting
      * a representation with malformed XML data. 
index bfaef0dc38e4d4f6b1c093cb925f3333e95b86e2..dae79c9d1a7c0279c1c010d84c51acecd4ab1636 100644 (file)
@@ -24,6 +24,7 @@
 package org.collectionspace.services.client.test;
 
 import java.util.List;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
@@ -99,13 +100,6 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
-    @Override
-    @Test(dependsOnMethods = {"create"}, 
-      expectedExceptions = IllegalArgumentException.class)
-    public void createNull() {
-        ClientResponse<Response> res = client.create(null);
-    }
-    
     // Placeholders until the two tests below can be uncommented.
     // See Issue CSPACE-401.
     public void createWithMalformedXml() {}
@@ -122,8 +116,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -143,8 +138,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -317,7 +313,8 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
         String method = REQUEST_TYPE.httpMethodName();
         String url = getResourceURL(knownResourceId);
         final String entity = MALFORMED_XML_DATA;
-        int statusCode = submitRequest(method, url, entity);
+        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)?
@@ -337,8 +334,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
index 24e28c8d921ff8f7a9e8fe5d34f39fae9377c049..d0cf49e0bfa196a66834d751b1d765a99d3c9d03 100644 (file)
@@ -24,6 +24,7 @@
  package org.collectionspace.services.client.test;
 
 import java.util.List;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
@@ -99,13 +100,6 @@ public class IntakeServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
-    @Override
-    @Test(dependsOnMethods = {"create"},
-        expectedExceptions = IllegalArgumentException.class)
-    public void createNull() {
-        ClientResponse<Response> res = client.create(null);
-    }
-    
     // Placeholders until the two tests below can be uncommented.
     // See Issue CSPACE-401.
     public void createWithMalformedXml() {}
@@ -122,8 +116,9 @@ public class IntakeServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -143,8 +138,9 @@ public class IntakeServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -314,8 +310,9 @@ public class IntakeServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -335,8 +332,9 @@ public class IntakeServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
index 37502c389274ddb0060c58d4d6dcaecdf5f18d23..d8fb8ce48c6ee8ca1576bf9f8080ba012cc980c9 100644 (file)
@@ -24,6 +24,7 @@
 package org.collectionspace.services.client.test;
 
 import java.util.List;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
@@ -97,13 +98,6 @@ public class RelationServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
-    @Override
-    @Test(dependsOnMethods = {"create"},
-        expectedExceptions = IllegalArgumentException.class)
-    public void createNull() {
-        ClientResponse<Response> res = client.create(null);
-    }
-
     // Placeholders until the two tests below can be uncommented.
     // See Issue CSPACE-401.
     public void createWithMalformedXml() {}
@@ -120,8 +114,9 @@ public class RelationServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -141,8 +136,9 @@ public class RelationServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -326,8 +322,9 @@ public class RelationServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -347,8 +344,9 @@ public class RelationServiceTest extends AbstractServiceTest {
         // 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, entity);
+        int statusCode = submitRequest(method, url, mediaType, entity);
         
         // Check the status code of the response: does it match
         // the expected response(s)?