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   
7   import java.io.File;
8   
9   /**
10   * Created with IntelliJ IDEA.
11   * User: chenchulakshmig
12   * Date: 2/25/14
13   * Time: 4:00 PM
14   * To change this template use File | Settings | File Templates.
15   */
16  public class LicenseAttachment_UT {
17      private static final Logger LOG = Logger.getLogger(LicenseAttachment_UT.class);
18  
19      @Test
20      public void deserializeAndSerialize() {
21          String input = "";
22          File file = null;
23          try {
24              file = new File(getClass().getResource("/documents/LicenseAttachment1.xml").toURI());
25              input = FileUtils.readFileToString(file);
26          } catch (Exception e) {
27              LOG.error("Exception :", e);
28          }
29          LicenseAttachment licenseAttachment = new LicenseAttachment();
30          licenseAttachment = (LicenseAttachment) licenseAttachment.deserialize(input);
31          licenseAttachment.setContent(null);
32          licenseAttachment.setFileName("123");
33          licenseAttachment.setFormat("pdf");
34          String serializeXml = licenseAttachment.serialize(licenseAttachment);
35          System.out.print(serializeXml);
36      }
37  }