]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
39105d7f61d832e847856a4b9b7e8ad634da4b66
[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 Logger logger =
60             LoggerFactory.getLogger(DimensionServiceTest.class);
61     // Instance variables specific to this test.
62     /** The SERVIC e_ pat h_ component. */
63     final String SERVICE_PATH_COMPONENT = "dimensions";
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 DimensionClient();
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(DimensionsCommonList.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         DimensionClient client = new DimensionClient();
102         String identifier = createIdentifier();
103         MultipartOutput multipart = createDimensionInstance(client.getCommonPartName(),
104                 identifier);
105         ClientResponse<Response> res = client.create(multipart);
106
107         int statusCode = res.getStatus();
108
109         // Check the status code of the response: does it match
110         // the expected response(s)?
111         //
112         // Specifically:
113         // Does it fall within the set of valid status codes?
114         // Does it exactly match the expected status code?
115         if (logger.isDebugEnabled()) {
116             logger.debug(testName + ": status = " + statusCode);
117         }
118         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
119                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
120         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
121
122         // Store the ID returned from the first resource created
123         // for additional tests below.
124         if (knownResourceId == null) {
125             knownResourceId = extractId(res);
126             if (logger.isDebugEnabled()) {
127                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
128             }
129         }
130
131         // Store the IDs from every resource created by tests,
132         // so they can be deleted after tests have been run.
133         allResourceIdsCreated.add(extractId(res));
134     }
135
136     /* (non-Javadoc)
137      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
138      */
139     @Override
140     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
141     dependsOnMethods = {"create"})
142     public void createList(String testName) throws Exception {
143         for (int i = 0; i < 3; i++) {
144             create(testName);
145         }
146     }
147
148     // Failure outcomes
149     // Placeholders until the three tests below can be uncommented.
150     // See Issue CSPACE-401.
151     /* (non-Javadoc)
152      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
153      */
154     @Override
155     public void createWithEmptyEntityBody(String testName) throws Exception {
156         //Should this really be empty?
157     }
158
159     /* (non-Javadoc)
160      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
161      */
162     @Override
163     public void createWithMalformedXml(String testName) throws Exception {
164         //Should this really be empty?
165     }
166
167     /* (non-Javadoc)
168      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
169      */
170     @Override
171     public void createWithWrongXmlSchema(String testName) throws Exception {
172         //Should this really be empty?
173     }
174
175     /*
176     @Override
177     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
178     dependsOnMethods = {"create", "testSubmitRequest"})
179     public void createWithEmptyEntityBody(String testName) throws Exception {
180
181     // Perform setup.
182     setupCreateWithEmptyEntityBody(testName);
183
184     // Submit the request to the service and store the response.
185     String method = REQUEST_TYPE.httpMethodName();
186     String url = getServiceRootURL();
187     String mediaType = MediaType.APPLICATION_XML;
188     final String entity = "";
189     int statusCode = submitRequest(method, url, mediaType, entity);
190
191     // Check the status code of the response: does it match
192     // the expected response(s)?
193     if(logger.isDebugEnabled()){
194     logger.debug("createWithEmptyEntityBody url=" + url +
195     " status=" + statusCode);
196     }
197     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
198     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
199     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
200     }
201
202     @Override
203     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
204     dependsOnMethods = {"create", "testSubmitRequest"})
205     public void createWithMalformedXml(String testName) throws Exception {
206
207     // Perform setup.
208     setupCreateWithMalformedXml(testName);
209
210     // Submit the request to the service and store the response.
211     String method = REQUEST_TYPE.httpMethodName();
212     String url = getServiceRootURL();
213     String mediaType = MediaType.APPLICATION_XML;
214     final String entity = MALFORMED_XML_DATA; // Constant from base class.
215     int statusCode = submitRequest(method, url, mediaType, entity);
216
217     // Check the status code of the response: does it match
218     // the expected response(s)?
219     if(logger.isDebugEnabled()){
220     logger.debug(testName + ": url=" + url +
221     " status=" + statusCode);
222     }
223     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
224     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
225     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
226     }
227
228     @Override
229     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
230     dependsOnMethods = {"create", "testSubmitRequest"})
231     public void createWithWrongXmlSchema(String testName) throws Exception {
232
233     // Perform setup.
234     setupCreateWithWrongXmlSchema(testName);
235
236     // Submit the request to the service and store the response.
237     String method = REQUEST_TYPE.httpMethodName();
238     String url = getServiceRootURL();
239     String mediaType = MediaType.APPLICATION_XML;
240     final String entity = WRONG_XML_SCHEMA_DATA;
241     int statusCode = submitRequest(method, url, mediaType, entity);
242
243     // Check the status code of the response: does it match
244     // the expected response(s)?
245     if(logger.isDebugEnabled()){
246     logger.debug(testName + ": url=" + url +
247     " status=" + statusCode);
248     }
249     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
250     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
251     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
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         DimensionClient client = new DimensionClient();
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         DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
285                 client.getCommonPartName(), DimensionsCommon.class);
286         Assert.assertNotNull(dimension);
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         DimensionClient client = new DimensionClient();
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 = {"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         DimensionClient client = new DimensionClient();
333         ClientResponse<DimensionsCommonList> res = client.readList();
334         DimensionsCommonList 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<DimensionsCommonList.DimensionListItem> items =
350                     list.getDimensionListItem();
351             int i = 0;
352             for (DimensionsCommonList.DimensionListItem item : items) {
353                 logger.debug(testName + ": list-item[" + i + "] csid="
354                         + item.getCsid());
355                 logger.debug(testName + ": list-item[" + i + "] objectNumber="
356                         + item.getDimension());
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         DimensionClient client = new DimensionClient();
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         DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
396                 client.getCommonPartName(), DimensionsCommon.class);
397         Assert.assertNotNull(dimension);
398
399         // Update the content of this resource.
400         dimension.setValue("updated-" + dimension.getValue());
401         dimension.setValueDate("updated-" + dimension.getValueDate());
402         if (logger.isDebugEnabled()) {
403             logger.debug("to be updated object");
404             logger.debug(objectAsXmlString(dimension, DimensionsCommon.class));
405         }
406         // Submit the request to the service and store the response.
407         MultipartOutput output = new MultipartOutput();
408         OutputPart commonPart = output.addPart(dimension, MediaType.APPLICATION_XML_TYPE);
409         commonPart.getHeaders().add("label", client.getCommonPartName());
410
411         res = client.update(knownResourceId, output);
412         int statusCode = res.getStatus();
413         // Check the status code of the response: does it match the expected response(s)?
414         if (logger.isDebugEnabled()) {
415             logger.debug(testName + ": status = " + statusCode);
416         }
417         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
418                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
419         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
420
421
422         input = (MultipartInput) res.getEntity();
423         DimensionsCommon updatedDimension =
424                 (DimensionsCommon) extractPart(input,
425                 client.getCommonPartName(), DimensionsCommon.class);
426         Assert.assertNotNull(updatedDimension);
427
428         Assert.assertEquals(updatedDimension.getValueDate(),
429                 dimension.getValueDate(),
430                 "Data in updated object did not match submitted data.");
431
432     }
433
434     // Failure outcomes
435     // Placeholders until the three tests below can be uncommented.
436     // See Issue CSPACE-401.
437     /* (non-Javadoc)
438      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
439      */
440     @Override
441     public void updateWithEmptyEntityBody(String testName) throws Exception {
442         //Should this really be empty?
443     }
444
445     /* (non-Javadoc)
446      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
447      */
448     @Override
449     public void updateWithMalformedXml(String testName) throws Exception {
450         //Should this really be empty?
451     }
452
453     /* (non-Javadoc)
454      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
455      */
456     @Override
457     public void updateWithWrongXmlSchema(String testName) throws Exception {
458         //Should this really be empty?
459     }
460
461     /*
462     @Override
463     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
464     dependsOnMethods = {"create", "update", "testSubmitRequest"})
465     public void updateWithEmptyEntityBody(String testName) throws Exception {
466
467     // Perform setup.
468     setupUpdateWithEmptyEntityBody(testName);
469
470     // Submit the request to the service and store the response.
471     String method = REQUEST_TYPE.httpMethodName();
472     String url = getResourceURL(knownResourceId);
473     String mediaType = MediaType.APPLICATION_XML;
474     final String entity = "";
475     int statusCode = submitRequest(method, url, mediaType, entity);
476
477     // Check the status code of the response: does it match
478     // the expected response(s)?
479     if(logger.isDebugEnabled()){
480     logger.debug(testName + ": url=" + url +
481     " status=" + statusCode);
482     }
483     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
484     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
485     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
486     }
487
488     @Override
489     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
490     dependsOnMethods = {"create", "update", "testSubmitRequest"})
491     public void updateWithMalformedXml(String testName) throws Exception {
492
493     // Perform setup.
494     setupUpdateWithMalformedXml(testName);
495
496     // Submit the request to the service and store the response.
497     String method = REQUEST_TYPE.httpMethodName();
498     String url = getResourceURL(knownResourceId);
499     String mediaType = MediaType.APPLICATION_XML;
500     final String entity = MALFORMED_XML_DATA;
501     int statusCode = submitRequest(method, url, mediaType, entity);
502
503     // Check the status code of the response: does it match
504     // the expected response(s)?
505     if(logger.isDebugEnabled()){
506     logger.debug(testName + ": url=" + url +
507     " status=" + statusCode);
508     }
509     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
510     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
511     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
512     }
513
514     @Override
515     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
516     dependsOnMethods = {"create", "update", "testSubmitRequest"})
517     public void updateWithWrongXmlSchema(String testName) throws Exception {
518
519     // Perform setup.
520     setupUpdateWithWrongXmlSchema(testName);
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     /* (non-Javadoc)
542      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
543      */
544     @Override
545     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
546     dependsOnMethods = {"update", "testSubmitRequest"})
547     public void updateNonExistent(String testName) throws Exception {
548
549         // Perform setup.
550         setupUpdateNonExistent(testName);
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         DimensionClient client = new DimensionClient();
556         MultipartOutput multipart = createDimensionInstance(client.getCommonPartName(),
557                 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         DimensionClient client = new DimensionClient();
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         DimensionClient client = new DimensionClient();
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 dimension instance.
670      *
671      * @param identifier the identifier
672      * @return the multipart output
673      */
674     private MultipartOutput createDimensionInstance(String commonPartName, String identifier) {
675         return createDimensionInstance(commonPartName, 
676                 "dimensionType-" + identifier,
677                 "entryNumber-" + identifier,
678                 "entryDate-" + identifier);
679     }
680
681     /**
682      * Creates the dimension instance.
683      *
684      * @param dimensionType the dimension type
685      * @param entryNumber the entry number
686      * @param entryDate the entry date
687      * @return the multipart output
688      */
689     private MultipartOutput createDimensionInstance(String commonPartName, String dimensionType, String entryNumber, String entryDate) {
690         DimensionsCommon dimension = new DimensionsCommon();
691         dimension.setDimension(dimensionType);
692         dimension.setValue(entryNumber);
693         dimension.setValueDate(entryDate);
694         MultipartOutput multipart = DimensionFactory.createDimensionInstance(
695                 commonPartName, dimension);
696
697         if (logger.isDebugEnabled()) {
698             logger.debug("to be created, dimension common");
699             logger.debug(objectAsXmlString(dimension,
700                     DimensionsCommon.class));
701         }
702
703         return multipart;
704     }
705 }