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 © 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.CollectionSpaceClient;
30 import org.collectionspace.services.client.IntakeClient;
31 import org.collectionspace.services.intake.EntryMethodList;
32 import org.collectionspace.services.intake.FieldCollectionEventNameList;
33 import org.collectionspace.services.intake.IntakesCommon;
34 import org.collectionspace.services.intake.IntakesCommonList;
35 import org.collectionspace.services.jaxb.AbstractCommonList;
37 import org.jboss.resteasy.client.ClientResponse;
38 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
39 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
40 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
41 import org.testng.Assert;
42 //import org.testng.annotations.AfterClass;
43 import org.testng.annotations.Test;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
49 * FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
50 * IntakeServiceTest, carries out tests against a
51 * deployed and running Intake Service.
53 * $LastChangedRevision$
56 public class IntakeServiceTest extends AbstractServiceTestImpl {
59 private final String CLASS_NAME = IntakeServiceTest.class.getName();
60 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
62 // Instance variables specific to this test.
63 /** The service path component. */
64 final String SERVICE_PATH_COMPONENT = "intakes";
66 /** The known resource id. */
67 private String knownResourceId = null;
70 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
73 protected CollectionSpaceClient getClientInstance() {
74 return new IntakeClient();
78 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
81 protected AbstractCommonList getAbstractCommonList(
82 ClientResponse<AbstractCommonList> response) {
83 return response.getEntity(IntakesCommonList.class);
86 // ---------------------------------------------------------------
87 // CRUD tests : CREATE tests
88 // ---------------------------------------------------------------
91 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
94 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
95 public void create(String testName) throws Exception {
97 if (logger.isDebugEnabled()) {
98 logger.debug(testBanner(testName, CLASS_NAME));
100 // Perform setup, such as initializing the type of service request
101 // (e.g. CREATE, DELETE), its valid and expected status codes, and
102 // its associated HTTP method name (e.g. POST, DELETE).
105 // Submit the request to the service and store the response.
106 IntakeClient client = new IntakeClient();
107 String identifier = createIdentifier();
108 MultipartOutput multipart = createIntakeInstance(identifier);
109 ClientResponse<Response> res = client.create(multipart);
111 int statusCode = res.getStatus();
113 // Check the status code of the response: does it match
114 // the expected response(s)?
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);
122 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
123 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
124 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
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);
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));
141 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
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++){
153 // Placeholders until the three tests below can be uncommented.
154 // See Issue CSPACE-401.
156 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
159 public void createWithEmptyEntityBody(String testName) throws Exception {
160 //Should this really be empty?
164 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
167 public void createWithMalformedXml(String testName) throws Exception {
168 //Should this really be empty?
172 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
175 public void createWithWrongXmlSchema(String testName) throws Exception {
176 //Should this really be empty?
181 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
182 dependsOnMethods = {"create", "testSubmitRequest"})
183 public void createWithEmptyEntityBody(String testName) throws Exception {
185 if (logger.isDebugEnabled()) {
186 logger.debug(testBanner(testName, CLASS_NAME));
189 setupCreateWithEmptyEntityBody();
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);
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);
204 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
205 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
206 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
210 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
211 dependsOnMethods = {"create", "testSubmitRequest"})
212 public void createWithMalformedXml(String testName) throws Exception {
214 if (logger.isDebugEnabled()) {
215 logger.debug(testBanner(testName, CLASS_NAME));
218 setupCreateWithMalformedXml();
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);
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);
233 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
234 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
235 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
239 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
240 dependsOnMethods = {"create", "testSubmitRequest"})
241 public void createWithWrongXmlSchema(String testName) throws Exception {
243 if (logger.isDebugEnabled()) {
244 logger.debug(testBanner(testName, CLASS_NAME));
247 setupCreateWithWrongXmlSchema(testName, logger);
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);
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);
262 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
263 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
264 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
268 // ---------------------------------------------------------------
269 // CRUD tests : READ tests
270 // ---------------------------------------------------------------
273 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
276 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
277 dependsOnMethods = {"create"})
278 public void read(String testName) throws Exception {
280 if (logger.isDebugEnabled()) {
281 logger.debug(testBanner(testName, CLASS_NAME));
286 // Submit the request to the service and store the response.
287 IntakeClient client = new IntakeClient();
288 ClientResponse<MultipartInput> res = client.read(knownResourceId);
289 int statusCode = res.getStatus();
291 // Check the status code of the response: does it match
292 // the expected response(s)?
293 if(logger.isDebugEnabled()){
294 logger.debug(testName + ": status = " + statusCode);
296 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
297 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
298 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
300 MultipartInput input = (MultipartInput) res.getEntity();
301 IntakesCommon intake = (IntakesCommon) extractPart(input,
302 client.getCommonPartName(), IntakesCommon.class);
303 Assert.assertNotNull(intake);
305 // Verify the number and contents of values in repeatable fields,
306 // as created in the instance record used for testing.
307 List<String> entryMethods =
308 intake.getEntryMethods().getEntryMethod();
309 Assert.assertTrue(entryMethods.size() > 0);
310 Assert.assertNotNull(entryMethods.get(0));
312 List<String> fieldCollectionEventNames =
313 intake.getFieldCollectionEventNames().getFieldCollectionEventName();
314 Assert.assertTrue(fieldCollectionEventNames.size() > 0);
315 Assert.assertNotNull(fieldCollectionEventNames.get(0));
320 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
323 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
324 dependsOnMethods = {"read"})
325 public void readNonExistent(String testName) throws Exception {
327 if (logger.isDebugEnabled()) {
328 logger.debug(testBanner(testName, CLASS_NAME));
331 setupReadNonExistent();
333 // Submit the request to the service and store the response.
334 IntakeClient client = new IntakeClient();
335 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
336 int statusCode = res.getStatus();
338 // Check the status code of the response: does it match
339 // the expected response(s)?
340 if(logger.isDebugEnabled()){
341 logger.debug(testName + ": status = " + statusCode);
343 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
344 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
345 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
348 // ---------------------------------------------------------------
349 // CRUD tests : READ_LIST tests
350 // ---------------------------------------------------------------
353 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
356 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
357 dependsOnMethods = {"createList", "read"})
358 public void readList(String testName) throws Exception {
360 if (logger.isDebugEnabled()) {
361 logger.debug(testBanner(testName, CLASS_NAME));
366 // Submit the request to the service and store the response.
367 IntakeClient client = new IntakeClient();
368 ClientResponse<IntakesCommonList> res = client.readList();
369 IntakesCommonList list = res.getEntity();
370 int statusCode = res.getStatus();
372 // Check the status code of the response: does it match
373 // the expected response(s)?
374 if(logger.isDebugEnabled()){
375 logger.debug(testName + ": status = " + statusCode);
377 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
378 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
379 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
381 // Optionally output additional data about list members for debugging.
382 boolean iterateThroughList = false;
383 if(iterateThroughList && logger.isDebugEnabled()){
384 List<IntakesCommonList.IntakeListItem> items =
385 list.getIntakeListItem();
387 for(IntakesCommonList.IntakeListItem item : items){
388 logger.debug(testName + ": list-item[" + i + "] csid=" +
390 logger.debug(testName + ": list-item[" + i + "] objectNumber=" +
391 item.getEntryNumber());
392 logger.debug(testName + ": list-item[" + i + "] URI=" +
402 // ---------------------------------------------------------------
403 // CRUD tests : UPDATE tests
404 // ---------------------------------------------------------------
407 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
410 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
411 dependsOnMethods = {"read"})
412 public void update(String testName) throws Exception {
414 if (logger.isDebugEnabled()) {
415 logger.debug(testBanner(testName, CLASS_NAME));
420 // Retrieve the contents of a resource to update.
421 IntakeClient client = new IntakeClient();
422 ClientResponse<MultipartInput> res =
423 client.read(knownResourceId);
424 if(logger.isDebugEnabled()){
425 logger.debug(testName + ": read status = " + res.getStatus());
427 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
429 if(logger.isDebugEnabled()){
430 logger.debug("got object to update with ID: " + knownResourceId);
432 MultipartInput input = (MultipartInput) res.getEntity();
433 IntakesCommon intake = (IntakesCommon) extractPart(input,
434 client.getCommonPartName(), IntakesCommon.class);
435 Assert.assertNotNull(intake);
437 // Update the content of this resource.
438 // Update the content of this resource.
439 intake.setEntryNumber("updated-" + intake.getEntryNumber());
440 intake.setEntryDate("updated-" + intake.getEntryDate());
441 if(logger.isDebugEnabled()){
442 logger.debug("to be updated object");
443 logger.debug(objectAsXmlString(intake, IntakesCommon.class));
445 // Submit the request to the service and store the response.
446 MultipartOutput output = new MultipartOutput();
447 OutputPart commonPart = output.addPart(intake, MediaType.APPLICATION_XML_TYPE);
448 commonPart.getHeaders().add("label", client.getCommonPartName());
450 res = client.update(knownResourceId, output);
451 int statusCode = res.getStatus();
452 // Check the status code of the response: does it match the expected response(s)?
453 if(logger.isDebugEnabled()){
454 logger.debug(testName + ": status = " + statusCode);
456 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
457 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
458 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
461 input = (MultipartInput) res.getEntity();
462 IntakesCommon updatedIntake =
463 (IntakesCommon) extractPart(input,
464 client.getCommonPartName(), IntakesCommon.class);
465 Assert.assertNotNull(updatedIntake);
467 Assert.assertEquals(updatedIntake.getEntryDate(),
468 intake.getEntryDate(),
469 "Data in updated object did not match submitted data.");
474 // Placeholders until the three tests below can be uncommented.
475 // See Issue CSPACE-401.
477 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
480 public void updateWithEmptyEntityBody(String testName) throws Exception {
481 //Should this really be empty?
485 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
488 public void updateWithMalformedXml(String testName) throws Exception {
489 //Should this really be empty?
493 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
496 public void updateWithWrongXmlSchema(String testName) throws Exception {
497 //Should this really be empty?
502 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
503 dependsOnMethods = {"create", "update", "testSubmitRequest"})
504 public void updateWithEmptyEntityBody(String testName) throws Exception {
506 if (logger.isDebugEnabled()) {
507 logger.debug(testBanner(testName, CLASS_NAME));
510 setupUpdateWithEmptyEntityBody();
512 // Submit the request to the service and store the response.
513 String method = REQUEST_TYPE.httpMethodName();
514 String url = getResourceURL(knownResourceId);
515 String mediaType = MediaType.APPLICATION_XML;
516 final String entity = "";
517 int statusCode = submitRequest(method, url, mediaType, entity);
519 // Check the status code of the response: does it match
520 // the expected response(s)?
521 if(logger.isDebugEnabled()){
522 logger.debug(testName + ": url=" + url +
523 " status=" + statusCode);
525 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
526 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
527 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
531 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
532 dependsOnMethods = {"create", "update", "testSubmitRequest"})
533 public void updateWithMalformedXml(String testName) throws Exception {
535 if (logger.isDebugEnabled()) {
536 logger.debug(testBanner(testName, CLASS_NAME));
539 setupUpdateWithMalformedXml();
541 // Submit the request to the service and store the response.
542 String method = REQUEST_TYPE.httpMethodName();
543 String url = getResourceURL(knownResourceId);
544 String mediaType = MediaType.APPLICATION_XML;
545 final String entity = MALFORMED_XML_DATA;
546 int statusCode = submitRequest(method, url, mediaType, entity);
548 // Check the status code of the response: does it match
549 // the expected response(s)?
550 if(logger.isDebugEnabled()){
551 logger.debug(testName + ": url=" + url +
552 " status=" + statusCode);
554 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
555 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
556 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
560 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
561 dependsOnMethods = {"create", "update", "testSubmitRequest"})
562 public void updateWithWrongXmlSchema(String testName) throws Exception {
564 if (logger.isDebugEnabled()) {
565 logger.debug(testBanner(testName, CLASS_NAME));
568 setupUpdateWithWrongXmlSchema();
570 // Submit the request to the service and store the response.
571 String method = REQUEST_TYPE.httpMethodName();
572 String url = getResourceURL(knownResourceId);
573 String mediaType = MediaType.APPLICATION_XML;
574 final String entity = WRONG_XML_SCHEMA_DATA;
575 int statusCode = submitRequest(method, url, mediaType, entity);
577 // Check the status code of the response: does it match
578 // the expected response(s)?
579 if(logger.isDebugEnabled()){
580 logger.debug(testName + ": url=" + url +
581 " status=" + statusCode);
583 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
584 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
585 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
590 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
593 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
594 dependsOnMethods = {"update", "testSubmitRequest"})
595 public void updateNonExistent(String testName) throws Exception {
597 if (logger.isDebugEnabled()) {
598 logger.debug(testBanner(testName, CLASS_NAME));
601 setupUpdateNonExistent();
603 // Submit the request to the service and store the response.
604 // Note: The ID used in this 'create' call may be arbitrary.
605 // The only relevant ID may be the one used in update(), below.
606 IntakeClient client = new IntakeClient();
607 MultipartOutput multipart = createIntakeInstance(NON_EXISTENT_ID);
608 ClientResponse<MultipartInput> res =
609 client.update(NON_EXISTENT_ID, multipart);
610 int statusCode = res.getStatus();
612 // Check the status code of the response: does it match
613 // the expected response(s)?
614 if(logger.isDebugEnabled()){
615 logger.debug(testName + ": status = " + statusCode);
617 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
618 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
619 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
622 // ---------------------------------------------------------------
623 // CRUD tests : DELETE tests
624 // ---------------------------------------------------------------
627 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
630 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
631 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
632 public void delete(String testName) throws Exception {
634 if (logger.isDebugEnabled()) {
635 logger.debug(testBanner(testName, CLASS_NAME));
640 // Submit the request to the service and store the response.
641 IntakeClient client = new IntakeClient();
642 ClientResponse<Response> res = client.delete(knownResourceId);
643 int statusCode = res.getStatus();
645 // Check the status code of the response: does it match
646 // the expected response(s)?
647 if(logger.isDebugEnabled()){
648 logger.debug(testName + ": status = " + statusCode);
650 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
651 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
652 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
657 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
660 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
661 dependsOnMethods = {"delete"})
662 public void deleteNonExistent(String testName) throws Exception {
664 if (logger.isDebugEnabled()) {
665 logger.debug(testBanner(testName, CLASS_NAME));
668 setupDeleteNonExistent();
670 // Submit the request to the service and store the response.
671 IntakeClient client = new IntakeClient();
672 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
673 int statusCode = res.getStatus();
675 // Check the status code of the response: does it match
676 // the expected response(s)?
677 if(logger.isDebugEnabled()){
678 logger.debug(testName + ": status = " + statusCode);
680 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
681 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
682 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
685 // ---------------------------------------------------------------
686 // Utility tests : tests of code used in tests above
687 // ---------------------------------------------------------------
689 * Tests the code for manually submitting data that is used by several
690 * of the methods above.
692 @Test(dependsOnMethods = {"create", "read"})
693 public void testSubmitRequest() {
695 // Expected status code: 200 OK
696 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
698 // Submit the request to the service and store the response.
699 String method = ServiceRequestType.READ.httpMethodName();
700 String url = getResourceURL(knownResourceId);
701 int statusCode = submitRequest(method, url);
703 // Check the status code of the response: does it match
704 // the expected response(s)?
705 if(logger.isDebugEnabled()){
706 logger.debug("testSubmitRequest: url=" + url +
707 " status=" + statusCode);
709 Assert.assertEquals(statusCode, EXPECTED_STATUS);
713 // ---------------------------------------------------------------
714 // Utility methods used by tests above
715 // ---------------------------------------------------------------
717 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
720 public String getServicePathComponent() {
721 return SERVICE_PATH_COMPONENT;
725 * Creates the intake instance.
727 * @param identifier the identifier
728 * @return the multipart output
730 private MultipartOutput createIntakeInstance(String identifier) {
731 return createIntakeInstance(
732 "entryNumber-" + identifier,
733 "entryDate-" + identifier,
734 "depositor-" + identifier);
738 * Creates the intake instance.
740 * @param entryNumber the entry number
741 * @param entryDate the entry date
742 * @param depositor the depositor
743 * @return the multipart output
745 private MultipartOutput createIntakeInstance(String entryNumber,
748 IntakesCommon intake = new IntakesCommon();
749 intake.setEntryNumber(entryNumber);
750 intake.setEntryDate(entryDate);
751 intake.setDepositor(depositor);
753 EntryMethodList entryMethodsList = new EntryMethodList();
754 List<String> entryMethods = entryMethodsList.getEntryMethod();
755 entryMethods.add("Left at doorstep");
756 entryMethods.add("Received via post");
757 intake.setEntryMethods(entryMethodsList);
759 FieldCollectionEventNameList eventNamesList = new FieldCollectionEventNameList();
760 List<String> eventNames = eventNamesList.getFieldCollectionEventName();
761 // FIXME Use properly formatted refNames for representative event names
762 // in this example test record. The following are mere placeholders.
763 eventNames.add("Field Collection Event Name-1");
764 eventNames.add("Field Collection Event Name-2");
765 intake.setFieldCollectionEventNames(eventNamesList);
767 MultipartOutput multipart = new MultipartOutput();
768 OutputPart commonPart =
769 multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
770 commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName());
772 if(logger.isDebugEnabled()){
773 logger.debug("to be created, intake common");
774 logger.debug(objectAsXmlString(intake, IntakesCommon.class));