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.LoanoutClient;
31 import org.collectionspace.services.jaxb.AbstractCommonList;
32 import org.collectionspace.services.loanout.LoansoutCommon;
33 import org.collectionspace.services.loanout.LoansoutCommonList;
35 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.Test;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
47 * LoanoutServiceTest, carries out tests against a
48 * deployed and running Loanout (aka Loans Out) Service.
50 * $LastChangedRevision$
53 public class LoanoutServiceTest extends AbstractServiceTestImpl {
56 private final String CLASS_NAME = LoanoutServiceTest.class.getName();
57 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
59 // Instance variables specific to this test.
60 /** The service path component. */
61 final String SERVICE_PATH_COMPONENT = "loansout";
63 /** The known resource id. */
64 private String knownResourceId = null;
67 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
70 protected CollectionSpaceClient getClientInstance() {
71 return new LoanoutClient();
75 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
78 protected AbstractCommonList getAbstractCommonList(
79 ClientResponse<AbstractCommonList> response) {
80 return response.getEntity(LoansoutCommonList.class);
83 // ---------------------------------------------------------------
84 // CRUD tests : CREATE tests
85 // ---------------------------------------------------------------
88 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
91 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
92 public void create(String testName) throws Exception {
94 if (logger.isDebugEnabled()) {
95 logger.debug(testBanner(testName, CLASS_NAME));
97 // Perform setup, such as initializing the type of service request
98 // (e.g. CREATE, DELETE), its valid and expected status codes, and
99 // its associated HTTP method name (e.g. POST, DELETE).
102 // Submit the request to the service and store the response.
103 LoanoutClient client = new LoanoutClient();
104 String identifier = createIdentifier();
105 MultipartOutput multipart = createLoanoutInstance(identifier);
106 ClientResponse<Response> res = client.create(multipart);
108 int statusCode = res.getStatus();
110 // Check the status code of the response: does it match
111 // the expected response(s)?
114 // Does it fall within the set of valid status codes?
115 // Does it exactly match the expected status code?
116 if(logger.isDebugEnabled()){
117 logger.debug(testName + ": status = " + statusCode);
119 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
120 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
121 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
123 // Store the ID returned from the first resource created
124 // for additional tests below.
125 if (knownResourceId == null){
126 knownResourceId = extractId(res);
127 if (logger.isDebugEnabled()) {
128 logger.debug(testName + ": knownResourceId=" + knownResourceId);
132 // Store the IDs from every resource created by tests,
133 // so they can be deleted after tests have been run.
134 allResourceIdsCreated.add(extractId(res));
138 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
141 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
142 dependsOnMethods = {"create"})
143 public void createList(String testName) throws Exception {
144 for(int i = 0; i < 3; i++){
150 // Placeholders until the three tests below can be uncommented.
151 // See Issue CSPACE-401.
153 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
156 public void createWithEmptyEntityBody(String testName) throws Exception {
157 //Should this really be empty?
161 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
164 public void createWithMalformedXml(String testName) throws Exception {
165 //Should this really be empty?
169 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
172 public void createWithWrongXmlSchema(String testName) throws Exception {
173 //Should this really be empty?
178 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
179 dependsOnMethods = {"create", "testSubmitRequest"})
180 public void createWithEmptyEntityBody(String testName) throws Exception {
182 if (logger.isDebugEnabled()) {
183 logger.debug(testBanner(testName, CLASS_NAME));
186 setupCreateWithEmptyEntityBody();
188 // Submit the request to the service and store the response.
189 String method = REQUEST_TYPE.httpMethodName();
190 String url = getServiceRootURL();
191 String mediaType = MediaType.APPLICATION_XML;
192 final String entity = "";
193 int statusCode = submitRequest(method, url, mediaType, entity);
195 // Check the status code of the response: does it match
196 // the expected response(s)?
197 if(logger.isDebugEnabled()){
198 logger.debug("createWithEmptyEntityBody url=" + url +
199 " status=" + statusCode);
201 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
202 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
203 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
207 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
208 dependsOnMethods = {"create", "testSubmitRequest"})
209 public void createWithMalformedXml(String testName) throws Exception {
211 if (logger.isDebugEnabled()) {
212 logger.debug(testBanner(testName, CLASS_NAME));
215 setupCreateWithMalformedXml();
217 // Submit the request to the service and store the response.
218 String method = REQUEST_TYPE.httpMethodName();
219 String url = getServiceRootURL();
220 String mediaType = MediaType.APPLICATION_XML;
221 final String entity = MALFORMED_XML_DATA; // Constant from base class.
222 int statusCode = submitRequest(method, url, mediaType, entity);
224 // Check the status code of the response: does it match
225 // the expected response(s)?
226 if(logger.isDebugEnabled()){
227 logger.debug(testName + ": url=" + url +
228 " status=" + statusCode);
230 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
231 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
232 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
236 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
237 dependsOnMethods = {"create", "testSubmitRequest"})
238 public void createWithWrongXmlSchema(String testName) throws Exception {
240 if (logger.isDebugEnabled()) {
241 logger.debug(testBanner(testName, CLASS_NAME));
244 setupCreateWithWrongXmlSchema();
246 // Submit the request to the service and store the response.
247 String method = REQUEST_TYPE.httpMethodName();
248 String url = getServiceRootURL();
249 String mediaType = MediaType.APPLICATION_XML;
250 final String entity = WRONG_XML_SCHEMA_DATA;
251 int statusCode = submitRequest(method, url, mediaType, entity);
253 // Check the status code of the response: does it match
254 // the expected response(s)?
255 if(logger.isDebugEnabled()){
256 logger.debug(testName + ": url=" + url +
257 " status=" + statusCode);
259 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
260 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
261 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
265 // ---------------------------------------------------------------
266 // CRUD tests : READ tests
267 // ---------------------------------------------------------------
270 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
273 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
274 dependsOnMethods = {"create"})
275 public void read(String testName) throws Exception {
277 if (logger.isDebugEnabled()) {
278 logger.debug(testBanner(testName, CLASS_NAME));
283 // Submit the request to the service and store the response.
284 LoanoutClient client = new LoanoutClient();
285 ClientResponse<MultipartInput> res = client.read(knownResourceId);
286 int statusCode = res.getStatus();
288 // Check the status code of the response: does it match
289 // the expected response(s)?
290 if(logger.isDebugEnabled()){
291 logger.debug(testName + ": status = " + statusCode);
293 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
294 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
295 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
297 MultipartInput input = (MultipartInput) res.getEntity();
298 LoansoutCommon loanout = (LoansoutCommon) extractPart(input,
299 client.getCommonPartName(), LoansoutCommon.class);
300 Assert.assertNotNull(loanout);
305 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
308 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
309 dependsOnMethods = {"read"})
310 public void readNonExistent(String testName) throws Exception {
312 if (logger.isDebugEnabled()) {
313 logger.debug(testBanner(testName, CLASS_NAME));
316 setupReadNonExistent();
318 // Submit the request to the service and store the response.
319 LoanoutClient client = new LoanoutClient();
320 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
321 int statusCode = res.getStatus();
323 // Check the status code of the response: does it match
324 // the expected response(s)?
325 if(logger.isDebugEnabled()){
326 logger.debug(testName + ": status = " + statusCode);
328 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
329 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
330 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
333 // ---------------------------------------------------------------
334 // CRUD tests : READ_LIST tests
335 // ---------------------------------------------------------------
338 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
341 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
342 dependsOnMethods = {"createList", "read"})
343 public void readList(String testName) throws Exception {
345 if (logger.isDebugEnabled()) {
346 logger.debug(testBanner(testName, CLASS_NAME));
351 // Submit the request to the service and store the response.
352 LoanoutClient client = new LoanoutClient();
353 ClientResponse<LoansoutCommonList> res = client.readList();
354 LoansoutCommonList list = res.getEntity();
355 int statusCode = res.getStatus();
357 // Check the status code of the response: does it match
358 // the expected response(s)?
359 if(logger.isDebugEnabled()){
360 logger.debug(testName + ": status = " + statusCode);
362 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
363 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
364 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
366 // Optionally output additional data about list members for debugging.
367 boolean iterateThroughList = false;
368 if(iterateThroughList && logger.isDebugEnabled()){
369 List<LoansoutCommonList.LoanoutListItem> items =
370 list.getLoanoutListItem();
372 for(LoansoutCommonList.LoanoutListItem item : items){
373 logger.debug(testName + ": list-item[" + i + "] csid=" +
375 logger.debug(testName + ": list-item[" + i + "] loanOutNumber=" +
376 item.getLoanOutNumber());
377 logger.debug(testName + ": list-item[" + i + "] URI=" +
387 // ---------------------------------------------------------------
388 // CRUD tests : UPDATE tests
389 // ---------------------------------------------------------------
392 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
395 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
396 dependsOnMethods = {"read"})
397 public void update(String testName) throws Exception {
399 if (logger.isDebugEnabled()) {
400 logger.debug(testBanner(testName, CLASS_NAME));
405 // Retrieve the contents of a resource to update.
406 LoanoutClient client = new LoanoutClient();
407 ClientResponse<MultipartInput> res =
408 client.read(knownResourceId);
409 if(logger.isDebugEnabled()){
410 logger.debug(testName + ": read status = " + res.getStatus());
412 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
414 if(logger.isDebugEnabled()){
415 logger.debug("got object to update with ID: " + knownResourceId);
417 MultipartInput input = (MultipartInput) res.getEntity();
418 LoansoutCommon loanout = (LoansoutCommon) extractPart(input,
419 client.getCommonPartName(), LoansoutCommon.class);
420 Assert.assertNotNull(loanout);
422 // Update the content of this resource.
423 loanout.setLoanOutNumber("updated-" + loanout.getLoanOutNumber());
424 loanout.setLoanReturnDate("updated-" + loanout.getLoanReturnDate());
425 if(logger.isDebugEnabled()){
426 logger.debug("to be updated object");
427 logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));
429 // Submit the request to the service and store the response.
430 MultipartOutput output = new MultipartOutput();
431 OutputPart commonPart = output.addPart(loanout, MediaType.APPLICATION_XML_TYPE);
432 commonPart.getHeaders().add("label", client.getCommonPartName());
434 res = client.update(knownResourceId, output);
435 int statusCode = res.getStatus();
436 // Check the status code of the response: does it match the expected response(s)?
437 if(logger.isDebugEnabled()){
438 logger.debug(testName + ": status = " + statusCode);
440 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
441 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
442 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
445 input = (MultipartInput) res.getEntity();
446 LoansoutCommon updatedLoanout =
447 (LoansoutCommon) extractPart(input,
448 client.getCommonPartName(), LoansoutCommon.class);
449 Assert.assertNotNull(updatedLoanout);
451 Assert.assertEquals(updatedLoanout.getLoanReturnDate(),
452 loanout.getLoanReturnDate(),
453 "Data in updated object did not match submitted data.");
458 // Placeholders until the three tests below can be uncommented.
459 // See Issue CSPACE-401.
461 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
464 public void updateWithEmptyEntityBody(String testName) throws Exception{
465 //Should this really be empty?
469 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
472 public void updateWithMalformedXml(String testName) throws Exception {
473 //Should this really be empty?
477 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
480 public void updateWithWrongXmlSchema(String testName) throws Exception {
481 //Should this really be empty?
486 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
487 dependsOnMethods = {"create", "update", "testSubmitRequest"})
488 public void updateWithEmptyEntityBody(String testName) throws Exception {
490 if (logger.isDebugEnabled()) {
491 logger.debug(testBanner(testName, CLASS_NAME));
494 setupUpdateWithEmptyEntityBody();
496 // Submit the request to the service and store the response.
497 String method = REQUEST_TYPE.httpMethodName();
498 String url = getResourceURL(knownResourceId);
499 String mediaType = MediaType.APPLICATION_XML;
500 final String entity = "";
501 int statusCode = submitRequest(method, url, mediaType, entity);
503 // Check the status code of the response: does it match
504 // the expected response(s)?
505 if(logger.isDebugEnabled()){
506 logger.debug(testName + ": url=" + url +
507 " status=" + statusCode);
509 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
510 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
511 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
515 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
516 dependsOnMethods = {"create", "update", "testSubmitRequest"})
517 public void updateWithMalformedXml(String testName) throws Exception {
519 if (logger.isDebugEnabled()) {
520 logger.debug(testBanner(testName, CLASS_NAME));
523 setupUpdateWithMalformedXml();
525 // Submit the request to the service and store the response.
526 String method = REQUEST_TYPE.httpMethodName();
527 String url = getResourceURL(knownResourceId);
528 String mediaType = MediaType.APPLICATION_XML;
529 final String entity = MALFORMED_XML_DATA;
530 int statusCode = submitRequest(method, url, mediaType, entity);
532 // Check the status code of the response: does it match
533 // the expected response(s)?
534 if(logger.isDebugEnabled()){
535 logger.debug(testName + ": url=" + url +
536 " status=" + statusCode);
538 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
539 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
540 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
544 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
545 dependsOnMethods = {"create", "update", "testSubmitRequest"})
546 public void updateWithWrongXmlSchema(String testName) throws Exception {
548 if (logger.isDebugEnabled()) {
549 logger.debug(testBanner(testName, CLASS_NAME));
552 setupUpdateWithWrongXmlSchema();
554 // Submit the request to the service and store the response.
555 String method = REQUEST_TYPE.httpMethodName();
556 String url = getResourceURL(knownResourceId);
557 String mediaType = MediaType.APPLICATION_XML;
558 final String entity = WRONG_XML_SCHEMA_DATA;
559 int statusCode = submitRequest(method, url, mediaType, entity);
561 // Check the status code of the response: does it match
562 // the expected response(s)?
563 if(logger.isDebugEnabled()){
564 logger.debug(testName + ": url=" + url +
565 " status=" + statusCode);
567 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
568 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
569 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
574 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
577 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
578 dependsOnMethods = {"update", "testSubmitRequest"})
579 public void updateNonExistent(String testName) throws Exception {
581 if (logger.isDebugEnabled()) {
582 logger.debug(testBanner(testName, CLASS_NAME));
585 setupUpdateNonExistent();
587 // Submit the request to the service and store the response.
588 // Note: The ID used in this 'create' call may be arbitrary.
589 // The only relevant ID may be the one used in update(), below.
590 LoanoutClient client = new LoanoutClient();
591 MultipartOutput multipart = createLoanoutInstance(NON_EXISTENT_ID);
592 ClientResponse<MultipartInput> res =
593 client.update(NON_EXISTENT_ID, multipart);
594 int statusCode = res.getStatus();
596 // Check the status code of the response: does it match
597 // the expected response(s)?
598 if(logger.isDebugEnabled()){
599 logger.debug(testName + ": status = " + statusCode);
601 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
602 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
603 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
606 // ---------------------------------------------------------------
607 // CRUD tests : DELETE tests
608 // ---------------------------------------------------------------
611 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
614 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
615 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
616 public void delete(String testName) throws Exception {
618 if (logger.isDebugEnabled()) {
619 logger.debug(testBanner(testName, CLASS_NAME));
624 // Submit the request to the service and store the response.
625 LoanoutClient client = new LoanoutClient();
626 ClientResponse<Response> res = client.delete(knownResourceId);
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);
641 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
644 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
645 dependsOnMethods = {"delete"})
646 public void deleteNonExistent(String testName) throws Exception {
648 if (logger.isDebugEnabled()) {
649 logger.debug(testBanner(testName, CLASS_NAME));
652 setupDeleteNonExistent();
654 // Submit the request to the service and store the response.
655 LoanoutClient client = new LoanoutClient();
656 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
657 int statusCode = res.getStatus();
659 // Check the status code of the response: does it match
660 // the expected response(s)?
661 if(logger.isDebugEnabled()){
662 logger.debug(testName + ": status = " + statusCode);
664 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
665 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
666 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
669 // ---------------------------------------------------------------
670 // Utility tests : tests of code used in tests above
671 // ---------------------------------------------------------------
673 * Tests the code for manually submitting data that is used by several
674 * of the methods above.
676 @Test(dependsOnMethods = {"create", "read"})
677 public void testSubmitRequest() {
679 // Expected status code: 200 OK
680 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
682 // Submit the request to the service and store the response.
683 String method = ServiceRequestType.READ.httpMethodName();
684 String url = getResourceURL(knownResourceId);
685 int statusCode = submitRequest(method, url);
687 // Check the status code of the response: does it match
688 // the expected response(s)?
689 if(logger.isDebugEnabled()){
690 logger.debug("testSubmitRequest: url=" + url +
691 " status=" + statusCode);
693 Assert.assertEquals(statusCode, EXPECTED_STATUS);
697 // ---------------------------------------------------------------
698 // Utility methods used by tests above
699 // ---------------------------------------------------------------
701 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
704 public String getServicePathComponent() {
705 return SERVICE_PATH_COMPONENT;
709 * Creates the loanout instance.
711 * @param identifier the identifier
712 * @return the multipart output
714 private MultipartOutput createLoanoutInstance(String identifier) {
715 return createLoanoutInstance(
716 "loanoutNumber-" + identifier,
717 "returnDate-" + identifier);
721 * Creates the loanout instance.
723 * @param loanOutNumber the loan out number
724 * @param returnDate the return date
725 * @return the multipart output
727 private MultipartOutput createLoanoutInstance(String loanOutNumber,
729 LoansoutCommon loanout = new LoansoutCommon();
730 loanout.setLoanOutNumber(loanOutNumber);
731 loanout.setLoanReturnDate(returnDate);
733 "urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'");
734 loanout.setBorrowersContact(
735 "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Chris Contact)'Chris Contact'");
736 loanout.setLoanPurpose("Allow people in cold climes to share the magic of Surfboards of the 1960s.");
737 MultipartOutput multipart = new MultipartOutput();
738 OutputPart commonPart =
739 multipart.addPart(loanout, MediaType.APPLICATION_XML_TYPE);
740 commonPart.getHeaders().add("label", new LoanoutClient().getCommonPartName());
742 if(logger.isDebugEnabled()){
743 logger.debug("to be created, loanout common");
744 logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));