Package org.jmock

Examples of org.jmock.Mockery


        mockery.checking(new Expectations() {{
            allowing(ctx).introspector();
            will(returnValue(new Introspector(JMock2TestPluginTest.this)));
            one(ctx).attributes().set(with(JMock2TestPlugin.MOCKERY), with(any(Mockery.class)));
        }});
        Mockery current = mockery;
        plugin.prepareTestInstance(ctx);
        assertEquals(mockery, current);
    }
View Full Code Here


            will(returnValue(new Introspector(test)));
            one(ctx).attributes().set(with(JMock2TestPlugin.MOCKERY), with(any(Mockery.class)));
        }});
        assertNotNull(test.mockery1);
        assertNull(test.mockery2);
        Mockery current = test.mockery1;
        plugin.prepareTestInstance(ctx);
        assertNotNull(test.mockery1);
        assertNotNull(test.mockery2);
        assertFalse(current.equals(test.mockery1));
    }
View Full Code Here

    @Test
    public void test_provider_field() throws Exception {
        final ProviderTest test = new ProviderTest() {
            @MockContextProvider
            private Mockery m = new Mockery();
        };
        mockery.checking(new Expectations() {{
            allowing(ctx).introspector();
            will(returnValue(new Introspector(test)));
            one(ctx).attributes().set(with(JMock2TestPlugin.MOCKERY), with(any(Mockery.class)));
View Full Code Here

    @Test
    public void test_provider_method() throws Exception {
        final ProviderTest test = new ProviderTest() {
            @MockContextProvider
            private Mockery build() {
                return new Mockery();
            }
        };
        mockery.checking(new Expectations() {{
            allowing(ctx).introspector();
            will(returnValue(new Introspector(test)));
View Full Code Here

    @Test
    public void test_provider_method_before_field() throws Exception {
        final ProviderTest test = new ProviderTest() {
            @MockContextProvider
            private Mockery m = new Mockery();

            @MockContextProvider
            private Mockery build() {
                return JMock2TestPluginTest.this.mockery3;
            }
View Full Code Here

        mockery.assertIsSatisfied();
    }

    @MockContextProvider
    Mockery buildMockery() {
        Mockery m = new Mockery();
        m.setImposteriser(ClassImposteriser.INSTANCE);
        m.setNamingScheme(LastWordNamingScheme.INSTANCE);
        m.setExpectationErrorTranslator(null);
        return m;
    }
View Full Code Here

    }

    @Override
    public void prepareTestInstance(TestContext context) {
        List<Field> mocks = context.introspector().selectFields(fieldsAnnotatedBy(Mock.class));
        Mockery mockery = findProvidedMockery(context);
        if (mockery == null) {
            mockery = new Mockery();
            for (Field mock : mocks) {
                if (!mock.getType().isInterface()) {
                    mockery.setImposteriser(ClassImposteriser.INSTANCE);
                    break;
                }
            }
        }
        context.attributes().set(MOCKERY, mockery);
        for (Field field : context.introspector().selectFields(and(fieldsAccepting(Mockery.class), fieldsAnnotatedBy(MockContext.class)))) {
            context.introspector().set(field, mockery);
        }
        for (Field field : mocks) {
            context.introspector().set(field, mockery.mock(field.getType(), field.getDeclaringClass().getName() + "." + field.getName()));
        }
    }
View Full Code Here

    Context ctx;
    JMock2TestPlugin plugin = new JMock2TestPlugin();

    @BeforeMethod
    public void setup() {
        mockery = new Mockery();
        ctx = mockery.mock(Context.class);
    }
View Full Code Here

        mockery.checking(new Expectations() {{
            allowing(ctx).getTest();
            will(returnValue(new TestInstance(JMock2TestPluginTest.this)));
            one(ctx).setAttribute(with("org.jmock.Mockery"), with(any(Mockery.class)));
        }});
        Mockery current = mockery;
        plugin.prepareTestInstance(ctx);
        assertEquals(mockery, current);
    }
View Full Code Here

            will(returnValue(new TestInstance(test)));
            one(ctx).setAttribute(with("org.jmock.Mockery"), with(any(Mockery.class)));
        }});
        assertNotNull(test.mockery1);
        assertNull(test.mockery2);
        Mockery current = test.mockery1;
        plugin.prepareTestInstance(ctx);
        assertNotNull(test.mockery1);
        assertNotNull(test.mockery2);
        assertFalse(current.equals(test.mockery1));
    }
View Full Code Here

TOP

Related Classes of org.jmock.Mockery

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.