1 package org.collectionspace.services.client.test;
3 import java.util.HashMap;
7 import javax.ws.rs.core.Response;
9 import org.collectionspace.services.client.AbstractCommonListUtils;
10 import org.collectionspace.services.client.AuthorityClient;
11 import org.collectionspace.services.client.AuthorityClientImpl;
12 import org.collectionspace.services.client.AuthorityProxy;
13 import org.collectionspace.services.client.CollectionSpaceClient;
14 import org.collectionspace.services.client.PayloadInputPart;
15 import org.collectionspace.services.client.PayloadOutputPart;
16 import org.collectionspace.services.client.PersonAuthorityClient;
17 import org.collectionspace.services.client.PoxPayloadOut;
18 import org.collectionspace.services.jaxb.AbstractCommonList;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21 import org.testng.Assert;
22 import org.testng.annotations.Test;
28 * @param <AUTHORITY_COMMON_TYPE>
29 * @param <AUTHORITY_ITEM_TYPE>
31 * All CRUD related authority test classes should extend this class.
34 public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHORITY_ITEM_TYPE>
35 extends AbstractPoxServiceTestImpl<AbstractCommonList, AUTHORITY_COMMON_TYPE> {
37 private final Logger logger = LoggerFactory.getLogger(AbstractAuthorityServiceTest.class);
39 protected String knownResourceShortIdentifer = null;
40 protected static final String READITEMS_SHORT_IDENTIFIER = "resourceWithItems";
41 protected String knownAuthorityWithItems = null;
43 protected static final String SAS_IDENTIFIER = "SAS";
44 protected String knownSASAuthorityResourceId = null;
45 protected String knownSASItemResourceId = null;
46 protected HashMap<String, String> allSASResourceItemIdsCreated = new HashMap<String, String>(); /* itemURN, parentURN */;
48 protected String knownResourceRefName = null;
49 protected String knownItemResourceId = null;
50 protected String knownItemResourceShortIdentifer = null;
51 protected int nItemsToCreateInList = 5;
53 public abstract void authorityTests(String testName);
54 protected abstract String createItemInAuthority(AuthorityClient client, String authorityId);
56 protected abstract AUTHORITY_ITEM_TYPE updateItemInstance(final AUTHORITY_ITEM_TYPE authorityItem);
57 protected abstract void compareUpdatedItemInstances(AUTHORITY_ITEM_TYPE original, AUTHORITY_ITEM_TYPE updated) throws Exception;
59 protected void setKnownItemResource(String id, String shortIdentifer ) {
60 knownItemResourceId = id;
61 knownItemResourceShortIdentifer = shortIdentifer;
64 protected void setKnownResource(String id, String shortIdentifer,
67 knownResourceShortIdentifer = shortIdentifer;
68 knownResourceRefName = refName;
71 protected String getSASAuthorityIdentifier() {
72 // TODO Auto-generated method stub
73 return this.getKnowResourceIdentifier() + this.SAS_IDENTIFIER;
76 protected String getUrnIdentifier(String shortId) {
77 return String.format("urn:cspace:name:(%s)", shortId);
81 * Sets up create tests.
83 protected void setupSync() {
84 testExpectedStatusCode = this.STATUS_OK;
85 testRequestType = ServiceRequestType.SYNC;
86 testSetup(testExpectedStatusCode, testRequestType);
90 * Gets a client to the SAS (Shared Authority Server)
94 protected AuthorityClient getSASClientInstance() {
95 return (AuthorityClient) this.getClientInstance(CollectionSpaceClient.SAS_CLIENT_PROPERTIES_FILENAME);
99 * Returns the root URL for a service.
101 * This URL consists of a base URL for all services, followed by
102 * a path component for the owning vocabulary, followed by the
103 * path component for the items.
105 * @return The root URL for a service.
107 protected String getItemServiceRootURL(String parentResourceIdentifier) {
108 return getResourceURL(parentResourceIdentifier) + "/" + getServicePathItemsComponent();
112 * Returns the URL of a specific resource managed by a service, and
113 * designated by an identifier (such as a universally unique ID, or UUID).
115 * @param resourceIdentifier An identifier (such as a UUID) for a resource.
117 * @return The URL of a specific resource managed by a service.
119 protected String getItemResourceURL(String parentResourceIdentifier, String resourceIdentifier) {
120 return getItemServiceRootURL(parentResourceIdentifier) + "/" + resourceIdentifier;
124 * For authorities we override this method so we can save the shortid.
127 protected String createWithIdentifier(String testName, String identifier) throws Exception {
128 String csid = createResource(testName, identifier);
129 // Store the ID returned from the first resource created
130 // for additional tests below.
131 if (getKnowResourceId() == null) {
132 setKnownResource(csid, identifier /*shortId*/, null /*refname*/ );
133 if (logger.isDebugEnabled()) {
134 logger.debug(testName + ": Setting knownResourceId=" + getKnowResourceId());
141 @Test(dependsOnMethods = {"readItem", "CRUDTests"})
142 public void testItemSubmitRequest() {
144 // Expected status code: 200 OK
145 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
147 // Submit the request to the service and store the response.
148 String method = ServiceRequestType.READ.httpMethodName();
149 String url = getItemResourceURL(knownResourceId, knownItemResourceId);
150 int statusCode = submitRequest(method, url);
152 // Check the status code of the response: does it match
153 // the expected response(s)?
154 if (logger.isDebugEnabled()) {
155 logger.debug("testItemSubmitRequest: url=" + url
156 + " status=" + statusCode);
158 Assert.assertEquals(statusCode, EXPECTED_STATUS);
162 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
163 dependsOnMethods = {"readItem"})
164 public void verifyIgnoredUpdateWithInAuthority(String testName) throws Exception {
168 // Submit the request to the service and store the response.
169 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =
170 (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
171 Response res = client.readItem(knownResourceId, knownItemResourceId);
172 AUTHORITY_ITEM_TYPE vitem = null;
174 int statusCode = res.getStatus();
176 // Check the status code of the response: does it match
177 // the expected response(s)?
178 if (logger.isDebugEnabled()) {
179 logger.debug(testName + " read authority:" + knownResourceId + "/Item:"
180 + knownItemResourceId + " status = " + statusCode);
182 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
183 invalidStatusCodeMessage(testRequestType, statusCode));
184 Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
186 vitem = extractItemCommonPartValue(res);
187 Assert.assertNotNull(vitem);
188 // Try to Update with new parent vocab (use self, for test).
189 Assert.assertEquals(client.getInAuthority(vitem), knownResourceId,
190 "VocabularyItem inAuthority does not match knownResourceId.");
191 client.setInAuthority(vitem, knownItemResourceId);
197 // Submit the updated resource to the service and store the response.
198 PoxPayloadOut output = this.createItemRequestTypeInstance(vitem);
199 res = client.updateItem(knownResourceId, knownItemResourceId, output);
201 int statusCode = res.getStatus();
203 // Check the status code of the response: does it match the expected response(s)?
204 if (logger.isDebugEnabled()) {
205 logger.debug(testName + ": status = " + statusCode);
207 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
208 invalidStatusCodeMessage(testRequestType, statusCode));
209 Assert.assertEquals(statusCode, testExpectedStatusCode);
214 res = client.readItem(knownResourceId, knownItemResourceId);
216 // Retrieve the updated resource and verify that the parent did not change
217 AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);
218 Assert.assertNotNull(updatedVocabularyItem);
220 // Verify that the updated resource received the correct data.
221 Assert.assertEquals(client.getInAuthority(updatedVocabularyItem),
223 "VocabularyItem allowed update to the parent (inAuthority).");
229 @Test(dataProvider = "testName", dependsOnMethods = {"CRUDTests"})
230 public void createItem(String testName) {
234 String newID = createItemInAuthority((AuthorityClient) getClientInstance(), knownResourceId);
236 // Store the ID returned from the first item resource created
237 // for additional tests below.
238 if (knownItemResourceId == null) {
239 knownItemResourceId = newID;
240 if (null != testName && logger.isDebugEnabled()) {
241 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
247 * Sync the local with the SAS
249 @Test(dataProvider = "testName", dependsOnMethods = {"createSASItem", "CRUDTests"})
250 public void syncWithSAS(String testName) {
252 AuthorityClient client = (AuthorityClient) this.getClientInstance();
255 // First create an empty instance of the authority, so we can sync items with it. We're
256 // using the short ID of the SAS authority. The short ID of the local and the SAS will (must) be the same.
258 String localAuthorityId = null;
260 localAuthorityId = createResource(client, testName, getSASAuthorityIdentifier());
261 } catch (Exception e) {
262 Assert.assertNotNull(localAuthorityId);
266 // Now we can try to sync the SAS authority with the local one we just created.
268 Response response = client.syncByName(getSASAuthorityIdentifier()); // Notice we're using the Short ID (short ID is the same on the local and SAS)
270 int statusCode = response.getStatus();
271 if (logger.isDebugEnabled()) {
272 logger.debug(testName + ": HTTP status = " + statusCode);
274 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
275 invalidStatusCodeMessage(testRequestType, statusCode));
276 Assert.assertEquals(statusCode, testExpectedStatusCode);
283 * SAS - Create a new authority on the SAS server.
286 @Test(dataProvider = "testName", dependsOnMethods = {"createItem", "CRUDTests"})
287 public void createSASAuthority(String testName) {
292 String newID = createResource(getSASClientInstance(), testName, getSASAuthorityIdentifier());
293 knownSASAuthorityResourceId = newID;
294 if (logger.isDebugEnabled()) {
295 String.format("Created SAS authority '%s' with CSID=%s.", getSASAuthorityIdentifier(), newID);
297 } catch (Exception e) {
298 logger.info(String.format("Failed to create SAS authority '%s'.", getSASAuthorityIdentifier()));
304 * SAS - Create an item in the SAS authority on the SAS server.
307 @Test(dataProvider = "testName", dependsOnMethods = {"createSASAuthority", "CRUDTests"})
308 public void createSASItem(String testName) {
312 String newID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceId);
314 // Store the ID returned from the first item resource created
315 // for additional tests below.
316 if (knownSASItemResourceId == null) {
317 knownSASItemResourceId = newID;
318 if (null != testName && logger.isDebugEnabled()) {
319 logger.debug(testName + ": knownSASItemResourceId=" + knownSASItemResourceId);
324 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
325 dependsOnMethods = {"createItem"})
326 public void createItemList(String testName) throws Exception {
327 knownAuthorityWithItems = createResource(testName, READITEMS_SHORT_IDENTIFIER);
328 for (int j = 0; j < nItemsToCreateInList; j++) {
329 createItemInAuthority((AuthorityClient) getClientInstance(), knownAuthorityWithItems);
336 * @param testName the test name
337 * @throws Exception the exception
339 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
340 dependsOnMethods = {"CRUDTests"})
341 public void readByName(String testName) throws Exception {
345 // Submit the request to the service and store the response.
346 AuthorityClient client = (AuthorityClient) this.getClientInstance();
347 Response res = client.readByName(getKnowResourceIdentifier());
349 int statusCode = res.getStatus();
351 // Check the status code of the response: does it match
352 // the expected response(s)?
353 if (logger.isDebugEnabled()) {
354 logger.debug(testName + ": status = " + statusCode);
356 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
357 invalidStatusCodeMessage(testRequestType, statusCode));
358 Assert.assertEquals(statusCode, testExpectedStatusCode);
360 AUTHORITY_COMMON_TYPE commonPart = extractCommonPartValue(res);
361 Assert.assertNotNull(commonPart);
368 * Extracts the common part item from a service's item payload.
374 public AUTHORITY_ITEM_TYPE extractItemCommonPartValue(Response res) throws Exception {
375 AUTHORITY_ITEM_TYPE result = null;
377 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
378 this.getClientInstance();
379 PayloadInputPart payloadInputPart = extractPart(res, client.getItemCommonPartName());
380 if (payloadInputPart != null) {
381 result = (AUTHORITY_ITEM_TYPE) payloadInputPart.getBody();
383 Assert.assertNotNull(result,
384 "Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");
389 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
390 dependsOnMethods = {"readItem"})
391 public void readItemNonExistent(String testName) {
393 setupReadNonExistent();
395 // Submit the request to the service and store the response.
396 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
397 this.getClientInstance();
398 Response res = client.readItem(knownResourceId, NON_EXISTENT_ID);
400 int statusCode = res.getStatus();
402 // Check the status code of the response: does it match
403 // the expected response(s)?
404 if (logger.isDebugEnabled()) {
405 logger.debug(testName + ": status = " + statusCode);
407 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
408 invalidStatusCodeMessage(testRequestType, statusCode));
409 Assert.assertEquals(statusCode, testExpectedStatusCode);
415 @Test(dataProvider = "testName",
416 dependsOnMethods = {"createItem"})
417 public void readItem(String testName) throws Exception {
421 // Submit the request to the service and store the response.
422 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
423 Response res = client.readItem(knownResourceId, knownItemResourceId);
425 int statusCode = res.getStatus();
427 // Check the status code of the response: does it match
428 // the expected response(s)?
429 if (logger.isDebugEnabled()) {
430 logger.debug(testName + ": status = " + statusCode);
432 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
433 invalidStatusCodeMessage(testRequestType, statusCode));
434 Assert.assertEquals(statusCode, testExpectedStatusCode);
436 AUTHORITY_ITEM_TYPE itemCommonPart = extractItemCommonPartValue(res);
437 Assert.assertNotNull(itemCommonPart);
438 Assert.assertEquals(client.getInAuthority(itemCommonPart), knownResourceId);
439 verifyReadItemInstance(itemCommonPart);
445 protected abstract void verifyReadItemInstance(AUTHORITY_ITEM_TYPE item) throws Exception;
447 @Test(dataProvider = "testName",
448 dependsOnMethods = {"testItemSubmitRequest", "updateItem", "verifyIgnoredUpdateWithInAuthority"})
449 public void deleteItem(String testName) throws Exception {
453 // Submit the request to the service and store the response.
454 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)
455 this.getClientInstance();
456 Response res = client.deleteItem(knownResourceId, knownItemResourceId);
459 statusCode = res.getStatus();
464 // Check the status code of the response: does it match
465 // the expected response(s)?
466 if (logger.isDebugEnabled()) {
467 logger.debug("delete: status = " + statusCode);
469 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
470 invalidStatusCodeMessage(testRequestType, statusCode));
471 Assert.assertEquals(statusCode, testExpectedStatusCode);
474 protected void readItemListInt(String vcsid, String shortId, String testName) {
478 // Submit the request to the service and store the response.
479 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
482 res = client.readItemList(vcsid, null, null);
483 } else if (shortId != null) {
484 res = client.readItemListForNamedAuthority(shortId, null, null);
486 Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");
489 int statusCode = res.getStatus();
491 // Check the status code of the response: does it match
492 // the expected response(s)?
493 if (logger.isDebugEnabled()) {
494 logger.debug(" " + testName + ": status = " + statusCode);
496 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
497 invalidStatusCodeMessage(testRequestType, statusCode));
498 Assert.assertEquals(statusCode, testExpectedStatusCode);
500 AbstractCommonList list = res.readEntity(AbstractCommonList.class);
501 List<AbstractCommonList.ListItem> items = list.getListItem();
502 int nItemsReturned = items.size();
503 long nItemsTotal = list.getTotalItems();
504 if (logger.isDebugEnabled()) {
505 logger.debug(" " + testName + ": Expected "
506 + nItemsToCreateInList + " items; got: " + nItemsReturned + " of: " + nItemsTotal);
508 Assert.assertEquals(nItemsTotal, nItemsToCreateInList);
510 if(logger.isTraceEnabled()){
511 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
518 @Test(dataProvider = "testName",
519 dependsOnMethods = {"createItemList"})
520 public void readItemList(String testName) {
521 readItemListInt(knownAuthorityWithItems, null, testName);
524 @Test(dataProvider = "testName",
525 dependsOnMethods = {"readItem"})
526 public void readItemListByName(String testName) {
527 readItemListInt(null, READITEMS_SHORT_IDENTIFIER, testName);
530 @Test(dataProvider = "testName",
531 dependsOnMethods = {"deleteItem"})
532 public void deleteNonExistentItem(String testName) {
534 setupDeleteNonExistent();
536 // Submit the request to the service and store the response.
537 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
538 Response res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
541 statusCode = res.getStatus();
546 // Check the status code of the response: does it match
547 // the expected response(s)?
548 if (logger.isDebugEnabled()) {
549 logger.debug(testName + ": status = " + statusCode);
551 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
552 invalidStatusCodeMessage(testRequestType, statusCode));
553 Assert.assertEquals(statusCode, testExpectedStatusCode);
556 protected String getServicePathItemsComponent() {
557 return AuthorityClient.ITEMS;
560 public PoxPayloadOut createItemRequestTypeInstance(AUTHORITY_ITEM_TYPE itemTypeInstance) {
561 PoxPayloadOut result = null;
563 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
564 PoxPayloadOut payloadOut = new PoxPayloadOut(this.getServicePathItemsComponent());
565 PayloadOutputPart part = payloadOut.addPart(client.getItemCommonPartName(), itemTypeInstance);
572 * Update an Authority item.
577 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
578 dependsOnMethods = {"readItem", "CRUDTests", "verifyIgnoredUpdateWithInAuthority"})
579 public void updateItem(String testName) throws Exception {
582 AUTHORITY_ITEM_TYPE theUpdate = null;
584 // Retrieve the contents of a resource to update.
585 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =
586 (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
587 Response res = client.readItem(knownResourceId, knownItemResourceId);
589 if (logger.isDebugEnabled()) {
590 logger.debug(testName + ": read status = " + res.getStatus());
592 Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
594 if (logger.isDebugEnabled()) {
595 logger.debug("got Authority item to update with ID: "
596 + knownItemResourceId
597 + " in authority: " + knownResourceId);
599 AUTHORITY_ITEM_TYPE authorityItem = extractItemCommonPartValue(res);
600 Assert.assertNotNull(authorityItem);
602 // Update the contents of this resource.
603 theUpdate = updateItemInstance(authorityItem);
604 if (logger.isDebugEnabled()) {
605 logger.debug("\n\nTo be updated fields: CSID = " + knownItemResourceId + "\n"
606 + objectAsXmlString(theUpdate));
612 // Submit the updated resource to the service and store the response.
613 PoxPayloadOut output = this.createItemRequestTypeInstance(theUpdate);
614 res = client.updateItem(knownResourceId, knownItemResourceId, output);
616 int statusCode = res.getStatus();
618 // Check the status code of the response: does it match the expected response(s)?
619 if (logger.isDebugEnabled()) {
620 logger.debug("updateItem: status = " + statusCode);
622 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
623 invalidStatusCodeMessage(testRequestType, statusCode));
624 Assert.assertEquals(statusCode, testExpectedStatusCode);
626 // Retrieve the updated resource and verify that its contents exist.
627 AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);
628 Assert.assertNotNull(updatedVocabularyItem);
630 compareUpdatedItemInstances(theUpdate, updatedVocabularyItem);
636 protected abstract PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier);
639 * @see org.collectionspace.services.client.test.ServiceTest#updateNonExistent(java.lang.String)
641 @Test(dataProvider = "testName",
642 dependsOnMethods = {"create", "update", "updateNonExistent"})
643 public void updateNonExistentItem(String testName) throws Exception {
645 setupUpdateNonExistent();
647 // Submit the request to the service and store the response.
648 // Note: The ID used in this 'create' call may be arbitrary.
649 // The only relevant ID may be the one used in update(), below.
650 AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =
651 (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();
652 PoxPayloadOut multipart = createNonExistenceItemInstance(client.getItemCommonPartName(), NON_EXISTENT_ID);
653 Response res = client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
655 int statusCode = res.getStatus();
657 // Check the status code of the response: does it match
658 // the expected response(s)?
659 if (logger.isDebugEnabled()) {
660 logger.debug(testName + ": status = " + statusCode);
662 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
663 invalidStatusCodeMessage(testRequestType, statusCode));
664 Assert.assertEquals(statusCode, testExpectedStatusCode);
671 // Methods to persuade TestNG to follow the correct test dependency path
674 @Test(dataProvider = "testName",
675 dependsOnMethods = {"createItem"})
676 public void baseAuthorityTests(String testName) {
677 // Do nothing. Here just to setup a test dependency chain.
681 * For convenience and terseness, this test method is the base of the test execution dependency chain. Other test methods may
682 * refer to this method in their @Test annotation declarations.
685 @Test(dataProvider = "testName",
687 "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})
688 public void CRUDTests(String testName) {
689 // TODO Auto-generated method stub
693 public void cleanUp() {
694 String noTest = System.getProperty("noTestCleanup");
695 if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
696 if (logger.isDebugEnabled()) {
697 logger.debug("Skipping Cleanup phase ...");
702 AuthorityClient client = (AuthorityClient) this.getClientInstance();
703 String parentResourceId;
704 String itemResourceId;
706 // Clean up all authority item resources.
708 for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
709 itemResourceId = entry.getKey();
710 parentResourceId = entry.getValue();
711 Response response = client.deleteItem(parentResourceId, itemResourceId);
713 int status = response.getStatus();
714 if (status != Response.Status.OK.getStatusCode()) {
715 logger.debug(String.format("Could not deleted authority item '%s' in authority '%s'.",
716 itemResourceId, parentResourceId));
723 // Clean up authority items using the SAS client.
725 client = (AuthorityClient) this.getSASClientInstance();
726 for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
727 itemResourceId = entry.getKey();
728 parentResourceId = entry.getValue();
729 // Note: Any non-success responses from the delete operation
730 // below are ignored and not reported.
731 client.deleteItem(parentResourceId, itemResourceId).close();
734 // Call out superclass's cleanUp method to delete the SAS authorities
736 super.cleanUp(client);
738 // Finally, call out superclass's cleanUp method to deleted the local authorities