]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-3899
authorLaramie Crocker <laramie@berkeley.edu>
Wed, 11 May 2011 03:57:31 +0000 (03:57 +0000)
committerLaramie Crocker <laramie@berkeley.edu>
Wed, 11 May 2011 03:57:31 +0000 (03:57 +0000)
services/batch/client/src/test/java/org/collectionspace/services/client/test/BatchAuthRefsTest.java [deleted file]
services/batch/client/src/test/java/org/collectionspace/services/client/test/BatchServiceTest.java
services/batch/jaxb/src/main/java/org/collectionspace/services/BatchJAXBSchema.java
services/batch/jaxb/src/main/java/org/collectionspace/services/BatchListItemJAXBSchema.java

diff --git a/services/batch/client/src/test/java/org/collectionspace/services/client/test/BatchAuthRefsTest.java b/services/batch/client/src/test/java/org/collectionspace/services/client/test/BatchAuthRefsTest.java
deleted file mode 100644 (file)
index 50c3dbe..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- * This document is a part of the source code and related artifacts
- * for CollectionSpace, an open source collections management system
- * for museums and related institutions:
- *
- * http://www.collectionspace.org
- * http://wiki.collectionspace.org
- *
- * Copyright © 2009 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0.
- * You may not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.collectionspace.services.client.test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.collectionspace.services.PersonJAXBSchema;
-import org.collectionspace.services.client.CollectionSpaceClient;
-import org.collectionspace.services.client.ContactClient;
-import org.collectionspace.services.client.BatchClient;
-import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PersonAuthorityClient;
-import org.collectionspace.services.client.PersonAuthorityClientUtils;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.batch.BatchCommon;
-
-import org.jboss.resteasy.client.ClientResponse;
-
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BatchAuthRefsTest, carries out Authority References tests against a deployed and running Batch (aka Loans Out) Service.
- * $LastChangedRevision:  $
- * $LastChangedDate:  $
- */
-public class BatchAuthRefsTest extends BaseServiceTest {
-
-    private final String CLASS_NAME = BatchAuthRefsTest.class.getName();
-    private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
-    final String PERSON_AUTHORITY_NAME = "BatchPersonAuth";
-    private String knownResourceId = null;
-    private List<String> batchIdsCreated = new ArrayList<String>();
-    private List<String> personIdsCreated = new ArrayList<String>();
-    private String personAuthCSID = null;
-    private String depositorRefName = null;
-
-    private String name = null;
-    private String className = null;
-    private String forDocType = null;
-    private String notes = null;
-
-    @Override
-       public String getServicePathComponent() {
-               return BatchClient.SERVICE_PATH_COMPONENT;
-       }
-
-       @Override
-       protected String getServiceName() {
-               return BatchClient.SERVICE_NAME;
-       }
-    
-    @Override
-    protected CollectionSpaceClient getClientInstance() {
-        throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
-    }
-
-    @Override
-    protected AbstractCommonList getAbstractCommonList(ClientResponse<AbstractCommonList> response) {
-        throw new UnsupportedOperationException(); //method not supported (or needed) in this test class
-    }
-
-    private PoxPayloadOut createBatchInstance(String className, String forDocType, String notes) {
-        this.className = className;
-        this.forDocType = forDocType;
-        this.notes = notes;
-
-        BatchCommon batch = new BatchCommon();
-        batch.setClassName(className);
-        batch.setForDocType(forDocType);
-        batch.setNotes(notes);
-
-        PoxPayloadOut multipart = new PoxPayloadOut(BatchClient.SERVICE_PAYLOAD_NAME);
-        PayloadOutputPart commonPart = multipart.addPart(batch, MediaType.APPLICATION_XML_TYPE);
-        commonPart.setLabel(new BatchClient().getCommonPartName());
-        logger.debug("to be created, batch common: " + objectAsXmlString(batch, BatchCommon.class));
-        return multipart;
-    }
-
-    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
-    public void createWithAuthRefs(String testName) throws Exception {
-        logger.debug(testBanner(testName, CLASS_NAME));
-        testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
-        String identifier = createIdentifier(); // Submit the request to the service and store the response.
-        createPersonRefs();// Create all the person refs and entities
-        // Create a new Loans In resource. One or more fields in this resource will be PersonAuthority
-        //    references, and will refer to Person resources by their refNames.
-        BatchClient batchClient = new BatchClient();
-        //private PoxPayloadOut createBatchInstance(String className, String forDocType, String notes) {
-        PoxPayloadOut multipart = createBatchInstance("className", "docType-"+identifier, "Notes-" + identifier);
-        ClientResponse<Response> res = batchClient.create(multipart);
-        assertStatusCode(res, testName);
-        if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
-            knownResourceId = extractId(res);
-        }
-        batchIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
-    }
-
-    protected void createPersonRefs() {
-        PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
-        // Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
-        PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        assertStatusCode(res, "createPersonRefs (not a surefire test)");
-        personAuthCSID = extractId(res);
-        String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
-        // Create temporary Person resources, and their corresponding refNames by which they can be identified.
-        String csid = "";
-
-        csid = createPerson("Owen the Cur", "Owner", "owenCurOwner", authRefName);
-        personIdsCreated.add(csid);
-        depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
-
-        csid = createPerson("Davenport", "Depositor", "davenportDepositor", authRefName);
-        personIdsCreated.add(csid);
-        depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
-    }
-
-    protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
-        PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
-        Map<String, String> personInfo = new HashMap<String, String>();
-        personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
-        personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
-        personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
-        PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, authRefName, personInfo, personAuthClient.getItemCommonPartName());
-        ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
-        assertStatusCode(res, "createPerson (not a surefire test)");
-        return extractId(res);
-    }
-
-    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"createWithAuthRefs"})
-    public void readAndCheckAuthRefs(String testName) throws Exception {
-        logger.debug(testBanner(testName, CLASS_NAME));
-        testSetup(STATUS_OK, ServiceRequestType.READ);
-        BatchClient batchClient = new BatchClient();
-        ClientResponse<String> res = batchClient.read(knownResourceId);
-        assertStatusCode(res, testName);
-        PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
-        BatchCommon batch = (BatchCommon) extractPart(input, batchClient.getCommonPartName(), BatchCommon.class);
-        Assert.assertNotNull(batch);
-        logger.debug(objectAsXmlString(batch, BatchCommon.class));
-
-        // Check a couple of fields
-        Assert.assertEquals(batch.getClassName(), className);
-        Assert.assertEquals(batch.getForDocType(), forDocType);
-        Assert.assertEquals(batch.getName(), name);
-        Assert.assertEquals(batch.getNotes(), notes);
-
-        // Get the auth refs and check them
-        ClientResponse<AuthorityRefList> res2 = batchClient.getAuthorityRefs(knownResourceId);
-        assertStatusCode(res2, testName);
-        AuthorityRefList list = res2.getEntity();
-        List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
-        int numAuthRefsFound = items.size();
-        logger.debug("Authority references, found " + numAuthRefsFound);
-        //Assert.assertEquals(numAuthRefsFound, NUM_AUTH_REFS_EXPECTED,
-        //                    "Did not find all expected authority references! " +
-        //                    "Expected " + NUM_AUTH_REFS_EXPECTED + ", found " + numAuthRefsFound);
-        if (logger.isDebugEnabled()) {
-            int i = 0;
-            for (AuthorityRefList.AuthorityRefItem item : items) {
-                logger.debug(testName + ": list-item[" + i + "] Field:" + item.getSourceField() + "= " + item.getAuthDisplayName() + item.getItemDisplayName());
-                logger.debug(testName + ": list-item[" + i + "] refName=" + item.getRefName());
-                logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri());
-                i++;
-            }
-        }
-    }
-
-    /**
-     * Deletes all resources created by tests, after all tests have been run.
-     * <p/>
-     * This cleanup method will always be run, even if one or more tests fail.
-     * For this reason, it attempts to remove all resources created
-     * at any point during testing, even if some of those resources
-     * may be expected to be deleted by certain tests.
-     */
-    @AfterClass(alwaysRun = true)
-    public void cleanUp() {
-        String noTest = System.getProperty("noTestCleanup");
-        if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
-            logger.debug("Skipping Cleanup phase ...");
-            return;
-        }
-        logger.debug("Cleaning up temporary resources created for testing ...");
-        PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
-        // Delete Person resource(s) (before PersonAuthority resources).
-        for (String resourceId : personIdsCreated) {
-            // Note: Any non-success responses are ignored and not reported.
-            personAuthClient.deleteItem(personAuthCSID, resourceId);
-        }
-        // Delete PersonAuthority resource(s).
-        // Note: Any non-success response is ignored and not reported.
-        if (personAuthCSID != null) {
-            personAuthClient.delete(personAuthCSID);
-            // Delete Loans In resource(s).
-            BatchClient batchClient = new BatchClient();
-            for (String resourceId : batchIdsCreated) {
-                // Note: Any non-success responses are ignored and not reported.
-                batchClient.delete(resourceId);
-            }
-        }
-    }
-
-}
index efc5051ac67c68000812b5d0cf7a5a8f95e2dc65..14467be1074eb1643ecd1d56470ee255637c888a 100644 (file)
@@ -140,23 +140,6 @@ public class BatchServiceTest extends AbstractServiceTestImpl {
                 i++;
             }
         }
