View Javadoc
1   package org.kuali.ole;
2   
3   import org.junit.Before;
4   import org.junit.Ignore;
5   import org.junit.Test;
6   import org.kuali.ole.service.OleDiagnosticsService;
7   import org.kuali.ole.service.OleSRUWebService;
8   import org.kuali.ole.serviceimpl.OleDiagnosticsServiceImpl;
9   import org.kuali.ole.serviceimpl.OleSRUWebServiceImpl;
10  import org.kuali.rice.core.api.config.property.Config;
11  import org.mockito.Mock;
12  import org.mockito.Mockito;
13  import org.mockito.MockitoAnnotations;
14  import org.slf4j.Logger;
15  import org.slf4j.LoggerFactory;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  import static junit.framework.Assert.assertNotNull;
21  /**
22   * Created with IntelliJ IDEA.
23   * User: ?
24   * Date: 7/19/12
25   * Time: 7:13 PM
26   * To change this template use File | Settings | File Templates.
27   */
28  
29  public class OleSRUWebService_UT extends BaseTestCase {
30  
31      private static Logger LOG = LoggerFactory.getLogger(OleValidateInputRequestService_UT.class);
32      private OleSRUWebService oleSRUWebService=new OleSRUWebServiceImpl();
33      private OleDiagnosticsService OleDiagnosticsServiceImpl=new OleDiagnosticsServiceImpl();
34  
35      @Mock
36      private Config mockConfig;
37  
38      @Before
39      public void setUp() throws Exception {
40          MockitoAnnotations.initMocks(this);
41          Mockito.when(mockConfig.getProperty("invalid.record.schema")).thenReturn("");
42          ((OleDiagnosticsServiceImpl) OleDiagnosticsServiceImpl).setCurrentContextConfig(mockConfig);
43          ((OleSRUWebServiceImpl)oleSRUWebService).setOleDiagnosticsService(OleDiagnosticsServiceImpl);
44          ((OleSRUWebServiceImpl) oleSRUWebService).setCurrentContextConfig(mockConfig);
45  
46      }
47  
48      @Test
49      public void testInputRequestValidation() throws Exception{
50  
51          Map reqParamMap=getReqParameters();
52          String respXML=oleSRUWebService.getOleSRUResponse(reqParamMap);
53          assertNotNull(respXML);
54      }
55  
56      public Map getReqParameters() {
57  
58          HashMap reqParamMap=new HashMap();
59          reqParamMap.put(OleSRUConstants.OperationType,OleSRUConstants.SEARCH_RETRIEVE);
60          reqParamMap.put(OleSRUConstants.VERSION,"1.1");
61          reqParamMap.put(OleSRUConstants.QUERY,"title=HTC");
62          reqParamMap.put(OleSRUConstants.START_RECORD,"1");
63          reqParamMap.put(OleSRUConstants.MAXIMUM_RECORDS,"10");
64          reqParamMap.put(OleSRUConstants.RECORD_PACKING,"xml");
65          reqParamMap.put(OleSRUConstants.RECORD_SCHEMA,"recordSchema");
66  
67          return reqParamMap;
68  
69      }
70  
71    }