Examples of Mock


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

Examples of com.mockobjects.dynamic.Mock

    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

Examples of com.mockobjects.dynamic.Mock

        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

Examples of com.mockobjects.dynamic.Mock

     * @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

Examples of com.mockobjects.dynamic.Mock

     * @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

Examples of org.apache.camel.cdi.Mock

    @Inject CamelContextMap camelContextMap;

    @Produces
    @Mock
    public MockEndpoint createMockEndpoint(InjectionPoint point) {
        Mock annotation = point.getAnnotated().getAnnotation(Mock.class);
        ObjectHelper.notNull(annotation, "Should be annotated with @Mock");
        String uri = annotation.value();
        if (ObjectHelper.isEmpty(uri)) {
            uri = "mock:" + point.getMember().getName();
        }
        return CamelContextHelper.getMandatoryEndpoint(getCamelContext(point, annotation.context()), uri, MockEndpoint.class);
    }
View Full Code Here

Examples of org.apache.onami.test.annotation.Mock

            checkState( !isTypeConflicts, "   Found multiple annotation @%s for type: %s; binding skipped!.",
                        Mock.class.getSimpleName(), type );
            for ( final Field field : fields )
            {
                final TypeLiteral literal = TypeLiteral.get( type );
                final Mock annoBy = field.getAnnotation( Mock.class );
                final Object mock = this.mockedFields.get( field );
                if ( annoBy.annotatedWith() != Mock.NoAnnotation.class )
                {
                    bind( literal ).annotatedWith( annoBy.annotatedWith() ).toInstance( mock );
                }
                else if ( !"".equals( annoBy.namedWith() ) )
                {
                    bind( literal ).annotatedWith( Names.named( annoBy.namedWith() ) ).toInstance( mock );
                }
                else
                {
                    bind( literal ).toInstance( mock );
                }
View Full Code Here

Examples of org.jbehave.core.mock.Mock

/**
* set balance = -50
*/
public class AccountIsOverdrawn extends GivenUsingMiniMock {
    public void setUp(World world) {
        Mock accountMock = (Mock)world.get("account", mock(Account.class));
        accountMock.stubs("getBalance").will(returnValue(-50));
    }
View Full Code Here

Examples of org.jbehave.core.mock.Mock

/** set overdraft limit = 0 */
public class AccountDoesNotHaveOverdraftFacility extends GivenUsingMiniMock {

    public void setUp(World world) {
        Mock account = (Mock) world.get("account", mock(Account.class));
        account.stubs("getOverdraftLimit").withNoArguments().will(returnValue(0));
    }
View Full Code Here

Examples of org.jbehave.core.mock.Mock

/** set balance = 50 */
public class AccountIsInCredit extends GivenUsingMiniMock {
   
    public void setUp(World world) {
        Mock account = (Mock) world.get("account", mock(Account.class));
        account.stubs("getBalance").withNoArguments().will(returnValue(50));
    }
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.