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.AbstractCommonListUtils;
29 import org.collectionspace.services.client.CollectionSpaceClient;
30 import org.collectionspace.services.client.ObjectExitClient;
31 import org.collectionspace.services.client.PayloadOutputPart;
32 import org.collectionspace.services.client.PoxPayloadIn;
33 import org.collectionspace.services.client.PoxPayloadOut;
34 import org.collectionspace.services.jaxb.AbstractCommonList;
35 import org.collectionspace.services.objectexit.ObjectexitCommon;
37 import org.jboss.resteasy.client.ClientResponse;
39 import org.testng.Assert;
40 import org.testng.annotations.Test;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
47 * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
48 * $LastChangedRevision: $
51 public class ObjectExitServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ObjectexitCommon> {
53 private final String CLASS_NAME = ObjectExitServiceTest.class.getName();
54 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
55 final String SERVICE_PATH_COMPONENT = "objectexit";
58 public String getServicePathComponent() {
59 return ObjectExitClient.SERVICE_PATH_COMPONENT;
63 protected String getServiceName() {
64 return ObjectExitClient.SERVICE_NAME;
68 protected CollectionSpaceClient getClientInstance() {
69 return new ObjectExitClient();
73 protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
74 return response.getEntity(AbstractCommonList.class);
77 // ---------------------------------------------------------------
78 // Utility methods used by tests above
79 // ---------------------------------------------------------------
82 protected PoxPayloadOut createInstance(String identifier) {
83 ObjectExitClient client = new ObjectExitClient();
84 return createObjectExitInstance(identifier);
87 private PoxPayloadOut createObjectExitInstance(String exitNumber) {
88 String identifier = "objectexitNumber-" + exitNumber;
89 ObjectexitCommon objectexit = new ObjectexitCommon();
90 objectexit.setExitNumber(identifier);
91 objectexit.setDepositor("urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'");
92 PoxPayloadOut multipart = new PoxPayloadOut(ObjectExitClient.SERVICE_PAYLOAD_NAME);
93 PayloadOutputPart commonPart = multipart.addPart(objectexit, MediaType.APPLICATION_XML_TYPE);
94 commonPart.setLabel(new ObjectExitClient().getCommonPartName());
96 if (logger.isDebugEnabled()) {
97 logger.debug("to be created, objectexit common");
98 logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
105 public void CRUDTests(String testName) {
106 // TODO Auto-generated method stub
110 protected PoxPayloadOut createInstance(String commonPartName,
112 PoxPayloadOut result = createObjectExitInstance(createIdentifier());
117 protected ObjectexitCommon updateInstance(ObjectexitCommon objectexitCommon) {
118 ObjectexitCommon result = new ObjectexitCommon();
120 result.setExitNumber("updated-" + objectexitCommon.getExitNumber());
126 protected void compareUpdatedInstances(ObjectexitCommon original,
127 ObjectexitCommon updated) throws Exception {
128 Assert.assertEquals(updated.getExitNumber(), original.getExitNumber());