1 package org.kuali.ole.deliver;
2
3 import org.apache.log4j.Logger;
4 import org.junit.Test;
5 import org.kuali.ole.deliver.bo.OlePatronLoanDocuments;
6 import javax.xml.bind.JAXBContext;
7 import javax.xml.bind.Marshaller;
8 import javax.xml.bind.Unmarshaller;
9 import java.io.StringReader;
10 import java.io.StringWriter;
11
12 import static junit.framework.Assert.assertEquals;
13
14
15
16
17
18
19
20
21
22
23 public class OlePatronLoanDocumentJaxb_UT {
24
25 private static final Logger LOG = Logger.getLogger(OlePatronLoanDocumentJaxb_UT.class);
26
27 @Test
28 public void testMarshalAndUnmarshall() throws Exception {
29 LOG.debug("Inside the testMarshalAndUnmarshall method");
30 JAXBContext jaxb = JAXBContext.newInstance(OlePatronLoanDocuments.class);
31 OlePatronLoanDocuments patronLoanDocuments = OlePatronLoanDocumentHelper.create();
32
33 Marshaller marshaller = jaxb.createMarshaller();
34 StringWriter writer = new StringWriter();
35 marshaller.marshal(patronLoanDocuments, writer);
36 LOG.info("Marshalled Patron is: " + writer.toString());
37 Unmarshaller unmarshaller = jaxb.createUnmarshaller();
38 OlePatronLoanDocuments unmarshalled = (OlePatronLoanDocuments)unmarshaller.unmarshal(new StringReader(writer.toString()));
39 assertEquals(patronLoanDocuments.getOlePatronLoanDocuments().get(0).getItemBarcode(), unmarshalled.getOlePatronLoanDocuments().get(0).getItemBarcode());
40 assertEquals(patronLoanDocuments.getOlePatronLoanDocuments().get(0).getTitle(), unmarshalled.getOlePatronLoanDocuments().get(0).getTitle());
41 assertEquals(patronLoanDocuments.getOlePatronLoanDocuments().get(0).getAuthor(), unmarshalled.getOlePatronLoanDocuments().get(0).getAuthor());
42 assertEquals(patronLoanDocuments.getOlePatronLoanDocuments().get(0).getCallNumber(), unmarshalled.getOlePatronLoanDocuments().get(0).getCallNumber());
43 assertEquals(patronLoanDocuments.getOlePatronLoanDocuments().get(0).getLocation(), unmarshalled.getOlePatronLoanDocuments().get(0).getLocation());
44
45
46 }
47 }