-
-        /*
-        List<AbstractCommonList.ListItem> items = list.getListItem();
-        int i = 0;
-        for(AbstractCommonList.ListItem item : items){
-            List<Element> elList = item.getAny();
-            StringBuilder elementStrings = new StringBuilder();
-            for(Element el : elList) {
-                Node textEl = el.getFirstChild();
-                if (textEl != null){
-                    elementStrings.append("["+el.getNodeName()+":"+textEl.getNodeValue()+"] ");
-                }
-            }
-            System.out.println("\r\n\r\n\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~"+testName + ": list-item[" + i + "]: "+elementStrings.toString());
-            i++;
-        }
-        */
     }
 
     @Override
index 8613c08687ff014e37a1c9f2311a9b80a461a5c8..99e8176186acd4a05b8db41d1f8432d34ec1f673 100644 (file)
@@ -4,13 +4,6 @@
 package org.collectionspace.services;
 
 public interface BatchJAXBSchema {
-    final static String OBJECT_EXIT_CURRENT_OWNER = "currentOwner";
-    final static String OBJECT_EXIT_DEPOSITOR = "depositor";
-    final static String OBJECT_EXIT_DATE = "exitDate";
-    final static String OBJECT_EXIT_METHODS = "exitMethods";
-    final static String OBJECT_EXIT_METHOD = "exitMethod";
-    final static String OBJECT_EXIT_NOTE = "exitNote";
-    final static String OBJECT_EXIT_NUMBER = "exitNumber";
-    final static String OBJECT_EXIT_REASON = "exitReason";
-    final static String OBJECT_EXIT_PACKING_NOTE = "packingNote";
+    final static String BATCH_NAME = "name";
+    final static String BATCH_FORDOCTYPE = "forDocType";
 }
index ab7f830294a878b023332dc9db9f164a4001cb06..4c8df2315dfcc826e4a7fab88c662e389a564374 100644 (file)
@@ -1,9 +1,6 @@
 package org.collectionspace.services;
 
 public interface BatchListItemJAXBSchema {
-    final static String OBJECT_EXIT_CURRENT_OWNER = "currentOwner";
-    final static String OBJECT_EXIT_NUMBER = "exitNumber";
-    
        final static String CSID = "csid";
        final static String URI = "url";
 }