View Javadoc
1   package org.kuali.ole.web;
2   
3   import org.apache.commons.io.FileUtils;
4   import org.junit.After;
5   import org.junit.Before;
6   import org.junit.Ignore;
7   import org.junit.Test;
8   import org.kuali.ole.RepositoryBrowser;
9   import org.kuali.ole.base.BaseTestCase;
10  import org.kuali.ole.docstore.indexer.solr.IndexerService;
11  import org.kuali.ole.docstore.model.enums.DocCategory;
12  import org.kuali.ole.docstore.model.enums.DocFormat;
13  import org.kuali.ole.docstore.model.enums.DocType;
14  import org.mockito.Mock;
15  import org.springframework.mock.web.MockHttpServletRequest;
16  import org.springframework.mock.web.MockHttpServletResponse;
17  import org.springframework.mock.web.MockServletContext;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  /**
23   * Created with IntelliJ IDEA.
24   * User: ?
25   * Date: 12/17/12
26   * Time: 12:03 AM
27   * To change this template use File | Settings | File Templates.
28   */
29  @Ignore
30  @Deprecated
31  public class GetUUIDServlet_UT
32          extends BaseTestCase {
33  
34      private RepositoryBrowser repositoryBrowser;
35      private MockHttpServletRequest  mockRequest  = new MockHttpServletRequest();
36      private MockHttpServletResponse mockResponse = new MockHttpServletResponse();
37      private MockServletContext mockServletContext = new MockServletContext();
38      GetUUIDServlet getUUIDServlet = new GetUUIDServlet();
39      private static final String RESULTS_JSP =
40                 "/getUUIDResults.jsp";
41      @Mock
42      private IndexerService mockIndexerService;
43  
44      @Override
45      @Before
46      public void setUp() throws Exception {
47          super.setUp();    //To change body of overridden methods use File | Settings | File Templates.
48      }
49  
50      @After
51      public void tearDown() throws Exception {
52      }
53  
54      @Test
55      public void testGetUUIDs() throws Exception {
56          List<String> uuidsList = new ArrayList<String>();
57          String category = DocCategory.WORK.getDescription();
58          String type = DocType.BIB.getDescription();
59          String format = DocFormat.MARC.getDescription();
60          String numUUIDs = "4";
61  
62  //        //Servlet code : Having problem with servlet context
63  //        mockRequest.setParameter("category", category );
64  //        mockRequest.setParameter("type", type );
65  //        mockRequest.setParameter("format", format );
66  //        mockRequest.setParameter("numUUIDs", numUUIDs );
67  //        getUUIDServlet.service(mockRequest, mockResponse);
68  //        getUUIDServlet.doPost(mockRequest, mockResponse);
69  //        System.out.println(mockRequest.getAttribute("result"));
70  //
71  
72  
73         try {
74              if (null != category && null != format && null != numUUIDs) {
75                  uuidsList = getRepositoryBrowser()
76                          .getUUIDs(category.toLowerCase(), type.toLowerCase(), format.toLowerCase(),
77                                    new Integer(numUUIDs));
78              }
79          }
80          catch (Exception e) {
81              uuidsList.add(e.getMessage());
82          }
83  
84          if(uuidsList.size() > 0 ){
85              System.out.println("UUIDs");
86              for(String uuid : uuidsList){
87              System.out.println(uuid);
88          }
89          }
90  
91      }
92  
93      public RepositoryBrowser getRepositoryBrowser() {
94          if (null == repositoryBrowser) {
95              repositoryBrowser = new RepositoryBrowser();
96          }
97          return repositoryBrowser;
98      }
99  }