2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright © 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.client.test;
25 import javax.ws.rs.core.MediaType;
26 import javax.ws.rs.core.Response;
28 import org.collectionspace.services.client.CollectionSpaceClient;
29 import org.collectionspace.services.client.ObjectExitClient;
30 import org.collectionspace.services.client.PayloadOutputPart;
31 import org.collectionspace.services.client.PoxPayloadOut;
32 import org.collectionspace.services.jaxb.AbstractCommonList;
33 import org.collectionspace.services.objectexit.ObjectexitCommon;
35 import org.testng.Assert;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
40 * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
41 * $LastChangedRevision: $
44 public class ObjectExitServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ObjectexitCommon> {
46 private final String CLASS_NAME = ObjectExitServiceTest.class.getName();
47 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
48 final String SERVICE_PATH_COMPONENT = "objectexit";
51 public String getServicePathComponent() {
52 return ObjectExitClient.SERVICE_PATH_COMPONENT;
56 protected String getServiceName() {
57 return ObjectExitClient.SERVICE_NAME;
61 protected CollectionSpaceClient getClientInstance() {
62 return new ObjectExitClient();
66 protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
67 return new ObjectExitClient(clientPropertiesFilename);
71 protected AbstractCommonList getCommonList(Response response) {
72 return response.readEntity(AbstractCommonList.class);
75 // ---------------------------------------------------------------
76 // Utility methods used by tests above
77 // ---------------------------------------------------------------
80 protected PoxPayloadOut createInstance(String identifier) {
81 ObjectExitClient client = new ObjectExitClient();
82 return createObjectExitInstance(identifier);
85 private PoxPayloadOut createObjectExitInstance(String exitNumber) {
86 String identifier = "objectexitNumber-" + exitNumber;
87 ObjectexitCommon objectexit = new ObjectexitCommon();
88 objectexit.setExitNumber(identifier);
89 objectexit.setDepositor("urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'");
90 PoxPayloadOut multipart = new PoxPayloadOut(ObjectExitClient.SERVICE_PAYLOAD_NAME);
91 PayloadOutputPart commonPart = multipart.addPart(objectexit, MediaType.APPLICATION_XML_TYPE);
92 commonPart.setLabel(new ObjectExitClient().getCommonPartName());
94 if (logger.isDebugEnabled()) {
95 logger.debug("to be created, objectexit common");
96 logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
103 public void CRUDTests(String testName) {
104 // TODO Auto-generated method stub
108 protected PoxPayloadOut createInstance(String commonPartName,
110 PoxPayloadOut result = createObjectExitInstance(createIdentifier());
115 protected ObjectexitCommon updateInstance(ObjectexitCommon objectexitCommon) {
116 ObjectexitCommon result = new ObjectexitCommon();
118 result.setExitNumber("updated-" + objectexitCommon.getExitNumber());
124 protected void compareUpdatedInstances(ObjectexitCommon original,
125 ObjectexitCommon updated) throws Exception {
126 Assert.assertEquals(updated.getExitNumber(), original.getExitNumber());