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
20
21
22
23
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
34
35
36
37 @Before
38 public void setUp() throws Exception {
39 }
40
41
42
43
44
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 }