]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
824163f0673329d347515a98cd3e62d9e3a78255
[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.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;
34
35 import org.testng.Assert;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 /**
40  * ObjectExitServiceTest, carries out tests against a deployed and running ObjectExit Service. <p/>
41  * $LastChangedRevision:  $
42  * $LastChangedDate:  $
43  */
44 public class ObjectExitServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ObjectexitCommon> {
45
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";
49
50     @Override
51         public String getServicePathComponent() {
52                 return ObjectExitClient.SERVICE_PATH_COMPONENT;
53         }
54
55         @Override
56         protected String getServiceName() {
57                 return ObjectExitClient.SERVICE_NAME;
58         }
59     
60     @Override
61     protected CollectionSpaceClient getClientInstance() {
62         return new ObjectExitClient();
63     }
64
65         @Override
66         protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
67         return new ObjectExitClient(clientPropertiesFilename);
68         }
69
70     @Override
71     protected AbstractCommonList getCommonList(Response response) {
72         return response.readEntity(AbstractCommonList.class);
73     }
74
75     // ---------------------------------------------------------------
76     // Utility methods used by tests above
77     // ---------------------------------------------------------------
78     
79     @Override
80     protected PoxPayloadOut createInstance(String identifier) {
81         ObjectExitClient client = new ObjectExitClient();
82         return createObjectExitInstance(identifier);
83     }
84     
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());
93
94         if (logger.isDebugEnabled()) {
95             logger.debug("to be created, objectexit common");
96             logger.debug(objectAsXmlString(objectexit, ObjectexitCommon.class));
97         }
98
99         return multipart;
100     }
101
102         @Override
103         public void CRUDTests(String testName) {
104                 // TODO Auto-generated method stub              
105         }
106
107         @Override
108         protected PoxPayloadOut createInstance(String commonPartName,
109                         String identifier) {
110         PoxPayloadOut result = createObjectExitInstance(createIdentifier());
111                 return result;
112         }
113
114         @Override
115         protected ObjectexitCommon updateInstance(ObjectexitCommon objectexitCommon) {
116                 ObjectexitCommon result = new ObjectexitCommon();
117
118                 result.setExitNumber("updated-" + objectexitCommon.getExitNumber());
119                 
120                 return result;
121         }
122
123         @Override
124         protected void compareUpdatedInstances(ObjectexitCommon original,
125                         ObjectexitCommon updated) throws Exception {
126                 Assert.assertEquals(updated.getExitNumber(), original.getExitNumber());
127         }
128 }