View Javadoc
1   package org.kuali.ole.docstore.common.document;
2   
3   import org.apache.commons.io.FileUtils;
4   import org.apache.log4j.Logger;
5   import org.junit.Test;
6   import org.kuali.ole.docstore.common.document.content.enums.DocCategory;
7   import org.kuali.ole.docstore.common.document.content.enums.DocFormat;
8   import org.kuali.ole.docstore.common.document.content.enums.DocType;
9   import org.kuali.ole.docstore.common.document.content.instance.CallNumber;
10  import org.kuali.ole.docstore.common.document.content.instance.OleHoldings;
11  import org.kuali.ole.docstore.common.document.content.instance.ShelvingScheme;
12  import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor;
13  import org.kuali.ole.docstore.common.util.ParseXml;
14  
15  import java.io.File;
16  
17  /**
18   * Created with IntelliJ IDEA.
19   * User: srirams
20   * Date: 1/8/14
21   * Time: 11:40 AM
22   * To change this template use File | Settings | File Templates.
23   */
24  public class PHoldingsOleml_UT {
25  
26      private static final Logger LOG = Logger.getLogger(PHoldingsOleml_UT.class);
27      @Test
28      public void deserializeAndSerialize(){
29          String input ="";
30          File file = null;
31          try {
32              file = new File(getClass().getResource("/documents/PHoldingsOleml1.xml").toURI());
33              input = FileUtils.readFileToString(file);
34          } catch (Exception e) {
35              LOG.error("Exception ", e);
36          }
37          PHoldingsOleml pHoldingsOleml = new PHoldingsOleml();
38          pHoldingsOleml = (PHoldingsOleml) pHoldingsOleml.deserialize(input);
39          pHoldingsOleml.setCallNumber("123");
40          pHoldingsOleml.setCallNumberType("LCC");
41          String serializeXml = pHoldingsOleml.serialize(pHoldingsOleml);
42          serializeXml= ParseXml.formatXml(serializeXml);
43          System.out.print(serializeXml);
44      }
45  
46      @Test
47      public void deserializeContentAndSerializeContent(){
48          String input ="";
49          File file = null;
50          try {
51              file = new File(getClass().getResource("/documents/PHoldingsOleml1.xml").toURI());
52              input = FileUtils.readFileToString(file);
53          } catch (Exception e) {
54              LOG.error("Exception ", e);
55          }
56          PHoldingsOleml pHoldingsOleml = new PHoldingsOleml();
57          pHoldingsOleml = (PHoldingsOleml) pHoldingsOleml.deserialize(input);
58          OleHoldings oleHoldings = (OleHoldings) pHoldingsOleml.deserializeContent(pHoldingsOleml.getContent());
59          String serializeXml = pHoldingsOleml.serializeContent(oleHoldings);
60          serializeXml = ParseXml.formatXml(serializeXml);
61          System.out.print(serializeXml);
62      }
63  
64  }