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