Package com.rop

Examples of com.rop.RopContext


     * @param serviceRouter
     */
    @Test
    public void testSimplestConfig() {
        assertNotNull(serviceRouter);
        RopContext ropContext = serviceRouter.getRopContext();
        assertNotNull(ropContext);
        assertTrue(ropContext.isSignEnable());
        assertNotNull(serviceRouter.getApplicationContext());
        assertEquals(serviceRouter.getExtErrorBasename(), "i18n/rop/ropError");
        assertEquals(serviceRouter.getListeners().size(), 0);
        assertEquals(serviceRouter.getInterceptors().size(), 0);
        assertNotNull(serviceRouter.getFormattingConversionService());
View Full Code Here


    @Test
    public void testIpParsed() {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        SessionManager sessionManager = mock(SessionManager.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);
        RopContext ropContext = mock(RopContext.class);

        //构造HttpServletRequest
        MockHttpServletRequest servletRequest = new MockHttpServletRequest();
        servletRequest.setRemoteAddr("1.1.1.1");
View Full Code Here

    public void testBuildBySysParams1() throws Exception {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        SessionManager sessionManager = mock(SessionManager.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);

        RopContext ropContext = mock(RopContext.class);
        ServiceMethodHandler methodHandler = mock(ServiceMethodHandler.class);
        when(ropContext.getServiceMethodHandler("method1", "3.0")).thenReturn(methodHandler);

        //构造HttpServletRequest
        MockHttpServletRequest servletRequest = new MockHttpServletRequest();

        servletRequest.setParameter(SystemParameterNames.getAppKey(), "appKey1");
View Full Code Here

    @Test
    public void testBuildBySysParams2() throws Exception {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        SessionManager sessionManager = mock(SessionManager.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);
        RopContext ropContext = mock(RopContext.class);


        //构造HttpServletRequest
        MockHttpServletRequest servletRequest = new MockHttpServletRequest();
        servletRequest.setParameter(SystemParameterNames.getLocale(), "xxx");
View Full Code Here

    @Test(expectedExceptions = {IllegalArgumentException.class})
    public void testBuildBySysParams3() throws Exception {
        FormattingConversionService conversionService = mock(FormattingConversionService.class);
        ServletRequestContextBuilder requestContextBuilder = new ServletRequestContextBuilder(conversionService);

        RopContext ropContext = mock(RopContext.class);
        ServiceMethodHandler methodHandler = mock(ServiceMethodHandler.class);
        when(ropContext.getServiceMethodHandler("method1", "3.0")).thenReturn(methodHandler);

        //创建SimpleRequestContext
        SimpleRopRequestContext requestContext =
                requestContextBuilder.buildBySysParams(ropContext, new Object(),null);
    }
View Full Code Here

*/
public class RopRequestMessageConverterTest {

    @Test
    public void testConvertOfXmlFormat() throws Exception {
        RopContext ropContext = mock(RopContext.class);
        SimpleRopRequestContext context = new SimpleRopRequestContext(ropContext);
        context.setMessageFormat(MessageFormat.xml);

        TypeDescriptor addrTypeDescriptor = TypeDescriptor.valueOf(Addresss.class);
        TypeDescriptor strTypeDescriptor = TypeDescriptor.valueOf(String.class);
View Full Code Here

        assertEquals(addresss.getStreets().size(), 2);
    }

    @Test
    public void testConvertOfJsonFormat() throws Exception {
        RopContext ropContext = mock(RopContext.class);
        SimpleRopRequestContext context = new SimpleRopRequestContext(ropContext);
        context.setMessageFormat(MessageFormat.json);

        TypeDescriptor addrTypeDescriptor = TypeDescriptor.valueOf(Addresss.class);
        TypeDescriptor strTypeDescriptor = TypeDescriptor.valueOf(String.class);
View Full Code Here

        ApplicationContext context = mock(ApplicationContext.class);
        when(context.getBeanNamesForType(Object.class)).thenReturn(new String[]{"service1"});
        Class withoutGroupServiceClass = WithoutGroupService.class;
        when(context.getType("service1")).thenReturn(withoutGroupServiceClass);

        RopContext registryMethod = new DefaultRopContext(context);
        ServiceMethodHandler handler = registryMethod.getServiceMethodHandler("service.method1", "1.0");
        ServiceMethodDefinition definition = handler.getServiceMethodDefinition();
        assertNotNull(definition);
        assertEquals(definition.getMethod(), "service.method1");
        assertEquals(definition.getMethodTitle(), "测试方法1");
        assertEquals(definition.getMethodGroup(), "GROUP1");
View Full Code Here

        ApplicationContext context = mock(ApplicationContext.class);

        when(context.getBeanNamesForType(Object.class)).thenReturn(new String[]{"service1"});
        Class withGroupServiceClass = WithGroupService.class;
        when(context.getType("service1")).thenReturn(withGroupServiceClass);
        RopContext ropContext = new DefaultRopContext(context);

        //method1:都在ServiceMethodGroup中定义,在ServiceMethod中直接采用
        ServiceMethodHandler handler = ropContext.getServiceMethodHandler("service.method1", "1.0");
        ServiceMethodDefinition definition = handler.getServiceMethodDefinition();
        assertNotNull(definition);
        assertEquals(definition.getMethod(), "service.method1");
        assertEquals(definition.getMethodTitle(), "测试方法1");
        assertEquals(definition.getMethodGroup(), "GROUP1");
        assertEquals(definition.getMethodGroupTitle(), "分组1");
        assertEquals(definition.getTags(), new String[]{"TAG1", "TAG2"});
        assertEquals(definition.isIgnoreSign(), true);
        assertEquals(definition.isNeedInSession(), false);
        assertEquals(definition.getTimeout(), 100);
        assertEquals(definition.getVersion(), "1.0");

        //method2:在ServiceMethodGroup中定义,在ServiceMethod显式覆盖之
        ServiceMethodHandler handler2 = ropContext.getServiceMethodHandler("service.method2", "2.0");
        ServiceMethodDefinition definition2 = handler2.getServiceMethodDefinition();
        assertNotNull(definition2);
        assertEquals(definition2.getMethod(), "service.method2");
        assertEquals(definition2.getMethodTitle(), "测试方法2");
        assertEquals(definition2.getMethodGroup(), "GROUP2");
View Full Code Here

        when(context.getBeanNamesForType(Object.class)).thenReturn(new String[]{"method1"});
        Class serviceClass = IgnoreSignRopRequestService.class;
        when(context.getType("method1")).thenReturn(serviceClass);

        RopContext ropContext = new DefaultRopContext(context);

        ServiceMethodHandler method1 = ropContext.getServiceMethodHandler("method1", "1.0");
        List<String> ignoreSignFieldNames = method1.getIgnoreSignFieldNames();
        assertNotNull(ignoreSignFieldNames);
        assertEquals(ignoreSignFieldNames.size(), 4);
        assertTrue(ignoreSignFieldNames.contains("field1"));
        assertTrue(ignoreSignFieldNames.contains("field3"));
View Full Code Here

TOP

Related Classes of com.rop.RopContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.