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.IntakesCommon;
33 import org.collectionspace.services.intake.IntakesCommonList;
34 import org.collectionspace.services.jaxb.AbstractCommonList;
36 import org.jboss.resteasy.client.ClientResponse;
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;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
48 * FIXME: http://issues.collectionspace.org/browse/CSPACE-1685
49 * IntakeServiceTest, carries out tests against a
50 * deployed and running Intake Service.
52 * $LastChangedRevision$
55 public class IntakeServiceTest extends AbstractServiceTestImpl {
58 private final String CLASS_NAME = IntakeServiceTest.class.getName();
59 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
61 // Instance variables specific to this test.
62 /** The service path component. */
63 final String SERVICE_PATH_COMPONENT = "intakes";
65 /** The known resource id. */
66 private String knownResourceId = null;
69 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
72 protected CollectionSpaceClient getClientInstance() {
73 return new IntakeClient();
77 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
80 protected AbstractCommonList getAbstractCommonList(
81 ClientResponse<AbstractCommonList> response) {
82 return response.getEntity(IntakesCommonList.class);
85 // ---------------------------------------------------------------
86 // CRUD tests : CREATE tests
87 // ---------------------------------------------------------------
90 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
93 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
94 public void create(String testName) throws Exception {
96 if (logger.isDebugEnabled()) {
97 logger.debug(testBanner(testName, CLASS_NAME));
99 // Perform setup, such as initializing the type of service request
100 // (e.g. CREATE, DELETE), its valid and expected status codes, and
101 // its associated HTTP method name (e.g. POST, DELETE).
104 // Submit the request to the service and store the response.
105 IntakeClient client = new IntakeClient();
106 String identifier = createIdentifier();
107 MultipartOutput multipart = createIntakeInstance(identifier);
108 ClientResponse<Response> res = client.create(multipart);
110 int statusCode = res.getStatus();
112 // Check the status code of the response: does it match
113 // the expected response(s)?
116 // Does it fall within the set of valid status codes?
117 // Does it exactly match the expected status code?
118 if(logger.isDebugEnabled()){
119 logger.debug(testName + ": status = " + statusCode);
121 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
122 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
123 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
125 // Store the ID returned from the first resource created
126 // for additional tests below.
127 if (knownResourceId == null){
128 knownResourceId = extractId(res);
129 if (logger.isDebugEnabled()) {
130 logger.debug(testName + ": knownResourceId=" + knownResourceId);
134 // Store the IDs from every resource created by tests,
135 // so they can be deleted after tests have been run.
136 allResourceIdsCreated.add(extractId(res));
140 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
143 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
144 dependsOnMethods = {"create"})
145 public void createList(String testName) throws Exception {
146 for(int i = 0; i < 3; i++){
152 // Placeholders until the three tests below can be uncommented.
153 // See Issue CSPACE-401.
155 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
158 public void createWithEmptyEntityBody(String testName) throws Exception {
159 //Should this really be empty?
163 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
166 public void createWithMalformedXml(String testName) throws Exception {
167 //Should this really be empty?
171 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
174 public void createWithWrongXmlSchema(String testName) throws Exception {
175 //Should this really be empty?
180 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
181 dependsOnMethods = {"create", "testSubmitRequest"})
182 public void createWithEmptyEntityBody(String testName) throws Exception {
184 if (logger.isDebugEnabled()) {
185 logger.debug(testBanner(testName, CLASS_NAME));
188 setupCreateWithEmptyEntityBody();
190 // Submit the request to the service and store the response.
191 String method = REQUEST_TYPE.httpMethodName();
192 String url = getServiceRootURL();
193 String mediaType = MediaType.APPLICATION_XML;
194 final String entity = "";
195 int statusCode = submitRequest(method, url, mediaType, entity);
197 // Check the status code of the response: does it match
198 // the expected response(s)?
199 if(logger.isDebugEnabled()){
200 logger.debug("createWithEmptyEntityBody url=" + url +
201 " status=" + statusCode);
203 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
204 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
205 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
209 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
210 dependsOnMethods = {"create", "testSubmitRequest"})
211 public void createWithMalformedXml(String testName) throws Exception {
213 if (logger.isDebugEnabled()) {
214 logger.debug(testBanner(testName, CLASS_NAME));
217 setupCreateWithMalformedXml();
219 // Submit the request to the service and store the response.
220 String method = REQUEST_TYPE.httpMethodName();
221 String url = getServiceRootURL();
222 String mediaType = MediaType.APPLICATION_XML;
223 final String entity = MALFORMED_XML_DATA; // Constant from base class.
224 int statusCode = submitRequest(method, url, mediaType, entity);
226 // Check the status code of the response: does it match
227 // the expected response(s)?
228 if(logger.isDebugEnabled()){
229 logger.debug(testName + ": url=" + url +
230 " status=" + statusCode);
232 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
233 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
234 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
238 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
239 dependsOnMethods = {"create", "testSubmitRequest"})
240 public void createWithWrongXmlSchema(String testName) throws Exception {
242 if (logger.isDebugEnabled()) {
243 logger.debug(testBanner(testName, CLASS_NAME));
246 setupCreateWithWrongXmlSchema(testName, logger);
248 // Submit the request to the service and store the response.
249 String method = REQUEST_TYPE.httpMethodName();
250 String url = getServiceRootURL();
251 String mediaType = MediaType.APPLICATION_XML;
252 final String entity = WRONG_XML_SCHEMA_DATA;
253 int statusCode = submitRequest(method, url, mediaType, entity);
255 // Check the status code of the response: does it match
256 // the expected response(s)?
257 if(logger.isDebugEnabled()){
258 logger.debug(testName + ": url=" + url +
259 " status=" + statusCode);
261 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
262 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
263 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
267 // ---------------------------------------------------------------
268 // CRUD tests : READ tests
269 // ---------------------------------------------------------------
272 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
275 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
276 dependsOnMethods = {"create"})
277 public void read(String testName) throws Exception {
279 if (logger.isDebugEnabled()) {
280 logger.debug(testBanner(testName, CLASS_NAME));
285 // Submit the request to the service and store the response.
286 IntakeClient client = new IntakeClient();
287 ClientResponse<MultipartInput> res = client.read(knownResourceId);
288 int statusCode = res.getStatus();
290 // Check the status code of the response: does it match
291 // the expected response(s)?
292 if(logger.isDebugEnabled()){
293 logger.debug(testName + ": status = " + statusCode);
295 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
296 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
297 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
299 MultipartInput input = (MultipartInput) res.getEntity();
300 IntakesCommon intake = (IntakesCommon) extractPart(input,
301 client.getCommonPartName(), IntakesCommon.class);
302 Assert.assertNotNull(intake);
304 // Verify the number and contents of values in repeatable fields,
305 // as created in the instance record used for testing.
306 List<String> entryMethods =
307 intake.getEntryMethods().getEntryMethod();
308 Assert.assertTrue(entryMethods.size() > 0);
309 Assert.assertNotNull(entryMethods.get(0));
314 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
317 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
318 dependsOnMethods = {"read"})
319 public void readNonExistent(String testName) throws Exception {
321 if (logger.isDebugEnabled()) {
322 logger.debug(testBanner(testName, CLASS_NAME));
325 setupReadNonExistent();
327 // Submit the request to the service and store the response.
328 IntakeClient client = new IntakeClient();
329 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
330 int statusCode = res.getStatus();
332 // Check the status code of the response: does it match
333 // the expected response(s)?
334 if(logger.isDebugEnabled()){
335 logger.debug(testName + ": status = " + statusCode);
337 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
338 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
339 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
342 // ---------------------------------------------------------------
343 // CRUD tests : READ_LIST tests
344 // ---------------------------------------------------------------
347 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
350 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
351 dependsOnMethods = {"createList", "read"})
352 public void readList(String testName) throws Exception {
354 if (logger.isDebugEnabled()) {
355 logger.debug(testBanner(testName, CLASS_NAME));
360 // Submit the request to the service and store the response.
361 IntakeClient client = new IntakeClient();
362 ClientResponse<IntakesCommonList> res = client.readList();
363 IntakesCommonList list = res.getEntity();
364 int statusCode = res.getStatus();
366 // Check the status code of the response: does it match
367 // the expected response(s)?
368 if(logger.isDebugEnabled()){
369 logger.debug(testName + ": status = " + statusCode);
371 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
372 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
373 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
375 // Optionally output additional data about list members for debugging.
376 boolean iterateThroughList = false;
377 if(iterateThroughList && logger.isDebugEnabled()){
378 List<IntakesCommonList.IntakeListItem> items =
379 list.getIntakeListItem();
381 for(IntakesCommonList.IntakeListItem item : items){
382 logger.debug(testName + ": list-item[" + i + "] csid=" +
384 logger.debug(testName + ": list-item[" + i + "] objectNumber=" +
385 item.getEntryNumber());
386 logger.debug(testName + ": list-item[" + i + "] URI=" +
396 // ---------------------------------------------------------------
397 // CRUD tests : UPDATE tests
398 // ---------------------------------------------------------------
401 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
404 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
405 dependsOnMethods = {"read"})
406 public void update(String testName) throws Exception {
408 if (logger.isDebugEnabled()) {
409 logger.debug(testBanner(testName, CLASS_NAME));
414 // Retrieve the contents of a resource to update.
415 IntakeClient client = new IntakeClient();
416 ClientResponse<MultipartInput> res =
417 client.read(knownResourceId);
418 if(logger.isDebugEnabled()){
419 logger.debug(testName + ": read status = " + res.getStatus());
421 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
423 if(logger.isDebugEnabled()){
424 logger.debug("got object to update with ID: " + knownResourceId);
426 MultipartInput input = (MultipartInput) res.getEntity();
427 IntakesCommon intake = (IntakesCommon) extractPart(input,
428 client.getCommonPartName(), IntakesCommon.class);
429 Assert.assertNotNull(intake);
431 // Update the content of this resource.
432 // Update the content of this resource.
433 intake.setEntryNumber("updated-" + intake.getEntryNumber());
434 intake.setEntryDate("updated-" + intake.getEntryDate());
435 if(logger.isDebugEnabled()){
436 logger.debug("to be updated object");
437 logger.debug(objectAsXmlString(intake, IntakesCommon.class));
439 // Submit the request to the service and store the response.
440 MultipartOutput output = new MultipartOutput();
441 OutputPart commonPart = output.addPart(intake, MediaType.APPLICATION_XML_TYPE);
442 commonPart.getHeaders().add("label", client.getCommonPartName());
444 res = client.update(knownResourceId, output);
445 int statusCode = res.getStatus();
446 // Check the status code of the response: does it match the expected response(s)?
447 if(logger.isDebugEnabled()){
448 logger.debug(testName + ": status = " + statusCode);
450 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
451 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
452 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
455 input = (MultipartInput) res.getEntity();
456 IntakesCommon updatedIntake =
457 (IntakesCommon) extractPart(input,
458 client.getCommonPartName(), IntakesCommon.class);
459 Assert.assertNotNull(updatedIntake);
461 Assert.assertEquals(updatedIntake.getEntryDate(),
462 intake.getEntryDate(),
463 "Data in updated object did not match submitted data.");
468 // Placeholders until the three tests below can be uncommented.
469 // See Issue CSPACE-401.
471 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
474 public void updateWithEmptyEntityBody(String testName) throws Exception {
475 //Should this really be empty?
479 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
482 public void updateWithMalformedXml(String testName) throws Exception {
483 //Should this really be empty?
487 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
490 public void updateWithWrongXmlSchema(String testName) throws Exception {
491 //Should this really be empty?
496 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
497 dependsOnMethods = {"create", "update", "testSubmitRequest"})
498 public void updateWithEmptyEntityBody(String testName) throws Exception {
500 if (logger.isDebugEnabled()) {
501 logger.debug(testBanner(testName, CLASS_NAME));
504 setupUpdateWithEmptyEntityBody();
506 // Submit the request to the service and store the response.
507 String method = REQUEST_TYPE.httpMethodName();
508 String url = getResourceURL(knownResourceId);
509 String mediaType = MediaType.APPLICATION_XML;
510 final String entity = "";
511 int statusCode = submitRequest(method, url, mediaType, entity);
513 // Check the status code of the response: does it match
514 // the expected response(s)?
515 if(logger.isDebugEnabled()){
516 logger.debug(testName + ": url=" + url +
517 " status=" + statusCode);
519 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
520 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
521 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
525 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
526 dependsOnMethods = {"create", "update", "testSubmitRequest"})
527 public void updateWithMalformedXml(String testName) throws Exception {
529 if (logger.isDebugEnabled()) {
530 logger.debug(testBanner(testName, CLASS_NAME));
533 setupUpdateWithMalformedXml();
535 // Submit the request to the service and store the response.
536 String method = REQUEST_TYPE.httpMethodName();
537 String url = getResourceURL(knownResourceId);
538 String mediaType = MediaType.APPLICATION_XML;
539 final String entity = MALFORMED_XML_DATA;
540 int statusCode = submitRequest(method, url, mediaType, entity);
542 // Check the status code of the response: does it match
543 // the expected response(s)?
544 if(logger.isDebugEnabled()){
545 logger.debug(testName + ": url=" + url +
546 " status=" + statusCode);
548 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
549 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
550 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
554 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
555 dependsOnMethods = {"create", "update", "testSubmitRequest"})
556 public void updateWithWrongXmlSchema(String testName) throws Exception {
558 if (logger.isDebugEnabled()) {
559 logger.debug(testBanner(testName, CLASS_NAME));
562 setupUpdateWithWrongXmlSchema();
564 // Submit the request to the service and store the response.
565 String method = REQUEST_TYPE.httpMethodName();
566 String url = getResourceURL(knownResourceId);
567 String mediaType = MediaType.APPLICATION_XML;
568 final String entity = WRONG_XML_SCHEMA_DATA;
569 int statusCode = submitRequest(method, url, mediaType, entity);
571 // Check the status code of the response: does it match
572 // the expected response(s)?
573 if(logger.isDebugEnabled()){
574 logger.debug(testName + ": url=" + url +
575 " status=" + statusCode);
577 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
578 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
579 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
584 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
587 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
588 dependsOnMethods = {"update", "testSubmitRequest"})
589 public void updateNonExistent(String testName) throws Exception {
591 if (logger.isDebugEnabled()) {
592 logger.debug(testBanner(testName, CLASS_NAME));
595 setupUpdateNonExistent();
597 // Submit the request to the service and store the response.
598 // Note: The ID used in this 'create' call may be arbitrary.
599 // The only relevant ID may be the one used in update(), below.
600 IntakeClient client = new IntakeClient();
601 MultipartOutput multipart = createIntakeInstance(NON_EXISTENT_ID);
602 ClientResponse<MultipartInput> res =
603 client.update(NON_EXISTENT_ID, multipart);
604 int statusCode = res.getStatus();
606 // Check the status code of the response: does it match
607 // the expected response(s)?
608 if(logger.isDebugEnabled()){
609 logger.debug(testName + ": status = " + statusCode);
611 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
612 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
613 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
616 // ---------------------------------------------------------------
617 // CRUD tests : DELETE tests
618 // ---------------------------------------------------------------
621 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
624 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
625 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
626 public void delete(String testName) throws Exception {
628 if (logger.isDebugEnabled()) {
629 logger.debug(testBanner(testName, CLASS_NAME));
634 // Submit the request to the service and store the response.
635 IntakeClient client = new IntakeClient();
636 ClientResponse<Response> res = client.delete(knownResourceId);
637 int statusCode = res.getStatus();
639 // Check the status code of the response: does it match
640 // the expected response(s)?
641 if(logger.isDebugEnabled()){
642 logger.debug(testName + ": status = " + statusCode);
644 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
645 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
646 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
651 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
654 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
655 dependsOnMethods = {"delete"})
656 public void deleteNonExistent(String testName) throws Exception {
658 if (logger.isDebugEnabled()) {
659 logger.debug(testBanner(testName, CLASS_NAME));
662 setupDeleteNonExistent();
664 // Submit the request to the service and store the response.
665 IntakeClient client = new IntakeClient();
666 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
667 int statusCode = res.getStatus();
669 // Check the status code of the response: does it match
670 // the expected response(s)?
671 if(logger.isDebugEnabled()){
672 logger.debug(testName + ": status = " + statusCode);
674 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
675 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
676 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
679 // ---------------------------------------------------------------
680 // Utility tests : tests of code used in tests above
681 // ---------------------------------------------------------------
683 * Tests the code for manually submitting data that is used by several
684 * of the methods above.
686 @Test(dependsOnMethods = {"create", "read"})
687 public void testSubmitRequest() {
689 // Expected status code: 200 OK
690 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
692 // Submit the request to the service and store the response.
693 String method = ServiceRequestType.READ.httpMethodName();
694 String url = getResourceURL(knownResourceId);
695 int statusCode = submitRequest(method, url);
697 // Check the status code of the response: does it match
698 // the expected response(s)?
699 if(logger.isDebugEnabled()){
700 logger.debug("testSubmitRequest: url=" + url +
701 " status=" + statusCode);
703 Assert.assertEquals(statusCode, EXPECTED_STATUS);
707 // ---------------------------------------------------------------
708 // Utility methods used by tests above
709 // ---------------------------------------------------------------
711 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
714 public String getServicePathComponent() {
715 return SERVICE_PATH_COMPONENT;
719 * Creates the intake instance.
721 * @param identifier the identifier
722 * @return the multipart output
724 private MultipartOutput createIntakeInstance(String identifier) {
725 return createIntakeInstance(
726 "entryNumber-" + identifier,
727 "entryDate-" + identifier,
728 "depositor-" + identifier);
732 * Creates the intake instance.
734 * @param entryNumber the entry number
735 * @param entryDate the entry date
736 * @param depositor the depositor
737 * @return the multipart output
739 private MultipartOutput createIntakeInstance(String entryNumber,
742 IntakesCommon intake = new IntakesCommon();
743 intake.setEntryNumber(entryNumber);
744 intake.setEntryDate(entryDate);
745 intake.setDepositor(depositor);
747 EntryMethodList entryMethodsList = new EntryMethodList();
748 List<String> entryMethods = entryMethodsList.getEntryMethod();
749 entryMethods.add("Left at doorstep");
750 entryMethods.add("Received via post");
751 intake.setEntryMethods(entryMethodsList);
753 MultipartOutput multipart = new MultipartOutput();
754 OutputPart commonPart =
755 multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
756 commonPart.getHeaders().add("label", new IntakeClient().getCommonPartName());
758 if(logger.isDebugEnabled()){
759 logger.debug("to be created, intake common");
760 logger.debug(objectAsXmlString(intake, IntakesCommon.class));