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.LoanoutClient;
32 import org.collectionspace.services.jaxb.AbstractCommonList;
33 import org.collectionspace.services.loanout.LoansoutCommon;
34 import org.collectionspace.services.loanout.LoansoutCommonList;
36 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 * LoanoutServiceTest, carries out tests against a
50 * deployed and running Loanout (aka Loans Out) Service.
52 * $LastChangedRevision: 1327 $
53 * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
55 public class LoanoutServiceTest extends AbstractServiceTestImpl {
58 private final Logger logger =
59 LoggerFactory.getLogger(LoanoutServiceTest.class);
61 // Instance variables specific to this test.
62 /** The SERVIC e_ pat h_ component. */
63 final String SERVICE_PATH_COMPONENT = "loansout";
65 /** The known resource id. */
66 private String knownResourceId = null;
68 /** The all resource ids created. */
69 private List<String> allResourceIdsCreated = new ArrayList<String>();
72 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
75 protected CollectionSpaceClient getClientInstance() {
76 return new LoanoutClient();
80 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
83 protected AbstractCommonList getAbstractCommonList(
84 ClientResponse<AbstractCommonList> response) {
85 return response.getEntity(LoansoutCommonList.class);
88 // ---------------------------------------------------------------
89 // CRUD tests : CREATE tests
90 // ---------------------------------------------------------------
93 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
96 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
97 public void create(String testName) throws Exception {
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).
102 setupCreate(testName);
104 // Submit the request to the service and store the response.
105 LoanoutClient client = new LoanoutClient();
106 String identifier = createIdentifier();
107 MultipartOutput multipart = createLoanoutInstance(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 {
162 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
165 public void createWithMalformedXml(String testName) throws Exception {
169 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
172 public void createWithWrongXmlSchema(String testName) throws Exception {
177 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
178 dependsOnMethods = {"create", "testSubmitRequest"})
179 public void createWithEmptyEntityBody(String testName) throws Exception {
182 setupCreateWithEmptyEntityBody(testName);
184 // Submit the request to the service and store the response.
185 String method = REQUEST_TYPE.httpMethodName();
186 String url = getServiceRootURL();
187 String mediaType = MediaType.APPLICATION_XML;
188 final String entity = "";
189 int statusCode = submitRequest(method, url, mediaType, entity);
191 // Check the status code of the response: does it match
192 // the expected response(s)?
193 if(logger.isDebugEnabled()){
194 logger.debug("createWithEmptyEntityBody url=" + url +
195 " status=" + statusCode);
197 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
198 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
199 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
203 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
204 dependsOnMethods = {"create", "testSubmitRequest"})
205 public void createWithMalformedXml(String testName) throws Exception {
208 setupCreateWithMalformedXml(testName);
210 // Submit the request to the service and store the response.
211 String method = REQUEST_TYPE.httpMethodName();
212 String url = getServiceRootURL();
213 String mediaType = MediaType.APPLICATION_XML;
214 final String entity = MALFORMED_XML_DATA; // Constant from base class.
215 int statusCode = submitRequest(method, url, mediaType, entity);
217 // Check the status code of the response: does it match
218 // the expected response(s)?
219 if(logger.isDebugEnabled()){
220 logger.debug(testName + ": url=" + url +
221 " status=" + statusCode);
223 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
224 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
225 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
229 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
230 dependsOnMethods = {"create", "testSubmitRequest"})
231 public void createWithWrongXmlSchema(String testName) throws Exception {
234 setupCreateWithWrongXmlSchema(testName);
236 // Submit the request to the service and store the response.
237 String method = REQUEST_TYPE.httpMethodName();
238 String url = getServiceRootURL();
239 String mediaType = MediaType.APPLICATION_XML;
240 final String entity = WRONG_XML_SCHEMA_DATA;
241 int statusCode = submitRequest(method, url, mediaType, entity);
243 // Check the status code of the response: does it match
244 // the expected response(s)?
245 if(logger.isDebugEnabled()){
246 logger.debug(testName + ": url=" + url +
247 " status=" + statusCode);
249 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
250 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
251 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
255 // ---------------------------------------------------------------
256 // CRUD tests : READ tests
257 // ---------------------------------------------------------------
260 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
263 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
264 dependsOnMethods = {"create"})
265 public void read(String testName) throws Exception {
270 // Submit the request to the service and store the response.
271 LoanoutClient client = new LoanoutClient();
272 ClientResponse<MultipartInput> res = client.read(knownResourceId);
273 int statusCode = res.getStatus();
275 // Check the status code of the response: does it match
276 // the expected response(s)?
277 if(logger.isDebugEnabled()){
278 logger.debug(testName + ": status = " + statusCode);
280 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
281 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
282 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
284 MultipartInput input = (MultipartInput) res.getEntity();
285 LoansoutCommon loanout = (LoansoutCommon) extractPart(input,
286 client.getCommonPartName(), LoansoutCommon.class);
287 Assert.assertNotNull(loanout);
292 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
295 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
296 dependsOnMethods = {"read"})
297 public void readNonExistent(String testName) throws Exception {
300 setupReadNonExistent(testName);
302 // Submit the request to the service and store the response.
303 LoanoutClient client = new LoanoutClient();
304 ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
305 int statusCode = res.getStatus();
307 // Check the status code of the response: does it match
308 // the expected response(s)?
309 if(logger.isDebugEnabled()){
310 logger.debug(testName + ": status = " + statusCode);
312 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
313 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
314 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
317 // ---------------------------------------------------------------
318 // CRUD tests : READ_LIST tests
319 // ---------------------------------------------------------------
322 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
325 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
326 dependsOnMethods = {"createList", "read"})
327 public void readList(String testName) throws Exception {
330 setupReadList(testName);
332 // Submit the request to the service and store the response.
333 LoanoutClient client = new LoanoutClient();
334 ClientResponse<LoansoutCommonList> res = client.readList();
335 LoansoutCommonList list = res.getEntity();
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 // Optionally output additional data about list members for debugging.
348 boolean iterateThroughList = false;
349 if(iterateThroughList && logger.isDebugEnabled()){
350 List<LoansoutCommonList.LoanoutListItem> items =
351 list.getLoanoutListItem();
353 for(LoansoutCommonList.LoanoutListItem item : items){
354 logger.debug(testName + ": list-item[" + i + "] csid=" +
356 logger.debug(testName + ": list-item[" + i + "] loanOutNumber=" +
357 item.getLoanOutNumber());
358 logger.debug(testName + ": list-item[" + i + "] URI=" +
368 // ---------------------------------------------------------------
369 // CRUD tests : UPDATE tests
370 // ---------------------------------------------------------------
373 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
376 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
377 dependsOnMethods = {"read"})
378 public void update(String testName) throws Exception {
381 setupUpdate(testName);
383 // Retrieve the contents of a resource to update.
384 LoanoutClient client = new LoanoutClient();
385 ClientResponse<MultipartInput> res =
386 client.read(knownResourceId);
387 if(logger.isDebugEnabled()){
388 logger.debug(testName + ": read status = " + res.getStatus());
390 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
392 if(logger.isDebugEnabled()){
393 logger.debug("got object to update with ID: " + knownResourceId);
395 MultipartInput input = (MultipartInput) res.getEntity();
396 LoansoutCommon loanout = (LoansoutCommon) extractPart(input,
397 client.getCommonPartName(), LoansoutCommon.class);
398 Assert.assertNotNull(loanout);
400 // Update the content of this resource.
401 loanout.setLoanOutNumber("updated-" + loanout.getLoanOutNumber());
402 loanout.setLoanReturnDate("updated-" + loanout.getLoanReturnDate());
403 if(logger.isDebugEnabled()){
404 logger.debug("to be updated object");
405 logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));
407 // Submit the request to the service and store the response.
408 MultipartOutput output = new MultipartOutput();
409 OutputPart commonPart = output.addPart(loanout, MediaType.APPLICATION_XML_TYPE);
410 commonPart.getHeaders().add("label", client.getCommonPartName());
412 res = client.update(knownResourceId, output);
413 int statusCode = res.getStatus();
414 // Check the status code of the response: does it match the expected response(s)?
415 if(logger.isDebugEnabled()){
416 logger.debug(testName + ": status = " + statusCode);
418 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
419 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
420 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
423 input = (MultipartInput) res.getEntity();
424 LoansoutCommon updatedLoanout =
425 (LoansoutCommon) extractPart(input,
426 client.getCommonPartName(), LoansoutCommon.class);
427 Assert.assertNotNull(updatedLoanout);
429 Assert.assertEquals(updatedLoanout.getLoanReturnDate(),
430 loanout.getLoanReturnDate(),
431 "Data in updated object did not match submitted data.");
436 // Placeholders until the three tests below can be uncommented.
437 // See Issue CSPACE-401.
439 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
442 public void updateWithEmptyEntityBody(String testName) throws Exception{
446 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
449 public void updateWithMalformedXml(String testName) throws Exception {
453 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
456 public void updateWithWrongXmlSchema(String testName) throws Exception {
461 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
462 dependsOnMethods = {"create", "update", "testSubmitRequest"})
463 public void updateWithEmptyEntityBody(String testName) throws Exception {
466 setupUpdateWithEmptyEntityBody(testName);
468 // Submit the request to the service and store the response.
469 String method = REQUEST_TYPE.httpMethodName();
470 String url = getResourceURL(knownResourceId);
471 String mediaType = MediaType.APPLICATION_XML;
472 final String entity = "";
473 int statusCode = submitRequest(method, url, mediaType, entity);
475 // Check the status code of the response: does it match
476 // the expected response(s)?
477 if(logger.isDebugEnabled()){
478 logger.debug(testName + ": url=" + url +
479 " status=" + statusCode);
481 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
482 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
483 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
487 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
488 dependsOnMethods = {"create", "update", "testSubmitRequest"})
489 public void updateWithMalformedXml(String testName) throws Exception {
492 setupUpdateWithMalformedXml(testName);
494 // Submit the request to the service and store the response.
495 String method = REQUEST_TYPE.httpMethodName();
496 String url = getResourceURL(knownResourceId);
497 String mediaType = MediaType.APPLICATION_XML;
498 final String entity = MALFORMED_XML_DATA;
499 int statusCode = submitRequest(method, url, mediaType, entity);
501 // Check the status code of the response: does it match
502 // the expected response(s)?
503 if(logger.isDebugEnabled()){
504 logger.debug(testName + ": url=" + url +
505 " status=" + statusCode);
507 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
508 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
509 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
513 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
514 dependsOnMethods = {"create", "update", "testSubmitRequest"})
515 public void updateWithWrongXmlSchema(String testName) throws Exception {
518 setupUpdateWithWrongXmlSchema(testName);
520 // Submit the request to the service and store the response.
521 String method = REQUEST_TYPE.httpMethodName();
522 String url = getResourceURL(knownResourceId);
523 String mediaType = MediaType.APPLICATION_XML;
524 final String entity = WRONG_XML_SCHEMA_DATA;
525 int statusCode = submitRequest(method, url, mediaType, entity);
527 // Check the status code of the response: does it match
528 // the expected response(s)?
529 if(logger.isDebugEnabled()){
530 logger.debug(testName + ": url=" + url +
531 " status=" + statusCode);
533 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
534 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
535 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
540 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
543 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
544 dependsOnMethods = {"update", "testSubmitRequest"})
545 public void updateNonExistent(String testName) throws Exception {
548 setupUpdateNonExistent(testName);
550 // Submit the request to the service and store the response.
551 // Note: The ID used in this 'create' call may be arbitrary.
552 // The only relevant ID may be the one used in update(), below.
553 LoanoutClient client = new LoanoutClient();
554 MultipartOutput multipart = createLoanoutInstance(NON_EXISTENT_ID);
555 ClientResponse<MultipartInput> res =
556 client.update(NON_EXISTENT_ID, multipart);
557 int statusCode = res.getStatus();
559 // Check the status code of the response: does it match
560 // the expected response(s)?
561 if(logger.isDebugEnabled()){
562 logger.debug(testName + ": status = " + statusCode);
564 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
565 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
566 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
569 // ---------------------------------------------------------------
570 // CRUD tests : DELETE tests
571 // ---------------------------------------------------------------
574 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
577 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
578 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
579 public void delete(String testName) throws Exception {
582 setupDelete(testName);
584 // Submit the request to the service and store the response.
585 LoanoutClient client = new LoanoutClient();
586 ClientResponse<Response> res = client.delete(knownResourceId);
587 int statusCode = res.getStatus();
589 // Check the status code of the response: does it match
590 // the expected response(s)?
591 if(logger.isDebugEnabled()){
592 logger.debug(testName + ": status = " + statusCode);
594 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
595 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
596 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
601 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
604 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
605 dependsOnMethods = {"delete"})
606 public void deleteNonExistent(String testName) throws Exception {
609 setupDeleteNonExistent(testName);
611 // Submit the request to the service and store the response.
612 LoanoutClient client = new LoanoutClient();
613 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
614 int statusCode = res.getStatus();
616 // Check the status code of the response: does it match
617 // the expected response(s)?
618 if(logger.isDebugEnabled()){
619 logger.debug(testName + ": status = " + statusCode);
621 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
622 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
623 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
626 // ---------------------------------------------------------------
627 // Utility tests : tests of code used in tests above
628 // ---------------------------------------------------------------
630 * Tests the code for manually submitting data that is used by several
631 * of the methods above.
633 @Test(dependsOnMethods = {"create", "read"})
634 public void testSubmitRequest() {
636 // Expected status code: 200 OK
637 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
639 // Submit the request to the service and store the response.
640 String method = ServiceRequestType.READ.httpMethodName();
641 String url = getResourceURL(knownResourceId);
642 int statusCode = submitRequest(method, url);
644 // Check the status code of the response: does it match
645 // the expected response(s)?
646 if(logger.isDebugEnabled()){
647 logger.debug("testSubmitRequest: url=" + url +
648 " status=" + statusCode);
650 Assert.assertEquals(statusCode, EXPECTED_STATUS);
654 // ---------------------------------------------------------------
655 // Cleanup of resources created during testing
656 // ---------------------------------------------------------------
659 * Deletes all resources created by tests, after all tests have been run.
661 * This cleanup method will always be run, even if one or more tests fail.
662 * For this reason, it attempts to remove all resources created
663 * at any point during testing, even if some of those resources
664 * may be expected to be deleted by certain tests.
666 @AfterClass(alwaysRun=true)
667 public void cleanUp() {
668 String noTest = System.getProperty("noTestCleanup");
669 if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
670 if (logger.isDebugEnabled()) {
671 logger.debug("Skipping Cleanup phase ...");
675 if (logger.isDebugEnabled()) {
676 logger.debug("Cleaning up temporary resources created for testing ...");
678 LoanoutClient client = new LoanoutClient();
679 for (String resourceId : allResourceIdsCreated) {
680 // Note: Any non-success responses are ignored and not reported.
681 ClientResponse<Response> res = client.delete(resourceId);
685 // ---------------------------------------------------------------
686 // Utility methods used by tests above
687 // ---------------------------------------------------------------
689 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
692 public String getServicePathComponent() {
693 return SERVICE_PATH_COMPONENT;
697 * Creates the loanout instance.
699 * @param identifier the identifier
700 * @return the multipart output
702 private MultipartOutput createLoanoutInstance(String identifier) {
703 return createLoanoutInstance(
704 "loanoutNumber-" + identifier,
705 "returnDate-" + identifier);
709 * Creates the loanout instance.
711 * @param loanOutNumber the loan out number
712 * @param returnDate the return date
713 * @return the multipart output
715 private MultipartOutput createLoanoutInstance(String loanOutNumber,
717 LoansoutCommon loanout = new LoansoutCommon();
718 loanout.setLoanOutNumber(loanOutNumber);
719 loanout.setLoanReturnDate(returnDate);
721 "urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'");
722 loanout.setBorrowersContact(
723 "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Chris Contact)'Chris Contact'");
724 loanout.setLoanPurpose("Allow people in cold climes to share the magic of Surfboards of the 1960s.");
725 MultipartOutput multipart = new MultipartOutput();
726 OutputPart commonPart =
727 multipart.addPart(loanout, MediaType.APPLICATION_XML_TYPE);
728 commonPart.getHeaders().add("label", new LoanoutClient().getCommonPartName());
730 if(logger.isDebugEnabled()){
731 logger.debug("to be created, loanout common");
732 logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));