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 org.collectionspace.services.client.CollectionSpaceClient;
26 import org.collectionspace.services.client.PottagClient;
27 import org.collectionspace.services.client.PayloadOutputPart;
28 import org.collectionspace.services.client.PoxPayloadOut;
29 import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
30 import org.collectionspace.services.jaxb.AbstractCommonList;
31 import org.collectionspace.services.pottag.PottagsCommon;
33 import org.testng.Assert;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
39 * PottagServiceTest, carries out tests against a
40 * deployed and running Pottag (aka Pot Tag) Service.
42 * $LastChangedRevision$
45 public class PottagServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, PottagsCommon> {
48 private final String CLASS_NAME = PottagServiceTest.class.getName();
49 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
50 // Instance variables specific to this test.
51 private final static String CURRENT_DATE_UTC = GregorianCalendarDateTimeUtils.currentDateUTC();
54 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
57 protected CollectionSpaceClient getClientInstance() throws Exception {
58 return new PottagClient();
62 protected void compareReadInstances(PottagsCommon original, PottagsCommon pottagCommon) throws Exception {
63 if (logger.isDebugEnabled()) {
64 logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
65 + "UTF-8 data received=" + pottagCommon.getLabelData());
68 Assert.assertEquals(pottagCommon.getLabelData(), getUTF8DataFragment(),
69 "UTF-8 data retrieved '" + pottagCommon.getLabelData()
70 + "' does not match expected data '" + getUTF8DataFragment());
74 protected void compareUpdatedInstances(PottagsCommon pottagCommon,
75 PottagsCommon updatedPottagCommon) throws Exception {
76 // Check selected fields in the updated common part.
77 Assert.assertEquals(updatedPottagCommon.getFamily(), pottagCommon.getFamily(),
78 "Data in updated object did not match submitted data.");
80 if (logger.isDebugEnabled()) {
81 logger.debug("UTF-8 data sent=" + pottagCommon.getLabelData() + "\n"
82 + "UTF-8 data received=" + updatedPottagCommon.getLabelData());
84 Assert.assertTrue(updatedPottagCommon.getLabelData().contains(getUTF8DataFragment()),
85 "UTF-8 data retrieved '" + updatedPottagCommon.getLabelData() + "' does not contain expected data '" + getUTF8DataFragment());
86 Assert.assertEquals(updatedPottagCommon.getLabelData(),
87 pottagCommon.getLabelData(), "Data in updated object did not match submitted data.");
90 // ---------------------------------------------------------------
91 // Utility methods used by tests above
92 // ---------------------------------------------------------------
95 public String getServiceName() {
96 return PottagClient.SERVICE_NAME;
100 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
103 public String getServicePathComponent() {
104 return PottagClient.SERVICE_PATH_COMPONENT;
108 protected PoxPayloadOut createInstance(String identifier) throws Exception {
109 return createPottagInstance(identifier);
113 * Creates the pottag instance.
115 * @param identifier the identifier
116 * @return the multipart output
119 private PoxPayloadOut createPottagInstance(String identifier) throws Exception {
120 return createPottagInstance(
121 "family-" + identifier,
122 "returnDate-" + identifier);
126 * Creates the pottag instance.
128 * @param familyName the pottag family
129 * @param returnDate the return date
130 * @return the multipart output
133 private PoxPayloadOut createPottagInstance(String familyName,
134 String returnDate) throws Exception {
136 PottagsCommon pottagCommon = new PottagsCommon();
137 pottagCommon.setFamily(familyName);
138 pottagCommon.setLocale("Mexico");
139 pottagCommon.setLabelData(getUTF8DataFragment());
141 PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
142 PayloadOutputPart commonPart =
143 multipart.addPart(new PottagClient().getCommonPartName(), pottagCommon);
145 if (logger.isDebugEnabled()) {
146 logger.debug("to be created, pottag common");
147 logger.debug(objectAsXmlString(pottagCommon, PottagsCommon.class));
154 public void CRUDTests(String testName) {
155 // TODO Auto-generated method stub
160 protected PoxPayloadOut createInstance(String commonPartName,
161 String identifier) throws Exception {
162 PoxPayloadOut result = createPottagInstance(identifier);
167 protected PottagsCommon updateInstance(PottagsCommon commonPartObject) {
168 // TODO Auto-generated method stub
173 protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
174 // TODO Auto-generated method stub