Package samples.expectnew

Examples of samples.expectnew.ExpectNewDemo


     * Verifies that the issue
     * http://code.google.com/p/powermock/issues/detail?id=10 is solved.
     */
    @Test
    public void testSimpleMultipleNewPrivate_tooFewTimesExpected() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();

        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).times(2);

View Full Code Here


        }
    }

    @Test
    public void testSimpleMultipleNewPrivate_ok() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();

        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).times(3);
View Full Code Here

        Whitebox.invokeMethod(tested, "simpleMultipleNewPrivate");
    }

    @Test
    public void testSimpleSingleNew_withOnce() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();

        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).once();

        replayAll();
        tested.simpleSingleNew();
        verifyAll();
    }
View Full Code Here

        verifyAll();
    }

    @Test
    public void testSimpleSingleNew_withAtLeastOnce() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();

        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).atLeastOnce();

        replayAll();
        tested.simpleSingleNew();
        verifyAll();
    }
View Full Code Here

public class VerifyNewWithoutWhenNewTest {

    @Test
    // TODO This should actually work in the future when issue 148 is resolved.
    public void verifyingNewWithoutExpectationWhenNoArgumentsThrowsISE() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();

        assertEquals("Hello world", tested.getMessage());

        try {
            verifyNew(MyClass.class).withNoArguments();
            fail("IllegalStateException expected");
        } catch (IllegalStateException e) {
View Full Code Here

        verifyAll();
    }

    @Test
    public void testSimpleMultipleNew_withAtLeastOnce() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();

        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).atLeastOnce();

        replayAll();
        tested.simpleMultipleNew();
        verifyAll();
    }
View Full Code Here

    }

    @Test
    // TODO This should actually work in the future when issue 148 is resolved.
    public void verifyingNewWithoutExpectationButWithArgumentsThrowsISE() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();
        assertEquals("Hello world", tested.getMessage());

        try {
            verifyNew(MyClass.class, Mockito.atLeastOnce()).withNoArguments();
            fail("IllegalStateException expected");
        } catch (IllegalStateException e) {
View Full Code Here

        }
    }

    @Test
    public void testSimpleMultipleNew_withRange_OK() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();
        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).times(1, 5);

        replayAll();

        tested.simpleMultipleNew();

        verifyAll();
    }
View Full Code Here

        verifyAll();
    }

    @Test
    public void testSimpleMultipleNew_anyTimes() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();
        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).anyTimes();

        replayAll();

        tested.simpleMultipleNew();

        verifyAll();
    }
View Full Code Here

        verifyAll();
    }

    @Test
    public void testSimpleMultipleNew_withRange_notWithinRange() throws Exception {
        ExpectNewDemo tested = new ExpectNewDemo();
        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).times(5, 7);

        replayAll();

        tested.simpleMultipleNew();

        try {
            verifyAll();
            fail("Should throw AssertionError.");
        } catch (AssertionError e) {
View Full Code Here

TOP

Related Classes of samples.expectnew.ExpectNewDemo

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.