]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-424,CSPACE-401: Added (currently commented-out) negative tests of create and...
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 9 Sep 2009 23:58:04 +0000 (23:58 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 9 Sep 2009 23:58:04 +0000 (23:58 +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 e4e42d5d3ecb601b68a17da9d99dae2db87877ba..63dea9bde66d7b168057379c8358f637d304bd23 100644 (file)
@@ -107,6 +107,15 @@ public abstract class AbstractServiceTest implements ServiceTest {
 
     // Failure outcomes
 
+    @Override
+    public abstract void createWithEmptyEntityBody();
+
+    protected void setupCreateWithEmptyEntityBody() {
+        clearSetup();
+        EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
+        REQUEST_TYPE = ServiceRequestType.CREATE;
+    }
+
     @Override
     public abstract void createWithMalformedXml();
 
@@ -197,6 +206,15 @@ public abstract class AbstractServiceTest implements ServiceTest {
 
     // Failure outcomes
 
+    @Override
+    public abstract void updateWithEmptyEntityBody();
+
+    protected void setupUpdateWithEmptyEntityBody() {
+        clearSetup();
+        EXPECTED_STATUS_CODE = Response.Status.BAD_REQUEST.getStatusCode();
+        REQUEST_TYPE = ServiceRequestType.UPDATE;
+    }
+
     @Override
     public abstract void updateWithMalformedXml();
 
index beebd5bffd08fab3f9823fb4243a33f50e8e6939..8305cae342bd16d00de9e7ba2f801c4137879a5c 100644 (file)
@@ -52,6 +52,12 @@ public interface ServiceTest {
 
     // Failure outcomes
 
+    /**
+     * Tests creation of a resource by submitting
+     * an empty entity body (aka empty payload). 
+     */
+    public void createWithEmptyEntityBody();
+
     /**
      * Tests creation of a resource by submitting
      * a representation with malformed XML data. 
@@ -126,6 +132,12 @@ public interface ServiceTest {
 
     // Failure outcomes
 
+    /**
+     * Tests updating the content of a resource
+     * by submitting an empty entity body (aka empty payload).
+     */
+    public void updateWithEmptyEntityBody();
+
     /**
      * Tests updating the content of a resource 
      * by submitting a representation with malformed
index dae79c9d1a7c0279c1c010d84c51acecd4ab1636..8ea4c8488b9ba2ce807bf4b689bc702ddd06b421 100644 (file)
@@ -100,12 +100,35 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
-    // Placeholders until the two tests below can be uncommented.
+    // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    public void createWithEmptyEntityBody() {}
     public void createWithMalformedXml() {}
     public void createWithWrongXmlSchema() {}
 
 /*
+    @Override
+    @Test(dependsOnMethods = {"create", "testSubmitRequest"})
+    public void createWithEmptyEntityBody() {
+    
+        // 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)?
+        verbose("createWithEmptyEntityBody url=" + url + " status=" + statusCode);
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
     @Override
     @Test(dependsOnMethods = {"create", "testSubmitRequest"})
     public void createWithMalformedXml() {
@@ -296,12 +319,35 @@ public class CollectionObjectServiceTest extends AbstractServiceTest {
     
     // Failure outcomes
 
-    // Placeholders until the two tests below can be uncommented.
+    // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    public void updateWithEmptyEntityBody() {}
     public void updateWithMalformedXml() {}
     public void updateWithWrongXmlSchema() {}
 
 /*
+    @Override
+    @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
+    public void updateWithEmptyEntityBody() {
+    
+        // 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)?
+        verbose("updateWithEmptyEntityBody 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 updateWithMalformedXml() {
index d0cf49e0bfa196a66834d751b1d765a99d3c9d03..28c937a9ada2410a117fd99d18a007666663e6c2 100644 (file)
@@ -100,12 +100,35 @@ public class IntakeServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
-    // Placeholders until the two tests below can be uncommented.
+    // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    public void createWithEmptyEntityBody() {}
     public void createWithMalformedXml() {}
     public void createWithWrongXmlSchema() {}
 
 /*
+    @Override
+    @Test(dependsOnMethods = {"create", "testSubmitRequest"})
+    public void createWithEmptyEntityBody() {
+    
+        // 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)?
+        verbose("createWithEmptyEntityBody url=" + url + " status=" + statusCode);
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
     @Override
     @Test(dependsOnMethods = {"create", "testSubmitRequest"})
     public void createWithMalformedXml() {
@@ -294,12 +317,35 @@ public class IntakeServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
-    // Placeholders until the two tests below can be uncommented.
+    // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    public void updateWithEmptyEntityBody() {}
     public void updateWithMalformedXml() {}
     public void updateWithWrongXmlSchema() {}
 
 /*
+    @Override
+    @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
+    public void updateWithEmptyEntityBody() {
+    
+        // 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)?
+        verbose("updateWithEmptyEntityBody 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 updateWithMalformedXml() {
index d8fb8ce48c6ee8ca1576bf9f8080ba012cc980c9..43fa7d9e08c55401b914997c756220b41bbdeef5 100644 (file)
@@ -98,12 +98,35 @@ public class RelationServiceTest extends AbstractServiceTest {
 
     // Failure outcomes
 
-    // Placeholders until the two tests below can be uncommented.
+    // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    public void createWithEmptyEntityBody() {}
     public void createWithMalformedXml() {}
     public void createWithWrongXmlSchema() {}
 
 /*
+    @Override
+    @Test(dependsOnMethods = {"create", "testSubmitRequest"})
+    public void createWithEmptyEntityBody() {
+    
+        // 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)?
+        verbose("createWithEmptyEntityBody url=" + url + " status=" + statusCode);
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
     @Override
     @Test(dependsOnMethods = {"create", "testSubmitRequest"})
     public void createWithMalformedXml() {
@@ -306,12 +329,35 @@ public class RelationServiceTest extends AbstractServiceTest {
     
     // Failure outcomes
 
-    // Placeholders until the two tests below can be uncommented.
+    // Placeholders until the three tests below can be uncommented.
     // See Issue CSPACE-401.
+    public void updateWithEmptyEntityBody() {}
     public void updateWithMalformedXml() {}
     public void updateWithWrongXmlSchema() {}
 
 /*
+    @Override
+    @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
+    public void updateWithEmptyEntityBody() {
+    
+        // 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)?
+        verbose("updateWithEmptyEntityBody 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 updateWithMalformedXml() {