View Javadoc

1   package org.kuali.ole.ingest;
2   
3   import org.junit.Test;
4   import org.kuali.ole.ingest.pojo.OlePatron;
5   import org.kuali.ole.ingest.pojo.OlePatronGroup;
6   
7   import java.io.File;
8   import java.net.URL;
9   import java.util.List;
10  
11  import static junit.framework.Assert.assertNotNull;
12  
13  
14  public class OlePatronRecordHandler_UT {
15      @Test
16      public void testBuildPatronFromFileContent() throws Exception {
17          URL resource = getClass().getResource("samplePatronRecord.xml");
18          File file = new File(resource.toURI());
19          String patronXML = new FileUtil().readFile(file);
20          OlePatronRecordHandler olePatronRecordHandler =
21                  new OlePatronRecordHandler();
22  
23          OlePatronGroup patron = olePatronRecordHandler.buildPatronFromFileContent(patronXML);
24          assertNotNull(patron);
25      }
26  
27      @Test
28      public void testToXML() throws Exception {
29          URL resource = getClass().getResource("samplePatronRecord.xml");
30          File file = new File(resource.toURI());
31          String patronXML = new FileUtil().readFile(file);
32          OlePatronRecordHandler olePatronRecordHandler =
33                  new OlePatronRecordHandler();
34  
35          OlePatronGroup patron = olePatronRecordHandler.buildPatronFromFileContent(patronXML);
36          assertNotNull(patron);
37          List<OlePatron> olePatron = patron.getPatronGroup();
38          String toXML = olePatronRecordHandler.toXML(olePatron);
39          assertNotNull(toXML);
40      }
41  
42  }