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