]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
26ef6c287c1b081b06dea3a10f47f88f043f7715
[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.ServiceGroupClient;
31 import org.collectionspace.services.client.ServiceGroupProxy;
32 import org.collectionspace.services.client.PayloadOutputPart;
33 import org.collectionspace.services.client.PoxPayloadIn;
34 import org.collectionspace.services.client.PoxPayloadOut;
35 import org.collectionspace.services.jaxb.AbstractCommonList;
36 import org.collectionspace.services.servicegroup.ServicegroupsCommon;
37
38 import org.jboss.resteasy.client.ClientResponse;
39
40 import org.testng.Assert;
41 import org.testng.annotations.Test;
42
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
45
46 /**
47  * ServiceGroupServiceTest, carries out tests against a deployed and running ServiceGroup Service. <p/>
48  * $LastChangedRevision:  $
49  * $LastChangedDate:  $
50  */
51 public class ServiceGroupServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ServicegroupsCommon> {
52
53     private final String CLASS_NAME = ServiceGroupServiceTest.class.getName();
54     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
55     final String SERVICE_PATH_COMPONENT = "servicegroups";
56     private String knownResourceId = null;
57
58     @Override
59         public String getServicePathComponent() {
60                 return ServiceGroupClient.SERVICE_PATH_COMPONENT;
61         }
62
63         @Override
64         protected String getServiceName() {
65                 return ServiceGroupClient.SERVICE_NAME;
66         }
67     
68     @Override
69     protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, ServiceGroupProxy> getClientInstance() {
70         return new ServiceGroupClient();
71     }
72
73     @Override
74     protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
75         return response.getEntity(AbstractCommonList.class);
76     }
77
78     // ---------------------------------------------------------------
79     // Utility methods used by tests above
80     // ---------------------------------------------------------------
81     
82     @Override
83     protected PoxPayloadOut createInstance(String identifier) {
84         ServiceGroupClient client = new ServiceGroupClient();
85         return createInstance(client.getCommonPartName(), identifier);
86     }
87     
88         @Override
89         protected PoxPayloadOut createInstance(String commonPartName,
90                         String identifier) {
91                 return createServiceGroupInstance(identifier);
92         }
93     
94     private PoxPayloadOut createServiceGroupInstance(String uid) {
95         String identifier = "name-" + uid;
96         ServicegroupsCommon servicegroup = new ServicegroupsCommon();
97         servicegroup.setName(identifier);
98         PoxPayloadOut multipart = new PoxPayloadOut(ServiceGroupClient.SERVICE_PAYLOAD_NAME);
99         PayloadOutputPart commonPart = multipart.addPart(servicegroup, MediaType.APPLICATION_XML_TYPE);
100         commonPart.setLabel(new ServiceGroupClient().getCommonPartName());
101
102         if (logger.isDebugEnabled()) {
103             logger.debug("to be created, servicegroup common");
104             logger.debug(objectAsXmlString(servicegroup, ServicegroupsCommon.class));
105         }
106
107         return multipart;
108     }
109
110         @Override
111         public void CRUDTests(String testName) {
112                 // TODO Auto-generated method stub
113                 
114         }
115
116         @Override
117         protected ServicegroupsCommon updateInstance(ServicegroupsCommon servicegroupsCommon) {
118                 ServicegroupsCommon result = new ServicegroupsCommon();
119                 
120         result.setName("updated-" + servicegroupsCommon.getName());
121                 
122                 return result;
123         }
124
125         @Override
126         protected void compareUpdatedInstances(ServicegroupsCommon original,
127                         ServicegroupsCommon updated) throws Exception {
128                 Assert.assertEquals(updated.getName(), original.getName());
129         }
130 }