Package com.mockobjects.dynamic

Examples of com.mockobjects.dynamic.Mock.proxy()


        String actionName = "my.actionName";
        TreeMap params = new TreeMap();
        params.put("hello", "world");
        params.put("foo", "bar");

        String urlString = urlHelper.buildUrl(actionName, (HttpServletRequest) mockHttpServletRequest.proxy(), (HttpServletResponse) mockHttpServletResponse.proxy(), params, null, true, true, false, false);
        assertEquals(expectedString, urlString);
    }

    public void testBuildUrlWithStringArray() {
        String expectedString = "my.actionName?foo=bar&hello=earth&hello=mars";
View Full Code Here


        String actionName = "my.actionName";
        TreeMap params = new TreeMap();
        params.put("hello", new String[]{"earth", "mars"});
        params.put("foo", "bar");

        String urlString = urlHelper.buildUrl(actionName, (HttpServletRequest) mockHttpServletRequest.proxy(), (HttpServletResponse) mockHttpServletResponse.proxy(), params);
        assertEquals(expectedString, urlString);
    }

    /**
     * The UrlHelper should build a URL that starts with "https" followed by the server name when the scheme of the
View Full Code Here

        String actionName = "/MyAction.action";
        TreeMap params = new TreeMap();
        params.put("hello", new String[]{"earth", "mars"});
        params.put("foo", "bar");

        String urlString = urlHelper.buildUrl(actionName, (HttpServletRequest) mockHttpServletRequest.proxy(), (HttpServletResponse) mockHttpServletResponse.proxy(), params, "https", true, true);
        assertEquals(expectedString, urlString);
    }

    /**
     * The UrlHelper should build a URL that starts with "http" followed by the server name when the scheme of the
View Full Code Here

        Result result = actionMapping.getResult();
        assertNotNull(result);
        assertTrue(result instanceof ServletRedirectResult);

        Mock invMock = new Mock(ActionInvocation.class);
        ActionInvocation inv = (ActionInvocation) invMock.proxy();
        ActionContext ctx = ActionContext.getContext();
        ctx.put(ServletActionContext.HTTP_REQUEST, request);
        StrutsMockHttpServletResponse response = new StrutsMockHttpServletResponse();
        ctx.put(ServletActionContext.HTTP_RESPONSE, response);
        invMock.expectAndReturn("getInvocationContext", ctx);
View Full Code Here

            Mock mockEnum = createEnumMock(mockCycleCtx, PROP_NAMES,
                    PROP_VALUES, false);
            addEnumPair(mockEnum, "cycleCtx", mockCycleCtx.proxy());
            closeEnum(mockEnum);
            mockCycleCtx
                    .matchAndReturn(METHOD_LIST, C.eq(""), mockEnum.proxy());
            mockCycleCtx.matchAndReturn(METHOD_LOOKUP, C.eq("cycleCtx"),
                    mockCycleCtx.proxy());
        }
        else
        {
View Full Code Here

        }
        for (int i = 0; i < MISSING_NAMES.length; i++)
        {
            bindError(mockCtx, MISSING_NAMES[i]);
        }
        mockCtx.matchAndReturn("hashCode", System.identityHashCode(mockCtx.proxy()));
       
        return mockCtx;
    }

    /**
 
View Full Code Here

        mockActionProxy.expectAndReturn("getNamespace", "/html");

        Mock mockActionInvocation = new Mock(ActionInvocation.class);
        mockActionInvocation.expectAndReturn("getProxy", mockActionProxy.proxy());
        mockActionInvocation.expectAndReturn("getStack", stack);
        actionInvocation = (ActionInvocation) mockActionInvocation.proxy();
    }


    class Bean {
        private String location;
View Full Code Here

        HashMap ctx = new HashMap();
        mockValueStack.expectAndReturn("getContext", ctx);
        mockValueStack.expectAndReturn("getContext", ctx);
        mockValueStack.expectAndReturn("getContext", ctx);
       
        ActionComponent comp = new ActionComponent((ValueStack) mockValueStack.proxy(), req, res);
        comp.addParameter("foo", "bar");
        comp.addParameter("baz", new String[]{"jim", "sarah"});
        Map params = comp.createParametersForContext();
        assertNotNull(params);
        assertEquals(2, params.size());
View Full Code Here

    public void testHandleResultNotModified() throws IOException {

        Mock mockHandlerXml = new Mock(ContentTypeHandler.class);
        mockHandlerXml.matchAndReturn("getExtension", "xml");
        mgr.handlersByExtension.put("xml", (ContentTypeHandler) mockHandlerXml.proxy());
        mgr.handleResult(null, new DefaultHttpHeaders().withStatus(SC_NOT_MODIFIED), new Object());

        assertEquals(0, mockResponse.getContentLength());
    }
View Full Code Here

                C.eq(ContentTypeHandlerManager.STRUTS_REST_HANDLER_OVERRIDE_PREFIX+"xml")), "xmlOverride");
        mockContainer.expectAndReturn("getInstance", C.args(C.eq(String.class),
                C.eq(ContentTypeHandlerManager.STRUTS_REST_HANDLER_OVERRIDE_PREFIX+"json")), null);
       
        DefaultContentTypeHandlerManager mgr = new DefaultContentTypeHandlerManager();
        mgr.setContainer((Container) mockContainer.proxy());

        Map<String,ContentTypeHandler> handlers = mgr.handlersByExtension;
        assertNotNull(handlers);
        assertEquals(2, handlers.size());
        assertEquals(mockHandlerXmlOverride.proxy(), handlers.get("xml"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.