]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
7f22bd1cdfc9dd7ba4207c76f1e4e7b7aa32ed4c
[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 © 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.CollectionSpaceClient;
30 import org.collectionspace.services.client.PayloadInputPart;
31 import org.collectionspace.services.client.PayloadOutputPart;
32 import org.collectionspace.services.client.PoxPayloadIn;
33 import org.collectionspace.services.client.PoxPayloadOut;
34 import org.collectionspace.services.client.ReportClient;
35 import org.collectionspace.services.report.ReportsCommon;
36 import org.collectionspace.services.report.ReportsCommonList;
37 import org.collectionspace.services.jaxb.AbstractCommonList;
38
39 import org.jboss.resteasy.client.ClientResponse;
40 import org.testng.Assert;
41 //import org.testng.annotations.AfterClass;
42 import org.testng.annotations.Test;
43
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46
47 /**
48  * FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
49  * ReportServiceTest, carries out tests against a
50  * deployed and running Report Service.
51  *
52  * $LastChangedRevision: 2261 $
53  * $LastChangedDate: 2010-05-28 16:52:22 -0700 (Fri, 28 May 2010) $
54  */
55 public class ReportServiceTest extends AbstractServiceTestImpl {
56
57     /** The logger. */
58     private final String CLASS_NAME = ReportServiceTest.class.getName();
59     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
60     final String SERVICE_NAME = "reports";
61     final String SERVICE_PATH_COMPONENT = "reports";
62     // Instance variables specific to this test.
63     /** The known resource id. */
64     private String knownResourceId = null;
65     
66     private String testDocType = "Acquisition";
67
68     /* (non-Javadoc)
69      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
70      */
71     @Override
72     protected CollectionSpaceClient getClientInstance() {
73         return new ReportClient();
74     }
75
76     /* (non-Javadoc)
77      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
78      */
79     @Override
80     protected AbstractCommonList getAbstractCommonList(
81             ClientResponse<AbstractCommonList> response) {
82         return response.getEntity(ReportsCommonList.class);
83     }
84
85 //    @Override
86 //    protected PoxPayloadOut createInstance(String identifier) {
87 //        PoxPayloadOut multipart = createReportInstance(identifier);
88 //        return multipart;
89 //    }
90         
91     // ---------------------------------------------------------------
92     // CRUD tests : CREATE tests
93     // ---------------------------------------------------------------
94     // Success outcomes
95     /* (non-Javadoc)
96      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
97      */
98     @Override
99     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
100     public void create(String testName) throws Exception {
101
102         if (logger.isDebugEnabled()) {
103             logger.debug(testBanner(testName, CLASS_NAME));
104         }
105         // Perform setup, such as initializing the type of service request
106         // (e.g. CREATE, DELETE), its valid and expected status codes, and
107         // its associated HTTP method name (e.g. POST, DELETE).
108         setupCreate();
109
110         // Submit the request to the service and store the response.
111         ReportClient client = new ReportClient();
112         String identifier = createIdentifier();
113         PoxPayloadOut multipart = createReportInstance(identifier);
114         ClientResponse<Response> res = client.create(multipart);
115
116         // Check the status code of the response: does it match
117         // the expected response(s)?
118         //
119         // Specifically:
120         // Does it fall within the set of valid status codes?
121         // Does it exactly match the expected status code?
122         int statusCode = res.getStatus();
123         if (logger.isDebugEnabled()) {
124             logger.debug(testName + ": status = " + statusCode);
125         }
126         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
127                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
128         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
129
130         // Store the ID returned from the first resource created
131         // for additional tests below.
132         if (knownResourceId == null) {
133             knownResourceId = extractId(res);
134             if (logger.isDebugEnabled()) {
135                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
136             }
137         }
138
139         // Store the IDs from every resource created by tests,
140         // so they can be deleted after tests have been run.
141         allResourceIdsCreated.add(extractId(res));
142     }
143
144     /* (non-Javadoc)
145      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
146      */
147     @Override
148     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
149     dependsOnMethods = {"create"})
150     public void createList(String testName) throws Exception {
151         for (int i = 0; i < 3; i++) {
152             create(testName);
153         }
154     }
155
156     // Failure outcomes
157     // Placeholders until the three tests below can be uncommented.
158     // See Issue CSPACE-401.
159     /* (non-Javadoc)
160      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
161      */
162     @Override
163     public void createWithEmptyEntityBody(String testName) throws Exception {
164         //Should this really be empty?
165     }
166
167     /* (non-Javadoc)
168      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
169      */
170     @Override
171     public void createWithMalformedXml(String testName) throws Exception {
172         //Should this really be empty?
173     }
174
175     /* (non-Javadoc)
176      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
177      */
178     @Override
179     public void createWithWrongXmlSchema(String testName) throws Exception {
180         //Should this really be empty?
181     }
182
183     // ---------------------------------------------------------------
184     // CRUD tests : READ tests
185     // ---------------------------------------------------------------
186     // Success outcomes
187     /* (non-Javadoc)
188      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
189      */
190     @Override
191     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
192     dependsOnMethods = {"create"})
193     public void read(String testName) throws Exception {
194
195         if (logger.isDebugEnabled()) {
196             logger.debug(testBanner(testName, CLASS_NAME));
197         }
198         // Perform setup.
199         setupRead();
200
201         // Submit the request to the service and store the response.
202         ReportClient client = new ReportClient();
203         ClientResponse<String> res = client.read(knownResourceId);
204
205         // Check the status code of the response: does it match
206         // the expected response(s)?
207         int statusCode = res.getStatus();
208         if (logger.isDebugEnabled()) {
209             logger.debug(testName + ": status = " + statusCode);
210         }
211         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
212                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
213         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
214
215         // Get the common part of the response and verify that it is not null.
216         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
217         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
218         ReportsCommon reportCommon = null;
219         if (payloadInputPart != null) {
220             reportCommon = (ReportsCommon) payloadInputPart.getBody();
221         }
222         Assert.assertNotNull(reportCommon);
223
224         // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
225         if (logger.isDebugEnabled()) {
226             logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
227                     + "UTF-8 data received=" + reportCommon.getNotes());
228         }
229         Assert.assertEquals(reportCommon.getNotes(), getUTF8DataFragment(),
230                 "UTF-8 data retrieved '" + reportCommon.getNotes()
231                 + "' does not match expected data '" + getUTF8DataFragment());
232     }
233
234     // Failure outcomes
235     /* (non-Javadoc)
236      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
237      */
238     @Override
239     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
240     dependsOnMethods = {"read"})
241     public void readNonExistent(String testName) throws Exception {
242
243         if (logger.isDebugEnabled()) {
244             logger.debug(testBanner(testName, CLASS_NAME));
245         }
246         // Perform setup.
247         setupReadNonExistent();
248
249         // Submit the request to the service and store the response.
250         ReportClient client = new ReportClient();
251         ClientResponse<String> res = client.read(NON_EXISTENT_ID);
252         int statusCode = res.getStatus();
253
254         // Check the status code of the response: does it match
255         // the expected response(s)?
256         if (logger.isDebugEnabled()) {
257             logger.debug(testName + ": status = " + statusCode);
258         }
259         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
260                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
261         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
262     }
263
264     // ---------------------------------------------------------------
265     // CRUD tests : READ_LIST tests
266     // ---------------------------------------------------------------
267     // Success outcomes
268     /* (non-Javadoc)
269      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
270      */
271     @Override
272     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
273     dependsOnMethods = {"createList", "read"})
274     public void readList(String testName) throws Exception {
275
276         if (logger.isDebugEnabled()) {
277             logger.debug(testBanner(testName, CLASS_NAME));
278         }
279         // Perform setup.
280         setupReadList();
281
282         // Submit the request to the service and store the response.
283         ReportClient client = new ReportClient();
284         ClientResponse<ReportsCommonList> res = client.readList();
285         ReportsCommonList list = res.getEntity();
286         int statusCode = res.getStatus();
287
288         // Check the status code of the response: does it match
289         // the expected response(s)?
290         if (logger.isDebugEnabled()) {
291             logger.debug(testName + ": status = " + statusCode);
292         }
293         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
294                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
295         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
296
297         List<ReportsCommonList.ReportListItem> items =
298             list.getReportListItem();
299         // Optionally output additional data about list members for debugging.
300         boolean iterateThroughList = false;
301         if (iterateThroughList && logger.isDebugEnabled()) {
302             int i = 0;
303             for (ReportsCommonList.ReportListItem item : items) {
304                 logger.debug(testName + ": list-item[" + i + "] csid="
305                         + item.getCsid());
306                 logger.debug(testName + ": list-item[" + i + "] name="
307                         + item.getName());
308                 logger.debug(testName + ": list-item[" + i + "] outputMIME="
309                         + item.getOutputMIME());
310                 logger.debug(testName + ": list-item[" + i + "] URI="
311                         + item.getUri());
312                 i++;
313             }
314         }
315     }
316
317     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
318                 dependsOnMethods = {"readList"})
319     public void readListFiltered(String testName) throws Exception {
320         if (logger.isDebugEnabled()) {
321                 logger.debug(testBanner(testName, CLASS_NAME));
322         }
323         // Perform setup.
324         setupReadList();
325
326         // Submit the request to the service and store the response.
327         ReportClient client = new ReportClient();
328         ClientResponse<ReportsCommonList> res = client.readListFiltered(
329                         testDocType, "single");
330         ReportsCommonList 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         List<ReportsCommonList.ReportListItem> items =
343                 list.getReportListItem();
344         // We must find the basic one we created
345         boolean fFoundBaseItem = false;
346                 for (ReportsCommonList.ReportListItem item : items) {
347                         if(knownResourceId.equalsIgnoreCase(item.getCsid())) {
348                                 fFoundBaseItem = true;
349                                 break;
350                         }
351                 }
352                 if(!fFoundBaseItem)
353                         Assert.fail("readListFiltered failed to return base item");
354                 
355                 // Now filter for something else, and ensure it is NOT returned
356         res = client.readListFiltered("Intake", "single");
357         list = res.getEntity();
358         statusCode = res.getStatus();
359
360         // Check the status code of the response: does it match
361         // the expected response(s)?
362         if (logger.isDebugEnabled()) {
363                 logger.debug(testName + ": status = " + statusCode);
364         }
365         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
366                         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
367         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
368
369         items = list.getReportListItem();
370         // We must NOT find the basic one we created
371                 for (ReportsCommonList.ReportListItem item : items) {
372                         Assert.assertNotSame(item.getCsid(), knownResourceId, 
373                                 "readListFiltered(\"Intake\", \"single\") incorrectly returned base item");
374                 }
375                 
376                 // Now filter for something else, and ensure it is NOT returned
377         res = client.readListFiltered(testDocType, "group");
378         list = res.getEntity();
379         statusCode = res.getStatus();
380
381         // Check the status code of the response: does it match
382         // the expected response(s)?
383         if (logger.isDebugEnabled()) {
384                 logger.debug(testName + ": status = " + statusCode);
385         }
386         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
387                         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
388         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
389
390         items = list.getReportListItem();
391         // We must NOT find the basic one we created
392                 for (ReportsCommonList.ReportListItem item : items) {
393                         Assert.assertNotSame(item.getCsid(), knownResourceId, 
394                                 "readListFiltered(\""+testDocType+"\", \"group\") incorrectly returned base item");
395                 }
396     }
397
398     // ---------------------------------------------------------------
399     // CRUD tests : UPDATE tests
400     // ---------------------------------------------------------------
401     // Success outcomes
402     /* (non-Javadoc)
403      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
404      */
405     @Override
406     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
407     dependsOnMethods = {"read", "readListFiltered"})
408     public void update(String testName) throws Exception {
409
410         if (logger.isDebugEnabled()) {
411             logger.debug(testBanner(testName, CLASS_NAME));
412         }
413         // Perform setup.
414         setupUpdate();
415
416         // Retrieve the contents of a resource to update.
417         ReportClient client = new ReportClient();
418         ClientResponse<String> res = client.read(knownResourceId);
419         if (logger.isDebugEnabled()) {
420             logger.debug(testName + ": read status = " + res.getStatus());
421         }
422         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
423         if (logger.isDebugEnabled()) {
424             logger.debug("got object to update with ID: " + knownResourceId);
425         }
426
427         // Extract the common part from the response.
428         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
429         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
430         ReportsCommon reportCommon = null;
431         if (payloadInputPart != null) {
432             reportCommon = (ReportsCommon) payloadInputPart.getBody();
433         }
434         Assert.assertNotNull(reportCommon);
435
436         // Update its content.
437         reportCommon.setName("updated-" + reportCommon.getName());
438         reportCommon.setOutputMIME("updated-" + reportCommon.getOutputMIME());
439         if (logger.isDebugEnabled()) {
440             logger.debug("to be updated object");
441             logger.debug(objectAsXmlString(reportCommon, ReportsCommon.class));
442         }
443         reportCommon.setNotes("updated-" + reportCommon.getNotes());
444
445         // Submit the updated common part in an update request to the service
446         // and store the response.
447         PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
448         PayloadOutputPart commonPart = output.addPart(reportCommon, MediaType.APPLICATION_XML_TYPE);
449         commonPart.setLabel(client.getCommonPartName());
450         res = client.update(knownResourceId, output);
451
452         // Check the status code of the response: does it match the expected response(s)?
453         int statusCode = res.getStatus();
454         if (logger.isDebugEnabled()) {
455             logger.debug(testName + ": status = " + statusCode);
456         }
457         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
458                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
459         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
460
461         // Extract the updated common part from the response.
462         input = new PoxPayloadIn(res.getEntity());
463         payloadInputPart = input.getPart(client.getCommonPartName());
464         ReportsCommon updatedReportCommon = null;
465         if (payloadInputPart != null) {
466             updatedReportCommon = (ReportsCommon) payloadInputPart.getBody();
467         }
468         Assert.assertNotNull(updatedReportCommon);
469         if (logger.isDebugEnabled()) {
470             logger.debug("updated object");
471             logger.debug(objectAsXmlString(updatedReportCommon, ReportsCommon.class));
472         }
473
474         // Check selected fields in the updated common part.
475         Assert.assertEquals(updatedReportCommon.getName(),
476                 reportCommon.getName(),
477                 "Data in updated object did not match submitted data.");
478
479         // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters.
480         if (logger.isDebugEnabled()) {
481             logger.debug("UTF-8 data sent=" + reportCommon.getNotes() + "\n"
482                     + "UTF-8 data received=" + updatedReportCommon.getNotes());
483         }
484         Assert.assertTrue(updatedReportCommon.getNotes().contains(getUTF8DataFragment()),
485                 "UTF-8 data retrieved '" + updatedReportCommon.getNotes()
486                 + "' does not contain expected data '" + getUTF8DataFragment());
487         Assert.assertEquals(updatedReportCommon.getNotes(),
488                 reportCommon.getNotes(),
489                 "Data in updated object did not match submitted data.");
490     }
491
492     // Failure outcomes
493     // Placeholders until the three tests below can be uncommented.
494     // See Issue CSPACE-401.
495     /* (non-Javadoc)
496      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
497      */
498     @Override
499     public void updateWithEmptyEntityBody(String testName) throws Exception {
500         //Should this really be empty?
501     }
502
503     /* (non-Javadoc)
504      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
505      */
506     @Override
507     public void updateWithMalformedXml(String testName) throws Exception {
508         //Should this really be empty?
509     }
510
511     /* (non-Javadoc)
512      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
513      */
514     @Override
515     public void updateWithWrongXmlSchema(String testName) throws Exception {
516         //Should this really be empty?
517     }
518
519     /* (non-Javadoc)
520      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
521      */
522     @Override
523     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
524     dependsOnMethods = {"update", "testSubmitRequest"})
525     public void updateNonExistent(String testName) throws Exception {
526
527         if (logger.isDebugEnabled()) {
528             logger.debug(testBanner(testName, CLASS_NAME));
529         }
530         // Perform setup.
531         setupUpdateNonExistent();
532
533         // Submit the request to the service and store the response.
534         // Note: The ID used in this 'create' call may be arbitrary.
535         // The only relevant ID may be the one used in update(), below.
536         ReportClient client = new ReportClient();
537         PoxPayloadOut multipart = createReportInstance(NON_EXISTENT_ID);
538         ClientResponse<String> res = client.update(NON_EXISTENT_ID, multipart);
539         int statusCode = res.getStatus();
540
541         // Check the status code of the response: does it match
542         // the expected response(s)?
543         if (logger.isDebugEnabled()) {
544             logger.debug(testName + ": status = " + statusCode);
545         }
546         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
547                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
548         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
549     }
550
551     // ---------------------------------------------------------------
552     // CRUD tests : DELETE tests
553     // ---------------------------------------------------------------
554     // Success outcomes
555     /* (non-Javadoc)
556      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
557      */
558     @Override
559     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
560     dependsOnMethods = {"create", "readListFiltered", "testSubmitRequest", "update", "readWorkflow"})
561     public void delete(String testName) throws Exception {
562
563         if (logger.isDebugEnabled()) {
564             logger.debug(testBanner(testName, CLASS_NAME));
565         }
566         // Perform setup.
567         setupDelete();
568
569         // Submit the request to the service and store the response.
570         ReportClient client = new ReportClient();
571         ClientResponse<Response> res = client.delete(knownResourceId);
572         int statusCode = res.getStatus();
573
574         // Check the status code of the response: does it match
575         // the expected response(s)?
576         if (logger.isDebugEnabled()) {
577             logger.debug(testName + ": 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     // Failure outcomes
585     /* (non-Javadoc)
586      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
587      */
588     @Override
589     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
590     dependsOnMethods = {"delete"})
591     public void deleteNonExistent(String testName) throws Exception {
592
593         if (logger.isDebugEnabled()) {
594             logger.debug(testBanner(testName, CLASS_NAME));
595         }
596         // Perform setup.
597         setupDeleteNonExistent();
598
599         // Submit the request to the service and store the response.
600         ReportClient client = new ReportClient();
601         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
602         int statusCode = res.getStatus();
603
604         // Check the status code of the response: does it match
605         // the expected response(s)?
606         if (logger.isDebugEnabled()) {
607             logger.debug(testName + ": status = " + statusCode);
608         }
609         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
610                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
611         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
612     }
613
614     // ---------------------------------------------------------------
615     // Utility tests : tests of code used in tests above
616     // ---------------------------------------------------------------
617     /**
618      * Tests the code for manually submitting data that is used by several
619      * of the methods above.
620      */
621     @Test(dependsOnMethods = {"create", "read"})
622     public void testSubmitRequest() {
623
624         // Expected status code: 200 OK
625         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
626
627         // Submit the request to the service and store the response.
628         String method = ServiceRequestType.READ.httpMethodName();
629         String url = getResourceURL(knownResourceId);
630         int statusCode = submitRequest(method, url);
631
632         // Check the status code of the response: does it match
633         // the expected response(s)?
634         if (logger.isDebugEnabled()) {
635             logger.debug("testSubmitRequest: url=" + url
636                     + " status=" + statusCode);
637         }
638         Assert.assertEquals(statusCode, EXPECTED_STATUS);
639
640     }
641
642     // ---------------------------------------------------------------
643     // Utility methods used by tests above
644     // ---------------------------------------------------------------
645     @Override
646     protected String getServiceName() {
647         return SERVICE_NAME;
648     }
649
650     /* (non-Javadoc)
651      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
652      */
653     @Override
654     public String getServicePathComponent() {
655         return SERVICE_PATH_COMPONENT;
656     }
657
658     /**
659      * Creates the report instance.
660      *
661      * @param identifier the identifier
662      * @return the multipart output
663      */
664     private PoxPayloadOut createReportInstance(String identifier) {
665         return createReportInstance(
666                 "Acquisition Summary", 
667                 testDocType, true, false, false, true,
668                 "acq_basic.jasper",
669                 "application/pdf");
670     }
671
672     /**
673      * Creates the report instance.
674      *
675      * @param name the report name
676      * @param filename the relative path to the report
677      * @param outputMIME the MIME type we will return for this report
678      * @return the multipart output
679      */
680     private PoxPayloadOut createReportInstance(String name,
681                 String forDocType,
682                 boolean supportsSingle, boolean supportsList, 
683                 boolean supportsGroup, boolean supportsNoContext, 
684             String filename,
685             String outputMIME) {
686         ReportsCommon reportCommon = new ReportsCommon();
687         reportCommon.setName(name);
688         reportCommon.setForDocType(forDocType);
689         reportCommon.setSupportsSingleDoc(supportsSingle);
690         reportCommon.setSupportsDocList(supportsList);
691         reportCommon.setSupportsGroup(supportsGroup);
692         reportCommon.setSupportsNoContext(supportsNoContext);
693         reportCommon.setFilename(filename);
694         reportCommon.setOutputMIME(outputMIME);
695         reportCommon.setNotes(getUTF8DataFragment()); // For UTF-8 tests
696
697         PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
698         PayloadOutputPart commonPart =
699                 multipart.addPart(reportCommon, MediaType.APPLICATION_XML_TYPE);
700         commonPart.setLabel(new ReportClient().getCommonPartName());
701
702         if (logger.isDebugEnabled()) {
703             logger.debug("to be created, report common");
704             logger.debug(objectAsXmlString(reportCommon, ReportsCommon.class));
705             logger.debug(multipart.toXML());
706         }
707
708         return multipart;
709     }
710 }