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;
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 * LoaninServiceTest, carries out tests against a
49 * deployed and running Loanin (aka Loans In) Service.
51 * $LastChangedRevision$
54 public class LoaninServiceTest extends AbstractServiceTestImpl {
57 private final String CLASS_NAME = LoaninServiceTest.class.getName();
58 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
60 // Instance variables specific to this test.
61 /** The service path component. */
62 final String SERVICE_PATH_COMPONENT = "loansin";
64 /** The known resource id. */
65 private String knownResourceId = null;
68 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
71 protected CollectionSpaceClient getClientInstance() {
72 return new LoaninClient();
76 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
79 protected AbstractCommonList getAbstractCommonList(
80 ClientResponse<AbstractCommonList> response) {
81 return response.getEntity(LoansinCommonList.class);
84 // ---------------------------------------------------------------
85 // CRUD tests : CREATE tests
86 // ---------------------------------------------------------------
89 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
92 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
93 public void create(String testName) throws Exception {
95 if (logger.isDebugEnabled()) {
96 logger.debug(testBanner(testName, CLASS_NAME));
98 // Perform setup, such as initializing the type of service request
99 // (e.g. CREATE, DELETE), its valid and expected status codes, and
100 // its associated HTTP method name (e.g. POST, DELETE).
103 // Submit the request to the service and store the response.
104 LoaninClient client = new LoaninClient();
105 String identifier = createIdentifier();
106 MultipartOutput multipart = createLoaninInstance(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 newID = extractId(res);
127 res.releaseConnection();
130 // Store the ID returned from the first resource created
131 // for additional tests below.
132 if (knownResourceId == null){
133 knownResourceId = newID;
134 if (logger.isDebugEnabled()) {
135 logger.debug(testName + ": knownResourceId=" + knownResourceId);
139 // Store the IDs from every resource created by tests,
140 // so they can be deleted after tests have been run.
141 allResourceIdsCreated.add(newID);
145 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
148 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
149 dependsOnMethods = {"create"})
150 public void createList(String testName) throws Exception {
151 for(int i = 0; i < 3; i++){
157 // Placeholders until the three tests below can be uncommented.
158 // See Issue CSPACE-401.
160 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
163 public void createWithEmptyEntityBody(String testName) throws Exception {
164 //Should this really be empty?
168 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
171 public void createWithMalformedXml(String testName) throws Exception {
172 //Should this really be empty?
176 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
179 public void createWithWrongXmlSchema(String testName) throws Exception {
180 //Should this really be empty?
185 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
186 dependsOnMethods = {"create", "testSubmitRequest"})
187 public void createWithEmptyEntityBody(String testName) throws Exception {
189 if (logger.isDebugEnabled()) {
190 logger.debug(testBanner(testName, CLASS_NAME));
193 setupCreateWithEmptyEntityBody();
195 // Submit the request to the service and store the response.
196 String method = REQUEST_TYPE.httpMethodName();
197 String url = getServiceRootURL();
198 String mediaType = MediaType.APPLICATION_XML;
199 final String entity = "";
200 int statusCode = submitRequest(method, url, mediaType, entity);
202 // Check the status code of the response: does it match
203 // the expected response(s)?
204 if(logger.isDebugEnabled()){
205 logger.debug("createWithEmptyEntityBody url=" + url +
206 " status=" + statusCode);
208 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
209 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
210 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
214 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
215 dependsOnMethods = {"create", "testSubmitRequest"})
216 public void createWithMalformedXml(String testName) throws Exception {
218 if (logger.isDebugEnabled()) {
219 logger.debug(testBanner(testName, CLASS_NAME));
222 setupCreateWithMalformedXml(testName, logger);
224 // Submit the request to the service and store the response.
225 String method = REQUEST_TYPE.httpMethodName();
226 String url = getServiceRootURL();
227 String mediaType = MediaType.APPLICATION_XML;
228 final String entity = MALFORMED_XML_DATA; // Constant from base class.
229 int statusCode = submitRequest(method, url, mediaType, entity);
231 // Check the status code of the response: does it match
232 // the expected response(s)?
233 if(logger.isDebugEnabled()){
234 logger.debug(testName + ": url=" + url +
235 " status=" + statusCode);
237 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
238 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
239 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
243 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
244 dependsOnMethods = {"create", "testSubmitRequest"})
245 public void createWithWrongXmlSchema(String testName) throws Exception {
247 if (logger.isDebugEnabled()) {
248 logger.debug(testBanner(testName, CLASS_NAME));
251 setupCreateWithWrongXmlSchema(testName, logger);
253 // Submit the request to the service and store the response.
254 String method = REQUEST_TYPE.httpMethodName();
255 String url = getServiceRootURL();
256 String mediaType = MediaType.APPLICATION_XML;
257 final String entity = WRONG_XML_SCHEMA_DATA;
258 int statusCode = submitRequest(method, url, mediaType, entity);
260 // Check the status code of the response: does it match
261 // the expected response(s)?
262 if(logger.isDebugEnabled()){
263 logger.debug(testName + ": url=" + url +
264 " status=" + statusCode);
266 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
267 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
268 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
272 // ---------------------------------------------------------------
273 // CRUD tests : READ tests
274 // ---------------------------------------------------------------
277 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
280 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
281 dependsOnMethods = {"create"})
282 public void read(String testName) throws Exception {
284 if (logger.isDebugEnabled()) {
285 logger.debug(testBanner(testName, CLASS_NAME));
290 // Submit the request to the service and store the response.
291 MultipartInput input = null;
292 LoaninClient client = new LoaninClient();
293 ClientResponse<MultipartInput> res = client.read(knownResourceId);
295 int statusCode = res.getStatus();
297 // Check the status code of the response: does it match
298 // the expected response(s)?
299 if(logger.isDebugEnabled()){
300 logger.debug(testName + ": status = " + statusCode);
302 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
303 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
304 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
306 input = res.getEntity();
308 res.releaseConnection();
311 LoansinCommon loanin = (LoansinCommon) extractPart(input,
312 client.getCommonPartName(), LoansinCommon.class);
313 Assert.assertNotNull(loanin);
318 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
321 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
322 dependsOnMethods = {"read"})
323 public void readNonExistent(String testName) throws Exception {
325 if (logger.isDebugEnabled()) {
326 logger.debug(testBanner(testName, CLASS_NAME));
329 setupReadNonExistent();
331 // Submit the request to the service and store the response.
332 LoaninClient client = new LoaninClient();
333 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
335 int statusCode = res.getStatus();
337 // Check the status code of the response: does it match
338 // the expected response(s)?
339 if(logger.isDebugEnabled()){
340 logger.debug(testName + ": status = " + statusCode);
342 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
343 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
344 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
346 res.releaseConnection();
350 // ---------------------------------------------------------------
351 // CRUD tests : READ_LIST tests
352 // ---------------------------------------------------------------
355 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
358 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
359 dependsOnMethods = {"createList", "read"})
360 public void readList(String testName) throws Exception {
362 if (logger.isDebugEnabled()) {
363 logger.debug(testBanner(testName, CLASS_NAME));
368 // Submit the request to the service and store the response.
369 LoansinCommonList list = null;
370 LoaninClient client = new LoaninClient();
371 ClientResponse<LoansinCommonList> res = client.readList();
373 int statusCode = res.getStatus();
375 // Check the status code of the response: does it match
376 // the expected response(s)?
377 if(logger.isDebugEnabled()){
378 logger.debug(testName + ": status = " + statusCode);
380 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
381 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
382 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
384 list = res.getEntity();
386 res.releaseConnection();
389 // Optionally output additional data about list members for debugging.
390 boolean iterateThroughList = false;
391 if (iterateThroughList && logger.isDebugEnabled()){
392 List<LoansinCommonList.LoaninListItem> items =
393 list.getLoaninListItem();
395 for(LoansinCommonList.LoaninListItem item : items){
396 logger.debug(testName + ": list-item[" + i + "] csid=" +
398 logger.debug(testName + ": list-item[" + i + "] loanInNumber=" +
399 item.getLoanInNumber());
400 logger.debug(testName + ": list-item[" + i + "] URI=" +
409 // ---------------------------------------------------------------
410 // CRUD tests : UPDATE tests
411 // ---------------------------------------------------------------
414 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
417 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
418 dependsOnMethods = {"read"})
419 public void update(String testName) throws Exception {
421 if (logger.isDebugEnabled()) {
422 logger.debug(testBanner(testName, CLASS_NAME));
427 // Retrieve the contents of a resource to update.
428 MultipartInput input = null;
429 LoaninClient client = new LoaninClient();
430 ClientResponse<MultipartInput> res =
431 client.read(knownResourceId);
433 if(logger.isDebugEnabled()){
434 logger.debug(testName + ": read status = " + res.getStatus());
436 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
438 if(logger.isDebugEnabled()){
439 logger.debug("got object to update with ID: " + knownResourceId);
441 input = res.getEntity();
443 res.releaseConnection();
446 LoansinCommon loanin = (LoansinCommon) extractPart(input,
447 client.getCommonPartName(), LoansinCommon.class);
448 Assert.assertNotNull(loanin);
450 // Update the content of this resource.
451 loanin.setLoanInNumber("updated-" + loanin.getLoanInNumber());
452 loanin.setLoanReturnDate("updated-" + loanin.getLoanReturnDate());
453 if(logger.isDebugEnabled()){
454 logger.debug("to be updated object");
455 logger.debug(objectAsXmlString(loanin, LoansinCommon.class));
457 // Submit the request to the service and store the response.
458 MultipartOutput output = new MultipartOutput();
459 OutputPart commonPart = output.addPart(loanin, MediaType.APPLICATION_XML_TYPE);
460 commonPart.getHeaders().add("label", client.getCommonPartName());
462 res = client.update(knownResourceId, output);
464 int statusCode = res.getStatus();
465 // Check the status code of the response: does it match the expected response(s)?
466 if(logger.isDebugEnabled()){
467 logger.debug(testName + ": status = " + statusCode);
469 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
470 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
471 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
474 input = (MultipartInput) res.getEntity();
476 res.releaseConnection();
479 LoansinCommon updatedLoanin =
480 (LoansinCommon) extractPart(input,
481 client.getCommonPartName(), LoansinCommon.class);
482 Assert.assertNotNull(updatedLoanin);
484 Assert.assertEquals(updatedLoanin.getLoanReturnDate(),
485 loanin.getLoanReturnDate(),
486 "Data in updated object did not match submitted data.");
490 // Placeholders until the three tests below can be uncommented.
491 // See Issue CSPACE-401.
493 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
496 public void updateWithEmptyEntityBody(String testName) throws Exception {
497 //Should this really be empty?
501 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
504 public void updateWithMalformedXml(String testName) throws Exception {
505 //Should this really be empty?
509 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
512 public void updateWithWrongXmlSchema(String testName) throws Exception {
513 //Should this really be empty?
518 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
519 dependsOnMethods = {"create", "update", "testSubmitRequest"})
520 public void updateWithEmptyEntityBody(String testName) throws Exception {
522 if (logger.isDebugEnabled()) {
523 logger.debug(testBanner(testName, CLASS_NAME));
526 setupUpdateWithEmptyEntityBody();
528 // Submit the request to the service and store the response.
529 String method = REQUEST_TYPE.httpMethodName();
530 String url = getResourceURL(knownResourceId);
531 String mediaType = MediaType.APPLICATION_XML;
532 final String entity = "";
533 int statusCode = submitRequest(method, url, mediaType, entity);
535 // Check the status code of the response: does it match
536 // the expected response(s)?
537 if(logger.isDebugEnabled()){
538 logger.debug(testName + ": url=" + url +
539 " status=" + statusCode);
541 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
542 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
543 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
547 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
548 dependsOnMethods = {"create", "update", "testSubmitRequest"})
549 public void updateWithMalformedXml(String testName) throws Exception {
551 if (logger.isDebugEnabled()) {
552 logger.debug(testBanner(testName, CLASS_NAME));
555 setupUpdateWithMalformedXml();
557 // Submit the request to the service and store the response.
558 String method = REQUEST_TYPE.httpMethodName();
559 String url = getResourceURL(knownResourceId);
560 String mediaType = MediaType.APPLICATION_XML;
561 final String entity = MALFORMED_XML_DATA;
562 int statusCode = submitRequest(method, url, mediaType, entity);
564 // Check the status code of the response: does it match
565 // the expected response(s)?
566 if(logger.isDebugEnabled()){
567 logger.debug(testName + ": url=" + url +
568 " status=" + statusCode);
570 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
571 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
572 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
576 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
577 dependsOnMethods = {"create", "update", "testSubmitRequest"})
578 public void updateWithWrongXmlSchema(String testName) throws Exception {
580 if (logger.isDebugEnabled()) {
581 logger.debug(testBanner(testName, CLASS_NAME));
584 setupUpdateWithWrongXmlSchema();
586 // Submit the request to the service and store the response.
587 String method = REQUEST_TYPE.httpMethodName();
588 String url = getResourceURL(knownResourceId);
589 String mediaType = MediaType.APPLICATION_XML;
590 final String entity = WRONG_XML_SCHEMA_DATA;
591 int statusCode = submitRequest(method, url, mediaType, entity);
593 // Check the status code of the response: does it match
594 // the expected response(s)?
595 if(logger.isDebugEnabled()){
596 logger.debug(testName + ": url=" + url +
597 " status=" + statusCode);
599 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
600 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
601 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
606 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
609 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
610 dependsOnMethods = {"update", "testSubmitRequest"})
611 public void updateNonExistent(String testName) throws Exception {
613 if (logger.isDebugEnabled()) {
614 logger.debug(testBanner(testName, CLASS_NAME));
617 setupUpdateNonExistent();
619 // Submit the request to the service and store the response.
620 // Note: The ID used in this 'create' call may be arbitrary.
621 // The only relevant ID may be the one used in update(), below.
622 LoaninClient client = new LoaninClient();
623 MultipartOutput multipart = createLoaninInstance(NON_EXISTENT_ID);
624 ClientResponse<MultipartInput> res =
625 client.update(NON_EXISTENT_ID, multipart);
627 int statusCode = res.getStatus();
629 // Check the status code of the response: does it match
630 // the expected response(s)?
631 if(logger.isDebugEnabled()){
632 logger.debug(testName + ": status = " + statusCode);
634 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
635 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
636 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
638 res.releaseConnection();
642 // ---------------------------------------------------------------
643 // CRUD tests : DELETE tests
644 // ---------------------------------------------------------------
647 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
650 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
651 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
652 public void delete(String testName) throws Exception {
654 if (logger.isDebugEnabled()) {
655 logger.debug(testBanner(testName, CLASS_NAME));
660 // Submit the request to the service and store the response.
661 LoaninClient client = new LoaninClient();
662 ClientResponse<Response> res = client.delete(knownResourceId);
664 int statusCode = res.getStatus();
666 // Check the status code of the response: does it match
667 // the expected response(s)?
668 if(logger.isDebugEnabled()){
669 logger.debug(testName + ": status = " + statusCode);
671 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
672 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
673 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
675 res.releaseConnection();
681 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
684 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
685 dependsOnMethods = {"delete"})
686 public void deleteNonExistent(String testName) throws Exception {
688 if (logger.isDebugEnabled()) {
689 logger.debug(testBanner(testName, CLASS_NAME));
692 setupDeleteNonExistent();
694 // Submit the request to the service and store the response.
695 LoaninClient client = new LoaninClient();
696 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
698 int statusCode = res.getStatus();
700 // Check the status code of the response: does it match
701 // the expected response(s)?
702 if(logger.isDebugEnabled()){
703 logger.debug(testName + ": status = " + statusCode);
705 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
706 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
707 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
709 res.releaseConnection();
713 // ---------------------------------------------------------------
714 // Utility tests : tests of code used in tests above
715 // ---------------------------------------------------------------
717 * Tests the code for manually submitting data that is used by several
718 * of the methods above.
720 @Test(dependsOnMethods = {"create", "read"})
721 public void testSubmitRequest() {
723 // Expected status code: 200 OK
724 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
726 // Submit the request to the service and store the response.
727 String method = ServiceRequestType.READ.httpMethodName();
728 String url = getResourceURL(knownResourceId);
729 int statusCode = submitRequest(method, url);
731 // Check the status code of the response: does it match
732 // the expected response(s)?
733 if(logger.isDebugEnabled()){
734 logger.debug("testSubmitRequest: url=" + url +
735 " status=" + statusCode);
737 Assert.assertEquals(statusCode, EXPECTED_STATUS);
741 // ---------------------------------------------------------------
742 // Utility methods used by tests above
743 // ---------------------------------------------------------------
745 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
748 public String getServicePathComponent() {
749 return SERVICE_PATH_COMPONENT;
753 * Creates the loanin instance.
755 * @param identifier the identifier
756 * @return the multipart output
758 private MultipartOutput createLoaninInstance(String identifier) {
759 return createLoaninInstance(
760 "loaninNumber-" + identifier,
761 "returnDate-" + identifier);
765 * Creates the loanin instance.
767 * @param loaninNumber the loanin number
768 * @param returnDate the return date
769 * @return the multipart output
771 private MultipartOutput createLoaninInstance(String loaninNumber,
773 LoansinCommon loanin = new LoansinCommon();
774 loanin.setLoanInNumber(loaninNumber);
775 loanin.setLoanReturnDate(returnDate);
776 loanin.setLender("urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Harry Lender)'Harry Lender'");
777 loanin.setLoanPurpose("For Surfboards of the 1960s exhibition.");
778 MultipartOutput multipart = new MultipartOutput();
779 OutputPart commonPart =
780 multipart.addPart(loanin, MediaType.APPLICATION_XML_TYPE);
781 commonPart.getHeaders().add("label", new LoaninClient().getCommonPartName());
783 if(logger.isDebugEnabled()){
784 logger.debug("to be created, loanin common");
785 logger.debug(objectAsXmlString(loanin, LoansinCommon.class));