View Javadoc
1   package org.kuali.ole.web;
2   
3   import org.junit.After;
4   import org.junit.Before;
5   import org.junit.Test;
6   import org.kuali.ole.base.BaseTestCase;
7   import org.kuali.ole.docstore.model.enums.DocCategory;
8   import org.kuali.ole.docstore.model.enums.DocFormat;
9   import org.kuali.ole.docstore.model.enums.DocType;
10  import org.slf4j.Logger;
11  import org.slf4j.LoggerFactory;
12  import org.springframework.mock.web.MockHttpServletRequest;
13  import org.springframework.mock.web.MockHttpServletResponse;
14  
15  import java.io.File;
16  
17  
18  /**
19   * Created with IntelliJ IDEA.
20   * User: ?
21   * Date: 12/15/12
22   * Time: 10:21 AM
23   * To change this template use File | Settings | File Templates.
24   */
25  public class BulkIngestServlet_UT
26          extends BaseTestCase {
27      private Logger                  logger       = LoggerFactory.getLogger(BulkIngestServlet_UT.class);
28      private MockHttpServletRequest  mockRequest  = new MockHttpServletRequest();
29      private MockHttpServletResponse mockResponse = new MockHttpServletResponse();
30      BulkIngestServlet bulkIngestServlet = new BulkIngestServlet();
31  
32      /**
33       * Method to setUp
34       *
35       * @throws Exception
36       */
37      @Before
38      public void setUp() throws Exception {
39      }
40  
41      /**
42       * Method to tearDown
43       *
44       * @throws Exception
45       */
46      @After
47      public void tearDown() throws Exception {
48      }
49  
50  
51      @Test
52      public void testBulkIngestDocstoreRequest() throws Exception {
53          File inputDir = new File(
54                  this.getClass().getResource("repository" + File.separator + "bulkIngest-Work-Bib-Marc-20.xml").toURI());
55          mockRequest.setParameter("bulkIngestFolder1", inputDir.getAbsolutePath());
56          mockRequest.setParameter("bulkIngestDocCategory", DocCategory.WORK.getDescription());
57          mockRequest.setParameter("bulkIngestDocType", DocType.BIB.getDescription());
58          mockRequest.setParameter("bulkIngestDocFormat", DocFormat.MARC.getDescription());
59          mockRequest.setParameter("bulkIngestDataFormat", "DocStore Request");
60          mockRequest.setParameter("action", "Start");
61          try {
62              bulkIngestServlet.doGet(mockRequest, mockResponse);
63          }
64          catch (Exception e) {
65              logger.error(e.getMessage(), e);
66          }
67      }
68  
69  
70      @Test
71      public void testBulkIngestStandardDocFormat() throws Exception {
72          File inputDir = new File(
73                  this.getClass().getResource("repository" + File.separator + "bulkIngest-Work-Bib-Marc-20.xml").toURI());
74          mockRequest.setParameter("bulkIngestFolder1", inputDir.getAbsolutePath());
75          mockRequest.setParameter("bulkIngestDocCategory", DocCategory.WORK.getDescription());
76          mockRequest.setParameter("bulkIngestDocType", DocType.BIB.getDescription());
77          mockRequest.setParameter("bulkIngestDocFormat", DocFormat.MARC.getDescription());
78          mockRequest.setParameter("bulkIngestDataFormat", "Standard Doc Format");
79          mockRequest.setParameter("action", "Start");
80          try {
81              bulkIngestServlet.doGet(mockRequest, mockResponse);
82          }
83          catch (Exception e) {
84              logger.error(e.getMessage(), e);
85          }
86      }
87  
88      @Test
89      public void testStopBulkIngestProcess() throws Exception {
90          File inputDir = new File(
91                  this.getClass().getResource("repository" + File.separator + "bulkIngest-Work-Bib-Marc-20.xml").toURI());
92          mockRequest.setParameter("bulkIngestFolder1", inputDir.getAbsolutePath());
93          mockRequest.setParameter("bulkIngestDocCategory", DocCategory.WORK.getDescription());
94          mockRequest.setParameter("bulkIngestDocType", DocType.BIB.getDescription());
95          mockRequest.setParameter("bulkIngestDocFormat", DocFormat.MARC.getDescription());
96          mockRequest.setParameter("bulkIngestDataFormat", "Standard Doc Format");
97          mockRequest.setParameter("action", "Stop");
98          bulkIngestServlet.doGet(mockRequest, mockResponse);
99      }
100 
101 
102 }