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:41 AM
22   * To change this template use File | Settings | File Templates.
23   */
24  public class EHoldingsOleml_UT {
25  
26      private static final Logger LOG = Logger.getLogger(EHoldingsOleml_UT.class);
27  
28      @Test
29      public void deserializeAndSerialize(){
30          String input ="";
31          File file = null;
32          try {
33              file = new File(getClass().getResource("/documents/EHoldingsOleml1.xml").toURI());
34              input = FileUtils.readFileToString(file);
35          } catch (Exception e) {
36              LOG.error("Exception ", e);
37          }
38          EHoldings eHoldings = new EHoldings();
39          eHoldings = (EHoldings) eHoldings.deserialize(input);
40          eHoldings.setCallNumber("123");
41          eHoldings.setCallNumberType("LCC");
42          String serializeXml = eHoldings.serialize(eHoldings);
43          serializeXml = ParseXml.formatXml(serializeXml);
44          System.out.println(serializeXml);
45  
46      }
47  
48      @Test
49      public void deserializeContentAndSerializeContent(){
50          String input ="";
51          File file = null;
52          try {
53              file = new File(getClass().getResource("/documents/EHoldingsOleml1.xml").toURI());
54              input = FileUtils.readFileToString(file);
55          } catch (Exception e) {
56              LOG.error("Exception ", e);
57          }
58          EHoldingsOleml eHoldings = new EHoldingsOleml();
59          eHoldings = (EHoldingsOleml) eHoldings.deserialize(input);
60          String content = eHoldings.getContent();
61          OleHoldings oleHoldings = (OleHoldings) eHoldings.deserializeContent(content);
62          String serializeXml = eHoldings.serializeContent(oleHoldings);
63          serializeXml = ParseXml.formatXml(serializeXml);
64          System.out.println(serializeXml);
65      }
66  
67  }