View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.docstore.discovery.solr.work.bib.dublin;
17  
18  import org.apache.commons.io.FileUtils;
19  import org.apache.solr.common.SolrInputDocument;
20  import org.junit.After;
21  import org.junit.Before;
22  import org.junit.Test;
23  import org.kuali.ole.docstore.discovery.BaseTestCase;
24  import org.kuali.ole.docstore.model.xmlpojo.work.bib.dublin.WorkBibDublinRecord;
25  import org.kuali.ole.docstore.model.xstream.work.bib.dublin.WorkBibDublinRecordProcessor;
26  import org.slf4j.Logger;
27  import org.slf4j.LoggerFactory;
28  
29  import java.io.File;
30  import java.net.URL;
31  
32  import static org.junit.Assert.fail;
33  
34  /**
35   * Class to Test WorkBibDublinDocBuilder.
36   *
37   * @author Rajesh Chowdary K
38   */
39  public class WorkBibDublinDocBuilder_UT extends BaseTestCase {
40      private static final Logger LOG = LoggerFactory.getLogger(WorkBibDublinDocBuilder_UT.class);
41  
42      private WorkBibDublinRecord record = new WorkBibDublinRecord();
43  
44      @Before
45      public void setUp() throws Exception {
46          String resFile = "/bib/bib/dublin/Bib-Bib-DublinQ-Test1.xml";
47          URL resource = getClass().getResource(resFile);
48          File file = new File(resource.toURI());
49          String fileContent;
50          fileContent = FileUtils.readFileToString(file);
51          WorkBibDublinRecordProcessor processor = new WorkBibDublinRecordProcessor();
52          record = processor.fromXML(fileContent);
53  //		LOG.info(record);
54      }
55  
56      @After
57      public void tearDown() throws Exception {
58      }
59  
60      @Test
61      public void testBuildSolrInputDocument() {
62          try {
63              WorkBibDublinDocBuilder builder = new WorkBibDublinDocBuilder();
64              SolrInputDocument sid = builder.buildSolrInputDocument(record);
65              LOG.info(sid.toString());
66          } catch (Exception e) {
67              LOG.error(e.getMessage() , e);
68              fail("Failed due to: " + e);
69  
70          }
71  
72      }
73  
74  }