]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
66728a0642910fa4b4477d2e577588fad4a9fa4c
[tmp/jakarta-migration.git] /
1 /**
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:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
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.
22  */
23 package org.collectionspace.services.client.test;
24
25 import javax.ws.rs.core.MediaType;
26 import javax.ws.rs.core.Response;
27
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;
36
37 import org.jboss.resteasy.client.ClientResponse;
38
39 import org.testng.Assert;
40 import org.testng.annotations.Test;
41
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
44
45
46 /**
47  * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
48  * $LastChangedRevision:  $
49  * $LastChangedDate:  $
50  */
51 public class ObjectExitServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ObjectexitCommon> {
52
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";
56
57     @Override
58         public String getServicePathComponent() {
59                 return ObjectExitClient.SERVICE_PATH_COMPONENT;
60         }
61
62         @Override
63         protected String getServiceName() {
64                 return ObjectExitClient.SERVICE_NAME;
65         }
66     
67     @Override
68     protected CollectionSpaceClient getClientInstance() {
69         return new ObjectExitClient();
70     }
71
72     @Override
73     protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
74         return response.getEntity(AbstractCommonList.class);
75     }
76
77     // ---------------------------------------------------------------
78     // Utility methods used by tests above
79     // ---------------------------------------------------------------
80     
81     @Override
82     protected PoxPayloadOut createInstance(String identifier) {
83         ObjectExitClient client = new ObjectExitClient();
84         return createObjectExitInstance(identifier);
85     }
86     
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());
95
96         if (logger.isDebugEnabled()) {
97             logger.debug("to be created, objectexit common");
98             logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
99         }
100
101         return multipart;
102     }
103
104         @Override
105         public void CRUDTests(String testName) {
106                 // TODO Auto-generated method stub              
107         }
108
109         @Override
110         protected PoxPayloadOut createInstance(String commonPartName,
111                         String identifier) {
112         PoxPayloadOut result = createObjectExitInstance(createIdentifier());
113                 return result;
114         }
115
116         @Override
117         protected ObjectexitCommon updateInstance(ObjectexitCommon objectexitCommon) {
118                 ObjectexitCommon result = new ObjectexitCommon();
119
120                 result.setExitNumber("updated-" + objectexitCommon.getExitNumber());
121                 
122                 return result;
123         }
124
125         @Override
126         protected void compareUpdatedInstances(ObjectexitCommon original,
127                         ObjectexitCommon updated) throws Exception {
128                 Assert.assertEquals(updated.getExitNumber(), original.getExitNumber());
129         }
130 }