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.bib.dc.unqualified.BibDublinUnQualifiedRecord; 007import org.kuali.ole.docstore.common.util.ParseXml; 008 009import java.io.File; 010 011/** 012 * Created with IntelliJ IDEA. 013 * User: sambasivam 014 * Date: 1/21/14 015 * Time: 4:01 PM 016 * To change this template use File | Settings | File Templates. 017 */ 018public class BibDcUnqualified_UT { 019 020 private static final Logger LOG = Logger.getLogger(BibDcUnqualified_UT.class); 021 022 @Test 023 public void deserializeAndSerialize(){ 024 String input =""; 025 File file = null; 026 try { 027 file = new File(getClass().getResource("/documents/BibDUnqualified1.xml").toURI()); 028 input = FileUtils.readFileToString(file); 029 } catch (Exception e) { 030 LOG.error("Exception :", e); 031 } 032 BibDcUnqualified bibDcUnqualified = new BibDcUnqualified(); 033 bibDcUnqualified = (BibDcUnqualified) bibDcUnqualified.deserialize(input); 034 bibDcUnqualified.setAuthor("author"); 035 bibDcUnqualified.setTitle("title"); 036 String serializeXml = bibDcUnqualified.serialize(bibDcUnqualified); 037 serializeXml = ParseXml.formatXml(serializeXml); 038 System.out.print(serializeXml); 039 } 040 041 @Test 042 public void deserializeContentAndSerializeContent(){ 043 String input =""; 044 File file = null; 045 try { 046 file = new File(getClass().getResource("/documents/BibMarc1.xml").toURI()); 047 input = FileUtils.readFileToString(file); 048 } catch (Exception e) { 049 LOG.error("Exception :", e); 050 } 051 BibDcUnqualified bibDcUnqualified = new BibDcUnqualified(); 052 bibDcUnqualified = (BibDcUnqualified) bibDcUnqualified.deserialize(input); 053 BibDublinUnQualifiedRecord bibMarcRecords = (BibDublinUnQualifiedRecord) bibDcUnqualified.deserializeContent(bibDcUnqualified.getContent()); 054 String serializeXml = bibDcUnqualified.serializeContent(bibMarcRecords); 055 serializeXml = ParseXml.formatXml(serializeXml); 056 System.out.println(serializeXml); 057 } 058}