Package com.mockobjects.dynamic

Examples of com.mockobjects.dynamic.Mock


     * inherit from EventSource. This should cause an exception.
     */
    @Test(expected = IllegalArgumentException.class)
    public void testEnableRuntimeExceptionsInvalid()
    {
        ConfigurationUtils.enableRuntimeExceptions((Configuration) new Mock(
                Configuration.class).proxy());
    }
View Full Code Here


    public void testEnableRuntimeExceptionsInvalid()
    {
        try
        {
            ConfigurationUtils
                    .enableRuntimeExceptions((Configuration) new Mock(
                            Configuration.class).proxy());
            fail("Could enable exceptions for non EventSource configuration!");
        }
        catch (IllegalArgumentException iex)
        {
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);
        invMock.expectAndReturn("getStack", ctx.getValueStack());
        result.execute(inv);
        assertEquals("http://www.google.com", response.getRedirectURL());
        //TODO: need to test location but there's noaccess to the property/method, unless we use reflection
    }
View Full Code Here

     * @param prefix the prefix
     * @return the mock for the context
     */
    private Mock createCtxMock(String prefix)
    {
        Mock mockCtx = new Mock(Context.class);
        for (int i = 0; i < PROP_NAMES.length; i++)
        {
            bind(mockCtx, prefix + PROP_NAMES[i], PROP_VALUES[i]);
            String errProp = (prefix.length() > 0) ? PROP_NAMES[i] : PREFIX
                    + PROP_NAMES[i];
            bindError(mockCtx, errProp);
        }
        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

     * @return the mock for the enumeration
     */
    private Mock createEnumMock(Mock mockCtx, String[] names, Object[] values,
            boolean close)
    {
        Mock mockEnum = new Mock(NamingEnumeration.class);
        for (int i = 0; i < names.length; i++)
        {
            addEnumPair(mockEnum, names[i], values[i]);
        }
        if (close)
View Full Code Here

    public void testEnableRuntimeExceptionsInvalid()
    {
        try
        {
            ConfigurationUtils
                    .enableRuntimeExceptions((Configuration) new Mock(
                            Configuration.class).proxy());
            fail("Could enable exceptions for non EventSource configuration!");
        }
        catch (IllegalArgumentException iex)
        {
View Full Code Here

        namespace = "/html";
        result = new VelocityResult();
        stack = ActionContext.getContext().getValueStack();
        ActionContext.getContext().setValueStack(stack);
        velocity = new TestVelocityEngine();
        mockActionProxy = new Mock(ActionProxy.class);
        mockActionProxy.expectAndReturn("getNamespace", "/html");

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

public class CompositeActionMapperTest extends TestCase {

    Mock mockContainer;
   
    public void setUp() throws Exception {
        mockContainer = new Mock(Container.class);
    }
View Full Code Here

        assertEquals(value, sessionMap.remove("KEY"));
        sessionMock.verify();
    }

    protected void setUp() throws Exception {
        sessionMock = new Mock(HttpSession.class);
        requestMock = new Mock(HttpServletRequest.class);
        requestMock.matchAndReturn("getSession", new Constraint[]{new IsEqual(Boolean.FALSE)}, sessionMock.proxy());
    }
View Full Code Here

    }

    protected void setUp() throws Exception {
        super.setUp();
        result = new HttpHeaderResult();
        responseMock = new Mock(HttpServletResponse.class);
        response = (HttpServletResponse) responseMock.proxy();
        invocation = (ActionInvocation) new Mock(ActionInvocation.class).proxy();
        reflectionProvider = container.getInstance(ReflectionProvider.class);
        ServletActionContext.setResponse(response);
    }
View Full Code Here

TOP

Related Classes of com.mockobjects.dynamic.Mock

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.