]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1248: Added test to demonstrate bug in which records containing a child repeat...
authorAron Roberts <aron@socrates.berkeley.edu>
Tue, 23 Mar 2010 20:46:51 +0000 (20:46 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Tue, 23 Mar 2010 20:46:51 +0000 (20:46 +0000)
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
services/collectionobject/client/src/test/resources/test-data/repfield_null1.xml [new file with mode: 0644]

index 5bbc7fdf0035ed6d272baec3bf4a039088262902..fdd7ed3ebe94f47278357229181a06e867af5f12 100644 (file)
@@ -116,29 +116,62 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
         allResourceIdsCreated.add(extractId(res));
     }
 
+
+    /*
+     * Tests to diagnose and verify the fixed status of CSPACE-1026,
+     * "Whitespace at certain points in payload cause failure"
+     */
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void createFromXmlCambridge(String testName) throws Exception {
-        createFromXmlFile(testName, "./test-data/testCambridge.xml", true);
+        String newId = 
+            createFromXmlFile(testName, "./test-data/testCambridge.xml", true);
+        testSubmitRequest(newId);
     }
 
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void createFromXmlRFWS1(String testName) throws Exception {
-        createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp1.xml", false);
+        String newId =
+            createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp1.xml", false);
+        testSubmitRequest(newId);
     }
 
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void createFromXmlRFWS2(String testName) throws Exception {
-        createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp2.xml", false);
+        String newId =
+            createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp2.xml", false);
+        testSubmitRequest(newId);
     }
 
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void createFromXmlRFWS3(String testName) throws Exception {
-        createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp3.xml", false);
+        String newId =
+            createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp3.xml", false);
+        testSubmitRequest(newId);
     }
 
     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
     public void createFromXmlRFWS4(String testName) throws Exception {
-        createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp4.xml", false);
+        String newId =
+            createFromXmlFile(testName, "./target/test-classes/test-data/repfield_whitesp4.xml", false);
+        testSubmitRequest(newId);
+    }
+
+    /*
+     * Tests to diagnose and verify the fixed status of CSPACE-1248,
+     * "Wedged records created!" (i.e. records with child repeatable
+     * fields, which contain null values, can be successfully created
+     * but an error occurs on trying to retrieve those records).
+     */
+    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
+    public void createWithNullValueRepeatableField(String testName) throws Exception {
+        String newId =
+            createFromXmlFile(testName, "./target/test-classes/test-data/repfield_null1.xml", false);
+        if (logger.isDebugEnabled()) {
+            logger.debug("Successfully created record with null value repeatable field.");
+            logger.debug("Attempting to retrieve just-created record ...");
+        }
+        // This test will fail until CSPACE-1248 is fixed:
+        // testSubmitRequest(newId);
     }
 
     /* (non-Javadoc)
@@ -682,15 +715,20 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
      * Tests the code for manually submitting data that is used by several
      * of the methods above.
      */
+
     @Test(dependsOnMethods = {"create", "read"})
     public void testSubmitRequest() throws Exception {
+        testSubmitRequest(knownResourceId);
+    }
+
+    private void testSubmitRequest(String resourceId) throws Exception {
 
         // Expected status code: 200 OK
         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
 
         // Submit the request to the service and store the response.
         String method = ServiceRequestType.READ.httpMethodName();
-        String url = getResourceURL(knownResourceId);
+        String url = getResourceURL(resourceId);
         int statusCode = submitRequest(method, url);
 
         // Check the status code of the response: does it match
@@ -852,7 +890,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
         return "collectionobjects_naturalhistory";
     }
 
-    private void createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception {
+    private String createFromXmlFile(String testName, String fileName, boolean useJaxb) throws Exception {
         // Perform setup, such as initializing the type of service request
         // (e.g. CREATE, DELETE), its valid and expected status codes, and
         // its associated HTTP method name (e.g. POST, DELETE).
@@ -876,6 +914,8 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        allResourceIdsCreated.add(extractId(res));
+        String newId = extractId(res);
+        allResourceIdsCreated.add(newId);
+        return newId;
     }
 }
diff --git a/services/collectionobject/client/src/test/resources/test-data/repfield_null1.xml b/services/collectionobject/client/src/test/resources/test-data/repfield_null1.xml
new file mode 100644 (file)
index 0000000..3eff5fc
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns2:collectionobjects_common xmlns:ns2="http://collectionspace.org/services/collectionobject">
+<objectNumber>objectNumber</objectNumber>
+<!-- test child repeatable field with null value -->
+<responsibleDepartments><responsibleDepartment></responsibleDepartment></responsibleDepartments>
+</ns2:collectionobjects_common>