View Javadoc
1   package org.kuali.ole.converter;
2   
3   import org.apache.commons.io.FileUtils;
4   import org.junit.Test;
5   import org.kuali.ole.docstore.xstream.BaseTestCase;
6   import org.kuali.ole.docstore.xstream.FileUtil;
7   import org.kuali.ole.pojo.bib.BibliographicRecord;
8   import org.slf4j.Logger;
9   import org.slf4j.LoggerFactory;
10  
11  import java.io.File;
12  import java.net.URL;
13  
14  import static junit.framework.Assert.assertNotNull;
15  
16  /**
17   * Created with IntelliJ IDEA.
18   * User: ?
19   * Date: ?
20   * Time: ?
21   * To change this template use File | Settings | File Templates.
22   */
23  public class MarcXMLConverter_UT extends BaseTestCase {
24      private static final Logger LOG = LoggerFactory.getLogger(MarcXMLConverter_UT.class);
25  
26  
27      @Test
28      public void testConvertMarcXML() throws Exception {
29          MarcXMLConverter marcXMLConverter = new MarcXMLConverter();
30          marcXMLConverter.generateMarcBean(new BibliographicRecord());
31          URL resource = getClass().getResource("/org/kuali/ole/duke.mrc");
32          File file = new File(resource.toURI());
33          String marcXMLFileName = marcXMLConverter.convertRawMarcToXML(file);
34          LOG.info("file:" + marcXMLFileName);
35          assertNotNull(marcXMLFileName);
36          File marcXMLFile = new File(marcXMLFileName);
37          String marcXML = new FileUtil().readFile(marcXMLFile);
38          LOG.info(marcXML);
39          FileUtils.deleteQuietly(marcXMLFile);
40  
41      }
42  
43  }