]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-527: Updated IntegrationTests module to use the new schema extension changes...
authorRichard Millet <richard.millet@berkeley.edu>
Wed, 14 Oct 2009 22:57:58 +0000 (22:57 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Wed, 14 Oct 2009 22:57:58 +0000 (22:57 +0000)
services/IntegrationTests/.classpath
services/IntegrationTests/src/test/java/org/collectionspace/services/ItegrationTests/test/CollectionSpaceIntegrationTest.java
services/IntegrationTests/src/test/java/org/collectionspace/services/ItegrationTests/test/RelationIntegrationTest.java
services/common/src/main/java/org/collectionspace/services/common/relation/nuxeo/RelationConstants.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandler.java
services/pom.xml

index c641afdb99c45b4211ac1ebdf9a7d58dc4ff480c..425cd1620f3d44a6c3d1d8c43488a67552f09765 100644 (file)
@@ -4,7 +4,7 @@
        <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
        <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
        <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
        <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
        <classpathentry kind="output" path="target/classes"/>\r
 </classpath>\r
index 475f881f9fec3cbe2473267d7c694f34362059eb..1f3bf427bf215f696586f75896c7190a5a630158 100644 (file)
@@ -1,3 +1,29 @@
+/**    \r
+ * CollectionSpaceIntegrationTest.java\r
+ *\r
+ * {Purpose of This Class}\r
+ *\r
+ * {Other Notes Relating to This Class (Optional)}\r
+ *\r
+ * $LastChangedBy: $\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ *\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright © 2009 {Contributing Institution}\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ */\r
 package org.collectionspace.services.ItegrationTests.test;\r
 \r
 import java.util.ArrayList;\r
@@ -7,40 +33,81 @@ import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;\r
 import javax.xml.bind.Marshaller;\r
 \r
-import org.collectionspace.services.collectionobject.CollectionObject;\r
-import org.collectionspace.services.intake.Intake;\r
-import org.collectionspace.services.relation.Relation;\r
+import org.collectionspace.services.collectionobject.CollectionobjectsCommon;\r
+import org.collectionspace.services.intake.IntakesCommon;\r
+import org.collectionspace.services.relation.RelationsCommon;\r
 import org.collectionspace.services.relation.RelationshipType;\r
 import org.jboss.resteasy.client.ClientResponse;\r
+import org.jboss.resteasy.plugins.providers.multipart.InputPart;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
 \r
+/**\r
+ * The Class CollectionSpaceIntegrationTest.\r
+ */\r
 public abstract class CollectionSpaceIntegrationTest {\r
 \r
        /*\r
         * Package scoped methods.\r
         */\r
 \r
-       void fillCollectionObject(CollectionObject co, String identifier) {\r
+       /**\r
+        * Fill collection object.\r
+        * \r
+        * @param co the co\r
+        * @param identifier the identifier\r
+        */\r
+       void fillCollectionObject(CollectionobjectsCommon co, String identifier) {\r
                fillCollectionObject(co, "objectNumber-" + identifier, "objectName-"\r
                                + identifier);\r
        }\r
 \r
-       void fillCollectionObject(CollectionObject co, String objectNumber,\r
+       /**\r
+        * Fill collection object.\r
+        * \r
+        * @param co the co\r
+        * @param objectNumber the object number\r
+        * @param objectName the object name\r
+        */\r
+       void fillCollectionObject(CollectionobjectsCommon co, String objectNumber,\r
                        String objectName) {\r
                co.setObjectNumber(objectNumber);\r
                co.setObjectName(objectName);\r
        }\r
 \r
-       void fillIntake(Intake theIntake, String identifier) {\r
+       /**\r
+        * Fill intake.\r
+        * \r
+        * @param theIntake the the intake\r
+        * @param identifier the identifier\r
+        */\r
+       void fillIntake(IntakesCommon theIntake, String identifier) {\r
                fillIntake(theIntake, "entryNumber-" + identifier, "entryDate-"\r
                                + identifier);\r
        }\r
 \r
-       void fillIntake(Intake theIntake, String entryNumber, String entryDate) {\r
+       /**\r
+        * Fill intake.\r
+        * \r
+        * @param theIntake the the intake\r
+        * @param entryNumber the entry number\r
+        * @param entryDate the entry date\r
+        */\r
+       void fillIntake(IntakesCommon theIntake, String entryNumber, String entryDate) {\r
                theIntake.setEntryNumber(entryNumber);\r
                theIntake.setEntryDate(entryDate);\r
        }\r
 \r
-    void fillRelation(Relation relation, String documentId1, String documentType1,\r
+    /**\r
+     * Fill relation.\r
+     * \r
+     * @param relation the relation\r
+     * @param documentId1 the document id1\r
+     * @param documentType1 the document type1\r
+     * @param documentId2 the document id2\r
+     * @param documentType2 the document type2\r
+     * @param rt the rt\r
+     */\r
+    void fillRelation(RelationsCommon relation, String documentId1, String documentType1,\r
                String documentId2, String documentType2, RelationshipType rt)\r
     {\r
         relation.setDocumentId1(documentId1);\r
@@ -51,11 +118,23 @@ public abstract class CollectionSpaceIntegrationTest {
         relation.setRelationshipType(rt);\r
     }\r
        \r
+       /**\r
+        * Creates the identifier.\r
+        * \r
+        * @return the string\r
+        */\r
        String createIdentifier() {\r
                long identifier = System.currentTimeMillis();\r
                return Long.toString(identifier);\r
        }\r
 \r
+       /**\r
+        * Extract id.\r
+        * \r
+        * @param res the res\r
+        * \r
+        * @return the string\r
+        */\r
        String extractId(ClientResponse<Response> res) {\r
                String result = null;\r
                \r
@@ -69,10 +148,56 @@ public abstract class CollectionSpaceIntegrationTest {
                return result;\r
        }\r
 \r
+       /**\r
+        * Extract part.\r
+        * \r
+        * @param input\r
+        *            the input\r
+        * @param label\r
+        *            the label\r
+        * @param clazz\r
+        *            the clazz\r
+        * \r
+        * @return the object\r
+        * \r
+        * @throws Exception\r
+        *             the exception\r
+        */\r
+       static Object extractPart(MultipartInput input, String label, Class clazz) {\r
+               Object obj = null;\r
+               \r
+               try {\r
+                       for (InputPart part : input.getParts()) {\r
+                               String partLabel = part.getHeaders().getFirst("label");\r
+                               if (label.equalsIgnoreCase(partLabel)) {\r
+                                       String partStr = part.getBodyAsString();\r
+                                       obj = part.getBody(clazz, null);\r
+                                       break;\r
+                               }\r
+                       }\r
+               } catch (Exception e) {\r
+                       e.printStackTrace();\r
+               }\r
+\r
+               return obj;\r
+       }\r
+       \r
+       /**\r
+        * Verbose.\r
+        * \r
+        * @param msg the msg\r
+        */\r
        void verbose(String msg) {\r
                System.out.println(msg);\r
        }\r
 \r
+       /**\r
+        * Verbose.\r
+        * \r
+        * @param msg the msg\r
+        * @param o the o\r
+        * @param clazz the clazz\r
+        */\r
        void verbose(String msg, Object o, Class clazz) {\r
                try {\r
                        verbose(msg);\r
@@ -85,6 +210,11 @@ public abstract class CollectionSpaceIntegrationTest {
                }\r
        }\r
 \r
+       /**\r
+        * Verbose map.\r
+        * \r
+        * @param map the map\r
+        */\r
        void verboseMap(MultivaluedMap map) {\r
                for (Object entry : map.entrySet()) {\r
                        MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry;\r
index 853141a767654cdbc7b3893241b4cd48f73755b3..57d0e277bef1c3a3938351c0431a29e1ddf69b66 100644 (file)
@@ -25,6 +25,8 @@ package org.collectionspace.services.ItegrationTests.test;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
@@ -50,23 +52,26 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 
 import org.collectionspace.services.client.TestServiceClient;
 
 import org.collectionspace.services.CollectionObjectJAXBSchema;
 import org.collectionspace.services.client.CollectionObjectClient;
-import org.collectionspace.services.collectionobject.CollectionObject;
-import org.collectionspace.services.collectionobject.CollectionObjectList;
+import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
+import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
 
 import org.collectionspace.services.IntakeJAXBSchema;
 import org.collectionspace.services.client.IntakeClient;
-import org.collectionspace.services.intake.Intake;
-import org.collectionspace.services.intake.IntakeList;
+import org.collectionspace.services.intake.IntakesCommon;
+import org.collectionspace.services.intake.IntakesCommonList;
 
 import org.collectionspace.services.common.relation.RelationJAXBSchema;
 import org.collectionspace.services.client.RelationClient;
-import org.collectionspace.services.relation.Relation;
-import org.collectionspace.services.relation.RelationList;
+import org.collectionspace.services.relation.RelationsCommon;
+import org.collectionspace.services.relation.RelationsCommonList;
 import org.collectionspace.services.relation.RelationshipType;
 
 /**
@@ -91,51 +96,77 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                //
                // First create a CollectionObject
                //
-               CollectionObject co = new CollectionObject();
+               CollectionobjectsCommon co = new CollectionobjectsCommon();
                fillCollectionObject(co, createIdentifier());
-           ClientResponse<Response> coResponse = collectionObjectClient.create(co);
-           Assert.assertEquals(coResponse.getStatus(), Response.Status.CREATED.getStatusCode());
-           String collectionObjectCsid = extractId(coResponse);
+               
+               // Next, create a part object
+               MultipartOutput multipart = new MultipartOutput();
+               OutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName());
+               // Make the create call and check the response
+               ClientResponse<Response> response = collectionObjectClient.create(multipart);
+               Assert.assertEquals(response.getStatus(), Response.Status.CREATED
+                               .getStatusCode());
+               String collectionObjectCsid = extractId(response);
+           
            
-           // Next, create an Intake record
-           Intake intake = new Intake();
+           // Next, create an Intake object
+           IntakesCommon intake = new IntakesCommon();
            fillIntake(intake, createIdentifier());
-           ClientResponse<Response> intakeResponse = intakeClient.create(intake);
-           Assert.assertEquals(intakeResponse.getStatus(), Response.Status.CREATED.getStatusCode());
-           String intakeCsid = extractId(intakeResponse);
+           // Create the a part object
+           multipart = new MultipartOutput();
+           commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+           commonPart.getHeaders().add("label", intakeClient.getCommonPartName());
+           // Make the call to create and check the response
+           response = intakeClient.create(multipart);
+           Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+           String intakeCsid = extractId(response);
            
-           // Lastly, relate the two entities
-           Relation relation = new Relation();
-           fillRelation(relation, collectionObjectCsid, CollectionObject.class.getSimpleName(),
-                       intakeCsid, Intake.class.getSimpleName(),
+           // Lastly, relate the two entities, by creating a new relation object
+           RelationsCommon relation = new RelationsCommon();
+           fillRelation(relation, collectionObjectCsid, CollectionobjectsCommon.class.getSimpleName(),
+                       intakeCsid, IntakesCommon.class.getSimpleName(),
                        RelationshipType.COLLECTIONOBJECT_INTAKE);
-           ClientResponse<Response> relationResponse = relationClient.create(relation); 
-           Assert.assertEquals(relationResponse.getStatus(), Response.Status.CREATED.getStatusCode());
-           String relationCsid = extractId(relationResponse);
+           // Create the part and fill it with the relation object
+           multipart = new MultipartOutput();
+           commonPart = multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
+           commonPart.getHeaders().add("label", relationClient.getCommonPartName());
+           // Make the call to crate
+           response = relationClient.create(multipart); 
+           Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+           String relationCsid = extractId(response);
            
            //
            // Now try to retrieve the Intake record of the CollectionObject.
            //
            String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.value();
-           ClientResponse<RelationList> resultResponse = relationClient.readList_SPO(collectionObjectCsid,
+           ClientResponse<RelationsCommonList> resultResponse = relationClient.readList_SPO(collectionObjectCsid,
                        predicate,
                        intakeCsid);
+           Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
            
            //
            // Each relation returned in the list needs to match what we
            // requested.
            //
-        RelationList relationList = resultResponse.getEntity();
-        List<RelationList.RelationListItem> relationListItems = relationList.getRelationListItem();
-        ClientResponse<Relation> resultRelationResponse;
-        Relation resultRelation = null;
+        RelationsCommonList relationList = resultResponse.getEntity();        
+        List<RelationsCommonList.RelationListItem> relationListItems = relationList.getRelationListItem();
+        Assert.assertFalse(relationListItems.isEmpty());
+        
+        ClientResponse<RelationsCommon> resultRelationResponse;
+        RelationsCommon resultRelation = null;
         int i = 0;
-        for(RelationList.RelationListItem listItem : relationListItems){
+        for(RelationsCommonList.RelationListItem listItem : relationListItems){
                
                String foundCsid = listItem.getCsid();
                try {
-                       resultRelationResponse = relationClient.read(foundCsid);
-                       resultRelation = resultRelationResponse.getEntity();
+                       ClientResponse<MultipartInput> multiPartResponse = relationClient.read(foundCsid);
+                       int responseStatus = multiPartResponse.getStatus();
+                       Assert.assertEquals(responseStatus, Response.Status.OK.getStatusCode());
+                       MultipartInput input = (MultipartInput) multiPartResponse.getEntity();
+                       resultRelation = (RelationsCommon) extractPart(input,
+                                       relationClient.getCommonPartName(),
+                                       RelationsCommon.class);
                } catch (Exception e) {
                        e.printStackTrace();
                }
index 69455525e6bc178e48ba8e8b4e31114de2e67cdb..762a32f154253805f3e56d7491f10bf34fd63509 100644 (file)
@@ -30,7 +30,7 @@ package org.collectionspace.services.common.relation.nuxeo;
 public class RelationConstants {
 
     public final static String NUXEO_DOCTYPE = "Relation";
-    public final static String NUXEO_SCHEMA_NAME = "relation";
+    public final static String NUXEO_SCHEMA_NAME = "relations_common";
     public final static String NUXEO_DC_TITLE = "CollectionSpace-Relation";
     /** The Constant REL_NUXEO_SCHEMA_ROOT_ELEMENT. */
     final public static String NUXEO_SCHEMA_ROOT_ELEMENT = "relationtype";
index aa3c1437005e94fcd72ed4fcf14cbb222b5a63e7..0ecb3f9ef6b291995cf96074cbc1ecfeef5d6f5b 100644 (file)
@@ -118,6 +118,12 @@ public abstract class RemoteDocumentModelHandler<T, TL>
         for(InputPart part : inputParts){
 
             String partLabel = part.getHeaders().getFirst("label");
+            if (partLabel == null) {
+                String msg = "Part label is missing or empty!";
+                logger.error(msg + "Ctx=" + getServiceContext().toString());
+                throw new BadRequestException(msg);
+            }
+            
             //skip if the part is not in metadata
             if(!partsMetaMap.containsKey(partLabel)){
                 continue;
index bc7d464b9721b7fbb7d26a855f93e56c65efa7bf..82aa9806deca3efba4b9b97b2dd56253d1b304ad 100644 (file)
         <module>relation</module>\r
         <!--module>query</module-->\r
         <module>acquisition</module>\r
-        \r
         <module>vocabulary</module>\r
-\r
         <module>id</module>\r
         <module>collectionobject</module>\r
         <module>intake</module>\r
         <module>JaxRsServiceProvider</module>\r
         <module>client</module>\r
         <module>sdk</module>\r
-        <!--module>IntegrationTests</module-->\r
+        <module>IntegrationTests</module>\r
     </modules>\r
 \r
     <repositories> </repositories>\r