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