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:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright (c) 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
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.
23 package org.collectionspace.services.client.test;
25 import java.util.List;
26 import javax.ws.rs.core.MediaType;
27 import javax.ws.rs.core.Response;
29 import org.collectionspace.services.client.AcquisitionClient;
30 import org.collectionspace.services.client.CollectionSpaceClient;
31 import org.collectionspace.services.jaxb.AbstractCommonList;
33 import org.collectionspace.services.acquisition.AcquisitionsCommon;
34 import org.collectionspace.services.acquisition.AcquisitionsCommonList;
35 import org.collectionspace.services.acquisition.AcquisitionDateList;
36 import org.collectionspace.services.acquisition.AcquisitionSourceList;
37 import org.jboss.resteasy.client.ClientResponse;
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.Test;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
49 * AcquisitionServiceTest, carries out tests against a
50 * deployed and running Acquisition Service.
52 * $LastChangedRevision: 621 $
53 * $LastChangedDate: 2009-09-02 16:49:01 -0700 (Wed, 02 Sep 2009) $
55 public class AcquisitionServiceTest extends AbstractServiceTestImpl {
58 private final String CLASS_NAME = AcquisitionServiceTest.class.getName();
59 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
61 // Instance variables specific to this test.
62 /** The known resource id. */
63 private String knownResourceId = null;
66 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
69 protected CollectionSpaceClient getClientInstance() {
70 return new AcquisitionClient();
74 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
77 protected AbstractCommonList getAbstractCommonList(
78 ClientResponse<AbstractCommonList> response) {
79 return response.getEntity(AcquisitionsCommonList.class);
82 // ---------------------------------------------------------------
83 // CRUD tests : CREATE tests
84 // ---------------------------------------------------------------
87 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
90 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
91 public void create(String testName) throws Exception {
93 if (logger.isDebugEnabled()) {
94 logger.debug(testBanner(testName, CLASS_NAME));
97 // Perform setup, such as initializing the type of service request
98 // (e.g. CREATE, DELETE), its valid and expected status codes, and
99 // its associated HTTP method name (e.g. POST, DELETE).
102 // Submit the request to the service and store the response.
103 String identifier = createIdentifier();
105 AcquisitionClient client = new AcquisitionClient();
106 MultipartOutput multipart = createAcquisitionInstance(identifier);
107 ClientResponse<Response> res = client.create(multipart);
109 int statusCode = res.getStatus();
111 // Check the status code of the response: does it match
112 // the expected response(s)?
115 // Does it fall within the set of valid status codes?
116 // Does it exactly match the expected status code?
117 if(logger.isDebugEnabled()){
118 logger.debug(testName + ": status = " + statusCode);
120 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
121 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
122 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
124 // Store the ID returned from the first resource created
125 // for additional tests below.
126 if (knownResourceId == null){
127 knownResourceId = extractId(res);
128 if (logger.isDebugEnabled()) {
129 logger.debug(testName + ": knownResourceId=" + knownResourceId);
133 // Store the IDs from every resource created by tests,
134 // so they can be deleted after tests have been run.
135 allResourceIdsCreated.add(extractId(res));
139 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
142 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
143 dependsOnMethods = {"create"})
144 public void createList(String testName) throws Exception {
145 for(int i = 0; i < 3; i++){
151 // Placeholders until the three tests below can be uncommented.
152 // See Issue CSPACE-401.
154 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
157 public void createWithEmptyEntityBody(String testName) throws Exception {
158 //Should this really be empty?
162 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
165 public void createWithMalformedXml(String testName) throws Exception {
166 //Should this really be empty?
170 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
173 public void createWithWrongXmlSchema(String testName) throws Exception {
174 //Should this really be empty?
179 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
180 dependsOnMethods = {"create", "testSubmitRequest"})
181 public void createWithMalformedXml(String testName) throws Exception {
183 if (logger.isDebugEnabled()) {
184 logger.debug(testBanner(testName, CLASS_NAME));
188 setupCreateWithMalformedXml();
190 // Submit the request to the service and store the response.
191 String method = REQUEST_TYPE.httpMethodName();
192 String url = getServiceRootURL();
193 final String entity = MALFORMED_XML_DATA; // Constant from base class.
194 int statusCode = submitRequest(method, url, entity);
196 // Check the status code of the response: does it match
197 // the expected response(s)?
198 if(logger.isDebugEnabled()){
199 logger.debug(testName + ": url=" + url +
200 " status=" + statusCode);
202 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
203 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
204 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
208 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
209 dependsOnMethods = {"create", "testSubmitRequest"})
210 public void createWithWrongXmlSchema(String testName) throws Exception {
212 if (logger.isDebugEnabled()) {
213 logger.debug(testBanner(testName, CLASS_NAME));
217 setupCreateWithWrongXmlSchema();
219 // Submit the request to the service and store the response.
220 String method = REQUEST_TYPE.httpMethodName();
221 String url = getServiceRootURL();
222 final String entity = WRONG_XML_SCHEMA_DATA;
223 int statusCode = submitRequest(method, url, entity);
225 // Check the status code of the response: does it match
226 // the expected response(s)?
227 if(logger.isDebugEnabled()){
228 logger.debug(testName + ": url=" + url +
229 " status=" + statusCode);
231 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
232 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
233 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
237 // ---------------------------------------------------------------
238 // CRUD tests : READ tests
239 // ---------------------------------------------------------------
242 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
245 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
246 dependsOnMethods = {"create"})
247 public void read(String testName) throws Exception {
249 if (logger.isDebugEnabled()) {
250 logger.debug(testBanner(testName, CLASS_NAME));
256 AcquisitionClient client = new AcquisitionClient();
258 // Submit the request to the service and store the response.
259 ClientResponse<MultipartInput> res = client.read(knownResourceId);
260 int statusCode = res.getStatus();
262 // Check the status code of the response: does it match
263 // the expected response(s)?
264 if(logger.isDebugEnabled()){
265 logger.debug(testName + ": status = " + statusCode);
267 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
268 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
269 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
271 MultipartInput input = (MultipartInput) res.getEntity();
272 AcquisitionsCommon acquisitionObject = (AcquisitionsCommon) extractPart(input,
273 client.getCommonPartName(), AcquisitionsCommon.class);
274 Assert.assertNotNull(acquisitionObject);
276 // Verify the number and contents of values in repeatable fields,
277 // as created in the instance record used for testing.
278 List<String> acqSources =
279 acquisitionObject.getAcquisitionSources().getAcquisitionSource();
280 Assert.assertTrue(acqSources.size() > 0);
281 Assert.assertNotNull(acqSources.get(0));
283 List<String> acqDates =
284 acquisitionObject.getAcquisitionDates().getAcquisitionDate();
285 Assert.assertTrue(acqDates.size() > 0);
286 Assert.assertNotNull(acqDates.get(0));
292 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
295 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
296 dependsOnMethods = {"read"})
297 public void readNonExistent(String testName) throws Exception {
299 if (logger.isDebugEnabled()) {
300 logger.debug(testBanner(testName, CLASS_NAME));
304 setupReadNonExistent();
306 // Submit the request to the service and store the response.
307 AcquisitionClient client = new AcquisitionClient();
308 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
309 int statusCode = res.getStatus();
311 // Check the status code of the response: does it match
312 // the expected response(s)?
313 if(logger.isDebugEnabled()){
314 logger.debug(testName + ": status = " + statusCode);
316 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
317 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
318 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
321 // ---------------------------------------------------------------
322 // CRUD tests : READ_LIST tests
323 // ---------------------------------------------------------------
326 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
329 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
330 dependsOnMethods = {"createList", "read"})
331 public void readList(String testName) throws Exception {
333 if (logger.isDebugEnabled()) {
334 logger.debug(testBanner(testName, CLASS_NAME));
340 // Submit the request to the service and store the response.
341 AcquisitionClient client = new AcquisitionClient();
342 ClientResponse<AcquisitionsCommonList> res = client.readList();
343 AcquisitionsCommonList list = res.getEntity();
344 int statusCode = res.getStatus();
346 // Check the status code of the response: does it match
347 // the expected response(s)?
348 if(logger.isDebugEnabled()){
349 logger.debug(testName + ": status = " + statusCode);
351 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
352 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
353 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
355 // Optionally output additional data about list members for debugging.
356 boolean iterateThroughList = false;
357 if(iterateThroughList && logger.isDebugEnabled()){
358 List<AcquisitionsCommonList.AcquisitionListItem> items =
359 list.getAcquisitionListItem();
361 for(AcquisitionsCommonList.AcquisitionListItem item : items){
362 logger.debug(testName + ": list-item[" + i + "] csid=" +
364 logger.debug(testName + ": list-item[" + i + "] objectNumber=" +
365 item.getAcquisitionReferenceNumber());
366 logger.debug(testName + ": list-item[" + i + "] acquisitionSources:");
367 AcquisitionSourceList acqSource = item.getAcquisitionSources();
368 for (String acquisitionSource : acqSource.getAcquisitionSource()) {
369 logger.debug("acquisitionSource=" + acquisitionSource);
371 logger.debug(testName + ": list-item[" + i + "] URI=" +
382 // ---------------------------------------------------------------
383 // CRUD tests : UPDATE tests
384 // ---------------------------------------------------------------
388 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
391 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
392 dependsOnMethods = {"read"})
393 public void update(String testName) throws Exception {
395 if (logger.isDebugEnabled()) {
396 logger.debug(testBanner(testName, CLASS_NAME));
402 // Retrieve the contents of a resource to update.
403 AcquisitionClient client = new AcquisitionClient();
404 ClientResponse<MultipartInput> res = client.read(knownResourceId);
405 if(logger.isDebugEnabled()){
406 logger.debug(testName + ": read status = " + res.getStatus());
408 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
410 if(logger.isDebugEnabled()){
411 logger.debug("got object to update with ID: " + knownResourceId);
413 MultipartInput input = (MultipartInput) res.getEntity();
415 AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
416 client.getCommonPartName(), AcquisitionsCommon.class);
417 Assert.assertNotNull(acquisition);
419 // Update the content of this resource.
420 acquisition.setAcquisitionReferenceNumber("updated-" + acquisition.getAcquisitionReferenceNumber());
421 if(logger.isDebugEnabled()){
422 logger.debug("updated object");
423 logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));
425 // Submit the request to the service and store the response.
426 MultipartOutput output = new MultipartOutput();
427 OutputPart commonPart = output.addPart(acquisition, MediaType.APPLICATION_XML_TYPE);
428 commonPart.getHeaders().add("label", client.getCommonPartName());
430 res = client.update(knownResourceId, output);
431 int statusCode = res.getStatus();
432 // Check the status code of the response: does it match the expected response(s)?
433 if(logger.isDebugEnabled()){
434 logger.debug(testName + ": status = " + statusCode);
436 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
437 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
438 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
441 input = (MultipartInput) res.getEntity();
442 AcquisitionsCommon updatedAcquisition =
443 (AcquisitionsCommon) extractPart(input,
444 client.getCommonPartName(), AcquisitionsCommon.class);
445 Assert.assertNotNull(updatedAcquisition);
447 Assert.assertEquals(updatedAcquisition.getAcquisitionReferenceNumber(),
448 acquisition.getAcquisitionReferenceNumber(),
449 "Data in updated object did not match submitted data.");
454 // Placeholders until the three tests below can be uncommented.
455 // See Issue CSPACE-401.
457 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
460 public void updateWithEmptyEntityBody(String testName) throws Exception {
461 //Should this really be empty?
465 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
468 public void updateWithMalformedXml(String testName) throws Exception {
469 //Should this really be empty?
473 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
476 public void updateWithWrongXmlSchema(String testName) throws Exception {
477 //Should this really be empty?
482 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
483 dependsOnMethods = {"create", "update", "testSubmitRequest"})
484 public void updateWithEmptyEntityBody(String testName) throws Exception {
486 if (logger.isDebugEnabled()) {
487 logger.debug(testBanner(testName, CLASS_NAME));
491 setupUpdateWithEmptyEntityBody();
493 // Submit the request to the service and store the response.
494 String method = REQUEST_TYPE.httpMethodName();
495 String url = getResourceURL(knownResourceId);
496 String mediaType = MediaType.APPLICATION_XML;
497 final String entity = "";
498 int statusCode = submitRequest(method, url, mediaType, entity);
500 // Check the status code of the response: does it match
501 // the expected response(s)?
502 if(logger.isDebugEnabled()){
503 (testName + ": url=" + url + " status=" + statusCode);
505 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
506 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
507 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
511 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
512 dependsOnMethods = {"create", "testSubmitRequest"})
513 public void createWithEmptyEntityBody(String testName) throws Exception {
515 if (logger.isDebugEnabled()) {
516 logger.debug(testBanner(testName, CLASS_NAME));
520 setupCreateWithEmptyEntityBody();
522 // Submit the request to the service and store the response.
523 String method = REQUEST_TYPE.httpMethodName();
524 String url = getServiceRootURL();
525 String mediaType = MediaType.APPLICATION_XML;
526 final String entity = "";
527 int statusCode = submitRequest(method, url, mediaType, entity);
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);
535 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
536 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
537 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
541 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
542 dependsOnMethods = {"create", "update", "testSubmitRequest"})
543 public void updateWithMalformedXml(String testName) throws Exception {
545 if (logger.isDebugEnabled()) {
546 logger.debug(testBanner(testName, CLASS_NAME));
550 setupUpdateWithMalformedXml();
552 // Submit the request to the service and store the response.
553 String method = REQUEST_TYPE.httpMethodName();
554 String url = getResourceURL(knownResourceId);
555 final String entity = MALFORMED_XML_DATA;
556 int statusCode = submitRequest(method, url, entity);
558 // Check the status code of the response: does it match
559 // the expected response(s)?
560 if(logger.isDebugEnabled()){
561 logger.debug(testName + ": url=" + url +
562 " status=" + statusCode);
564 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
565 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
566 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
570 @Test(dependsOnMethods = {"create", "update", "testSubmitRequest"})
571 public void updateWithWrongXmlSchema(String testName) {
573 if (logger.isDebugEnabled()) {
574 logger.debug(testBanner(testName, CLASS_NAME));
578 setupUpdateWithWrongXmlSchema();
580 // Submit the request to the service and store the response.
581 String method = REQUEST_TYPE.httpMethodName();
582 String url = getResourceURL(knownResourceId);
583 final String entity = WRONG_XML_SCHEMA_DATA;
584 int statusCode = submitRequest(method, url, entity);
586 // Check the status code of the response: does it match
587 // the expected response(s)?
588 if(logger.isDebugEnabled()){
589 logger.debug(testName + ": url=" + url +
590 " status=" + statusCode);
592 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
593 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
594 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
599 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
602 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
603 dependsOnMethods = {"update", "testSubmitRequest"})
604 public void updateNonExistent(String testName) throws Exception {
606 if (logger.isDebugEnabled()) {
607 logger.debug(testBanner(testName, CLASS_NAME));
611 setupUpdateNonExistent();
613 // Submit the request to the service and store the response.
614 // Note: The ID used in this 'create' call may be arbitrary.
615 // The only relevant ID may be the one used in update(), below.
616 AcquisitionClient client = new AcquisitionClient();
617 MultipartOutput multipart = createAcquisitionInstance(NON_EXISTENT_ID);
618 ClientResponse<MultipartInput> res =
619 client.update(NON_EXISTENT_ID, multipart);
620 int statusCode = res.getStatus();
622 // Check the status code of the response: does it match
623 // the expected response(s)?
624 if(logger.isDebugEnabled()){
625 logger.debug(testName + ": status = " + statusCode);
627 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
628 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
629 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
632 // ---------------------------------------------------------------
633 // CRUD tests : DELETE tests
634 // ---------------------------------------------------------------
637 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
640 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
641 dependsOnMethods = {"create", "read", "update"})
642 public void delete(String testName) throws Exception {
644 if (logger.isDebugEnabled()) {
645 logger.debug(testBanner(testName, CLASS_NAME));
651 // Submit the request to the service and store the response.
652 AcquisitionClient client = new AcquisitionClient();
653 ClientResponse<Response> res = client.delete(knownResourceId);
654 int statusCode = res.getStatus();
656 // Check the status code of the response: does it match
657 // the expected response(s)?
658 if(logger.isDebugEnabled()){
659 logger.debug(testName + ": status = " + statusCode);
661 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
662 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
663 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
668 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
671 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
672 dependsOnMethods = {"delete"})
673 public void deleteNonExistent(String testName) throws Exception {
675 if (logger.isDebugEnabled()) {
676 logger.debug(testBanner(testName, CLASS_NAME));
680 setupDeleteNonExistent();
682 // Submit the request to the service and store the response.
683 AcquisitionClient client = new AcquisitionClient();
684 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
685 int statusCode = res.getStatus();
687 // Check the status code of the response: does it match
688 // the expected response(s)?
689 if(logger.isDebugEnabled()){
690 logger.debug(testName + ": status = " + statusCode);
692 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
693 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
694 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
697 // ---------------------------------------------------------------
698 // Utility tests : tests of code used in tests above
699 // ---------------------------------------------------------------
701 * Tests the code for manually submitting data that is used by several
702 * of the methods above.
706 @Test(dependsOnMethods = {"create", "read"})
707 public void testSubmitRequest() throws Exception {
712 // Submit the request to the service and store the response.
713 String method = ServiceRequestType.READ.httpMethodName();
714 String url = getResourceURL(knownResourceId);
715 int statusCode = submitRequest(method, url);
717 // Check the status code of the response: does it match
718 // the expected response(s)?
719 if(logger.isDebugEnabled()){
720 logger.debug("testSubmitRequest: url=" + url +
721 " status=" + statusCode);
723 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
727 // ---------------------------------------------------------------
728 // Utility methods used by tests above
729 // ---------------------------------------------------------------
731 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
734 public String getServicePathComponent() {
735 return new AcquisitionClient().getServicePathComponent();
740 * Creates the acquisition instance.
742 * @param identifier the identifier
743 * @return the multipart output
745 private MultipartOutput createAcquisitionInstance(String identifier) {
746 AcquisitionsCommon acquisition = new AcquisitionsCommon();
747 acquisition.setAcquisitionReferenceNumber("acquisitionReferenceNumber-" + identifier);
748 AcquisitionSourceList acqSourcesList = new AcquisitionSourceList();
749 List<String> acqSources = acqSourcesList.getAcquisitionSource();
750 // FIXME Use properly formatted refNames for representative acquisition
751 // sources in this example test record. The following are mere placeholders.
752 acqSources.add("Donor Acquisition Source-" + identifier);
753 acqSources.add("Museum Acquisition Source-" + identifier);
754 acquisition.setAcquisitionSources(acqSourcesList);
755 AcquisitionDateList acqDatesList = new AcquisitionDateList();
756 List<String> acqDates = acqDatesList.getAcquisitionDate();
757 // FIXME Use properly timestamps for representative acquisition
758 // dates in this example test record. The following are mere placeholders.
759 acqDates.add("First Acquisition Date -" + identifier);
760 acqDates.add("Second Acquisition Date-" + identifier);
761 acquisition.setAcquisitionDates(acqDatesList);
762 MultipartOutput multipart = new MultipartOutput();
763 OutputPart commonPart = multipart.addPart(acquisition,
764 MediaType.APPLICATION_XML_TYPE);
765 commonPart.getHeaders().add("label", new AcquisitionClient().getCommonPartName());
767 if(logger.isDebugEnabled()){
768 logger.debug("to be created, acquisition common");
769 logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));