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.xmlpojo.ingest.Response;
8   import org.kuali.ole.service.MultiPartBagRequestClient;
9   import org.springframework.mock.web.MockHttpServletRequest;
10  import org.springframework.mock.web.MockHttpServletResponse;
11  
12  import java.io.File;
13  import java.util.List;
14  
15  /**
16   * Created with IntelliJ IDEA.
17   * User: ?
18   * Date: 12/17/12
19   * Time: 12:56 AM
20   * To change this template use File | Settings | File Templates.
21   */
22  public class MultiPartBagRequestClientServlet_UT extends BaseTestCase {
23      private MockHttpServletRequest  mockRequest  = new MockHttpServletRequest();
24      private MockHttpServletResponse mockResponse = new MockHttpServletResponse();
25      MultiPartBagRequestClientServlet bagRequestClientServlet = new MultiPartBagRequestClientServlet();
26  
27      @Override
28            @Before
29            public void setUp() throws Exception {
30                super.setUp();    //To change body of overridden methods use File | Settings | File Templates.
31            }
32  
33            @After
34            public void tearDown() throws Exception {
35            }
36  
37      @Test
38      public void testMultiPartBagItIngest() throws Exception {
39          File inputDir = new File(this.getClass().getResource("license/ingest").toURI());
40          mockRequest.setParameter("restUrl","http://dev.docstore.ole.kuali.org/rest/documents" );
41          mockRequest.setParameter("requestFolderPath", inputDir.getPath());
42          bagRequestClientServlet.doGet(mockRequest, mockResponse);
43  
44          /*MultiPartBagRequestClient multiPartBagRequestClient = new MultiPartBagRequestClient();
45          List<Response> responseList = multiPartBagRequestClient.runMultiPartRequestsAtLocation(inputDir.getPath(), null);
46          Response response = responseList.get(0);
47          String responseString = new org.kuali.ole.docstore.model.xstream.ingest.ResponseHandler().toXML(response);
48          System.out.println("bagIt Ingest Response" + responseString);
49  */
50      }
51  
52      @Test
53      public void testMultiPartBagItCheckout() throws Exception {
54          File inputDir = new File(this.getClass().getResource("license/checkout").toURI());
55          MultiPartBagRequestClient multiPartBagRequestClient = new MultiPartBagRequestClient();
56          List<Response> responseList = multiPartBagRequestClient.runMultiPartRequestsAtLocation(inputDir.getPath(), null);
57          Response response = responseList.get(0);
58          String responseString = new org.kuali.ole.docstore.model.xstream.ingest.ResponseHandler().toXML(response);
59          System.out.println("bagIt Checkout Response" + responseString);
60  
61      }
62  
63      @Test
64      public void testMultiPartBagItCheckin() throws Exception {
65          File inputDir = new File(this.getClass().getResource("license/checkin").toURI());
66          MultiPartBagRequestClient multiPartBagRequestClient = new MultiPartBagRequestClient();
67          List<Response> responseList = multiPartBagRequestClient.runMultiPartRequestsAtLocation(inputDir.getPath(), null);
68          Response response = responseList.get(0);
69          String responseString = new org.kuali.ole.docstore.model.xstream.ingest.ResponseHandler().toXML(response);
70          System.out.println("bagIt Checkin Response" + responseString);
71  
72      }
73  
74      @Test
75      public void testMultiPartBagItDelete() throws Exception {
76          File inputDir = new File(this.getClass().getResource("license/delete").toURI());
77          MultiPartBagRequestClient multiPartBagRequestClient = new MultiPartBagRequestClient();
78          List<Response> responseList = multiPartBagRequestClient.runMultiPartRequestsAtLocation(inputDir.getPath(), null);
79          Response response = responseList.get(0);
80          String responseString = new org.kuali.ole.docstore.model.xstream.ingest.ResponseHandler().toXML(response);
81          System.out.println("bagIt Delete Response" + responseString);
82  
83      }
84  }