View Javadoc
1   package org.kuali.ole;
2   
3   import org.apache.commons.io.FileUtils;
4   import org.junit.Test;
5   import org.kuali.ole.docstore.xstream.FileUtil;
6   import org.slf4j.Logger;
7   import org.slf4j.LoggerFactory;
8   
9   import java.io.File;
10  import java.net.URL;
11  
12  import static junit.framework.Assert.assertNotNull;
13  
14  /**
15   * Created by IntelliJ IDEA.
16   * User: pvsubrah
17   * Date: 4/2/12
18   * Time: 4:04 PM
19   * To change this template use File | Settings | File Templates.
20   */
21  public class MarcXMLGenerator_UT {
22      public static final Logger LOG = LoggerFactory.getLogger(MarcXMLGenerator_UT.class);
23  
24      @Test
25      public void testGenerateMarcXML() throws Exception {
26          MarcXMLGenerator marcXMLGenerator = new MarcXMLGenerator();
27  //        URL resource = getClass().getResource("iu.mrc");
28          URL resource = getClass().getResource("duke.mrc");
29          File file = new File(resource.toURI());
30  
31          String marcXMLFileName = marcXMLGenerator.convertRawMarcToXML(file);
32          assertNotNull(marcXMLFileName);
33  
34          File marcXMLFile = new File(marcXMLFileName);
35          String marcXML = new FileUtil().readFile(marcXMLFile);
36          LOG.info(marcXML);
37  
38          FileUtils.deleteQuietly(marcXMLFile);
39  
40      }
41  
42      @Test
43      public void testGenerateMarcXMLFromRawMarcContent() throws Exception {
44          MarcXMLGenerator marcXMLGenerator = new MarcXMLGenerator();
45          URL resource = getClass().getResource("iu.mrc");
46          File file = new File(resource.toURI());
47  
48          String fileContent = new FileUtilForRawMarc().readFile(file);
49  
50          String marcContent = marcXMLGenerator.convert(fileContent);
51          assertNotNull(marcContent);
52          LOG.info(marcContent);
53      }
54  }