001package org.kuali.ole;
002
003import org.junit.Before;
004import org.junit.Ignore;
005import org.junit.Test;
006import org.kuali.ole.service.OleDiagnosticsService;
007import org.kuali.ole.service.OleSRUWebService;
008import org.kuali.ole.serviceimpl.OleDiagnosticsServiceImpl;
009import org.kuali.ole.serviceimpl.OleSRUWebServiceImpl;
010import org.kuali.rice.core.api.config.property.Config;
011import org.mockito.Mock;
012import org.mockito.Mockito;
013import org.mockito.MockitoAnnotations;
014import org.slf4j.Logger;
015import org.slf4j.LoggerFactory;
016
017import java.util.HashMap;
018import java.util.Map;
019
020import static junit.framework.Assert.assertNotNull;
021/**
022 * Created with IntelliJ IDEA.
023 * User: ?
024 * Date: 7/19/12
025 * Time: 7:13 PM
026 * To change this template use File | Settings | File Templates.
027 */
028
029public class OleSRUWebService_UT extends BaseTestCase {
030
031    private static Logger LOG = LoggerFactory.getLogger(OleValidateInputRequestService_UT.class);
032    private OleSRUWebService oleSRUWebService=new OleSRUWebServiceImpl();
033    private OleDiagnosticsService OleDiagnosticsServiceImpl=new OleDiagnosticsServiceImpl();
034
035    @Mock
036    private Config mockConfig;
037
038    @Before
039    public void setUp() throws Exception {
040        MockitoAnnotations.initMocks(this);
041        Mockito.when(mockConfig.getProperty("invalid.record.schema")).thenReturn("");
042        ((OleDiagnosticsServiceImpl) OleDiagnosticsServiceImpl).setCurrentContextConfig(mockConfig);
043        ((OleSRUWebServiceImpl)oleSRUWebService).setOleDiagnosticsService(OleDiagnosticsServiceImpl);
044        ((OleSRUWebServiceImpl) oleSRUWebService).setCurrentContextConfig(mockConfig);
045
046    }
047
048    @Test
049    public void testInputRequestValidation() throws Exception{
050
051        Map reqParamMap=getReqParameters();
052        String respXML=oleSRUWebService.getOleSRUResponse(reqParamMap);
053        assertNotNull(respXML);
054    }
055
056    public Map getReqParameters() {
057
058        HashMap reqParamMap=new HashMap();
059        reqParamMap.put(OleSRUConstants.OperationType,OleSRUConstants.SEARCH_RETRIEVE);
060        reqParamMap.put(OleSRUConstants.VERSION,"1.1");
061        reqParamMap.put(OleSRUConstants.QUERY,"title=HTC");
062        reqParamMap.put(OleSRUConstants.START_RECORD,"1");
063        reqParamMap.put(OleSRUConstants.MAXIMUM_RECORDS,"10");
064        reqParamMap.put(OleSRUConstants.RECORD_PACKING,"xml");
065        reqParamMap.put(OleSRUConstants.RECORD_SCHEMA,"recordSchema");
066
067        return reqParamMap;
068
069    }
070
071  }