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 (c)) 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 java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
29 import javax.ws.rs.core.MediaType;
30 import javax.ws.rs.core.Response;
32 import org.collectionspace.services.LocationJAXBSchema;
33 import org.collectionspace.services.client.CollectionSpaceClient;
34 import org.collectionspace.services.client.ContactClient;
35 import org.collectionspace.services.client.ContactClientUtils;
36 import org.collectionspace.services.contact.ContactsCommon;
37 import org.collectionspace.services.contact.ContactsCommonList;
38 import org.collectionspace.services.client.LocationAuthorityClient;
39 import org.collectionspace.services.client.LocationAuthorityClientUtils;
40 import org.collectionspace.services.jaxb.AbstractCommonList;
41 import org.collectionspace.services.location.LocationauthoritiesCommon;
42 import org.collectionspace.services.location.LocationauthoritiesCommonList;
43 import org.collectionspace.services.location.LocationsCommon;
44 import org.collectionspace.services.location.LocationsCommonList;
45 import org.jboss.resteasy.client.ClientResponse;
46 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
47 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
48 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
51 import org.testng.Assert;
52 import org.testng.annotations.AfterClass;
53 import org.testng.annotations.Test;
56 * LocationAuthorityServiceTest, carries out tests against a
57 * deployed and running LocationAuthority Service.
59 * $LastChangedRevision: 753 $
60 * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
62 public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
65 private final String CLASS_NAME = LocationAuthorityServiceTest.class.getName();
66 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
68 // Instance variables specific to this test.
70 /** The SERVICE path component. */
71 final String SERVICE_PATH_COMPONENT = "locationauthorities";
73 /** The ITEM service path component. */
74 final String ITEM_SERVICE_PATH_COMPONENT = "items";
76 /** The CONTACT service path component. */
77 final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
79 final String TEST_NAME = "Shelf 1";
80 final String TEST_SHORTID = "shelf1";
81 final String TEST_CONDITION_NOTE = "Basically clean";
82 final String TEST_CONDITION_NOTE_DATE = "June 11, 1979";
83 final String TEST_SECURITY_NOTE = "Kind of safe";
84 // TODO Make loc type be a controlled vocab term.
85 final String TEST_LOCATION_TYPE = "Shelf";
86 // TODO Make status type be a controlled vocab term.
87 final String TEST_STATUS = "Approved";
89 /** The known resource id. */
90 private String knownResourceId = null;
91 private String knownResourceShortIdentifer = null;
92 private String knownResourceRefName = null;
93 private String knownLocationTypeRefName = null;
94 private String knownItemResourceId = null;
95 private String knownItemResourceShortIdentifer = null;
96 private String knownContactResourceId = null;
98 /** The n items to create in list. */
99 private int nItemsToCreateInList = 3;
101 /** The all resource ids created. */
102 private List<String> allResourceIdsCreated = new ArrayList<String>();
104 /** The all item resource ids created. */
105 private Map<String, String> allItemResourceIdsCreated =
106 new HashMap<String, String>();
108 protected void setKnownResource( String id, String shortIdentifer,
110 knownResourceId = id;
111 knownResourceShortIdentifer = shortIdentifer;
112 knownResourceRefName = refName;
115 protected void setKnownItemResource( String id, String shortIdentifer ) {
116 knownItemResourceId = id;
117 knownItemResourceShortIdentifer = shortIdentifer;
121 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
124 protected CollectionSpaceClient getClientInstance() {
125 return new LocationAuthorityClient();
129 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
132 protected AbstractCommonList getAbstractCommonList(
133 ClientResponse<AbstractCommonList> response) {
134 return response.getEntity(LocationsCommonList.class);
137 // ---------------------------------------------------------------
138 // CRUD tests : CREATE tests
139 // ---------------------------------------------------------------
142 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
145 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
147 public void create(String testName) throws Exception {
149 if (logger.isDebugEnabled()) {
150 logger.debug(testBanner(testName, CLASS_NAME));
152 // Perform setup, such as initializing the type of service request
153 // (e.g. CREATE, DELETE), its valid and expected status codes, and
154 // its associated HTTP method name (e.g. POST, DELETE).
157 // Submit the request to the service and store the response.
158 LocationAuthorityClient client = new LocationAuthorityClient();
159 String shortId = createIdentifier();
160 String displayName = "displayName-" + shortId;
161 String baseRefName = LocationAuthorityClientUtils.createLocationAuthRefName(shortId, null);
162 MultipartOutput multipart =
163 LocationAuthorityClientUtils.createLocationAuthorityInstance(
164 displayName, shortId, client.getCommonPartName());
166 ClientResponse<Response> res = client.create(multipart);
168 int statusCode = res.getStatus();
170 // Check the status code of the response: does it match
171 // the expected response(s)?
174 // Does it fall within the set of valid status codes?
175 // Does it exactly match the expected status code?
176 if(logger.isDebugEnabled()){
177 logger.debug(testName + ": status = " + statusCode);
179 Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
180 invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
181 Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
183 newID = LocationAuthorityClientUtils.extractId(res);
185 res.releaseConnection();
187 // Store the ID returned from the first resource created
188 // for additional tests below.
189 if (knownResourceId == null){
190 setKnownResource( newID, shortId, baseRefName );
191 if (logger.isDebugEnabled()) {
192 logger.debug(testName + ": knownResourceId=" + knownResourceId);
195 // Store the IDs from every resource created by tests,
196 // so they can be deleted after tests have been run.
197 allResourceIdsCreated.add(newID);
203 * @param testName the test name
205 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
206 groups = {"create"}, dependsOnMethods = {"create"})
207 public void createItem(String testName) {
208 if(logger.isDebugEnabled()){
209 logger.debug(testBanner(testName, CLASS_NAME));
212 createItemInAuthority(knownResourceId, knownResourceRefName);
216 * Creates the item in authority.
218 * @param vcsid the vcsid
219 * @param authRefName the auth ref name
222 private String createItemInAuthority(String vcsid, String authRefName) {
224 final String testName = "createItemInAuthority("+vcsid+","+authRefName+")";
225 if(logger.isDebugEnabled()){
226 logger.debug(testBanner(testName, CLASS_NAME));
229 // Submit the request to the service and store the response.
230 LocationAuthorityClient client = new LocationAuthorityClient();
231 Map<String, String> shelf1Map = new HashMap<String,String>();
232 // TODO Make loc type and status be controlled vocabs.
233 shelf1Map.put(LocationJAXBSchema.NAME, TEST_NAME);
234 shelf1Map.put(LocationJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
235 shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
236 shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
237 shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
238 shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
239 shelf1Map.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
241 String newID = LocationAuthorityClientUtils.createItemInAuthority(vcsid,
242 authRefName, shelf1Map, client );
244 // Store the ID returned from the first item resource created
245 // for additional tests below.
246 if (knownItemResourceId == null){
247 setKnownItemResource(newID, TEST_SHORTID);
248 if (logger.isDebugEnabled()) {
249 logger.debug(testName + ": knownItemResourceId=" + newID);
253 // Store the IDs from any item resources created
254 // by tests, along with the IDs of their parents, so these items
255 // can be deleted after all tests have been run.
256 allItemResourceIdsCreated.put(newID, vcsid);
265 // Placeholders until the three tests below can be uncommented.
266 // See Issue CSPACE-401.
268 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
271 public void createWithEmptyEntityBody(String testName) throws Exception {
275 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
278 public void createWithMalformedXml(String testName) throws Exception {
282 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
285 public void createWithWrongXmlSchema(String testName) throws Exception {
289 // ---------------------------------------------------------------
290 // CRUD tests : CREATE LIST tests
291 // ---------------------------------------------------------------
294 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
297 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
298 groups = {"createList"}, dependsOnGroups = {"create"})
299 public void createList(String testName) throws Exception {
300 for (int i = 0; i < nItemsToCreateInList; i++) {
306 * Creates the item list.
308 * @param testName the test name
309 * @throws Exception the exception
311 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
312 groups = {"createList"}, dependsOnMethods = {"createList"})
313 public void createItemList(String testName) throws Exception {
314 // Add items to the initially-created, known parent record.
315 for (int j = 0; j < nItemsToCreateInList; j++) {
316 createItem(testName);
320 // ---------------------------------------------------------------
321 // CRUD tests : READ tests
322 // ---------------------------------------------------------------
325 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
328 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
329 groups = {"read"}, dependsOnGroups = {"create"})
330 public void read(String testName) throws Exception {
332 if (logger.isDebugEnabled()) {
333 logger.debug(testBanner(testName, CLASS_NAME));
338 // Submit the request to the service and store the response.
339 LocationAuthorityClient client = new LocationAuthorityClient();
341 ClientResponse<MultipartInput> res = client.read(knownResourceId);
343 int statusCode = res.getStatus();
345 // Check the status code of the response: does it match
346 // the expected response(s)?
347 if(logger.isDebugEnabled()){
348 logger.debug(testName + ": status = " + statusCode);
350 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
351 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
352 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
353 //FIXME: remove the following try catch once Aron fixes signatures
355 MultipartInput input = (MultipartInput) res.getEntity();
356 LocationauthoritiesCommon locationAuthority =
357 (LocationauthoritiesCommon) extractPart(input,
358 client.getCommonPartName(), LocationauthoritiesCommon.class);
359 Assert.assertNotNull(locationAuthority);
360 } catch (Exception e) {
361 throw new RuntimeException(e);
364 res.releaseConnection();
371 * @param testName the test name
372 * @throws Exception the exception
374 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
375 groups = {"read"}, dependsOnGroups = {"create"})
376 public void readByName(String testName) throws Exception {
378 if (logger.isDebugEnabled()) {
379 logger.debug(testBanner(testName+"("+knownResourceShortIdentifer+")", CLASS_NAME));
384 // Submit the request to the service and store the response.
385 LocationAuthorityClient client = new LocationAuthorityClient();
386 ClientResponse<MultipartInput> res = client.readByName(knownResourceShortIdentifer);
388 int statusCode = res.getStatus();
390 // Check the status code of the response: does it match
391 // the expected response(s)?
392 if(logger.isDebugEnabled()){
393 logger.debug(testName + ": status = " + statusCode);
395 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
396 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
397 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
398 //FIXME: remove the following try catch once Aron fixes signatures
400 MultipartInput input = (MultipartInput) res.getEntity();
401 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
402 client.getCommonPartName(), LocationauthoritiesCommon.class);
403 Assert.assertNotNull(locationAuthority);
404 } catch (Exception e) {
405 throw new RuntimeException(e);
408 res.releaseConnection();
416 * @param testName the test name
417 * @throws Exception the exception
419 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
420 groups = {"read"}, dependsOnMethods = {"read"})
421 public void readItem(String testName) throws Exception {
423 if (logger.isDebugEnabled()) {
424 logger.debug(testBanner(testName, CLASS_NAME));
429 // Submit the request to the service and store the response.
430 LocationAuthorityClient client = new LocationAuthorityClient();
431 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
433 int statusCode = res.getStatus();
435 // Check the status code of the response: does it match
436 // the expected response(s)?
437 if(logger.isDebugEnabled()){
438 logger.debug(testName + ": status = " + statusCode);
440 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
441 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
442 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
444 // Check whether we've received a location.
445 MultipartInput input = (MultipartInput) res.getEntity();
446 LocationsCommon location = (LocationsCommon) extractPart(input,
447 client.getItemCommonPartName(), LocationsCommon.class);
448 Assert.assertNotNull(location);
449 boolean showFull = true;
450 if(showFull && logger.isDebugEnabled()){
451 logger.debug(testName + ": returned payload:");
452 logger.debug(objectAsXmlString(location, LocationsCommon.class));
454 Assert.assertEquals(location.getInAuthority(), knownResourceId);
456 res.releaseConnection();
462 * Verify item display name.
464 * @param testName the test name
465 * @throws Exception the exception
467 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
468 dependsOnMethods = {"readItem", "updateItem"})
469 public void verifyItemDisplayName(String testName) throws Exception {
471 if (logger.isDebugEnabled()) {
472 logger.debug(testBanner(testName, CLASS_NAME));
477 // Submit the request to the service and store the response.
478 LocationAuthorityClient client = new LocationAuthorityClient();
479 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
481 int statusCode = res.getStatus();
483 // Check the status code of the response: does it match
484 // the expected response(s)?
485 if(logger.isDebugEnabled()){
486 logger.debug(testName + ": status = " + statusCode);
488 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
489 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
490 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
492 // Check whether location has expected displayName.
493 MultipartInput input = (MultipartInput) res.getEntity();
494 LocationsCommon location = (LocationsCommon) extractPart(input,
495 client.getItemCommonPartName(), LocationsCommon.class);
496 Assert.assertNotNull(location);
497 String displayName = location.getDisplayName();
498 // Make sure displayName matches computed form
499 String expectedDisplayName =
500 LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
501 Assert.assertNotNull(displayName, expectedDisplayName);
503 // Update the shortName and verify the computed name is updated.
504 location.setCsid(null);
505 location.setDisplayNameComputed(true);
506 location.setName("updated-" + TEST_NAME);
507 expectedDisplayName =
508 LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
510 // Submit the updated resource to the service and store the response.
511 MultipartOutput output = new MultipartOutput();
512 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
513 commonPart.getHeaders().add("label", client.getItemCommonPartName());
514 res.releaseConnection();
515 res = client.updateItem(knownResourceId, knownItemResourceId, output);
516 statusCode = res.getStatus();
518 // Check the status code of the response: does it match the expected response(s)?
519 if(logger.isDebugEnabled()){
520 logger.debug("updateItem: status = " + statusCode);
522 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
523 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
524 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
526 // Retrieve the updated resource and verify that its contents exist.
527 input = (MultipartInput) res.getEntity();
528 LocationsCommon updatedLocation =
529 (LocationsCommon) extractPart(input,
530 client.getItemCommonPartName(), LocationsCommon.class);
531 Assert.assertNotNull(updatedLocation);
533 // Verify that the updated resource received the correct data.
534 Assert.assertEquals(updatedLocation.getName(), location.getName(),
535 "Updated ForeName in Location did not match submitted data.");
536 // Verify that the updated resource computes the right displayName.
537 Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
538 "Updated ForeName in Location not reflected in computed DisplayName.");
540 // Now Update the displayName, not computed and verify the computed name is overriden.
541 location.setDisplayNameComputed(false);
542 expectedDisplayName = "TestName";
543 location.setDisplayName(expectedDisplayName);
545 // Submit the updated resource to the service and store the response.
546 output = new MultipartOutput();
547 commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
548 commonPart.getHeaders().add("label", client.getItemCommonPartName());
549 res.releaseConnection();
550 res = client.updateItem(knownResourceId, knownItemResourceId, output);
551 statusCode = res.getStatus();
553 // Check the status code of the response: does it match the expected response(s)?
554 if(logger.isDebugEnabled()){
555 logger.debug("updateItem: status = " + statusCode);
557 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
558 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
559 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
561 // Retrieve the updated resource and verify that its contents exist.
562 input = (MultipartInput) res.getEntity();
564 (LocationsCommon) extractPart(input,
565 client.getItemCommonPartName(), LocationsCommon.class);
566 Assert.assertNotNull(updatedLocation);
568 // Verify that the updated resource received the correct data.
569 Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
570 "Updated displayNameComputed in Location did not match submitted data.");
571 // Verify that the updated resource computes the right displayName.
572 Assert.assertEquals(updatedLocation.getDisplayName(),
574 "Updated DisplayName (not computed) in Location not stored.");
576 res.releaseConnection();
581 * Verify illegal item display name.
583 * @param testName the test name
584 * @throws Exception the exception
586 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
587 dependsOnMethods = {"verifyItemDisplayName"})
588 public void verifyIllegalItemDisplayName(String testName) throws Exception {
590 if (logger.isDebugEnabled()) {
591 logger.debug(testBanner(testName, CLASS_NAME));
594 // FIXME: create a setup configuration for this operation.
595 setupUpdateWithWrongXmlSchema();
597 // Submit the request to the service and store the response.
598 LocationAuthorityClient client = new LocationAuthorityClient();
599 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
601 int statusCode = res.getStatus();
603 // Check the status code of the response: does it match
604 // the expected response(s)?
605 if(logger.isDebugEnabled()){
606 logger.debug(testName + ": status = " + statusCode);
608 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
609 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
610 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
612 // Check whether Location has expected displayName.
613 MultipartInput input = (MultipartInput) res.getEntity();
614 LocationsCommon location = (LocationsCommon) extractPart(input,
615 client.getItemCommonPartName(), LocationsCommon.class);
616 Assert.assertNotNull(location);
617 // Try to Update with computed false and no displayName
618 location.setDisplayNameComputed(false);
619 location.setDisplayName(null);
621 // Submit the updated resource to the service and store the response.
622 MultipartOutput output = new MultipartOutput();
623 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
624 commonPart.getHeaders().add("label", client.getItemCommonPartName());
625 res.releaseConnection();
626 res = client.updateItem(knownResourceId, knownItemResourceId, output);
627 statusCode = res.getStatus();
629 // Check the status code of the response: does it match the expected response(s)?
630 if(logger.isDebugEnabled()){
631 logger.debug("updateItem: status = " + statusCode);
633 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
634 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
635 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
637 res.releaseConnection();
644 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
647 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
648 groups = {"read"}, dependsOnMethods = {"read"})
649 public void readNonExistent(String testName) {
651 if (logger.isDebugEnabled()) {
652 logger.debug(testBanner(testName, CLASS_NAME));
655 setupReadNonExistent();
657 // Submit the request to the service and store the response.
658 LocationAuthorityClient client = new LocationAuthorityClient();
659 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
661 int statusCode = res.getStatus();
663 // Check the status code of the response: does it match
664 // the expected response(s)?
665 if(logger.isDebugEnabled()){
666 logger.debug(testName + ": status = " + statusCode);
668 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
669 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
670 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
672 res.releaseConnection();
677 * Read item non existent.
679 * @param testName the test name
681 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
682 groups = {"read"}, dependsOnMethods = {"readItem"})
683 public void readItemNonExistent(String testName) {
685 if (logger.isDebugEnabled()) {
686 logger.debug(testBanner(testName, CLASS_NAME));
689 setupReadNonExistent();
691 // Submit the request to the service and store the response.
692 LocationAuthorityClient client = new LocationAuthorityClient();
693 ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
695 int statusCode = res.getStatus();
697 // Check the status code of the response: does it match
698 // the expected response(s)?
699 if(logger.isDebugEnabled()){
700 logger.debug(testName + ": status = " + statusCode);
702 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
703 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
704 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
706 res.releaseConnection();
711 // ---------------------------------------------------------------
712 // CRUD tests : READ_LIST tests
713 // ---------------------------------------------------------------
717 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
720 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
721 groups = {"readList"}, dependsOnGroups = {"createList", "read"})
722 public void readList(String testName) throws Exception {
724 if (logger.isDebugEnabled()) {
725 logger.debug(testBanner(testName, CLASS_NAME));
730 // Submit the request to the service and store the response.
731 LocationAuthorityClient client = new LocationAuthorityClient();
732 ClientResponse<LocationauthoritiesCommonList> res = client.readList();
734 LocationauthoritiesCommonList list = res.getEntity();
735 int statusCode = res.getStatus();
737 // Check the status code of the response: does it match
738 // the expected response(s)?
739 if(logger.isDebugEnabled()){
740 logger.debug(testName + ": status = " + statusCode);
742 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
743 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
744 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
746 // Optionally output additional data about list members for debugging.
747 boolean iterateThroughList = false;
748 if (iterateThroughList && logger.isDebugEnabled()) {
749 List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
750 list.getLocationauthorityListItem();
752 for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
753 String csid = item.getCsid();
754 logger.debug(testName + ": list-item[" + i + "] csid=" +
756 logger.debug(testName + ": list-item[" + i + "] displayName=" +
757 item.getDisplayName());
758 logger.debug(testName + ": list-item[" + i + "] URI=" +
760 readItemList(csid, null);
765 res.releaseConnection();
772 @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
773 public void readItemList() {
774 String testName = "readItemList";
775 if (logger.isDebugEnabled()) {
776 logger.debug(testBanner(testName, CLASS_NAME));
778 readItemList(knownResourceId, null);
782 * Read item list by authority name.
784 @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
785 public void readItemListByAuthorityName() {
786 String testName = "readItemListByAuthorityName";
787 if (logger.isDebugEnabled()) {
788 logger.debug(testBanner(testName, CLASS_NAME));
790 readItemList(null, knownResourceShortIdentifer);
796 * @param vcsid the vcsid
797 * @param name the name
799 private void readItemList(String vcsid, String shortId) {
801 String testName = "readItemList";
806 // Submit the request to the service and store the response.
807 LocationAuthorityClient client = new LocationAuthorityClient();
808 ClientResponse<LocationsCommonList> res = null;
810 res = client.readItemList(vcsid);
811 } else if(shortId!= null) {
812 res = client.readItemListForNamedAuthority(shortId);
814 Assert.fail("readItemList passed null csid and name!");
817 LocationsCommonList list = res.getEntity();
818 int statusCode = res.getStatus();
820 // Check the status code of the response: does it match
821 // the expected response(s)?
822 if(logger.isDebugEnabled()){
823 logger.debug(testName + ": status = " + statusCode);
825 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
826 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
827 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
829 List<LocationsCommonList.LocationListItem> items =
830 list.getLocationListItem();
831 int nItemsReturned = items.size();
832 // There will be one item created, associated with a
833 // known parent resource, by the createItem test.
835 // In addition, there will be 'nItemsToCreateInList'
836 // additional items created by the createItemList test,
837 // all associated with the same parent resource.
838 int nExpectedItems = nItemsToCreateInList + 1;
839 if(logger.isDebugEnabled()){
840 logger.debug(testName + ": Expected "
841 + nExpectedItems +" items; got: "+nItemsReturned);
843 Assert.assertEquals(nItemsReturned, nExpectedItems);
846 for (LocationsCommonList.LocationListItem item : items) {
847 Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
848 Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
849 // Optionally output additional data about list members for debugging.
850 boolean showDetails = true;
851 if (showDetails && logger.isDebugEnabled()) {
852 logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
854 logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
856 logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
857 item.getDisplayName());
858 logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
864 res.releaseConnection();
872 // ---------------------------------------------------------------
873 // CRUD tests : UPDATE tests
874 // ---------------------------------------------------------------
877 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
880 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
881 groups = {"update"}, dependsOnGroups = {"read", "readList"})
882 public void update(String testName) throws Exception {
884 if (logger.isDebugEnabled()) {
885 logger.debug(testBanner(testName, CLASS_NAME));
890 // Retrieve the contents of a resource to update.
891 LocationAuthorityClient client = new LocationAuthorityClient();
892 ClientResponse<MultipartInput> res = client.read(knownResourceId);
894 if(logger.isDebugEnabled()){
895 logger.debug(testName + ": read status = " + res.getStatus());
897 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
899 if(logger.isDebugEnabled()){
900 logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
902 MultipartInput input = (MultipartInput) res.getEntity();
903 LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
904 client.getCommonPartName(), LocationauthoritiesCommon.class);
905 Assert.assertNotNull(locationAuthority);
907 // Update the contents of this resource.
908 locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
909 locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
910 if(logger.isDebugEnabled()){
911 logger.debug("to be updated LocationAuthority");
912 logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
915 // Submit the updated resource to the service and store the response.
916 MultipartOutput output = new MultipartOutput();
917 OutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
918 commonPart.getHeaders().add("label", client.getCommonPartName());
919 res.releaseConnection();
920 res = client.update(knownResourceId, output);
921 int statusCode = res.getStatus();
923 // Check the status code of the response: does it match the expected response(s)?
924 if(logger.isDebugEnabled()){
925 logger.debug(testName + ": status = " + statusCode);
927 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
928 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
929 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
931 // Retrieve the updated resource and verify that its contents exist.
932 input = (MultipartInput) res.getEntity();
933 LocationauthoritiesCommon updatedLocationAuthority =
934 (LocationauthoritiesCommon) extractPart(input,
935 client.getCommonPartName(), LocationauthoritiesCommon.class);
936 Assert.assertNotNull(updatedLocationAuthority);
938 // Verify that the updated resource received the correct data.
939 Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
940 locationAuthority.getDisplayName(),
941 "Data in updated object did not match submitted data.");
943 res.releaseConnection();
950 * @param testName the test name
951 * @throws Exception the exception
953 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
954 groups = {"update"}, dependsOnMethods = {"update"})
955 public void updateItem(String testName) throws Exception {
957 if (logger.isDebugEnabled()) {
958 logger.debug(testBanner(testName, CLASS_NAME));
963 // Retrieve the contents of a resource to update.
964 LocationAuthorityClient client = new LocationAuthorityClient();
965 ClientResponse<MultipartInput> res =
966 client.readItem(knownResourceId, knownItemResourceId);
968 if(logger.isDebugEnabled()){
969 logger.debug(testName + ": read status = " + res.getStatus());
971 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
973 if(logger.isDebugEnabled()){
974 logger.debug("got Location to update with ID: " +
975 knownItemResourceId +
976 " in LocationAuthority: " + knownResourceId );
978 MultipartInput input = (MultipartInput) res.getEntity();
979 LocationsCommon location = (LocationsCommon) extractPart(input,
980 client.getItemCommonPartName(), LocationsCommon.class);
981 Assert.assertNotNull(location);
983 // Update the contents of this resource.
984 location.setCsid(null);
985 location.setName("updated-" + location.getName());
986 if(logger.isDebugEnabled()){
987 logger.debug("to be updated Location");
988 logger.debug(objectAsXmlString(location,
989 LocationsCommon.class));
992 // Submit the updated resource to the service and store the response.
993 MultipartOutput output = new MultipartOutput();
994 OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
995 commonPart.getHeaders().add("label", client.getItemCommonPartName());
996 res.releaseConnection();
997 res = client.updateItem(knownResourceId, knownItemResourceId, output);
998 int statusCode = res.getStatus();
1000 // Check the status code of the response: does it match the expected response(s)?
1001 if(logger.isDebugEnabled()){
1002 logger.debug(testName + ": status = " + statusCode);
1004 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1005 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1006 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1008 // Retrieve the updated resource and verify that its contents exist.
1009 input = (MultipartInput) res.getEntity();
1010 LocationsCommon updatedLocation =
1011 (LocationsCommon) extractPart(input,
1012 client.getItemCommonPartName(), LocationsCommon.class);
1013 Assert.assertNotNull(updatedLocation);
1015 // Verify that the updated resource received the correct data.
1016 Assert.assertEquals(updatedLocation.getName(), location.getName(),
1017 "Data in updated Location did not match submitted data.");
1019 res.releaseConnection();
1024 // Placeholders until the three tests below can be uncommented.
1025 // See Issue CSPACE-401.
1027 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1030 public void updateWithEmptyEntityBody(String testName) throws Exception {
1034 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1037 public void updateWithMalformedXml(String testName) throws Exception {
1041 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1044 public void updateWithWrongXmlSchema(String testName) throws Exception {
1049 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1052 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1053 groups = {"update"}, dependsOnMethods = {"update", "testSubmitRequest"})
1054 public void updateNonExistent(String testName) throws Exception {
1056 if (logger.isDebugEnabled()) {
1057 logger.debug(testBanner(testName, CLASS_NAME));
1060 setupUpdateNonExistent();
1062 // Submit the request to the service and store the response.
1063 // Note: The ID(s) used when creating the request payload may be arbitrary.
1064 // The only relevant ID may be the one used in update(), below.
1065 LocationAuthorityClient client = new LocationAuthorityClient();
1066 String displayName = "displayName-NON_EXISTENT_ID";
1067 MultipartOutput multipart = LocationAuthorityClientUtils.createLocationAuthorityInstance(
1068 displayName, "nonEx", client.getCommonPartName());
1069 ClientResponse<MultipartInput> res =
1070 client.update(NON_EXISTENT_ID, multipart);
1072 int statusCode = res.getStatus();
1074 // Check the status code of the response: does it match
1075 // the expected response(s)?
1076 if(logger.isDebugEnabled()){
1077 logger.debug(testName + ": status = " + statusCode);
1079 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1080 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1081 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1083 res.releaseConnection();
1088 * Update non existent item.
1090 * @param testName the test name
1091 * @throws Exception the exception
1093 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1094 groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
1095 public void updateNonExistentItem(String testName) throws Exception {
1097 if (logger.isDebugEnabled()) {
1098 logger.debug(testBanner(testName, CLASS_NAME));
1101 setupUpdateNonExistent();
1103 // Submit the request to the service and store the response.
1104 // Note: The ID used in this 'create' call may be arbitrary.
1105 // The only relevant ID may be the one used in update(), below.
1106 LocationAuthorityClient client = new LocationAuthorityClient();
1107 Map<String, String> nonexMap = new HashMap<String,String>();
1108 nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
1109 nonexMap.put(LocationJAXBSchema.SHORT_IDENTIFIER, "nonEx");
1110 nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
1111 nonexMap.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
1112 MultipartOutput multipart =
1113 LocationAuthorityClientUtils.createLocationInstance(NON_EXISTENT_ID,
1114 LocationAuthorityClientUtils.createLocationRefName(knownResourceRefName, "nonEx", "Non Existent"),
1115 nonexMap, client.getItemCommonPartName() );
1116 ClientResponse<MultipartInput> res =
1117 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
1119 int statusCode = res.getStatus();
1121 // Check the status code of the response: does it match
1122 // the expected response(s)?
1123 if(logger.isDebugEnabled()){
1124 logger.debug(testName + ": status = " + statusCode);
1126 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1127 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1128 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1130 res.releaseConnection();
1134 // ---------------------------------------------------------------
1135 // CRUD tests : DELETE tests
1136 // ---------------------------------------------------------------
1139 // Note: delete sub-resources in ascending hierarchical order,
1140 // before deleting their parents.
1145 * @param testName the test name
1146 * @throws Exception the exception
1148 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1149 //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"})
1150 groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
1151 public void deleteItem(String testName) throws Exception {
1153 if (logger.isDebugEnabled()) {
1154 logger.debug(testBanner(testName, CLASS_NAME));
1159 if(logger.isDebugEnabled()){
1160 logger.debug("parentcsid =" + knownResourceId +
1161 " itemcsid = " + knownItemResourceId);
1164 // Submit the request to the service and store the response.
1165 LocationAuthorityClient client = new LocationAuthorityClient();
1166 ClientResponse<Response> res =
1167 client.deleteItem(knownResourceId, knownItemResourceId);
1169 int statusCode = res.getStatus();
1171 // Check the status code of the response: does it match
1172 // the expected response(s)?
1173 if(logger.isDebugEnabled()){
1174 logger.debug(testName + ": status = " + statusCode);
1176 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1177 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1178 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1180 res.releaseConnection();
1185 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1188 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1189 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1190 public void delete(String testName) throws Exception {
1192 if (logger.isDebugEnabled()) {
1193 logger.debug(testBanner(testName, CLASS_NAME));
1198 if(logger.isDebugEnabled()){
1199 logger.debug("parentcsid =" + knownResourceId);
1202 // Submit the request to the service and store the response.
1203 LocationAuthorityClient client = new LocationAuthorityClient();
1204 ClientResponse<Response> res = client.delete(knownResourceId);
1206 int statusCode = res.getStatus();
1208 // Check the status code of the response: does it match
1209 // the expected response(s)?
1210 if(logger.isDebugEnabled()){
1211 logger.debug(testName + ": status = " + statusCode);
1213 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1214 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1215 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1217 res.releaseConnection();
1223 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1226 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1227 groups = {"delete"}, dependsOnMethods = {"delete"})
1228 public void deleteNonExistent(String testName) throws Exception {
1230 if (logger.isDebugEnabled()) {
1231 logger.debug(testBanner(testName, CLASS_NAME));
1234 setupDeleteNonExistent();
1236 // Submit the request to the service and store the response.
1237 LocationAuthorityClient client = new LocationAuthorityClient();
1238 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1240 int statusCode = res.getStatus();
1242 // Check the status code of the response: does it match
1243 // the expected response(s)?
1244 if(logger.isDebugEnabled()){
1245 logger.debug(testName + ": status = " + statusCode);
1247 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1248 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1249 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1251 res.releaseConnection();
1256 * Delete non existent item.
1258 * @param testName the test name
1260 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
1261 groups = {"delete"}, dependsOnMethods = {"deleteItem"})
1262 public void deleteNonExistentItem(String testName) {
1264 if (logger.isDebugEnabled()) {
1265 logger.debug(testBanner(testName, CLASS_NAME));
1268 setupDeleteNonExistent();
1270 // Submit the request to the service and store the response.
1271 LocationAuthorityClient client = new LocationAuthorityClient();
1272 ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
1274 int statusCode = res.getStatus();
1276 // Check the status code of the response: does it match
1277 // the expected response(s)?
1278 if(logger.isDebugEnabled()){
1279 logger.debug(testName + ": status = " + statusCode);
1281 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1282 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1283 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1285 res.releaseConnection();
1289 // ---------------------------------------------------------------
1290 // Utility tests : tests of code used in tests above
1291 // ---------------------------------------------------------------
1293 * Tests the code for manually submitting data that is used by several
1294 * of the methods above.
1296 @Test(dependsOnMethods = {"create", "read"})
1297 public void testSubmitRequest() {
1299 // Expected status code: 200 OK
1300 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1302 // Submit the request to the service and store the response.
1303 String method = ServiceRequestType.READ.httpMethodName();
1304 String url = getResourceURL(knownResourceId);
1305 int statusCode = submitRequest(method, url);
1307 // Check the status code of the response: does it match
1308 // the expected response(s)?
1309 if(logger.isDebugEnabled()){
1310 logger.debug("testSubmitRequest: url=" + url +
1311 " status=" + statusCode);
1313 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1318 * Test item submit request.
1320 @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
1321 public void testItemSubmitRequest() {
1323 // Expected status code: 200 OK
1324 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1326 // Submit the request to the service and store the response.
1327 String method = ServiceRequestType.READ.httpMethodName();
1328 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
1329 int statusCode = submitRequest(method, url);
1331 // Check the status code of the response: does it match
1332 // the expected response(s)?
1333 if(logger.isDebugEnabled()){
1334 logger.debug("testItemSubmitRequest: url=" + url +
1335 " status=" + statusCode);
1337 Assert.assertEquals(statusCode, EXPECTED_STATUS);
1341 // ---------------------------------------------------------------
1342 // Cleanup of resources created during testing
1343 // ---------------------------------------------------------------
1346 * Deletes all resources created by tests, after all tests have been run.
1348 * This cleanup method will always be run, even if one or more tests fail.
1349 * For this reason, it attempts to remove all resources created
1350 * at any point during testing, even if some of those resources
1351 * may be expected to be deleted by certain tests.
1354 @AfterClass(alwaysRun=true)
1355 public void cleanUp() {
1356 String noTest = System.getProperty("noTestCleanup");
1357 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1358 if (logger.isDebugEnabled()) {
1359 logger.debug("Skipping Cleanup phase ...");
1363 if (logger.isDebugEnabled()) {
1364 logger.debug("Cleaning up temporary resources created for testing ...");
1366 String parentResourceId;
1367 String itemResourceId;
1368 // Clean up contact resources.
1369 LocationAuthorityClient client = new LocationAuthorityClient();
1370 parentResourceId = knownResourceId;
1371 // Clean up item resources.
1372 for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
1373 itemResourceId = entry.getKey();
1374 parentResourceId = entry.getValue();
1375 // Note: Any non-success responses from the delete operation
1376 // below are ignored and not reported.
1377 ClientResponse<Response> res =
1378 client.deleteItem(parentResourceId, itemResourceId);
1379 res.releaseConnection();
1381 // Clean up parent resources.
1382 for (String resourceId : allResourceIdsCreated) {
1383 // Note: Any non-success responses from the delete operation
1384 // below are ignored and not reported.
1385 ClientResponse<Response> res = client.delete(resourceId);
1386 res.releaseConnection();
1390 // ---------------------------------------------------------------
1391 // Utility methods used by tests above
1392 // ---------------------------------------------------------------
1394 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
1397 public String getServicePathComponent() {
1398 return SERVICE_PATH_COMPONENT;
1402 * Gets the item service path component.
1404 * @return the item service path component
1406 public String getItemServicePathComponent() {
1407 return ITEM_SERVICE_PATH_COMPONENT;
1411 * Returns the root URL for the item service.
1413 * This URL consists of a base URL for all services, followed by
1414 * a path component for the owning parent, followed by the
1415 * path component for the items.
1417 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1418 * parent authority resource of the relevant item resource.
1420 * @return The root URL for the item service.
1422 protected String getItemServiceRootURL(String parentResourceIdentifier) {
1423 return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
1427 * Returns the URL of a specific item resource managed by a service, and
1428 * designated by an identifier (such as a universally unique ID, or UUID).
1430 * @param parentResourceIdentifier An identifier (such as a UUID) for the
1431 * parent authority resource of the relevant item resource.
1433 * @param itemResourceIdentifier An identifier (such as a UUID) for an
1436 * @return The URL of a specific item resource managed by a service.
1438 protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
1439 return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;