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.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;
38 import org.jboss.resteasy.client.ClientResponse;
40 import org.testng.Assert;
41 import org.testng.annotations.Test;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
47 * ServiceGroupServiceTest, carries out tests against a deployed and running ServiceGroup Service. <p/>
48 * $LastChangedRevision: $
51 public class ServiceGroupServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ServicegroupsCommon> {
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;
59 public String getServicePathComponent() {
60 return ServiceGroupClient.SERVICE_PATH_COMPONENT;
64 protected String getServiceName() {
65 return ServiceGroupClient.SERVICE_NAME;
69 protected CollectionSpaceClient<AbstractCommonList, PoxPayloadOut, String, ServiceGroupProxy> getClientInstance() {
70 return new ServiceGroupClient();
74 protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
75 return response.getEntity(AbstractCommonList.class);
78 // ---------------------------------------------------------------
79 // Utility methods used by tests above
80 // ---------------------------------------------------------------
83 protected PoxPayloadOut createInstance(String identifier) {
84 ServiceGroupClient client = new ServiceGroupClient();
85 return createInstance(client.getCommonPartName(), identifier);
89 protected PoxPayloadOut createInstance(String commonPartName,
91 return createServiceGroupInstance(identifier);
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());
102 if (logger.isDebugEnabled()) {
103 logger.debug("to be created, servicegroup common");
104 logger.debug(objectAsXmlString(servicegroup, ServicegroupsCommon.class));
111 public void CRUDTests(String testName) {
112 // TODO Auto-generated method stub
117 protected ServicegroupsCommon updateInstance(ServicegroupsCommon servicegroupsCommon) {
118 ServicegroupsCommon result = new ServicegroupsCommon();
120 result.setName("updated-" + servicegroupsCommon.getName());
126 protected void compareUpdatedInstances(ServicegroupsCommon original,
127 ServicegroupsCommon updated) throws Exception {
128 Assert.assertEquals(updated.getName(), original.getName());