Package org.easymock.tests

Examples of org.easymock.tests.IMethods


* @author OFFIS, Tammo Freese
*/
public class NameTest {
    @Test
    public void nameForMock() {
        final IMethods mock = createMock("mock", IMethods.class);
        mock.simpleMethod();
        replay(mock);
        try {
            verify(mock);
        } catch (final AssertionError expected) {
            final String actualMessage = expected.getMessage();
View Full Code Here


        }
    }

    @Test
    public void nameForStrictMock() {
        final IMethods mock = createStrictMock("mock", IMethods.class);
        mock.simpleMethod();
        replay(mock);
        try {
            verify(mock);
        } catch (final AssertionError expected) {
            final String actualMessage = expected.getMessage();
View Full Code Here

        }
    }

    @Test
    public void nameForNiceMock() {
        final IMethods mock = createNiceMock("mock", IMethods.class);
        mock.simpleMethod();
        replay(mock);
        try {
            verify(mock);
        } catch (final AssertionError expected) {
            final String actualMessage = expected.getMessage();
View Full Code Here

    }

    @Test
    public void nameForMocksControl() {
        final IMocksControl control = createControl();
        final IMethods mock = control.createMock("mock", IMethods.class);
        mock.simpleMethod();
        replay(mock);
        try {
            verify(mock);
        } catch (final AssertionError expected) {
            final String actualMessage = expected.getMessage();
View Full Code Here

    }

    @Test
    public void resumeIfFailure() {
        final IMethods mock = createMock(IMethods.class);
        expect(mock.oneArg(true)).andReturn("foo").anyTimes();
        replay(mock);

        mock.oneArg(true);

        try {
            mock.simpleMethod();
        } catch (final AssertionError error) {
        }

        mock.oneArg(true);

        verify(mock);
    }
View Full Code Here

        verify(mock);
    }

    @Test
    public void defaultResetToNice() {
        final IMethods mock = createMock(IMethods.class);

        expect(mock.oneArg(true)).andReturn("foo");
        replay(mock);

        resetToNice(mock);

        replay(mock);

        assertNull(mock.oneArg(true));

        verify(mock);
    }
View Full Code Here

        verify(mock);
    }

    @Test
    public void strictResetToDefault() {
        final IMethods mock = createStrictMock(IMethods.class);

        expect(mock.oneArg(true)).andReturn("foo");
        expect(mock.oneArg(false)).andReturn("foo");

        replay(mock);

        resetToDefault(mock);

        expect(mock.oneArg(false)).andReturn("foo");
        expect(mock.oneArg(true)).andReturn("foo");

        replay(mock);

        assertEquals("foo", mock.oneArg(false));
        assertEquals("foo", mock.oneArg(true));

        verify(mock);
    }
View Full Code Here

        verify(mock);
    }

    @Test
    public void niceToStrict() {
        final IMethods mock = createNiceMock(IMethods.class);

        expect(mock.oneArg(false)).andReturn("foo");

        replay(mock);

        assertNull(mock.oneArg(true));

        resetToStrict(mock);

        expect(mock.oneArg(false)).andReturn("foo");
        expect(mock.oneArg(true)).andReturn("foo");

        replay(mock);

        try {
            mock.oneArg(true);
            fail();
        } catch (final AssertionError e) {
        }

        assertEquals("foo", mock.oneArg(false));
        assertEquals("foo", mock.oneArg(true));

        verify(mock);
    }
View Full Code Here

        verifyAll();
    }

    @Test
    public void niceToStrict() {
        final IMethods mock1 = createNiceMock(IMethods.class);
        final IMethods mock2 = createNiceMock(IMethods.class);

        expect(mock1.oneArg(false)).andReturn("foo");
        expect(mock2.oneArg(false)).andReturn("foo");

        replayAll();

        assertNull(mock1.oneArg(true));
        assertNull(mock2.oneArg(true));

        resetAllToStrict();

        expect(mock1.oneArg(false)).andReturn("foo");
        expect(mock1.oneArg(true)).andReturn("foo");
        expect(mock2.oneArg(false)).andReturn("foo");
        expect(mock2.oneArg(true)).andReturn("foo");

        replayAll();

        try {
            mock1.oneArg(true);
            fail("Should be strict");
        } catch (final AssertionError e) {
        }
        try {
            mock2.oneArg(true);
            fail("Should be strict");
        } catch (final AssertionError e) {
        }

        assertEquals("foo", mock1.oneArg(false));
        assertEquals("foo", mock1.oneArg(true));
        assertEquals("foo", mock2.oneArg(false));
        assertEquals("foo", mock2.oneArg(true));

        verifyAll();
    }
View Full Code Here

    @Rule
    public FilteringRule rule = new FilteringRule("net.sf.cglib", "org.objenesis");

    @Test
    public void testInterfaceMocking() {
        final IMethods mock = createMock(IMethods.class);
        expect(mock.booleanReturningMethod(1)).andReturn(true);
        replayAll();
        assertTrue(mock.booleanReturningMethod(1));
        verifyAll();
    }
View Full Code Here

TOP

Related Classes of org.easymock.tests.IMethods

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.