001package org.kuali.ole.docstore.common.document;
002
003import org.apache.commons.io.FileUtils;
004import org.apache.log4j.Logger;
005import org.junit.Assert;
006import org.junit.Test;
007import org.kuali.ole.docstore.common.document.content.bib.marc.*;
008import org.kuali.ole.docstore.common.util.ParseXml;
009
010import java.io.File;
011import java.net.URISyntaxException;
012import java.util.ArrayList;
013import java.util.List;
014
015/**
016 * Created with IntelliJ IDEA.
017 * User: srirams
018 * Date: 1/8/14
019 * Time: 11:40 AM
020 * To change this template use File | Settings | File Templates.
021 */
022public class BibMarc_UT {
023
024    private static final Logger LOG = Logger.getLogger(BibMarc_UT.class);
025
026    @Test
027    public void deserializeAndSerialize(){
028        String input ="";
029        File file = null;
030        try {
031            file = new File(getClass().getResource("/documents/BibMarc1.xml").toURI());
032            input = FileUtils.readFileToString(file);
033        } catch (Exception e) {
034            LOG.error("Exception :", e);
035        }
036        BibMarc bibMarc = new BibMarc();
037        bibMarc = (BibMarc) bibMarc.deserialize(input);
038        bibMarc.setAuthor("author");
039        bibMarc.setTitle("title");
040        String serializeXml = bibMarc.serialize(bibMarc);
041        serializeXml = ParseXml.formatXml(serializeXml);
042        System.out.print(serializeXml);
043    }
044
045    @Test
046    public void deserializeContentAndSerializeContent(){
047        String input ="";
048        File file = null;
049        try {
050            file = new File(getClass().getResource("/documents/BibMarc1.xml").toURI());
051            input = FileUtils.readFileToString(file);
052        } catch (Exception e) {
053            LOG.error("Exception :", e);
054        }
055        BibMarc bibMarc = new BibMarc();
056        bibMarc = (BibMarc) bibMarc.deserialize(input);
057        BibMarcRecords bibMarcRecords = (BibMarcRecords) bibMarc.deserializeContent(bibMarc.getContent());
058        String serializeXml = bibMarc.serializeContent(bibMarcRecords);
059        serializeXml = ParseXml.formatXml(serializeXml);
060        System.out.println(serializeXml);
061    }
062}