]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
9ed5bdbfdb973b9ec49c63c8a5d67cbf45fd23aa
[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.DimensionClient;
32 import org.collectionspace.services.client.DimensionFactory;
33 import org.collectionspace.services.dimension.DimensionsCommon;
34 import org.collectionspace.services.dimension.DimensionsCommonList;
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  * DimensionServiceTest, carries out tests against a
51  * deployed and running Dimension Service.
52  *
53  * $LastChangedRevision: 917 $
54  * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
55  */
56 public class DimensionServiceTest extends AbstractServiceTestImpl {
57
58     /** The logger. */
59     private final String CLASS_NAME = DimensionServiceTest.class.getName();
60     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
61
62     // Instance variables specific to this test.
63     /** The SERVIC e_ pat h_ component. */
64     final String SERVICE_PATH_COMPONENT = "dimensions";
65     /** The known resource id. */
66     private String knownResourceId = null;
67
68     /* (non-Javadoc)
69      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
70      */
71     @Override
72     protected CollectionSpaceClient getClientInstance() {
73         return new DimensionClient();
74     }
75
76     /* (non-Javadoc)
77      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
78      */
79     @Override
80     protected AbstractCommonList getAbstractCommonList(
81             ClientResponse<AbstractCommonList> response) {
82         return response.getEntity(DimensionsCommonList.class);
83     }
84
85     // ---------------------------------------------------------------
86     // CRUD tests : CREATE tests
87     // ---------------------------------------------------------------
88     // Success outcomes
89     /* (non-Javadoc)
90      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
91      */
92     @Override
93     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
94     public void create(String testName) throws Exception {
95
96         if (logger.isDebugEnabled()) {
97             logger.debug(testBanner(testName, CLASS_NAME));
98         }
99         // Perform setup, such as initializing the type of service request
100         // (e.g. CREATE, DELETE), its valid and expected status codes, and
101         // its associated HTTP method name (e.g. POST, DELETE).
102         setupCreate();
103
104         // Submit the request to the service and store the response.
105         DimensionClient client = new DimensionClient();
106         String identifier = createIdentifier();
107         MultipartOutput multipart = createDimensionInstance(client.getCommonPartName(),
108                 identifier);
109         ClientResponse<Response> res = client.create(multipart);
110
111         int statusCode = res.getStatus();
112
113         // Check the status code of the response: does it match
114         // the expected response(s)?
115         //
116         // Specifically:
117         // Does it fall within the set of valid status codes?
118         // Does it exactly match the expected status code?
119         if (logger.isDebugEnabled()) {
120             logger.debug(testName + ": status = " + statusCode);
121         }
122         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
123                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
124         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
125
126         // Store the ID returned from the first resource created
127         // for additional tests below.
128         if (knownResourceId == null) {
129             knownResourceId = extractId(res);
130             if (logger.isDebugEnabled()) {
131                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
132             }
133         }
134
135         // Store the IDs from every resource created by tests,
136         // so they can be deleted after tests have been run.
137         allResourceIdsCreated.add(extractId(res));
138     }
139
140     /* (non-Javadoc)
141      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
142      */
143     @Override
144     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
145     dependsOnMethods = {"create"})
146     public void createList(String testName) throws Exception {
147         for (int i = 0; i < 3; i++) {
148             create(testName);
149         }
150     }
151
152     // Failure outcomes
153     // Placeholders until the three tests below can be uncommented.
154     // See Issue CSPACE-401.
155     /* (non-Javadoc)
156      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
157      */
158     @Override
159     public void createWithEmptyEntityBody(String testName) throws Exception {
160         //Should this really be empty?
161     }
162
163     /* (non-Javadoc)
164      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
165      */
166     @Override
167     public void createWithMalformedXml(String testName) throws Exception {
168         //Should this really be empty?
169     }
170
171     /* (non-Javadoc)
172      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
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();
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     // CRUD tests : READ tests
269     // ---------------------------------------------------------------
270     // Success outcomes
271     /* (non-Javadoc)
272      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
273      */
274     @Override
275     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
276     dependsOnMethods = {"create"})
277     public void read(String testName) throws Exception {
278
279         if (logger.isDebugEnabled()) {
280             logger.debug(testBanner(testName, CLASS_NAME));
281         }
282         // Perform setup.
283         setupRead();
284
285         // Submit the request to the service and store the response.
286         DimensionClient client = new DimensionClient();
287         ClientResponse<MultipartInput> res = client.read(knownResourceId);
288         int statusCode = res.getStatus();
289
290         // Check the status code of the response: does it match
291         // the expected response(s)?
292         if (logger.isDebugEnabled()) {
293             logger.debug(testName + ": status = " + statusCode);
294         }
295         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
296                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
297         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
298
299         MultipartInput input = (MultipartInput) res.getEntity();
300         DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
301                 client.getCommonPartName(), DimensionsCommon.class);
302         Assert.assertNotNull(dimension);
303     }
304
305     // Failure outcomes
306     /* (non-Javadoc)
307      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
308      */
309     @Override
310     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
311     dependsOnMethods = {"read"})
312     public void readNonExistent(String testName) throws Exception {
313
314         if (logger.isDebugEnabled()) {
315             logger.debug(testBanner(testName, CLASS_NAME));
316         }
317         // Perform setup.
318         setupReadNonExistent();
319
320         // Submit the request to the service and store the response.
321         DimensionClient client = new DimensionClient();
322         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
323         int statusCode = res.getStatus();
324
325         // Check the status code of the response: does it match
326         // the expected response(s)?
327         if (logger.isDebugEnabled()) {
328             logger.debug(testName + ": status = " + statusCode);
329         }
330         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
331                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
332         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
333     }
334
335     // ---------------------------------------------------------------
336     // CRUD tests : READ_LIST tests
337     // ---------------------------------------------------------------
338     // Success outcomes
339     /* (non-Javadoc)
340      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
341      */
342     @Override
343     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
344     dependsOnMethods = {"read"})
345     public void readList(String testName) throws Exception {
346
347         if (logger.isDebugEnabled()) {
348             logger.debug(testBanner(testName, CLASS_NAME));
349         }
350         // Perform setup.
351         setupReadList();
352
353         // Submit the request to the service and store the response.
354         DimensionClient client = new DimensionClient();
355         ClientResponse<DimensionsCommonList> res = client.readList();
356         DimensionsCommonList list = res.getEntity();
357         int statusCode = res.getStatus();
358
359         // Check the status code of the response: does it match
360         // the expected response(s)?
361         if (logger.isDebugEnabled()) {
362             logger.debug(testName + ": status = " + statusCode);
363         }
364         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
365                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
366         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
367
368         // Optionally output additional data about list members for debugging.
369         boolean iterateThroughList = false;
370         if (iterateThroughList && logger.isDebugEnabled()) {
371             List<DimensionsCommonList.DimensionListItem> items =
372                     list.getDimensionListItem();
373             int i = 0;
374             for (DimensionsCommonList.DimensionListItem item : items) {
375                 logger.debug(testName + ": list-item[" + i + "] csid="
376                         + item.getCsid());
377                 logger.debug(testName + ": list-item[" + i + "] objectNumber="
378                         + item.getDimension());
379                 logger.debug(testName + ": list-item[" + i + "] URI="
380                         + item.getUri());
381                 i++;
382             }
383         }
384
385     }
386
387     // Failure outcomes
388     // None at present.
389     // ---------------------------------------------------------------
390     // CRUD tests : UPDATE tests
391     // ---------------------------------------------------------------
392     // Success outcomes
393     /* (non-Javadoc)
394      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
395      */
396     @Override
397     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
398     dependsOnMethods = {"read"})
399     public void update(String testName) throws Exception {
400
401         if (logger.isDebugEnabled()) {
402             logger.debug(testBanner(testName, CLASS_NAME));
403         }
404         // Perform setup.
405         setupUpdate();
406
407         // Retrieve the contents of a resource to update.
408         DimensionClient client = new DimensionClient();
409         ClientResponse<MultipartInput> res =
410                 client.read(knownResourceId);
411         if (logger.isDebugEnabled()) {
412             logger.debug(testName + ": read status = " + res.getStatus());
413         }
414         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
415
416         if (logger.isDebugEnabled()) {
417             logger.debug("got object to update with ID: " + knownResourceId);
418         }
419         MultipartInput input = (MultipartInput) res.getEntity();
420         DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
421                 client.getCommonPartName(), DimensionsCommon.class);
422         Assert.assertNotNull(dimension);
423
424         // Update the content of this resource.
425         dimension.setValue("updated-" + dimension.getValue());
426         dimension.setValueDate("updated-" + dimension.getValueDate());
427         if (logger.isDebugEnabled()) {
428             logger.debug("to be updated object");
429             logger.debug(objectAsXmlString(dimension, DimensionsCommon.class));
430         }
431         // Submit the request to the service and store the response.
432         MultipartOutput output = new MultipartOutput();
433         OutputPart commonPart = output.addPart(dimension, MediaType.APPLICATION_XML_TYPE);
434         commonPart.getHeaders().add("label", client.getCommonPartName());
435
436         res = client.update(knownResourceId, output);
437         int statusCode = res.getStatus();
438         // Check the status code of the response: does it match the expected response(s)?
439         if (logger.isDebugEnabled()) {
440             logger.debug(testName + ": status = " + statusCode);
441         }
442         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
443                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
444         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
445
446
447         input = (MultipartInput) res.getEntity();
448         DimensionsCommon updatedDimension =
449                 (DimensionsCommon) extractPart(input,
450                 client.getCommonPartName(), DimensionsCommon.class);
451         Assert.assertNotNull(updatedDimension);
452
453         Assert.assertEquals(updatedDimension.getValueDate(),
454                 dimension.getValueDate(),
455                 "Data in updated object did not match submitted data.");
456
457     }
458
459     // Failure outcomes
460     // Placeholders until the three tests below can be uncommented.
461     // See Issue CSPACE-401.
462     /* (non-Javadoc)
463      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
464      */
465     @Override
466     public void updateWithEmptyEntityBody(String testName) throws Exception {
467         //Should this really be empty?
468     }
469
470     /* (non-Javadoc)
471      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
472      */
473     @Override
474     public void updateWithMalformedXml(String testName) throws Exception {
475         //Should this really be empty?
476     }
477
478     /* (non-Javadoc)
479      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
480      */
481     @Override
482     public void updateWithWrongXmlSchema(String testName) throws Exception {
483         //Should this really be empty?
484     }
485
486     /*
487     @Override
488     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
489     dependsOnMethods = {"create", "update", "testSubmitRequest"})
490     public void updateWithEmptyEntityBody(String testName) throws Exception {
491
492         if (logger.isDebugEnabled()) {
493             logger.debug(testBanner(testName, CLASS_NAME));
494         }
495         // Perform setup.
496         setupUpdateWithEmptyEntityBody();
497
498         // Submit the request to the service and store the response.
499         String method = REQUEST_TYPE.httpMethodName();
500         String url = getResourceURL(knownResourceId);
501         String mediaType = MediaType.APPLICATION_XML;
502         final String entity = "";
503         int statusCode = submitRequest(method, url, mediaType, entity);
504
505         // Check the status code of the response: does it match
506         // the expected response(s)?
507         if(logger.isDebugEnabled()){
508         logger.debug(testName + ": url=" + url +
509         " status=" + statusCode);
510         }
511         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
512         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
513         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
514     }
515
516     @Override
517     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
518     dependsOnMethods = {"create", "update", "testSubmitRequest"})
519     public void updateWithMalformedXml(String testName) throws Exception {
520
521         if (logger.isDebugEnabled()) {
522             logger.debug(testBanner(testName, CLASS_NAME));
523         }
524         // Perform setup.
525         setupUpdateWithMalformedXml(testName, logger);
526
527         // Submit the request to the service and store the response.
528         String method = REQUEST_TYPE.httpMethodName();
529         String url = getResourceURL(knownResourceId);
530         String mediaType = MediaType.APPLICATION_XML;
531         final String entity = MALFORMED_XML_DATA;
532         int statusCode = submitRequest(method, url, mediaType, entity);
533
534         // Check the status code of the response: does it match
535         // the expected response(s)?
536         if(logger.isDebugEnabled()){
537         logger.debug(testName + ": url=" + url +
538         " status=" + statusCode);
539         }
540         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
541         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
542         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
543     }
544
545     @Override
546     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
547     dependsOnMethods = {"create", "update", "testSubmitRequest"})
548     public void updateWithWrongXmlSchema(String testName) throws Exception {
549
550         if (logger.isDebugEnabled()) {
551             logger.debug(testBanner(testName, CLASS_NAME));
552         }
553         // Perform setup.
554         setupUpdateWithWrongXmlSchema(testName, logger);
555
556         // Submit the request to the service and store the response.
557         String method = REQUEST_TYPE.httpMethodName();
558         String url = getResourceURL(knownResourceId);
559         String mediaType = MediaType.APPLICATION_XML;
560         final String entity = WRONG_XML_SCHEMA_DATA;
561         int statusCode = submitRequest(method, url, mediaType, entity);
562
563         // Check the status code of the response: does it match
564         // the expected response(s)?
565         if(logger.isDebugEnabled()){
566         logger.debug(testName + ": url=" + url +
567         " status=" + statusCode);
568         }
569         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
570         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
571         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
572     }
573      */
574
575     /* (non-Javadoc)
576      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
577      */
578     @Override
579     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
580     dependsOnMethods = {"update", "testSubmitRequest"})
581     public void updateNonExistent(String testName) throws Exception {
582
583         if (logger.isDebugEnabled()) {
584             logger.debug(testBanner(testName, CLASS_NAME));
585         }
586         // Perform setup.
587         setupUpdateNonExistent();
588
589         // Submit the request to the service and store the response.
590         // Note: The ID used in this 'create' call may be arbitrary.
591         // The only relevant ID may be the one used in update(), below.
592         DimensionClient client = new DimensionClient();
593         MultipartOutput multipart = createDimensionInstance(client.getCommonPartName(),
594                 NON_EXISTENT_ID);
595         ClientResponse<MultipartInput> res =
596                 client.update(NON_EXISTENT_ID, multipart);
597         int statusCode = res.getStatus();
598
599         // Check the status code of the response: does it match
600         // the expected response(s)?
601         if (logger.isDebugEnabled()) {
602             logger.debug(testName + ": status = " + statusCode);
603         }
604         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
605                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
606         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
607     }
608
609     // ---------------------------------------------------------------
610     // CRUD tests : DELETE tests
611     // ---------------------------------------------------------------
612     // Success outcomes
613     /* (non-Javadoc)
614      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
615      */
616     @Override
617     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
618     dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
619     public void delete(String testName) throws Exception {
620
621         if (logger.isDebugEnabled()) {
622             logger.debug(testBanner(testName, CLASS_NAME));
623         }
624         // Perform setup.
625         setupDelete();
626
627         // Submit the request to the service and store the response.
628         DimensionClient client = new DimensionClient();
629         ClientResponse<Response> res = client.delete(knownResourceId);
630         int statusCode = res.getStatus();
631
632         // Check the status code of the response: does it match
633         // the expected response(s)?
634         if (logger.isDebugEnabled()) {
635             logger.debug(testName + ": status = " + statusCode);
636         }
637         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
638                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
639         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
640     }
641
642     // Failure outcomes
643     /* (non-Javadoc)
644      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
645      */
646     @Override
647     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
648     dependsOnMethods = {"delete"})
649     public void deleteNonExistent(String testName) throws Exception {
650
651         if (logger.isDebugEnabled()) {
652             logger.debug(testBanner(testName, CLASS_NAME));
653         }
654         // Perform setup.
655         setupDeleteNonExistent();
656
657         // Submit the request to the service and store the response.
658         DimensionClient client = new DimensionClient();
659         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
660         int statusCode = res.getStatus();
661
662         // Check the status code of the response: does it match
663         // the expected response(s)?
664         if (logger.isDebugEnabled()) {
665             logger.debug(testName + ": status = " + statusCode);
666         }
667         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
668                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
669         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
670     }
671
672     // ---------------------------------------------------------------
673     // Utility tests : tests of code used in tests above
674     // ---------------------------------------------------------------
675     /**
676      * Tests the code for manually submitting data that is used by several
677      * of the methods above.
678      */
679     @Test(dependsOnMethods = {"create", "read"})
680     public void testSubmitRequest() {
681
682         // Expected status code: 200 OK
683         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
684
685         // Submit the request to the service and store the response.
686         String method = ServiceRequestType.READ.httpMethodName();
687         String url = getResourceURL(knownResourceId);
688         int statusCode = submitRequest(method, url);
689
690         // Check the status code of the response: does it match
691         // the expected response(s)?
692         if (logger.isDebugEnabled()) {
693             logger.debug("testSubmitRequest: url=" + url
694                     + " status=" + statusCode);
695         }
696         Assert.assertEquals(statusCode, EXPECTED_STATUS);
697
698     }
699
700     // ---------------------------------------------------------------
701     // Utility methods used by tests above
702     // ---------------------------------------------------------------
703     /* (non-Javadoc)
704      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
705      */
706     @Override
707     public String getServicePathComponent() {
708         return SERVICE_PATH_COMPONENT;
709     }
710
711     /**
712      * Creates the dimension instance.
713      *
714      * @param identifier the identifier
715      * @return the multipart output
716      */
717     private MultipartOutput createDimensionInstance(String commonPartName, String identifier) {
718         return createDimensionInstance(commonPartName, 
719                 "dimensionType-" + identifier,
720                 "entryNumber-" + identifier,
721                 "entryDate-" + identifier);
722     }
723
724     /**
725      * Creates the dimension instance.
726      *
727      * @param dimensionType the dimension type
728      * @param entryNumber the entry number
729      * @param entryDate the entry date
730      * @return the multipart output
731      */
732     private MultipartOutput createDimensionInstance(String commonPartName, String dimensionType, String entryNumber, String entryDate) {
733         DimensionsCommon dimension = new DimensionsCommon();
734         dimension.setDimension(dimensionType);
735         dimension.setValue(entryNumber);
736         dimension.setValueDate(entryDate);
737         MultipartOutput multipart = DimensionFactory.createDimensionInstance(
738                 commonPartName, dimension);
739
740         if (logger.isDebugEnabled()) {
741             logger.debug("to be created, dimension common");
742             logger.debug(objectAsXmlString(dimension,
743                     DimensionsCommon.class));
744         }
745
746         return multipart;
747     }
748 }