Package org.easymock.tests

Examples of org.easymock.tests.IMethods


    private static final int THREAD_COUNT = 10;

    @Test
    public void testThreadSafe() throws Throwable {

        final IMethods mock = createMock(IMethods.class);
        expect(mock.oneArg("test")).andReturn("result").times(THREAD_COUNT);

        replay(mock);

        final Callable<String> replay = new Callable<String>() {
            public String call() throws Exception {
                return mock.oneArg("test");
            }
        };

        final ExecutorService service = Executors.newFixedThreadPool(THREAD_COUNT);
View Full Code Here


    }

    @Test
    public void testThreadNotSafe() throws Throwable {

        final IMethods mock = createMock(IMethods.class);
        expect(mock.oneArg("test")).andReturn("result").times(THREAD_COUNT);

        makeThreadSafe(mock, false);

        checkIsUsedInOneThread(mock, true);

        replay(mock);

        final Callable<String> replay = new Callable<String>() {
            public String call() throws Exception {
                return mock.oneArg("test");
            }
        };

        final ExecutorService service = Executors.newFixedThreadPool(THREAD_COUNT);
View Full Code Here

        assertTrue(exceptionThrown);
    }

    @Test
    public void testMockUsedCorrectly() {
        final IMethods mock = createMock(IMethods.class);
        expect(mock.oneArg("test")).andReturn("result").times(2);

        checkIsUsedInOneThread(mock, true);

        replay(mock);

        mock.oneArg("test");
        mock.oneArg("test");

        verify(mock);
    }
View Full Code Here

    @Test
    public void testRecordingInMultipleThreads() throws InterruptedException, ExecutionException {

        final Callable<String> replay = new Callable<String>() {
            public String call() throws Exception {
                final IMethods mock = createMock(IMethods.class);
                expect(mock.oneArg("test")).andReturn("result");

                replay(mock);

                final String s = mock.oneArg("test");

                verify(mock);

                return s;
            }
View Full Code Here

*/
public class UsageMatchersTest {
    @Test(expected = IllegalStateException.class)
    public void additionalMatchersFailAtReplay() {

        final IMethods mock = createMock(IMethods.class);
        lt(5);

        replay(mock);
    }
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.