001package org.kuali.ole;
002
003import org.apache.commons.io.FileUtils;
004import org.junit.Test;
005import org.kuali.ole.docstore.xstream.FileUtil;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009import java.io.File;
010import java.net.URL;
011
012import static junit.framework.Assert.assertNotNull;
013
014/**
015 * Created by IntelliJ IDEA.
016 * User: pvsubrah
017 * Date: 4/2/12
018 * Time: 4:04 PM
019 * To change this template use File | Settings | File Templates.
020 */
021public class MarcXMLGenerator_UT {
022    public static final Logger LOG = LoggerFactory.getLogger(MarcXMLGenerator_UT.class);
023
024    @Test
025    public void testGenerateMarcXML() throws Exception {
026        MarcXMLGenerator marcXMLGenerator = new MarcXMLGenerator();
027//        URL resource = getClass().getResource("iu.mrc");
028        URL resource = getClass().getResource("duke.mrc");
029        File file = new File(resource.toURI());
030
031        String marcXMLFileName = marcXMLGenerator.convertRawMarcToXML(file);
032        assertNotNull(marcXMLFileName);
033
034        File marcXMLFile = new File(marcXMLFileName);
035        String marcXML = new FileUtil().readFile(marcXMLFile);
036        LOG.info(marcXML);
037
038        FileUtils.deleteQuietly(marcXMLFile);
039
040    }
041
042    @Test
043    public void testGenerateMarcXMLFromRawMarcContent() throws Exception {
044        MarcXMLGenerator marcXMLGenerator = new MarcXMLGenerator();
045        URL resource = getClass().getResource("iu.mrc");
046        File file = new File(resource.toURI());
047
048        String fileContent = new FileUtilForRawMarc().readFile(file);
049
050        String marcContent = marcXMLGenerator.convert(fileContent);
051        assertNotNull(marcContent);
052        LOG.info(marcContent);
053    }
054}