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.bib.dc.unqualified.BibDublinUnQualifiedRecord;
7   import org.kuali.ole.docstore.common.util.ParseXml;
8   
9   import java.io.File;
10  
11  /**
12   * Created with IntelliJ IDEA.
13   * User: sambasivam
14   * Date: 1/21/14
15   * Time: 4:01 PM
16   * To change this template use File | Settings | File Templates.
17   */
18  public class BibDcUnqualified_UT {
19  
20      private static final Logger LOG = Logger.getLogger(BibDcUnqualified_UT.class);
21  
22      @Test
23      public void deserializeAndSerialize(){
24          String input ="";
25          File file = null;
26          try {
27              file = new File(getClass().getResource("/documents/BibDUnqualified1.xml").toURI());
28              input = FileUtils.readFileToString(file);
29          } catch (Exception e) {
30              LOG.error("Exception :", e);
31          }
32          BibDcUnqualified bibDcUnqualified = new BibDcUnqualified();
33          bibDcUnqualified = (BibDcUnqualified) bibDcUnqualified.deserialize(input);
34          bibDcUnqualified.setAuthor("author");
35          bibDcUnqualified.setTitle("title");
36          String serializeXml = bibDcUnqualified.serialize(bibDcUnqualified);
37          serializeXml = ParseXml.formatXml(serializeXml);
38          System.out.print(serializeXml);
39      }
40  
41      @Test
42      public void deserializeContentAndSerializeContent(){
43          String input ="";
44          File file = null;
45          try {
46              file = new File(getClass().getResource("/documents/BibMarc1.xml").toURI());
47              input = FileUtils.readFileToString(file);
48          } catch (Exception e) {
49              LOG.error("Exception :", e);
50          }
51          BibDcUnqualified bibDcUnqualified = new BibDcUnqualified();
52          bibDcUnqualified = (BibDcUnqualified) bibDcUnqualified.deserialize(input);
53          BibDublinUnQualifiedRecord bibMarcRecords = (BibDublinUnQualifiedRecord) bibDcUnqualified.deserializeContent(bibDcUnqualified.getContent());
54          String serializeXml = bibDcUnqualified.serializeContent(bibMarcRecords);
55          serializeXml = ParseXml.formatXml(serializeXml);
56          System.out.println(serializeXml);
57      }
58  }