alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

EasyMock example source code file (ReplayStateInvalidCallsTest.java)

This example EasyMock source code file (ReplayStateInvalidCallsTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - EasyMock tags/keywords

before, exception, exception, mocksbehavior, replaystate, replaystate, replaystateinvalidcallstest, runnable, runtimeexception, runtimeexception, test, test

The EasyMock ReplayStateInvalidCallsTest.java source code

/*
 * Copyright (c) 2001-2007 OFFIS, Tammo Freese.
 * This program is made available under the terms of the MIT License.
 */
package org.easymock.tests;

import org.easymock.MockControl;
import org.easymock.internal.MocksBehavior;
import org.easymock.internal.ReplayState;
import org.easymock.internal.RuntimeExceptionWrapper;
import org.junit.Before;
import org.junit.Test;

public class ReplayStateInvalidCallsTest {

    private ReplayState control;

    private Exception exception;

    @Before
    public void setUp() {
        exception = new Exception();
        control = new ReplayState(new MocksBehavior(false));
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void expectAndThrowLongWithMinMax() {
        control.andThrow(exception);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void expectAndReturnObjectWithMinMax() {
        control.andReturn("");
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void setDefaultMatcher() {
        control.setDefaultMatcher(MockControl.ARRAY_MATCHER);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void asStub() {
        control.asStub();
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void setMatcher() {
        control.setMatcher(null, MockControl.ARRAY_MATCHER);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void setDefaultReturnValue() {
        control.setDefaultReturnValue("");
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void setDefaultThrowable() {
        control.setDefaultThrowable(exception);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void setDefaultVoidCallable() {
        control.setDefaultVoidCallable();
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void replay() {
        control.replay();
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void checkOrder() {
        control.checkOrder(true);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void andStubReturn() {
        control.andStubReturn("7");
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void andStubThrow() {
        control.andStubThrow(new RuntimeException());
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void andStubAnswer() {
        control.andStubAnswer(null);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void times() {
        control.times(MockControl.ONE);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void callback() {
        control.callback(new Runnable() {
            public void run() {
            };
        });
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void andReturn() {
        control.andReturn(null);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void andThrow() {
        control.andThrow(new RuntimeException());
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void andAnswer() {
        control.andAnswer(null);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void defaultThrowable() {
        control.setDefaultThrowable(new RuntimeException());
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void defaultReturnValue() {
        control.setDefaultReturnValue(null);
    }

    @Test(expected = RuntimeExceptionWrapper.class)
    public void defaultVoidCallable() {
        control.setDefaultVoidCallable();
    }
}

Other EasyMock examples (source code examples)

Here is a short list of links related to this EasyMock ReplayStateInvalidCallsTest.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.