]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
c15786e08f0e7a31acb9b30f4dc4414c8b9fc3dc
[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 (c) 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 java.util.ArrayList;
26 import java.util.List;
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
29
30 import org.collectionspace.services.client.AcquisitionClient;
31 import org.collectionspace.services.client.CollectionSpaceClient;
32 import org.collectionspace.services.jaxb.AbstractCommonList;
33
34 import org.collectionspace.services.acquisition.AcquisitionsCommon;
35 import org.collectionspace.services.acquisition.AcquisitionsCommonList;
36 import org.collectionspace.services.acquisition.AcquisitionSourceList;
37 import org.jboss.resteasy.client.ClientResponse;
38
39 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
40 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
41 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
42 import org.testng.Assert;
43 import org.testng.annotations.AfterClass;
44 import org.testng.annotations.Test;
45
46 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory;
48
49 /**
50  * AcquisitionServiceTest, carries out tests against a
51  * deployed and running Acquisition Service.
52  * 
53  * $LastChangedRevision: 621 $
54  * $LastChangedDate: 2009-09-02 16:49:01 -0700 (Wed, 02 Sep 2009) $
55  */
56 public class AcquisitionServiceTest extends AbstractServiceTestImpl {
57
58     private final Logger logger =
59         LoggerFactory.getLogger(AcquisitionServiceTest.class);
60
61     // Instance variables specific to this test.
62     private String knownResourceId = null;
63     private List<String> allResourceIdsCreated = new ArrayList();
64
65     /* (non-Javadoc)
66      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
67      */
68     @Override
69     protected CollectionSpaceClient getClientInstance() {
70         return new AcquisitionClient();
71     }
72     
73     /* (non-Javadoc)
74      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
75      */
76     @Override
77         protected AbstractCommonList getAbstractCommonList(
78                         ClientResponse<AbstractCommonList> response) {
79         return response.getEntity(AcquisitionsCommonList.class);
80     }
81
82     // ---------------------------------------------------------------
83     // CRUD tests : CREATE tests
84     // ---------------------------------------------------------------
85     // Success outcomes
86     @Override
87     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
88     public void create(String testName) throws Exception {
89
90         // Perform setup, such as initializing the type of service request
91         // (e.g. CREATE, DELETE), its valid and expected status codes, and
92         // its associated HTTP method name (e.g. POST, DELETE).
93         setupCreate(testName);
94
95         // Submit the request to the service and store the response.
96         String identifier = createIdentifier();
97
98         AcquisitionClient client = new AcquisitionClient();
99         MultipartOutput multipart = createAcquisitionInstance(identifier);
100         ClientResponse<Response> res = client.create(multipart);
101
102         int statusCode = res.getStatus();
103
104         // Check the status code of the response: does it match
105         // the expected response(s)?
106         //
107         // Specifically:
108         // Does it fall within the set of valid status codes?
109         // Does it exactly match the expected status code?
110         if(logger.isDebugEnabled()){
111             logger.debug(testName + ": status = " + statusCode);
112         }
113         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
114                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
115         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
116
117         // Store the ID returned from the first resource created
118         // for additional tests below.
119         if (knownResourceId == null){
120             knownResourceId = extractId(res);
121             if (logger.isDebugEnabled()) {
122                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
123             }
124         }
125         
126         // Store the IDs from every resource created by tests,
127         // so they can be deleted after tests have been run.
128         allResourceIdsCreated.add(extractId(res));
129     }
130
131     @Override
132     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
133        dependsOnMethods = {"create"})
134     public void createList(String testName) throws Exception {
135         for(int i = 0; i < 3; i++){
136             create(testName);
137         }
138     }
139
140     // Failure outcomes
141     // Placeholders until the three tests below can be uncommented.
142     // See Issue CSPACE-401.
143     @Override
144     public void createWithEmptyEntityBody(String testName) throws Exception {
145     }
146
147     @Override
148     public void createWithMalformedXml(String testName) throws Exception {
149     }
150
151     @Override
152     public void createWithWrongXmlSchema(String testName) throws Exception {
153     }
154
155     /*
156     @Override
157     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
158         dependsOnMethods = {"create", "testSubmitRequest"})
159     public void createWithMalformedXml(String testName) throws Exception {
160     
161     // Perform setup.
162     setupCreateWithMalformedXml();
163
164     // Submit the request to the service and store the response.
165     String method = REQUEST_TYPE.httpMethodName();
166     String url = getServiceRootURL();
167     final String entity = MALFORMED_XML_DATA; // Constant from base class.
168     int statusCode = submitRequest(method, url, entity);
169
170     // Check the status code of the response: does it match
171     // the expected response(s)?
172     if(logger.isDebugEnabled()){
173         logger.debug(testName + ": url=" + url +
174             " status=" + statusCode);
175      }
176     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
177     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
178     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
179     }
180
181     @Override
182     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
183         dependsOnMethods = {"create", "testSubmitRequest"})
184     public void createWithWrongXmlSchema() throws Exception {
185     
186     // Perform setup.
187     setupCreateWithWrongXmlSchema();
188
189     // Submit the request to the service and store the response.
190     String method = REQUEST_TYPE.httpMethodName();
191     String url = getServiceRootURL();
192     final String entity = WRONG_XML_SCHEMA_DATA;
193     int statusCode = submitRequest(method, url, entity);
194
195     // Check the status code of the response: does it match
196     // the expected response(s)?
197     if(logger.isDebugEnabled()){
198         logger.debug(testName + ": url=" + url +
199             " status=" + statusCode);
200      }
201     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
202     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
203     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
204     }
205      */
206
207     // ---------------------------------------------------------------
208     // CRUD tests : READ tests
209     // ---------------------------------------------------------------
210     // Success outcomes
211     @Override
212     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
213         dependsOnMethods = {"create"})
214     public void read(String testName) throws Exception {
215
216         // Perform setup.
217         setupRead(testName);
218
219         AcquisitionClient client = new AcquisitionClient();
220
221         // Submit the request to the service and store the response.
222         ClientResponse<MultipartInput> res = client.read(knownResourceId);
223         int statusCode = res.getStatus();
224
225         // Check the status code of the response: does it match
226         // the expected response(s)?
227         if(logger.isDebugEnabled()){
228             logger.debug(testName + ": status = " + statusCode);
229         }
230         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
231                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
232         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
233
234         MultipartInput input = (MultipartInput) res.getEntity();
235         AcquisitionsCommon acquisitionObject = (AcquisitionsCommon) extractPart(input,
236                 client.getCommonPartName(), AcquisitionsCommon.class);
237         Assert.assertNotNull(acquisitionObject);
238
239     }
240
241     // Failure outcomes
242     @Override
243     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
244         dependsOnMethods = {"read"})
245     public void readNonExistent(String testName) throws Exception {
246
247         // Perform setup.
248         setupReadNonExistent(testName);
249
250         // Submit the request to the service and store the response.
251         AcquisitionClient client = new AcquisitionClient();
252         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
253         int statusCode = res.getStatus();
254
255         // Check the status code of the response: does it match
256         // the expected response(s)?
257         if(logger.isDebugEnabled()){
258             logger.debug(testName + ": status = " + statusCode);
259         }
260         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
261                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
262         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
263     }
264
265     // ---------------------------------------------------------------
266     // CRUD tests : READ_LIST tests
267     // ---------------------------------------------------------------
268     // Success outcomes
269     @Override
270     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
271         dependsOnMethods = {"createList", "read"})
272     public void readList(String testName) throws Exception {
273
274         // Perform setup.
275         setupReadList(testName);
276
277         // Submit the request to the service and store the response.
278         AcquisitionClient client = new AcquisitionClient();
279         ClientResponse<AcquisitionsCommonList> res = client.readList();
280         AcquisitionsCommonList list = res.getEntity();
281         int statusCode = res.getStatus();
282
283         // Check the status code of the response: does it match
284         // the expected response(s)?
285         if(logger.isDebugEnabled()){
286             logger.debug(testName + ": status = " + statusCode);
287         }
288         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
289                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
290         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
291
292         // Optionally output additional data about list members for debugging.
293         boolean iterateThroughList = false;
294         if(iterateThroughList && logger.isDebugEnabled()){
295             List<AcquisitionsCommonList.AcquisitionListItem> items =
296                     list.getAcquisitionListItem();
297             int i = 0;
298             for(AcquisitionsCommonList.AcquisitionListItem item : items){
299                 logger.debug(testName + ": list-item[" + i + "] csid=" +
300                     item.getCsid());
301                 logger.debug(testName + ": list-item[" + i + "] objectNumber=" +
302                     item.getAcquisitionReferenceNumber());
303                 logger.debug(testName + ": list-item[" + i + "] acquisitionSources:");
304                 AcquisitionSourceList acqSource = item.getAcquisitionSources();
305                 for (String acquisitionSource : acqSource.getAcquisitionSource()) {
306                     logger.debug("acquisitionSource=" + acquisitionSource);
307                 }
308                 logger.debug(testName + ": list-item[" + i + "] URI=" +
309                     item.getUri());
310                 i++;
311             }
312         }
313
314     }
315
316     // Failure outcomes
317     // None at present.
318
319     // ---------------------------------------------------------------
320     // CRUD tests : UPDATE tests
321     // ---------------------------------------------------------------
322
323     // Success outcomes
324     @Override
325     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
326         dependsOnMethods = {"read"})
327     public void update(String testName) throws Exception {
328
329         // Perform setup.
330         setupUpdate(testName);
331
332         // Retrieve the contents of a resource to update.
333         AcquisitionClient client = new AcquisitionClient();
334         ClientResponse<MultipartInput> res = client.read(knownResourceId);
335         if(logger.isDebugEnabled()){
336             logger.debug(testName + ": read status = " + res.getStatus());
337         }
338         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
339
340         if(logger.isDebugEnabled()){
341             logger.debug("got object to update with ID: " + knownResourceId);
342         }
343         MultipartInput input = (MultipartInput) res.getEntity();
344
345         AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
346                 client.getCommonPartName(), AcquisitionsCommon.class);
347         Assert.assertNotNull(acquisition);
348
349         // Update the content of this resource.
350         acquisition.setAcquisitionReferenceNumber("updated-" + acquisition.getAcquisitionReferenceNumber());
351         if(logger.isDebugEnabled()){
352             logger.debug("updated object");
353             logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));
354         }
355         // Submit the request to the service and store the response.
356         MultipartOutput output = new MultipartOutput();
357         OutputPart commonPart = output.addPart(acquisition, MediaType.APPLICATION_XML_TYPE);
358         commonPart.getHeaders().add("label", client.getCommonPartName());
359
360         res = client.update(knownResourceId, output);
361         int statusCode = res.getStatus();
362         // Check the status code of the response: does it match the expected response(s)?
363         if(logger.isDebugEnabled()){
364             logger.debug(testName + ": status = " + statusCode);
365         }
366         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
367                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
368         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
369
370
371         input = (MultipartInput) res.getEntity();
372         AcquisitionsCommon updatedAcquisition =
373                 (AcquisitionsCommon) extractPart(input,
374                         client.getCommonPartName(), AcquisitionsCommon.class);
375         Assert.assertNotNull(updatedAcquisition);
376
377         Assert.assertEquals(updatedAcquisition.getAcquisitionReferenceNumber(),
378                 acquisition.getAcquisitionReferenceNumber(),
379                 "Data in updated object did not match submitted data.");
380
381     }
382
383     // Failure outcomes
384     // Placeholders until the three tests below can be uncommented.
385     // See Issue CSPACE-401.
386     @Override
387     public void updateWithEmptyEntityBody(String testName) throws Exception {
388     }
389
390     @Override
391     public void updateWithMalformedXml(String testName) throws Exception {
392     }
393
394     @Override
395     public void updateWithWrongXmlSchema(String testName) throws Exception {
396     }
397
398     /*
399     @Override
400     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
401         dependsOnMethods = {"create", "update", "testSubmitRequest"})
402     public void updateWithEmptyEntityBody(String testName) throws Exception {
403     
404     // Perform setup.
405     setupUpdateWithEmptyEntityBody(testName);
406
407     // Submit the request to the service and store the response.
408     String method = REQUEST_TYPE.httpMethodName();
409     String url = getResourceURL(knownResourceId);
410     String mediaType = MediaType.APPLICATION_XML;
411     final String entity = "";
412     int statusCode = submitRequest(method, url, mediaType, entity);
413
414     // Check the status code of the response: does it match
415     // the expected response(s)?
416     if(logger.isDebugEnabled()){
417         (testName + ": url=" + url + " status=" + statusCode);
418     }
419     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
420     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
421     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
422     }
423
424     @Override
425     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
426         dependsOnMethods = {"create", "testSubmitRequest"})
427     public void createWithEmptyEntityBody() throws Exception {
428     
429     // Perform setup.
430     setupCreateWithEmptyEntityBody(testName);
431
432     // Submit the request to the service and store the response.
433     String method = REQUEST_TYPE.httpMethodName();
434     String url = getServiceRootURL();
435     String mediaType = MediaType.APPLICATION_XML;
436     final String entity = "";
437     int statusCode = submitRequest(method, url, mediaType, entity);
438
439     // Check the status code of the response: does it match
440     // the expected response(s)?
441     if(logger.isDebugEnabled()){
442         logger.debug(testName + ": url=" + url +
443             " status=" + statusCode);
444     }
445     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
446     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
447     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
448     }
449
450     @Override
451     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
452         dependsOnMethods = {"create", "update", "testSubmitRequest"})
453     public void updateWithMalformedXml(String testName) throws Exception {
454
455     // Perform setup.
456     setupUpdateWithMalformedXml(testName);
457
458     // Submit the request to the service and store the response.
459     String method = REQUEST_TYPE.httpMethodName();
460     String url = getResourceURL(knownResourceId);
461     final String entity = MALFORMED_XML_DATA;
462     int statusCode = submitRequest(method, url, entity);
463
464     // Check the status code of the response: does it match
465     // the expected response(s)?
466     if(logger.isDebugEnabled()){
467         logger.debug(testName + ": url=" + url +
468             " status=" + statusCode);
469      }
470     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
471     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
472     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
473     }
474
475     @Override
476     @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
477     public void updateWithWrongXmlSchema(String testName) {
478     
479     // Perform setup.
480     setupUpdateWithWrongXmlSchema(testName);
481
482     // Submit the request to the service and store the response.
483     String method = REQUEST_TYPE.httpMethodName();
484     String url = getResourceURL(knownResourceId);
485     final String entity = WRONG_XML_SCHEMA_DATA;
486     int statusCode = submitRequest(method, url, entity);
487
488     // Check the status code of the response: does it match
489     // the expected response(s)?
490     if(logger.isDebugEnabled()){
491         logger.debug(testName + ": url=" + url +
492             " status=" + statusCode);
493      }
494     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
495     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
496     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
497     }
498      */
499     
500     @Override
501     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
502         dependsOnMethods = {"update", "testSubmitRequest"})
503     public void updateNonExistent(String testName) throws Exception {
504
505         // Perform setup.
506         setupUpdateNonExistent(testName);
507
508         // Submit the request to the service and store the response.
509         // Note: The ID used in this 'create' call may be arbitrary.
510         // The only relevant ID may be the one used in update(), below.
511         AcquisitionClient client = new AcquisitionClient();
512         MultipartOutput multipart = createAcquisitionInstance(NON_EXISTENT_ID);
513         ClientResponse<MultipartInput> res =
514             client.update(NON_EXISTENT_ID, multipart);
515         int statusCode = res.getStatus();
516
517         // Check the status code of the response: does it match
518         // the expected response(s)?
519         if(logger.isDebugEnabled()){
520             logger.debug(testName + ": status = " + statusCode);
521         }
522         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
523                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
524         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
525     }
526
527     // ---------------------------------------------------------------
528     // CRUD tests : DELETE tests
529     // ---------------------------------------------------------------
530     // Success outcomes
531     @Override
532     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
533         dependsOnMethods = {"create", "read", "update"})
534     public void delete(String testName) throws Exception {
535
536         // Perform setup.
537         setupDelete(testName);
538
539         // Submit the request to the service and store the response.
540         AcquisitionClient client = new AcquisitionClient();
541         ClientResponse<Response> res = client.delete(knownResourceId);
542         int statusCode = res.getStatus();
543
544         // Check the status code of the response: does it match
545         // the expected response(s)?
546         if(logger.isDebugEnabled()){
547             logger.debug(testName + ": status = " + statusCode);
548         }
549         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
550                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
551         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
552     }
553
554     // Failure outcomes
555     @Override
556     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
557         dependsOnMethods = {"delete"})
558     public void deleteNonExistent(String testName) throws Exception {
559
560         // Perform setup.
561         setupDeleteNonExistent(testName);
562
563         // Submit the request to the service and store the response.
564         AcquisitionClient client = new AcquisitionClient();
565         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
566         int statusCode = res.getStatus();
567
568         // Check the status code of the response: does it match
569         // the expected response(s)?
570         if(logger.isDebugEnabled()){
571             logger.debug(testName + ": status = " + statusCode);
572         }
573         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
574                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
575         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
576     }
577
578     // ---------------------------------------------------------------
579     // Utility tests : tests of code used in tests above
580     // ---------------------------------------------------------------
581     /**
582      * Tests the code for manually submitting data that is used by several
583      * of the methods above.
584      */
585     @Test(dependsOnMethods = {"create", "read"})
586     public void testSubmitRequest() throws Exception {
587
588         // Expected status code: 200 OK
589         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
590
591         // Submit the request to the service and store the response.
592         String method = ServiceRequestType.READ.httpMethodName();
593         String url = getResourceURL(knownResourceId);
594         int statusCode = submitRequest(method, url);
595
596         // Check the status code of the response: does it match
597         // the expected response(s)?
598         if(logger.isDebugEnabled()){
599             logger.debug("testSubmitRequest: url=" + url +
600                 " status=" + statusCode);
601         }
602         Assert.assertEquals(statusCode, EXPECTED_STATUS);
603
604     }
605
606     // ---------------------------------------------------------------
607     // Cleanup of resources created during testing
608     // ---------------------------------------------------------------
609
610     /**
611      * Deletes all resources created by tests, after all tests have been run.
612      *
613      * This cleanup method will always be run, even if one or more tests fail.
614      * For this reason, it attempts to remove all resources created
615      * at any point during testing, even if some of those resources
616      * may be expected to be deleted by certain tests.
617      */
618     @AfterClass(alwaysRun=true)
619     public void cleanUp() {
620         String noTest = System.getProperty("noTestCleanup");
621         if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
622             if (logger.isDebugEnabled()) {
623                 logger.debug("Skipping Cleanup phase ...");
624             }
625             return;
626         }
627         if (logger.isDebugEnabled()) {
628             logger.debug("Cleaning up temporary resources created for testing ...");
629         }
630         AcquisitionClient client = new AcquisitionClient();
631         for (String resourceId : allResourceIdsCreated) {
632             // Note: Any non-success responses are ignored and not reported.
633             ClientResponse<Response> res = client.delete(resourceId);
634         }
635     }
636
637     // ---------------------------------------------------------------
638     // Utility methods used by tests above
639     // ---------------------------------------------------------------
640     @Override
641     public String getServicePathComponent() {
642         return new AcquisitionClient().getServicePathComponent();
643     }
644
645
646     private MultipartOutput createAcquisitionInstance(String identifier) {
647         AcquisitionsCommon acquisition = new AcquisitionsCommon();
648         acquisition.setAcquisitionReferenceNumber("acquisitionReferenceNumber-"  + identifier);
649         AcquisitionSourceList acqSourcesList = new AcquisitionSourceList();
650         List<String> sources = acqSourcesList.getAcquisitionSource();
651         // @TODO Use properly formatted refNames for representative acquisition
652         // sources in this example test record. The following are mere placeholders.
653         sources.add("Donor Acquisition Source-" + identifier);
654         sources.add("Museum Acquisition Source-" + identifier);
655         acquisition.setAcquisitionSources(acqSourcesList);
656         MultipartOutput multipart = new MultipartOutput();
657         OutputPart commonPart = multipart.addPart(acquisition,
658             MediaType.APPLICATION_XML_TYPE);
659         commonPart.getHeaders().add("label", new AcquisitionClient().getCommonPartName());
660
661         if(logger.isDebugEnabled()){
662             logger.debug("to be created, acquisition common");
663             logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));
664         }
665         return multipart;
666     }
667 }