Package org.jmock.integration.junit4

Examples of org.jmock.integration.junit4.JUnit4Mockery


    }

    @Test
    public void testRun() {
        final boolean pause = true;
        final Mockery mockCtx = new JUnit4Mockery();
        final Worker worker = mockCtx.mock(Worker.class);
        mockCtx.checking(new Expectations(){{
            oneOf(worker).togglePause(pause);
        }});
        final PauseCommand pauseCmd = new PauseCommand(pause);
        pauseCmd.setWorker(worker);
        pauseCmd.run();
        mockCtx.assertIsSatisfied();
    }
View Full Code Here


    }

    @Test
    public void testRun() {
        final boolean shutdown = true;
        final Mockery mockCtx = new JUnit4Mockery();
        final Worker worker = mockCtx.mock(Worker.class);
        mockCtx.checking(new Expectations(){{
            oneOf(worker).end(shutdown);
        }});
        final ShutdownCommand shutdownCmd = new ShutdownCommand(shutdown);
        shutdownCmd.setWorker(worker);
        shutdownCmd.run();
        mockCtx.assertIsSatisfied();
    }
View Full Code Here

    private QueueInfoDAORedisImpl qInfoDAO;
   
    @SuppressWarnings("unchecked")
    @Before
    public void setUp() {
        this.mockCtx = new JUnit4Mockery();
        this.mockCtx.setImposteriser(ClassImposteriser.INSTANCE);
        this.mockCtx.setThreadingPolicy(new Synchroniser());
        this.pool = this.mockCtx.mock(Pool.class);
        this.jedis = this.mockCtx.mock(Jedis.class);
        this.qInfoDAO = new QueueInfoDAORedisImpl(new ConfigBuilder().build(), this.pool);
View Full Code Here

            new DefaultExceptionHandler().onException(null, new JsonGenerationException("foo"), null));
    }

    @Test
    public void testOnException_Interrupted() {
        final Mockery mockCtx = new JUnit4Mockery();
        final JobExecutor jobEx = mockCtx.mock(JobExecutor.class);
        mockCtx.checking(new Expectations(){{
            allowing(jobEx).isShutdown(); will(returnValue(false));
        }});
        Assert.assertEquals(RecoveryStrategy.PROCEED,
            new DefaultExceptionHandler().onException(jobEx, new InterruptedException("foo"), null));
        mockCtx.assertIsSatisfied();
    }
View Full Code Here

        mockCtx.assertIsSatisfied();
    }

    @Test
    public void testOnException_InterruptedShutdown() {
        final Mockery mockCtx = new JUnit4Mockery();
        final JobExecutor jobEx = mockCtx.mock(JobExecutor.class);
        mockCtx.checking(new Expectations(){{
            allowing(jobEx).isShutdown(); will(returnValue(true));
        }});
        Assert.assertEquals(RecoveryStrategy.TERMINATE,
            new DefaultExceptionHandler().onException(jobEx, new InterruptedException("foo"), null));
        mockCtx.assertIsSatisfied();
    }
View Full Code Here

    private WorkerListener listener;

    @Before
    public void setUp() {
        this.delegate = new WorkerListenerDelegate();
        this.mockCtx = new JUnit4Mockery();
        this.listener = this.mockCtx.mock(WorkerListener.class);
    }
View Full Code Here

    private FailureDAORedisImpl failureDAO;
   
    @SuppressWarnings("unchecked")
    @Before
    public void setUp() {
        this.mockCtx = new JUnit4Mockery();
        this.mockCtx.setImposteriser(ClassImposteriser.INSTANCE);
        this.mockCtx.setThreadingPolicy(new Synchroniser());
        this.pool = this.mockCtx.mock(Pool.class);
        this.jedis = this.mockCtx.mock(Jedis.class);
        this.failureDAO = new FailureDAORedisImpl(new ConfigBuilder().build(), this.pool);
View Full Code Here

    private WorkerInfoDAORedisImpl workerInfoDAO;
   
    @SuppressWarnings("unchecked")
    @Before
    public void setUp() {
        this.mockCtx = new JUnit4Mockery();
        this.mockCtx.setImposteriser(ClassImposteriser.INSTANCE);
        this.mockCtx.setThreadingPolicy(new Synchroniser());
        this.pool = this.mockCtx.mock(Pool.class);
        this.jedis = this.mockCtx.mock(Jedis.class);
        this.workerInfoDAO = new WorkerInfoDAORedisImpl(new ConfigBuilder().build(), this.pool);
View Full Code Here

    private WorkerPool pool;
   
    @SuppressWarnings("unchecked")
    @Before
    public void setUp() throws Exception {
        this.mockCtx = new JUnit4Mockery();
        this.mockCtx.setThreadingPolicy(new Synchroniser());
        this.workerFactory = this.mockCtx.mock(Callable.class);
        this.workers.add(this.mockCtx.mock(Worker.class, "Worker1"));
        this.workers.add(this.mockCtx.mock(Worker.class, "Worker2"));
        this.eventEmitters.add(this.mockCtx.mock(WorkerEventEmitter.class, "WorkerEventEmitter1"));
View Full Code Here

    private PoolWork<String,String> work;
   
    @SuppressWarnings("unchecked")
    @Before
    public void setUp() {
        this.mockCtx = new JUnit4Mockery();
        this.mockCtx.setImposteriser(ClassImposteriser.INSTANCE);
        this.pool = this.mockCtx.mock(Pool.class);
        this.work = this.mockCtx.mock(PoolWork.class);
    }
View Full Code Here

TOP

Related Classes of org.jmock.integration.junit4.JUnit4Mockery

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.