001package org.kuali.ole.converter;
002
003import org.apache.commons.io.FileUtils;
004import org.junit.Test;
005import org.kuali.ole.docstore.xstream.BaseTestCase;
006import org.kuali.ole.docstore.xstream.FileUtil;
007import org.kuali.ole.pojo.bib.BibliographicRecord;
008import org.slf4j.Logger;
009import org.slf4j.LoggerFactory;
010
011import java.io.File;
012import java.net.URL;
013
014import static junit.framework.Assert.assertNotNull;
015
016/**
017 * Created with IntelliJ IDEA.
018 * User: ?
019 * Date: ?
020 * Time: ?
021 * To change this template use File | Settings | File Templates.
022 */
023public class MarcXMLConverter_UT extends BaseTestCase {
024    private static final Logger LOG = LoggerFactory.getLogger(MarcXMLConverter_UT.class);
025
026
027    @Test
028    public void testConvertMarcXML() throws Exception {
029        MarcXMLConverter marcXMLConverter = new MarcXMLConverter();
030        marcXMLConverter.generateMarcBean(new BibliographicRecord());
031        URL resource = getClass().getResource("/org/kuali/ole/duke.mrc");
032        File file = new File(resource.toURI());
033        String marcXMLFileName = marcXMLConverter.convertRawMarcToXML(file);
034        LOG.info("file:" + marcXMLFileName);
035        assertNotNull(marcXMLFileName);
036        File marcXMLFile = new File(marcXMLFileName);
037        String marcXML = new FileUtil().readFile(marcXMLFile);
038        LOG.info(marcXML);
039        FileUtils.deleteQuietly(marcXMLFile);
040
041    }
042
043}