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