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