]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
3bacb0a2dbba34e0939dac1600f881a3e791d36f
[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.Response;
28
29 import org.collectionspace.services.client.AbstractCommonListUtils;
30 import org.collectionspace.services.client.CollectionSpaceClient;
31 import org.collectionspace.services.client.LoaninClient;
32 import org.collectionspace.services.client.PayloadInputPart;
33 import org.collectionspace.services.client.PayloadOutputPart;
34 import org.collectionspace.services.client.PoxPayloadIn;
35 import org.collectionspace.services.client.PoxPayloadOut;
36 import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
37 import org.collectionspace.services.jaxb.AbstractCommonList;
38 import org.collectionspace.services.loanin.LenderGroup;
39 import org.collectionspace.services.loanin.LenderGroupList;
40 import org.collectionspace.services.loanin.LoansinCommon;
41
42 import org.jboss.resteasy.client.ClientResponse;
43 import org.testng.Assert;
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$
53  * $LastChangedDate$
54  */
55 public class LoaninServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, LoansinCommon> {
56
57     /** The logger. */
58     private final String CLASS_NAME = LoaninServiceTest.class.getName();
59     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
60     // Instance variables specific to this test.
61     /** The service path component. */
62     final String SERVICE_NAME = "loansin";
63     final String SERVICE_PATH_COMPONENT = "loansin";
64     private String LENDER_REF_NAME =
65             "urn:cspace:org.collectionspace.demo:personauthorities:name(TestPersonAuth):item:name(HarryLender)'Harry Lender'";
66     private final static String CURRENT_DATE_UTC =
67             GregorianCalendarDateTimeUtils.currentDateUTC();
68
69     /* (non-Javadoc)
70      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
71      */
72     @Override
73     protected CollectionSpaceClient getClientInstance() {
74         return new LoaninClient();
75     }
76
77     /* (non-Javadoc)
78      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
79      */
80     @Override
81     protected AbstractCommonList getCommonList(Response response) {
82         return response.readEntity(AbstractCommonList.class);
83     }
84
85     // ---------------------------------------------------------------
86     // CRUD tests : CREATE tests
87     // ---------------------------------------------------------------
88     
89     // Success outcomes
90     
91     /* (non-Javadoc)
92      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
93      */
94     @Override
95 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
96     public void create(String testName) throws Exception {
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).
100         setupCreate();
101
102         // Submit the request to the service and store the response.
103         LoaninClient client = new LoaninClient();
104         String identifier = createIdentifier();
105         PoxPayloadOut multipart = createLoaninInstance(identifier);
106         String newID = null;
107         Response res = client.create(multipart);
108         try {
109             int statusCode = res.getStatus();
110
111             // Check the status code of the response: does it match
112             // the expected response(s)?
113             //
114             // Specifically:
115             // Does it fall within the set of valid status codes?
116             // Does it exactly match the expected status code?
117             if (logger.isDebugEnabled()) {
118                 logger.debug(testName + ": status = " + statusCode);
119             }
120             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
121                     invalidStatusCodeMessage(testRequestType, statusCode));
122             Assert.assertEquals(statusCode, testExpectedStatusCode);
123
124             newID = extractId(res);
125         } finally {
126                 if (res != null) {
127                 res.close();
128             }
129         }
130
131         // Store the ID returned from the first resource created
132         // for additional tests below.
133         if (knownResourceId == null) {
134             knownResourceId = newID;
135             if (logger.isDebugEnabled()) {
136                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
137             }
138         }
139
140         // Store the IDs from every resource created by tests,
141         // so they can be deleted after tests have been run.
142         allResourceIdsCreated.add(newID);
143     }
144
145     /* (non-Javadoc)
146      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
147      */
148     @Override
149 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
150 //    dependsOnMethods = {"create"})
151     public void createList(String testName) throws Exception {
152         for (int i = 0; i < 3; i++) {
153             create(testName);
154         }
155     }
156
157
158     /*
159     @Override
160     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
161     dependsOnMethods = {"create", "testSubmitRequest"})
162     public void createWithEmptyEntityBody(String testName) throws Exception {
163     
164     if (logger.isDebugEnabled()) {
165     logger.debug(testBanner(testName, CLASS_NAME));
166     }
167     // Perform setup.
168     setupCreateWithEmptyEntityBody();
169     
170     // Submit the request to the service and store the response.
171     String method = REQUEST_TYPE.httpMethodName();
172     String url = getServiceRootURL();
173     String mediaType = MediaType.APPLICATION_XML;
174     final String entity = "";
175     int statusCode = submitRequest(method, url, mediaType, entity);
176     
177     // Check the status code of the response: does it match
178     // the expected response(s)?
179     if(logger.isDebugEnabled()){
180     logger.debug("createWithEmptyEntityBody url=" + url +
181     " status=" + statusCode);
182     }
183     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
184     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
185     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
186     }
187     
188     @Override
189     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
190     dependsOnMethods = {"create", "testSubmitRequest"})
191     public void createWithMalformedXml(String testName) throws Exception {
192     
193     if (logger.isDebugEnabled()) {
194     logger.debug(testBanner(testName, CLASS_NAME));
195     }
196     // Perform setup.
197     setupCreateWithMalformedXml(testName, logger);
198     
199     // Submit the request to the service and store the response.
200     String method = REQUEST_TYPE.httpMethodName();
201     String url = getServiceRootURL();
202     String mediaType = MediaType.APPLICATION_XML;
203     final String entity = MALFORMED_XML_DATA; // Constant from base class.
204     int statusCode = submitRequest(method, url, mediaType, entity);
205     
206     // Check the status code of the response: does it match
207     // the expected response(s)?
208     if(logger.isDebugEnabled()){
209     logger.debug(testName + ": url=" + url +
210     " status=" + statusCode);
211     }
212     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
213     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
214     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
215     }
216     
217     @Override
218     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
219     dependsOnMethods = {"create", "testSubmitRequest"})
220     public void createWithWrongXmlSchema(String testName) throws Exception {
221     
222     if (logger.isDebugEnabled()) {
223     logger.debug(testBanner(testName, CLASS_NAME));
224     }
225     // Perform setup.
226     setupCreateWithWrongXmlSchema(testName, logger);
227     
228     // Submit the request to the service and store the response.
229     String method = REQUEST_TYPE.httpMethodName();
230     String url = getServiceRootURL();
231     String mediaType = MediaType.APPLICATION_XML;
232     final String entity = WRONG_XML_SCHEMA_DATA;
233     int statusCode = submitRequest(method, url, mediaType, entity);
234     
235     // Check the status code of the response: does it match
236     // the expected response(s)?
237     if(logger.isDebugEnabled()){
238     logger.debug(testName + ": url=" + url +
239     " status=" + statusCode);
240     }
241     Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
242     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
243     Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
244     }
245      */
246     
247     // ---------------------------------------------------------------
248     // CRUD tests : READ tests
249     // ---------------------------------------------------------------
250     
251     // Success outcomes
252     
253     /* (non-Javadoc)
254      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
255      */
256     @Override
257 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
258 //    dependsOnMethods = {"create"})
259     public void read(String testName) throws Exception {
260         // Perform setup.
261         setupRead();
262
263         // Submit the request to the service and store the response.
264         LoaninClient client = new LoaninClient();
265         Response res = client.read(knownResourceId);
266         PoxPayloadIn input = null;
267         try {
268             assertStatusCode(res, testName);
269             input = new PoxPayloadIn((String)res.getEntity());
270         } finally {
271                 if (res != null) {
272                 res.close();
273             }
274         }
275
276         // Get the common part of the response and verify that it is not null.
277         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
278         LoansinCommon loaninCommon = null;
279         if (payloadInputPart != null) {
280             loaninCommon = (LoansinCommon) payloadInputPart.getBody();
281         }
282         Assert.assertNotNull(loaninCommon);
283
284         // Check selected fields.
285         LenderGroupList lenderGroupList = loaninCommon.getLenderGroupList();
286         Assert.assertNotNull(lenderGroupList);
287         List<LenderGroup> lenderGroups = lenderGroupList.getLenderGroup();
288         Assert.assertNotNull(lenderGroups);
289         Assert.assertTrue(lenderGroups.size() > 0);
290         String lender = lenderGroups.get(0).getLender();
291         Assert.assertEquals(lender, LENDER_REF_NAME);
292
293         if (logger.isDebugEnabled()) {
294             logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n"
295                     + "UTF-8 data received=" + loaninCommon.getLoanInNote());
296         }
297
298         Assert.assertEquals(loaninCommon.getLoanInNote(), getUTF8DataFragment(),
299                 "UTF-8 data retrieved '" + loaninCommon.getLoanInNote()
300                 + "' does not match expected data '" + getUTF8DataFragment());
301     }
302
303     // Failure outcomes
304     
305     /* (non-Javadoc)
306      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
307      */
308     @Override
309 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
310 //    dependsOnMethods = {"read"})
311     public void readNonExistent(String testName) throws Exception {
312         // Perform setup.
313         setupReadNonExistent();
314
315         // Submit the request to the service and store the response.
316         LoaninClient client = new LoaninClient();
317         Response res = client.read(NON_EXISTENT_ID);
318         try {
319             int statusCode = res.getStatus();
320
321             // Check the status code of the response: does it match
322             // the expected response(s)?
323             if (logger.isDebugEnabled()) {
324                 logger.debug(testName + ": status = " + statusCode);
325             }
326             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
327                     invalidStatusCodeMessage(testRequestType, statusCode));
328             Assert.assertEquals(statusCode, testExpectedStatusCode);
329         } finally {
330                 if (res != null) {
331                 res.close();
332             }
333         }
334     }
335
336     // ---------------------------------------------------------------
337     // CRUD tests : READ_LIST tests
338     // ---------------------------------------------------------------
339     
340     // Success outcomes
341     
342     /* (non-Javadoc)
343      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
344      */
345     @Override
346 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
347 //    dependsOnMethods = {"createList", "read"})
348     public void readList(String testName) throws Exception {
349         // Perform setup.
350         setupReadList();
351
352         // Submit the request to the service and store the response.
353         AbstractCommonList list = null;
354         LoaninClient client = new LoaninClient();
355         Response res = client.readList();
356         assertStatusCode(res, testName);
357         try {
358             int statusCode = res.getStatus();
359
360             // Check the status code of the response: does it match
361             // the expected response(s)?
362             if (logger.isDebugEnabled()) {
363                 logger.debug(testName + ": status = " + statusCode);
364             }
365             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
366                     invalidStatusCodeMessage(testRequestType, statusCode));
367             Assert.assertEquals(statusCode, testExpectedStatusCode);
368
369             list = res.readEntity(getCommonListType());
370         } finally {
371                 if (res != null) {
372                 res.close();
373             }
374         }
375
376         // Optionally output additional data about list members for debugging.
377         boolean iterateThroughList = true;
378         if(iterateThroughList && logger.isDebugEnabled()){
379                 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
380         }
381
382     }
383
384     // Failure outcomes
385     // None at present.
386     
387     // ---------------------------------------------------------------
388     // CRUD tests : UPDATE tests
389     // ---------------------------------------------------------------
390     
391     // Success outcomes
392     
393     /* (non-Javadoc)
394      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
395      */
396     @Override
397 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
398 //    dependsOnMethods = {"read"})
399     public void update(String testName) throws Exception {
400         // Perform setup.
401         setupRead();
402
403         // Retrieve the contents of a resource to update.
404         LoaninClient client = new LoaninClient();
405         Response res = client.read(knownResourceId);
406         PoxPayloadIn input = null;
407         try {
408                 assertStatusCode(res, testName);
409             input = new PoxPayloadIn((String)res.getEntity());
410                 if (logger.isDebugEnabled()) {
411                 logger.debug("got object to update with ID: " + knownResourceId);
412             }
413         } finally {
414                 if (res != null) {
415                 res.close();
416             }
417         }
418
419         // Extract the common part from the response.
420         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
421         LoansinCommon loaninCommon = null;
422         if (payloadInputPart != null) {
423             loaninCommon = (LoansinCommon) payloadInputPart.getBody();
424         }
425         Assert.assertNotNull(loaninCommon);
426
427         // Update the content of this resource.
428         loaninCommon.setLoanInNumber("updated-" + loaninCommon.getLoanInNumber());
429         loaninCommon.setLoanInNote("updated-" + loaninCommon.getLoanInNote());
430         if (logger.isDebugEnabled()) {
431             logger.debug("to be updated object");
432             logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
433         }
434
435         setupUpdate();
436         
437         // Submit the updated common part in an update request to the service
438         // and store the response.
439         PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
440         PayloadOutputPart commonPart = output.addPart(client.getCommonPartName(), loaninCommon);
441         res = client.update(knownResourceId, output);
442         try {
443                 assertStatusCode(res, testName);
444             int statusCode = res.getStatus();
445             // Check the status code of the response: does it match the expected response(s)?
446             if (logger.isDebugEnabled()) {
447                 logger.debug(testName + ": status = " + statusCode);
448             }
449             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
450                     invalidStatusCodeMessage(testRequestType, statusCode));
451             Assert.assertEquals(statusCode, testExpectedStatusCode);
452             input = new PoxPayloadIn((String)res.getEntity());
453         } finally {
454                 if (res != null) {
455                 res.close();
456             }
457         }
458
459         // Extract the updated common part from the response.
460         payloadInputPart = input.getPart(client.getCommonPartName());
461         LoansinCommon updatedLoaninCommon = null;
462         if (payloadInputPart != null) {
463             updatedLoaninCommon = (LoansinCommon) payloadInputPart.getBody();
464         }
465         Assert.assertNotNull(updatedLoaninCommon);
466
467         // Check selected fields in the updated common part.
468         Assert.assertEquals(updatedLoaninCommon.getLoanInNumber(),
469                 loaninCommon.getLoanInNumber(),
470                 "Data in updated object did not match submitted data.");
471
472         if (logger.isDebugEnabled()) {
473             logger.debug("UTF-8 data sent=" + loaninCommon.getLoanInNote() + "\n"
474                     + "UTF-8 data received=" + updatedLoaninCommon.getLoanInNote());
475         }
476         Assert.assertTrue(updatedLoaninCommon.getLoanInNote().contains(getUTF8DataFragment()),
477                 "UTF-8 data retrieved '" + updatedLoaninCommon.getLoanInNote()
478                 + "' does not contain expected data '" + getUTF8DataFragment());
479         Assert.assertEquals(updatedLoaninCommon.getLoanInNote(),
480                 loaninCommon.getLoanInNote(),
481                 "Data in updated object did not match submitted data.");
482     }
483
484     @Override
485 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
486 //    dependsOnMethods = {"update", "testSubmitRequest"})
487     public void updateNonExistent(String testName) throws Exception {
488         // Perform setup.
489         setupUpdateNonExistent();
490
491         // Submit the request to the service and store the response.
492         // Note: The ID used in this 'create' call may be arbitrary.
493         // The only relevant ID may be the one used in update(), below.
494         LoaninClient client = new LoaninClient();
495         PoxPayloadOut multipart = createLoaninInstance(NON_EXISTENT_ID);
496         Response res = client.update(NON_EXISTENT_ID, multipart);
497         try {
498             int statusCode = res.getStatus();
499
500             // Check the status code of the response: does it match
501             // the expected response(s)?
502             if (logger.isDebugEnabled()) {
503                 logger.debug(testName + ": status = " + statusCode);
504             }
505             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
506                     invalidStatusCodeMessage(testRequestType, statusCode));
507             Assert.assertEquals(statusCode, testExpectedStatusCode);
508         } finally {
509                 if (res != null) {
510                 res.close();
511             }
512         }
513     }
514
515     // ---------------------------------------------------------------
516     // CRUD tests : DELETE tests
517     // ---------------------------------------------------------------
518     
519     // Success outcomes
520     
521     /* (non-Javadoc)
522      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
523      */
524     @Override
525 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
526 //    dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
527     public void delete(String testName) throws Exception {
528         // Perform setup.
529         setupDelete();
530
531         // Submit the request to the service and store the response.
532         LoaninClient client = new LoaninClient();
533         Response res = client.delete(knownResourceId);
534         try {
535             int statusCode = res.getStatus();
536
537             // Check the status code of the response: does it match
538             // the expected response(s)?
539             if (logger.isDebugEnabled()) {
540                 logger.debug(testName + ": status = " + statusCode);
541             }
542             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
543                     invalidStatusCodeMessage(testRequestType, statusCode));
544             Assert.assertEquals(statusCode, testExpectedStatusCode);
545         } finally {
546                 if (res != null) {
547                 res.close();
548             }
549         }
550     }
551
552     // Failure outcomes
553     
554     /* (non-Javadoc)
555      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
556      */
557     @Override
558 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
559 //    dependsOnMethods = {"delete"})
560     public void deleteNonExistent(String testName) throws Exception {
561         // Perform setup.
562         setupDeleteNonExistent();
563
564         // Submit the request to the service and store the response.
565         LoaninClient client = new LoaninClient();
566         Response res = client.delete(NON_EXISTENT_ID);
567         try {
568             int statusCode = res.getStatus();
569
570             // Check the status code of the response: does it match
571             // the expected response(s)?
572             if (logger.isDebugEnabled()) {
573                 logger.debug(testName + ": status = " + statusCode);
574             }
575             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
576                     invalidStatusCodeMessage(testRequestType, statusCode));
577             Assert.assertEquals(statusCode, testExpectedStatusCode);
578         } finally {
579                 if (res != null) {
580                 res.close();
581             }
582         }
583     }
584
585     // ---------------------------------------------------------------
586     // Utility tests : tests of code used in tests above
587     // ---------------------------------------------------------------
588     
589     /**
590      * Tests the code for manually submitting data that is used by several
591      * of the methods above.
592      */
593 //    @Test(dependsOnMethods = {"create", "read"})
594     public void testSubmitRequest() {
595
596         // Expected status code: 200 OK
597         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
598
599         // Submit the request to the service and store the response.
600         String method = ServiceRequestType.READ.httpMethodName();
601         String url = getResourceURL(knownResourceId);
602         int statusCode = submitRequest(method, url);
603
604         // Check the status code of the response: does it match
605         // the expected response(s)?
606         if (logger.isDebugEnabled()) {
607             logger.debug("testSubmitRequest: url=" + url
608                     + " status=" + statusCode);
609         }
610         Assert.assertEquals(statusCode, EXPECTED_STATUS);
611
612     }
613
614     // ---------------------------------------------------------------
615     // Utility methods used by tests above
616     // ---------------------------------------------------------------
617     
618     @Override
619     public String getServiceName() {
620         return SERVICE_NAME;
621     }
622
623     /* (non-Javadoc)
624      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
625      */
626     @Override
627     public String getServicePathComponent() {
628         return SERVICE_PATH_COMPONENT;
629     }
630
631     @Override
632     protected PoxPayloadOut createInstance(String identifier) {
633         return createLoaninInstance(identifier);
634     }
635
636     /**
637      * Creates the loanin instance.
638      *
639      * @param identifier the identifier
640      * @return the multipart output
641      */
642     private PoxPayloadOut createLoaninInstance(String identifier) {
643         return createLoaninInstance(
644                 "loaninNumber-" + identifier,
645                 "returnDate-" + identifier);
646     }
647
648     /**
649      * Creates the loanin instance.
650      *
651      * @param loaninNumber the loanin number
652      * @param returnDate the return date
653      * @return the multipart output
654      */
655     private PoxPayloadOut createLoaninInstance(String loaninNumber,
656             String returnDate) {
657
658         LoansinCommon loaninCommon = new LoansinCommon();
659         loaninCommon.setLoanInNumber(loaninNumber);
660         loaninCommon.setLoanReturnDate(CURRENT_DATE_UTC);
661         LenderGroupList lenderGroupList = new LenderGroupList();
662         LenderGroup lenderGroup = new LenderGroup();
663         lenderGroup.setLender(LENDER_REF_NAME);
664         lenderGroupList.getLenderGroup().add(lenderGroup);
665         loaninCommon.setLenderGroupList(lenderGroupList);
666         loaninCommon.setLoanPurpose("For Surfboards of the 1960s exhibition.");
667         loaninCommon.setLoanInNote(getUTF8DataFragment());
668
669         PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
670         PayloadOutputPart commonPart =
671                 multipart.addPart(new LoaninClient().getCommonPartName(), loaninCommon);
672
673         if (logger.isDebugEnabled()) {
674             logger.debug("to be created, loanin common");
675             logger.debug(objectAsXmlString(loaninCommon, LoansinCommon.class));
676         }
677
678         return multipart;
679     }
680
681         @Override
682         public void CRUDTests(String testName) {
683                 // TODO Auto-generated method stub
684                 
685         }
686
687         @Override
688         protected PoxPayloadOut createInstance(String commonPartName,
689                         String identifier) {
690         PoxPayloadOut result = createLoaninInstance(identifier);
691         return result;
692         }
693
694         @Override
695         protected LoansinCommon updateInstance(LoansinCommon commonPartObject) {
696                 // TODO Auto-generated method stub
697                 return null;
698         }
699
700         @Override
701         protected void compareUpdatedInstances(LoansinCommon original,
702                         LoansinCommon updated) throws Exception {
703                 // TODO Auto-generated method stub
704                 
705         }
706 }