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.ArrayList;
26 import java.util.List;
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
30 import org.collectionspace.services.client.CollectionSpaceClient;
31 import org.collectionspace.services.client.LoaninClient;
32 import org.collectionspace.services.jaxb.AbstractCommonList;
33 import org.collectionspace.services.loanin.LoansinCommon;
34 import org.collectionspace.services.loanin.LoansinCommonList;
35 import org.collectionspace.services.loanin.LenderList;
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 * LoaninServiceTest, carries out tests against a
50 * deployed and running Loanin (aka Loans In) Service.
52 * $LastChangedRevision$
55 public class LoaninServiceTest extends AbstractServiceTestImpl {
58 private final String CLASS_NAME = LoaninServiceTest.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 = "loansin";
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 LoaninClient();
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(LoansinCommonList.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 LoaninClient client = new LoaninClient();
106 String identifier = createIdentifier();
107 MultipartOutput multipart = createLoaninInstance(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 newID = extractId(res);
128 res.releaseConnection();
131 // Store the ID returned from the first resource created
132 // for additional tests below.
133 if (knownResourceId == null){
134 knownResourceId = newID;
135 if (logger.isDebugEnabled()) {
136 logger.debug(testName + ": knownResourceId=" + knownResourceId);
140 // Store the IDs from every resource created by tests,
141 // so they can be deleted after tests have been run.
142 allResourceIdsCreated.add(newID);
146 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
149 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
150 dependsOnMethods = {"create"})
151 public void createList(String testName) throws Exception {
152 for(int i = 0; i < 3; i++){
158 // Placeholders until the three tests below can be uncommented.
159 // See Issue CSPACE-401.
161 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
164 public void createWithEmptyEntityBody(String testName) throws Exception {
165 //Should this really be empty?
169 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
172 public void createWithMalformedXml(String testName) throws Exception {
173 //Should this really be empty?
177 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
180 public void createWithWrongXmlSchema(String testName) throws Exception {
181 //Should this really be empty?
186 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
187 dependsOnMethods = {"create", "testSubmitRequest"})
188 public void createWithEmptyEntityBody(String testName) throws Exception {
190 if (logger.isDebugEnabled()) {
191 logger.debug(testBanner(testName, CLASS_NAME));
194 setupCreateWithEmptyEntityBody();
196 // Submit the request to the service and store the response.
197 String method = REQUEST_TYPE.httpMethodName();
198 String url = getServiceRootURL();
199 String mediaType = MediaType.APPLICATION_XML;
200 final String entity = "";
201 int statusCode = submitRequest(method, url, mediaType, entity);
203 // Check the status code of the response: does it match
204 // the expected response(s)?
205 if(logger.isDebugEnabled()){
206 logger.debug("createWithEmptyEntityBody url=" + url +
207 " status=" + statusCode);
209 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
210 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
211 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
215 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
216 dependsOnMethods = {"create", "testSubmitRequest"})
217 public void createWithMalformedXml(String testName) throws Exception {
219 if (logger.isDebugEnabled()) {
220 logger.debug(testBanner(testName, CLASS_NAME));
223 setupCreateWithMalformedXml(testName, logger);
225 // Submit the request to the service and store the response.
226 String method = REQUEST_TYPE.httpMethodName();
227 String url = getServiceRootURL();
228 String mediaType = MediaType.APPLICATION_XML;
229 final String entity = MALFORMED_XML_DATA; // Constant from base class.
230 int statusCode = submitRequest(method, url, mediaType, entity);
232 // Check the status code of the response: does it match
233 // the expected response(s)?
234 if(logger.isDebugEnabled()){
235 logger.debug(testName + ": url=" + url +
236 " status=" + statusCode);
238 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
239 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
240 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
244 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
245 dependsOnMethods = {"create", "testSubmitRequest"})
246 public void createWithWrongXmlSchema(String testName) throws Exception {
248 if (logger.isDebugEnabled()) {
249 logger.debug(testBanner(testName, CLASS_NAME));
252 setupCreateWithWrongXmlSchema(testName, logger);
254 // Submit the request to the service and store the response.
255 String method = REQUEST_TYPE.httpMethodName();
256 String url = getServiceRootURL();
257 String mediaType = MediaType.APPLICATION_XML;
258 final String entity = WRONG_XML_SCHEMA_DATA;
259 int statusCode = submitRequest(method, url, mediaType, entity);
261 // Check the status code of the response: does it match
262 // the expected response(s)?
263 if(logger.isDebugEnabled()){
264 logger.debug(testName + ": url=" + url +
265 " status=" + statusCode);
267 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
268 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
269 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
273 // ---------------------------------------------------------------
274 // CRUD tests : READ tests
275 // ---------------------------------------------------------------
278 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
281 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
282 dependsOnMethods = {"create"})
283 public void read(String testName) throws Exception {
285 if (logger.isDebugEnabled()) {
286 logger.debug(testBanner(testName, CLASS_NAME));
291 // Submit the request to the service and store the response.
292 MultipartInput input = null;
293 LoaninClient client = new LoaninClient();
294 ClientResponse<MultipartInput> res = client.read(knownResourceId);
296 int statusCode = res.getStatus();
298 // Check the status code of the response: does it match
299 // the expected response(s)?
300 if(logger.isDebugEnabled()){
301 logger.debug(testName + ": status = " + statusCode);
303 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
304 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
305 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
307 input = res.getEntity();
309 res.releaseConnection();
312 LoansinCommon loanin = (LoansinCommon) extractPart(input,
313 client.getCommonPartName(), LoansinCommon.class);
314 Assert.assertNotNull(loanin);
319 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
322 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
323 dependsOnMethods = {"read"})
324 public void readNonExistent(String testName) throws Exception {
326 if (logger.isDebugEnabled()) {
327 logger.debug(testBanner(testName, CLASS_NAME));
330 setupReadNonExistent();
332 // Submit the request to the service and store the response.
333 LoaninClient client = new LoaninClient();
334 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);
347 res.releaseConnection();
351 // ---------------------------------------------------------------
352 // CRUD tests : READ_LIST tests
353 // ---------------------------------------------------------------
356 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
359 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
360 dependsOnMethods = {"createList", "read"})
361 public void readList(String testName) throws Exception {
363 if (logger.isDebugEnabled()) {
364 logger.debug(testBanner(testName, CLASS_NAME));
369 // Submit the request to the service and store the response.
370 LoansinCommonList list = null;
371 LoaninClient client = new LoaninClient();
372 ClientResponse<LoansinCommonList> res = client.readList();
374 int statusCode = res.getStatus();
376 // Check the status code of the response: does it match
377 // the expected response(s)?
378 if(logger.isDebugEnabled()){
379 logger.debug(testName + ": status = " + statusCode);
381 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
382 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
383 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
385 list = res.getEntity();
387 res.releaseConnection();
390 // Optionally output additional data about list members for debugging.
391 boolean iterateThroughList = false;
392 if (iterateThroughList && logger.isDebugEnabled()){
393 List<LoansinCommonList.LoaninListItem> items =
394 list.getLoaninListItem();
396 for(LoansinCommonList.LoaninListItem item : items){
397 logger.debug(testName + ": list-item[" + i + "] csid=" +
399 logger.debug(testName + ": list-item[" + i + "] loanInNumber=" +
400 item.getLoanInNumber());
401 logger.debug(testName + ": list-item[" + i + "] URI=" +
410 // ---------------------------------------------------------------
411 // CRUD tests : UPDATE tests
412 // ---------------------------------------------------------------
415 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
418 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
419 dependsOnMethods = {"read"})
420 public void update(String testName) throws Exception {
422 if (logger.isDebugEnabled()) {
423 logger.debug(testBanner(testName, CLASS_NAME));
428 // Retrieve the contents of a resource to update.
429 MultipartInput input = null;
430 LoaninClient client = new LoaninClient();
431 ClientResponse<MultipartInput> res =
432 client.read(knownResourceId);
434 if(logger.isDebugEnabled()){
435 logger.debug(testName + ": read status = " + res.getStatus());
437 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
439 if(logger.isDebugEnabled()){
440 logger.debug("got object to update with ID: " + knownResourceId);
442 input = res.getEntity();
444 res.releaseConnection();
447 LoansinCommon loanin = (LoansinCommon) extractPart(input,
448 client.getCommonPartName(), LoansinCommon.class);
449 Assert.assertNotNull(loanin);
451 // Update the content of this resource.
452 loanin.setLoanInNumber("updated-" + loanin.getLoanInNumber());
453 loanin.setLoanReturnDate("updated-" + loanin.getLoanReturnDate());
454 if(logger.isDebugEnabled()){
455 logger.debug("to be updated object");
456 logger.debug(objectAsXmlString(loanin, LoansinCommon.class));
458 // Submit the request to the service and store the response.
459 MultipartOutput output = new MultipartOutput();
460 OutputPart commonPart = output.addPart(loanin, MediaType.APPLICATION_XML_TYPE);
461 commonPart.getHeaders().add("label", client.getCommonPartName());
463 res = client.update(knownResourceId, output);
465 int statusCode = res.getStatus();
466 // Check the status code of the response: does it match the expected response(s)?
467 if(logger.isDebugEnabled()){
468 logger.debug(testName + ": status = " + statusCode);
470 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
471 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
472 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
475 input = (MultipartInput) res.getEntity();
477 res.releaseConnection();
480 LoansinCommon updatedLoanin =
481 (LoansinCommon) extractPart(input,
482 client.getCommonPartName(), LoansinCommon.class);
483 Assert.assertNotNull(updatedLoanin);
485 Assert.assertEquals(updatedLoanin.getLoanReturnDate(),
486 loanin.getLoanReturnDate(),
487 "Data in updated object did not match submitted data.");
491 // Placeholders until the three tests below can be uncommented.
492 // See Issue CSPACE-401.
494 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
497 public void updateWithEmptyEntityBody(String testName) throws Exception {
498 //Should this really be empty?
502 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
505 public void updateWithMalformedXml(String testName) throws Exception {
506 //Should this really be empty?
510 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
513 public void updateWithWrongXmlSchema(String testName) throws Exception {
514 //Should this really be empty?
519 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
520 dependsOnMethods = {"create", "update", "testSubmitRequest"})
521 public void updateWithEmptyEntityBody(String testName) throws Exception {
523 if (logger.isDebugEnabled()) {
524 logger.debug(testBanner(testName, CLASS_NAME));
527 setupUpdateWithEmptyEntityBody();
529 // Submit the request to the service and store the response.
530 String method = REQUEST_TYPE.httpMethodName();
531 String url = getResourceURL(knownResourceId);
532 String mediaType = MediaType.APPLICATION_XML;
533 final String entity = "";
534 int statusCode = submitRequest(method, url, mediaType, entity);
536 // Check the status code of the response: does it match
537 // the expected response(s)?
538 if(logger.isDebugEnabled()){
539 logger.debug(testName + ": url=" + url +
540 " status=" + statusCode);
542 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
543 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
544 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
548 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
549 dependsOnMethods = {"create", "update", "testSubmitRequest"})
550 public void updateWithMalformedXml(String testName) throws Exception {
552 if (logger.isDebugEnabled()) {
553 logger.debug(testBanner(testName, CLASS_NAME));
556 setupUpdateWithMalformedXml();
558 // Submit the request to the service and store the response.
559 String method = REQUEST_TYPE.httpMethodName();
560 String url = getResourceURL(knownResourceId);
561 String mediaType = MediaType.APPLICATION_XML;
562 final String entity = MALFORMED_XML_DATA;
563 int statusCode = submitRequest(method, url, mediaType, entity);
565 // Check the status code of the response: does it match
566 // the expected response(s)?
567 if(logger.isDebugEnabled()){
568 logger.debug(testName + ": url=" + url +
569 " status=" + statusCode);
571 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
572 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
573 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
577 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
578 dependsOnMethods = {"create", "update", "testSubmitRequest"})
579 public void updateWithWrongXmlSchema(String testName) throws Exception {
581 if (logger.isDebugEnabled()) {
582 logger.debug(testBanner(testName, CLASS_NAME));
585 setupUpdateWithWrongXmlSchema();
587 // Submit the request to the service and store the response.
588 String method = REQUEST_TYPE.httpMethodName();
589 String url = getResourceURL(knownResourceId);
590 String mediaType = MediaType.APPLICATION_XML;
591 final String entity = WRONG_XML_SCHEMA_DATA;
592 int statusCode = submitRequest(method, url, mediaType, entity);
594 // Check the status code of the response: does it match
595 // the expected response(s)?
596 if(logger.isDebugEnabled()){
597 logger.debug(testName + ": url=" + url +
598 " status=" + statusCode);
600 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
601 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
602 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
607 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
610 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
611 dependsOnMethods = {"update", "testSubmitRequest"})
612 public void updateNonExistent(String testName) throws Exception {
614 if (logger.isDebugEnabled()) {
615 logger.debug(testBanner(testName, CLASS_NAME));
618 setupUpdateNonExistent();
620 // Submit the request to the service and store the response.
621 // Note: The ID used in this 'create' call may be arbitrary.
622 // The only relevant ID may be the one used in update(), below.
623 LoaninClient client = new LoaninClient();
624 MultipartOutput multipart = createLoaninInstance(NON_EXISTENT_ID);
625 ClientResponse<MultipartInput> res =
626 client.update(NON_EXISTENT_ID, multipart);
628 int statusCode = res.getStatus();
630 // Check the status code of the response: does it match
631 // the expected response(s)?
632 if(logger.isDebugEnabled()){
633 logger.debug(testName + ": status = " + statusCode);
635 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
636 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
637 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
639 res.releaseConnection();
643 // ---------------------------------------------------------------
644 // CRUD tests : DELETE tests
645 // ---------------------------------------------------------------
648 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
651 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
652 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
653 public void delete(String testName) throws Exception {
655 if (logger.isDebugEnabled()) {
656 logger.debug(testBanner(testName, CLASS_NAME));
661 // Submit the request to the service and store the response.
662 LoaninClient client = new LoaninClient();
663 ClientResponse<Response> res = client.delete(knownResourceId);
665 int statusCode = res.getStatus();
667 // Check the status code of the response: does it match
668 // the expected response(s)?
669 if(logger.isDebugEnabled()){
670 logger.debug(testName + ": status = " + statusCode);
672 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
673 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
674 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
676 res.releaseConnection();
682 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
685 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
686 dependsOnMethods = {"delete"})
687 public void deleteNonExistent(String testName) throws Exception {
689 if (logger.isDebugEnabled()) {
690 logger.debug(testBanner(testName, CLASS_NAME));
693 setupDeleteNonExistent();
695 // Submit the request to the service and store the response.
696 LoaninClient client = new LoaninClient();
697 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
699 int statusCode = res.getStatus();
701 // Check the status code of the response: does it match
702 // the expected response(s)?
703 if(logger.isDebugEnabled()){
704 logger.debug(testName + ": status = " + statusCode);
706 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
707 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
708 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
710 res.releaseConnection();
714 // ---------------------------------------------------------------
715 // Utility tests : tests of code used in tests above
716 // ---------------------------------------------------------------
718 * Tests the code for manually submitting data that is used by several
719 * of the methods above.
721 @Test(dependsOnMethods = {"create", "read"})
722 public void testSubmitRequest() {
724 // Expected status code: 200 OK
725 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
727 // Submit the request to the service and store the response.
728 String method = ServiceRequestType.READ.httpMethodName();
729 String url = getResourceURL(knownResourceId);
730 int statusCode = submitRequest(method, url);
732 // Check the status code of the response: does it match
733 // the expected response(s)?
734 if(logger.isDebugEnabled()){
735 logger.debug("testSubmitRequest: url=" + url +
736 " status=" + statusCode);
738 Assert.assertEquals(statusCode, EXPECTED_STATUS);
742 // ---------------------------------------------------------------
743 // Utility methods used by tests above
744 // ---------------------------------------------------------------
746 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
749 public String getServicePathComponent() {
750 return SERVICE_PATH_COMPONENT;
754 * Creates the loanin instance.
756 * @param identifier the identifier
757 * @return the multipart output
759 private MultipartOutput createLoaninInstance(String identifier) {
760 return createLoaninInstance(
761 "loaninNumber-" + identifier,
762 "returnDate-" + identifier);
766 * Creates the loanin instance.
768 * @param loaninNumber the loanin number
769 * @param returnDate the return date
770 * @return the multipart output
772 private MultipartOutput createLoaninInstance(String loaninNumber,
774 LoansinCommon loanin = new LoansinCommon();
775 loanin.setLoanInNumber(loaninNumber);
776 loanin.setLoanReturnDate(returnDate);
777 LenderList lenderList = new LenderList();
778 lenderList.getLender().add(
779 "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Harry Lender)'Harry Lender'");
780 lenderList.getLender().add(
781 "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Sally Lender)'Sally Lender'");
782 loanin.setLenders(lenderList);
783 loanin.setLoanPurpose("For Surfboards of the 1960s exhibition.");
784 MultipartOutput multipart = new MultipartOutput();
785 OutputPart commonPart =
786 multipart.addPart(loanin, MediaType.APPLICATION_XML_TYPE);
787 commonPart.getHeaders().add("label", new LoaninClient().getCommonPartName());
789 if(logger.isDebugEnabled()){
790 logger.debug("to be created, loanin common");
791 logger.debug(objectAsXmlString(loanin, LoansinCommon.class));