001package org.kuali.ole.docstore.common.document; 002 003import org.apache.commons.io.FileUtils; 004import org.apache.log4j.Logger; 005import org.junit.Test; 006import org.kuali.ole.docstore.common.document.content.enums.DocCategory; 007import org.kuali.ole.docstore.common.document.content.enums.DocFormat; 008import org.kuali.ole.docstore.common.document.content.enums.DocType; 009import org.kuali.ole.docstore.common.document.content.instance.CallNumber; 010import org.kuali.ole.docstore.common.document.content.instance.OleHoldings; 011import org.kuali.ole.docstore.common.document.content.instance.ShelvingScheme; 012import org.kuali.ole.docstore.common.document.content.instance.xstream.HoldingOlemlRecordProcessor; 013import org.kuali.ole.docstore.common.util.ParseXml; 014 015import java.io.File; 016 017/** 018 * Created with IntelliJ IDEA. 019 * User: srirams 020 * Date: 1/8/14 021 * Time: 11:41 AM 022 * To change this template use File | Settings | File Templates. 023 */ 024public class EHoldingsOleml_UT { 025 026 private static final Logger LOG = Logger.getLogger(EHoldingsOleml_UT.class); 027 028 @Test 029 public void deserializeAndSerialize(){ 030 String input =""; 031 File file = null; 032 try { 033 file = new File(getClass().getResource("/documents/EHoldingsOleml1.xml").toURI()); 034 input = FileUtils.readFileToString(file); 035 } catch (Exception e) { 036 LOG.error("Exception ", e); 037 } 038 EHoldings eHoldings = new EHoldings(); 039 eHoldings = (EHoldings) eHoldings.deserialize(input); 040 eHoldings.setCallNumber("123"); 041 eHoldings.setCallNumberType("LCC"); 042 String serializeXml = eHoldings.serialize(eHoldings); 043 serializeXml = ParseXml.formatXml(serializeXml); 044 System.out.println(serializeXml); 045 046 } 047 048 @Test 049 public void deserializeContentAndSerializeContent(){ 050 String input =""; 051 File file = null; 052 try { 053 file = new File(getClass().getResource("/documents/EHoldingsOleml1.xml").toURI()); 054 input = FileUtils.readFileToString(file); 055 } catch (Exception e) { 056 LOG.error("Exception ", e); 057 } 058 EHoldingsOleml eHoldings = new EHoldingsOleml(); 059 eHoldings = (EHoldingsOleml) eHoldings.deserialize(input); 060 String content = eHoldings.getContent(); 061 OleHoldings oleHoldings = (OleHoldings) eHoldings.deserializeContent(content); 062 String serializeXml = eHoldings.serializeContent(oleHoldings); 063 serializeXml = ParseXml.formatXml(serializeXml); 064 System.out.println(serializeXml); 065 } 066 067}