001package org.kuali.ole.web; 002 003import org.junit.After; 004import org.junit.Before; 005import org.junit.Test; 006import org.kuali.ole.base.BaseTestCase; 007import org.kuali.ole.docstore.model.enums.DocCategory; 008import org.kuali.ole.docstore.model.enums.DocFormat; 009import org.kuali.ole.docstore.model.enums.DocType; 010import org.slf4j.Logger; 011import org.slf4j.LoggerFactory; 012import org.springframework.mock.web.MockHttpServletRequest; 013import org.springframework.mock.web.MockHttpServletResponse; 014 015import java.io.File; 016 017 018/** 019 * Created with IntelliJ IDEA. 020 * User: ? 021 * Date: 12/15/12 022 * Time: 10:21 AM 023 * To change this template use File | Settings | File Templates. 024 */ 025public class BulkIngestServlet_UT 026 extends BaseTestCase { 027 private Logger logger = LoggerFactory.getLogger(BulkIngestServlet_UT.class); 028 private MockHttpServletRequest mockRequest = new MockHttpServletRequest(); 029 private MockHttpServletResponse mockResponse = new MockHttpServletResponse(); 030 BulkIngestServlet bulkIngestServlet = new BulkIngestServlet(); 031 032 /** 033 * Method to setUp 034 * 035 * @throws Exception 036 */ 037 @Before 038 public void setUp() throws Exception { 039 } 040 041 /** 042 * Method to tearDown 043 * 044 * @throws Exception 045 */ 046 @After 047 public void tearDown() throws Exception { 048 } 049 050 051 @Test 052 public void testBulkIngestDocstoreRequest() throws Exception { 053 File inputDir = new File( 054 this.getClass().getResource("repository" + File.separator + "bulkIngest-Work-Bib-Marc-20.xml").toURI()); 055 mockRequest.setParameter("bulkIngestFolder1", inputDir.getAbsolutePath()); 056 mockRequest.setParameter("bulkIngestDocCategory", DocCategory.WORK.getDescription()); 057 mockRequest.setParameter("bulkIngestDocType", DocType.BIB.getDescription()); 058 mockRequest.setParameter("bulkIngestDocFormat", DocFormat.MARC.getDescription()); 059 mockRequest.setParameter("bulkIngestDataFormat", "DocStore Request"); 060 mockRequest.setParameter("action", "Start"); 061 try { 062 bulkIngestServlet.doGet(mockRequest, mockResponse); 063 } 064 catch (Exception e) { 065 logger.error(e.getMessage(), e); 066 } 067 } 068 069 070 @Test 071 public void testBulkIngestStandardDocFormat() throws Exception { 072 File inputDir = new File( 073 this.getClass().getResource("repository" + File.separator + "bulkIngest-Work-Bib-Marc-20.xml").toURI()); 074 mockRequest.setParameter("bulkIngestFolder1", inputDir.getAbsolutePath()); 075 mockRequest.setParameter("bulkIngestDocCategory", DocCategory.WORK.getDescription()); 076 mockRequest.setParameter("bulkIngestDocType", DocType.BIB.getDescription()); 077 mockRequest.setParameter("bulkIngestDocFormat", DocFormat.MARC.getDescription()); 078 mockRequest.setParameter("bulkIngestDataFormat", "Standard Doc Format"); 079 mockRequest.setParameter("action", "Start"); 080 try { 081 bulkIngestServlet.doGet(mockRequest, mockResponse); 082 } 083 catch (Exception e) { 084 logger.error(e.getMessage(), e); 085 } 086 } 087 088 @Test 089 public void testStopBulkIngestProcess() throws Exception { 090 File inputDir = new File( 091 this.getClass().getResource("repository" + File.separator + "bulkIngest-Work-Bib-Marc-20.xml").toURI()); 092 mockRequest.setParameter("bulkIngestFolder1", inputDir.getAbsolutePath()); 093 mockRequest.setParameter("bulkIngestDocCategory", DocCategory.WORK.getDescription()); 094 mockRequest.setParameter("bulkIngestDocType", DocType.BIB.getDescription()); 095 mockRequest.setParameter("bulkIngestDocFormat", DocFormat.MARC.getDescription()); 096 mockRequest.setParameter("bulkIngestDataFormat", "Standard Doc Format"); 097 mockRequest.setParameter("action", "Stop"); 098 bulkIngestServlet.doGet(mockRequest, mockResponse); 099 } 100 101 102}