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