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.instance.CallNumber;
7   import org.kuali.ole.docstore.common.document.content.instance.ShelvingScheme;
8   import org.kuali.ole.docstore.common.document.content.instance.xstream.ItemOlemlRecordProcessor;
9   import org.kuali.ole.docstore.common.util.ParseXml;
10  
11  import java.io.File;
12  
13  /**
14   * Created with IntelliJ IDEA.
15   * User: srirams
16   * Date: 1/8/14
17   * Time: 11:44 AM
18   * To change this template use File | Settings | File Templates.
19   */
20  public class ItemOleml_UT {
21  
22      private static final Logger LOG = Logger.getLogger(ItemOleml_UT.class);
23      @Test
24      public void deserializeAndSerialize(){
25          String input ="";
26          File file = null;
27          try {
28              file = new File(getClass().getResource("/documents/ItemOleml1.xml").toURI());
29              input = FileUtils.readFileToString(file);
30          } catch (Exception e) {
31              LOG.error("Exception ", e);
32          }
33          ItemOleml item = new ItemOleml();
34          item = (ItemOleml) item.deserialize(input);
35          item.setCallNumber("123");
36          item.setCallNumberType("LCC");
37          item.setBarcode("123456");
38          String serializeXml = item.serialize(item);
39          serializeXml = ParseXml.formatXml(serializeXml);
40          System.out.print(serializeXml);
41  
42      }
43  
44      @Test
45      public void deserializeContentAndSerializeContent(){
46          String input ="";
47          File file = null;
48          try {
49              file = new File(getClass().getResource("/documents/ItemOleml1.xml").toURI());
50              input = FileUtils.readFileToString(file);
51          } catch (Exception e) {
52              LOG.error("Exception ", e);
53          }
54          ItemOleml item = new ItemOleml();
55          item = (ItemOleml) item.deserialize(input);
56          org.kuali.ole.docstore.common.document.content.instance.Item itemDocument = (org.kuali.ole.docstore.common.document.content.instance.Item) item.deserializeContent(item.getContent());
57          String serializeXml = item.serializeContent(itemDocument);
58          serializeXml = ParseXml.formatXml(serializeXml);
59          System.out.print(serializeXml);
60      }
61  
62  }