]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
4a72a4d005944514b5f04c85c6cd7b2db51aab14
[tmp/jakarta-migration.git] /
1 /**
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:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
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.
22  */
23 package org.collectionspace.services.client.test;
24
25 import java.util.ArrayList;
26 import java.util.List;
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
29
30 import org.collectionspace.services.client.LoaninClient;
31 import org.collectionspace.services.loanin.LoansinCommon;
32 import org.collectionspace.services.loanin.LoansinCommonList;
33 import org.collectionspace.services.loanin.LenderList;
34
35
36 import org.jboss.resteasy.client.ClientResponse;
37
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;
44
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
47
48 /**
49  * LoaninServiceTest, carries out tests against a
50  * deployed and running Loanin (aka Loans In) Service.
51  *
52  * $LastChangedRevision: 1327 $
53  * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
54  */
55 public class LoaninServiceTest extends AbstractServiceTestImpl {
56
57    private final Logger logger =
58        LoggerFactory.getLogger(LoaninServiceTest.class);
59
60     // Instance variables specific to this test.
61     final String SERVICE_PATH_COMPONENT = "loansin";
62     private String knownResourceId = null;
63     private List<String> allResourceIdsCreated = new ArrayList();
64
65     // ---------------------------------------------------------------
66     // CRUD tests : CREATE tests
67     // ---------------------------------------------------------------
68     // Success outcomes
69     @Override
70     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
71     public void create(String testName) throws Exception {
72
73         // Perform setup, such as initializing the type of service request
74         // (e.g. CREATE, DELETE), its valid and expected status codes, and
75         // its associated HTTP method name (e.g. POST, DELETE).
76         setupCreate(testName);
77
78         // Submit the request to the service and store the response.
79         LoaninClient client = new LoaninClient();
80         String identifier = createIdentifier();
81         MultipartOutput multipart = createLoaninInstance(identifier);
82         ClientResponse<Response> res = client.create(multipart);
83
84         int statusCode = res.getStatus();
85
86         // Check the status code of the response: does it match
87         // the expected response(s)?
88         //
89         // Specifically:
90         // Does it fall within the set of valid status codes?
91         // Does it exactly match the expected status code?
92         if(logger.isDebugEnabled()){
93             logger.debug(testName + ": status = " + statusCode);
94         }
95         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
96                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
97         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
98
99         // Store the ID returned from the first resource created
100         // for additional tests below.
101         if (knownResourceId == null){
102             knownResourceId = extractId(res);
103             if (logger.isDebugEnabled()) {
104                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
105             }
106         }
107         
108         // Store the IDs from every resource created by tests,
109         // so they can be deleted after tests have been run.
110         allResourceIdsCreated.add(extractId(res));
111     }
112
113     @Override
114     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
115         dependsOnMethods = {"create"})
116     public void createList(String testName) throws Exception {
117         for(int i = 0; i < 3; i++){
118             create(testName);
119         }
120     }
121
122     // Failure outcomes
123     // Placeholders until the three tests below can be uncommented.
124     // See Issue CSPACE-401.
125     @Override
126     public void createWithEmptyEntityBody(String testName) throws Exception {
127     }
128
129     @Override
130     public void createWithMalformedXml(String testName) throws Exception {
131     }
132
133     @Override
134     public void createWithWrongXmlSchema(String testName) throws Exception {
135     }
136
137     /*
138     @Override
139     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
140         dependsOnMethods = {"create", "testSubmitRequest"})
141     public void createWithEmptyEntityBody(String testName) throws Exception {
142
143     // Perform setup.
144     setupCreateWithEmptyEntityBody(testName);
145
146     // Submit the request to the service and store the response.
147     String method = REQUEST_TYPE.httpMethodName();
148     String url = getServiceRootURL();
149     String mediaType = MediaType.APPLICATION_XML;
150     final String entity = "";
151     int statusCode = submitRequest(method, url, mediaType, entity);
152
153     // Check the status code of the response: does it match
154     // the expected response(s)?
155     if(logger.isDebugEnabled()){
156         logger.debug("createWithEmptyEntityBody url=" + url +
157             " status=" + statusCode);
158      }
159     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
160     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
161     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
162     }
163
164     @Override
165     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
166         dependsOnMethods = {"create", "testSubmitRequest"})
167     public void createWithMalformedXml(String testName) throws Exception {
168
169     // Perform setup.
170     setupCreateWithMalformedXml(testName);
171
172     // Submit the request to the service and store the response.
173     String method = REQUEST_TYPE.httpMethodName();
174     String url = getServiceRootURL();
175     String mediaType = MediaType.APPLICATION_XML;
176     final String entity = MALFORMED_XML_DATA; // Constant from base class.
177     int statusCode = submitRequest(method, url, mediaType, entity);
178
179     // Check the status code of the response: does it match
180     // the expected response(s)?
181     if(logger.isDebugEnabled()){
182         logger.debug(testName + ": url=" + url +
183             " status=" + statusCode);
184      }
185     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
186     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
187     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
188     }
189
190     @Override
191     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
192         dependsOnMethods = {"create", "testSubmitRequest"})
193     public void createWithWrongXmlSchema(String testName) throws Exception {
194
195     // Perform setup.
196     setupCreateWithWrongXmlSchema(testName);
197
198     // Submit the request to the service and store the response.
199     String method = REQUEST_TYPE.httpMethodName();
200     String url = getServiceRootURL();
201     String mediaType = MediaType.APPLICATION_XML;
202     final String entity = WRONG_XML_SCHEMA_DATA;
203     int statusCode = submitRequest(method, url, mediaType, entity);
204
205     // Check the status code of the response: does it match
206     // the expected response(s)?
207     if(logger.isDebugEnabled()){
208         logger.debug(testName + ": url=" + url +
209             " status=" + statusCode);
210      }
211     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
212     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
213     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
214     }
215      */
216
217     // ---------------------------------------------------------------
218     // CRUD tests : READ tests
219     // ---------------------------------------------------------------
220     // Success outcomes
221     @Override
222     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
223         dependsOnMethods = {"create"})
224     public void read(String testName) throws Exception {
225
226         // Perform setup.
227         setupRead(testName);
228
229         // Submit the request to the service and store the response.
230         LoaninClient client = new LoaninClient();
231         ClientResponse<MultipartInput> res = client.read(knownResourceId);
232         int statusCode = res.getStatus();
233
234         // Check the status code of the response: does it match
235         // the expected response(s)?
236         if(logger.isDebugEnabled()){
237             logger.debug(testName + ": status = " + statusCode);
238         }
239         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
240                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
241         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
242
243         MultipartInput input = (MultipartInput) res.getEntity();
244         LoansinCommon loanin = (LoansinCommon) extractPart(input,
245                 client.getCommonPartName(), LoansinCommon.class);
246         Assert.assertNotNull(loanin);
247     }
248
249     // Failure outcomes
250     @Override
251     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
252         dependsOnMethods = {"read"})
253     public void readNonExistent(String testName) throws Exception {
254
255         // Perform setup.
256         setupReadNonExistent(testName);
257
258         // Submit the request to the service and store the response.
259         LoaninClient client = new LoaninClient();
260         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
261         int statusCode = res.getStatus();
262
263         // Check the status code of the response: does it match
264         // the expected response(s)?
265         if(logger.isDebugEnabled()){
266             logger.debug(testName + ": status = " + statusCode);
267         }
268         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
269                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
270         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
271     }
272
273     // ---------------------------------------------------------------
274     // CRUD tests : READ_LIST tests
275     // ---------------------------------------------------------------
276     // Success outcomes
277     @Override
278     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
279         dependsOnMethods = {"createList", "read"})
280     public void readList(String testName) throws Exception {
281
282         // Perform setup.
283         setupReadList(testName);
284
285         // Submit the request to the service and store the response.
286         LoaninClient client = new LoaninClient();
287         ClientResponse<LoansinCommonList> res = client.readList();
288         LoansinCommonList list = res.getEntity();
289         int statusCode = res.getStatus();
290
291         // Check the status code of the response: does it match
292         // the expected response(s)?
293         if(logger.isDebugEnabled()){
294             logger.debug(testName + ": status = " + statusCode);
295         }
296         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
297                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
298         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
299
300         // Optionally output additional data about list members for debugging.
301         boolean iterateThroughList = false;
302         if(iterateThroughList && logger.isDebugEnabled()){
303             List<LoansinCommonList.LoaninListItem> items =
304                     list.getLoaninListItem();
305             int i = 0;
306             for(LoansinCommonList.LoaninListItem item : items){
307                 logger.debug(testName + ": list-item[" + i + "] csid=" +
308                         item.getCsid());
309                 logger.debug(testName + ": list-item[" + i + "] loanInNumber=" +
310                         item.getLoanInNumber());
311                 logger.debug(testName + ": list-item[" + i + "] URI=" +
312                         item.getUri());
313                 i++;
314             }
315         }
316
317     }
318
319     // Failure outcomes
320     // None at present.
321     // ---------------------------------------------------------------
322     // CRUD tests : UPDATE tests
323     // ---------------------------------------------------------------
324     // Success outcomes
325     @Override
326     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
327         dependsOnMethods = {"read"})
328     public void update(String testName) throws Exception {
329
330         // Perform setup.
331         setupUpdate(testName);
332
333         // Retrieve the contents of a resource to update.
334         LoaninClient client = new LoaninClient();
335         ClientResponse<MultipartInput> res =
336                 client.read(knownResourceId);
337         if(logger.isDebugEnabled()){
338             logger.debug(testName + ": read status = " + res.getStatus());
339         }
340         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
341
342         if(logger.isDebugEnabled()){
343             logger.debug("got object to update with ID: " + knownResourceId);
344         }
345         MultipartInput input = (MultipartInput) res.getEntity();
346         LoansinCommon loanin = (LoansinCommon) extractPart(input,
347                 client.getCommonPartName(), LoansinCommon.class);
348         Assert.assertNotNull(loanin);
349
350         // Update the content of this resource.
351         loanin.setLoanInNumber("updated-" + loanin.getLoanInNumber());
352         loanin.setLoanReturnDate("updated-" + loanin.getLoanReturnDate());
353         if(logger.isDebugEnabled()){
354             logger.debug("to be updated object");
355             logger.debug(objectAsXmlString(loanin, LoansinCommon.class));
356         }
357         // Submit the request to the service and store the response.
358         MultipartOutput output = new MultipartOutput();
359         OutputPart commonPart = output.addPart(loanin, MediaType.APPLICATION_XML_TYPE);
360         commonPart.getHeaders().add("label", client.getCommonPartName());
361
362         res = client.update(knownResourceId, output);
363         int statusCode = res.getStatus();
364         // Check the status code of the response: does it match the expected response(s)?
365         if(logger.isDebugEnabled()){
366             logger.debug(testName + ": status = " + statusCode);
367         }
368         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
369                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
370         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
371
372
373         input = (MultipartInput) res.getEntity();
374         LoansinCommon updatedLoanin =
375                 (LoansinCommon) extractPart(input,
376                         client.getCommonPartName(), LoansinCommon.class);
377         Assert.assertNotNull(updatedLoanin);
378
379         Assert.assertEquals(updatedLoanin.getLoanReturnDate(),
380                 loanin.getLoanReturnDate(),
381                 "Data in updated object did not match submitted data.");
382
383     }
384
385     // Failure outcomes
386     // Placeholders until the three tests below can be uncommented.
387     // See Issue CSPACE-401.
388     @Override
389     public void updateWithEmptyEntityBody(String testName) throws Exception{
390     }
391     @Override
392     public void updateWithMalformedXml(String testName) throws Exception {
393     }
394     @Override
395     public void updateWithWrongXmlSchema(String testName) throws Exception {
396     }
397
398     /*
399     @Override
400     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
401         dependsOnMethods = {"create", "update", "testSubmitRequest"})
402     public void updateWithEmptyEntityBody(String testName) throws Exception {
403
404     // Perform setup.
405     setupUpdateWithEmptyEntityBody(testName);
406
407     // Submit the request to the service and store the response.
408     String method = REQUEST_TYPE.httpMethodName();
409     String url = getResourceURL(knownResourceId);
410     String mediaType = MediaType.APPLICATION_XML;
411     final String entity = "";
412     int statusCode = submitRequest(method, url, mediaType, entity);
413
414     // Check the status code of the response: does it match
415     // the expected response(s)?
416     if(logger.isDebugEnabled()){
417         logger.debug(testName + ": url=" + url +
418             " status=" + statusCode);
419      }
420     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
421     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
422     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
423     }
424
425     @Override
426     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
427         dependsOnMethods = {"create", "update", "testSubmitRequest"})
428     public void updateWithMalformedXml(String testName) throws Exception {
429
430     // Perform setup.
431     setupUpdateWithMalformedXml(testName);
432
433     // Submit the request to the service and store the response.
434     String method = REQUEST_TYPE.httpMethodName();
435     String url = getResourceURL(knownResourceId);
436     String mediaType = MediaType.APPLICATION_XML;
437     final String entity = MALFORMED_XML_DATA;
438     int statusCode = submitRequest(method, url, mediaType, entity);
439
440     // Check the status code of the response: does it match
441     // the expected response(s)?
442     if(logger.isDebugEnabled()){
443         logger.debug(testName + ": url=" + url +
444          " status=" + statusCode);
445      }
446     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
447     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
448     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
449     }
450
451     @Override
452     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
453         dependsOnMethods = {"create", "update", "testSubmitRequest"})
454     public void updateWithWrongXmlSchema(String testName) throws Exception {
455
456     // Perform setup.
457     setupUpdateWithWrongXmlSchema(testName);
458
459     // Submit the request to the service and store the response.
460     String method = REQUEST_TYPE.httpMethodName();
461     String url = getResourceURL(knownResourceId);
462     String mediaType = MediaType.APPLICATION_XML;
463     final String entity = WRONG_XML_SCHEMA_DATA;
464     int statusCode = submitRequest(method, url, mediaType, entity);
465
466     // Check the status code of the response: does it match
467     // the expected response(s)?
468     if(logger.isDebugEnabled()){
469         logger.debug(testName + ": url=" + url +
470         " status=" + statusCode);
471      }
472     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
473     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
474     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
475     }
476      */
477
478     @Override
479     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
480         dependsOnMethods = {"update", "testSubmitRequest"})
481     public void updateNonExistent(String testName) throws Exception {
482
483         // Perform setup.
484         setupUpdateNonExistent(testName);
485
486         // Submit the request to the service and store the response.
487         // Note: The ID used in this 'create' call may be arbitrary.
488         // The only relevant ID may be the one used in update(), below.
489         LoaninClient client = new LoaninClient();
490         MultipartOutput multipart = createLoaninInstance(NON_EXISTENT_ID);
491         ClientResponse<MultipartInput> res =
492                 client.update(NON_EXISTENT_ID, multipart);
493         int statusCode = res.getStatus();
494
495         // Check the status code of the response: does it match
496         // the expected response(s)?
497         if(logger.isDebugEnabled()){
498             logger.debug(testName + ": status = " + statusCode);
499         }
500         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
501                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
502         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
503     }
504
505     // ---------------------------------------------------------------
506     // CRUD tests : DELETE tests
507     // ---------------------------------------------------------------
508     // Success outcomes
509     @Override
510     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
511         dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
512     public void delete(String testName) throws Exception {
513
514         // Perform setup.
515         setupDelete(testName);
516
517         // Submit the request to the service and store the response.
518         LoaninClient client = new LoaninClient();
519         ClientResponse<Response> res = client.delete(knownResourceId);
520         int statusCode = res.getStatus();
521
522         // Check the status code of the response: does it match
523         // the expected response(s)?
524         if(logger.isDebugEnabled()){
525             logger.debug(testName + ": status = " + statusCode);
526         }
527         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
528                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
529         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
530     }
531
532     // Failure outcomes
533     @Override
534     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
535         dependsOnMethods = {"delete"})
536     public void deleteNonExistent(String testName) throws Exception {
537
538         // Perform setup.
539         setupDeleteNonExistent(testName);
540
541         // Submit the request to the service and store the response.
542         LoaninClient client = new LoaninClient();
543         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
544         int statusCode = res.getStatus();
545
546         // Check the status code of the response: does it match
547         // the expected response(s)?
548         if(logger.isDebugEnabled()){
549             logger.debug(testName + ": status = " + statusCode);
550         }
551         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
552                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
553         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
554     }
555
556     // ---------------------------------------------------------------
557     // Utility tests : tests of code used in tests above
558     // ---------------------------------------------------------------
559     /**
560      * Tests the code for manually submitting data that is used by several
561      * of the methods above.
562      */
563     @Test(dependsOnMethods = {"create", "read"})
564     public void testSubmitRequest() {
565
566         // Expected status code: 200 OK
567         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
568
569         // Submit the request to the service and store the response.
570         String method = ServiceRequestType.READ.httpMethodName();
571         String url = getResourceURL(knownResourceId);
572         int statusCode = submitRequest(method, url);
573
574         // Check the status code of the response: does it match
575         // the expected response(s)?
576         if(logger.isDebugEnabled()){
577             logger.debug("testSubmitRequest: url=" + url +
578                 " status=" + statusCode);
579         }
580         Assert.assertEquals(statusCode, EXPECTED_STATUS);
581
582     }
583
584     // ---------------------------------------------------------------
585     // Cleanup of resources created during testing
586     // ---------------------------------------------------------------
587
588     /**
589      * Deletes all resources created by tests, after all tests have been run.
590      *
591      * This cleanup method will always be run, even if one or more tests fail.
592      * For this reason, it attempts to remove all resources created
593      * at any point during testing, even if some of those resources
594      * may be expected to be deleted by certain tests.
595      */
596     @AfterClass(alwaysRun=true)
597     public void cleanUp() {
598         if (logger.isDebugEnabled()) {
599             logger.debug("Cleaning up temporary resources created for testing ...");
600         }
601        LoaninClient client = new LoaninClient();
602        for (String resourceId : allResourceIdsCreated) {
603             // Note: Any non-success responses are ignored and not reported.
604             ClientResponse<Response> res = client.delete(resourceId);
605         }
606     }
607
608     // ---------------------------------------------------------------
609     // Utility methods used by tests above
610     // ---------------------------------------------------------------
611     @Override
612     public String getServicePathComponent() {
613         return SERVICE_PATH_COMPONENT;
614     }
615
616     private MultipartOutput createLoaninInstance(String identifier) {
617         return createLoaninInstance(
618                 "entryNumber-" + identifier,
619                 "entryDate-" + identifier);
620     }
621
622     private MultipartOutput createLoaninInstance(String loanInNumber,
623                 String returnDate) {
624         LoansinCommon loanin = new LoansinCommon();
625         loanin.setLoanInNumber(loanInNumber);
626         loanin.setLoanReturnDate(returnDate);
627         LenderList lenderList = new LenderList();
628         lenderList.getLender().add(
629             "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Harry Lender)'Harry Lender'");
630         lenderList.getLender().add(
631             "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Sally Lender)'Sally Lender'");
632         loanin.setLenders(lenderList);
633         loanin.setLoanPurpose("For Surfboards of the 1960s exhibition.");
634         MultipartOutput multipart = new MultipartOutput();
635         OutputPart commonPart =
636             multipart.addPart(loanin, MediaType.APPLICATION_XML_TYPE);
637         commonPart.getHeaders().add("label", new LoaninClient().getCommonPartName());
638
639         if(logger.isDebugEnabled()){
640             logger.debug("to be created, loanin common");
641             logger.debug(objectAsXmlString(loanin, LoansinCommon.class));
642         }
643
644         return multipart;
645     }
646 }