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