Package samples.finalmocking

Examples of samples.finalmocking.FinalDemo


    private ArgumentCaptor<String> captor;

    @Test
    public void captorAnnotationWorks() throws Exception {
        final String expected = "testing";
        FinalDemo demo = mock(FinalDemo.class);
        demo.say(expected);

        verify(demo).say(captor.capture());
        assertEquals(expected, captor.getValue());
    }
View Full Code Here


@PrepareForTest(FinalDemo.class)
public class FinalTest extends PowerMockTestCase {

    @Test
    public void mockingFinalClassesAndMethodsWorkWithTestNGAndEasyMock() throws Exception {
        final FinalDemo finalDemo = createMock(FinalDemo.class);

        expect(finalDemo.say("something")).andReturn("something else");

        replayAll();

        final String actual = finalDemo.say("something");

        verifyAll();

        assertEquals("something else", actual);
    }
View Full Code Here

@PrepareForTest(FinalDemo.class)
public class FinalDemoTest {

  @Test
  public void testSay() throws Exception {
    FinalDemo tested = createMock(FinalDemo.class);
    String expected = "Hello altered World";
    expect(tested.say("hello")).andReturn("Hello altered World");
    replay(tested);

    String actual = tested.say("hello");

    verify(tested);
    assertEquals("Expected and actual did not match", expected, actual);

    // Should still be mocked by now.
    try {
      tested.say("world");
      fail("Should throw AssertionError!");
    } catch (AssertionError e) {
      assertEquals("\n  Unexpected method call FinalDemo.say(\"world\"):", e.getMessage());
    }
View Full Code Here

  }

  @Test
  public void testSayFinalNative() throws Exception {
    FinalDemo tested = createMock(FinalDemo.class);
    String expected = "Hello altered World";
    expect(tested.sayFinalNative("hello")).andReturn("Hello altered World");
    replay(tested);

    String actual = tested.sayFinalNative("hello");

    verify(tested);
    assertEquals("Expected and actual did not match", expected, actual);

    // Should still be mocked by now.
    try {
      tested.sayFinalNative("world");
      fail("Should throw AssertionError!");
    } catch (AssertionError e) {
      assertEquals("\n  Unexpected method call FinalDemo.sayFinalNative(\"world\"):", e.getMessage());
    }
  }
View Full Code Here

public class NoDuplicateTest {

  @Test
  @PrepareForTest(FinalDemo.class)
  public void assertThatPrepareForTestAnnotationAtMethodLevelButNotClassLevelWorks() throws Exception {
    FinalDemo tested = createMock(FinalDemo.class);
    String expected = "Hello altered World";
    expect(tested.say("hello")).andReturn("Hello altered World");
    replay(tested);

    String actual = tested.say("hello");

    verify(tested);
    assertEquals("Expected and actual did not match", expected, actual);

    // Should still be mocked by now.
    try {
      tested.say("world");
      fail("Should throw AssertionError!");
    } catch (AssertionError e) {
      assertEquals("\n  Unexpected method call FinalDemo.say(\"world\"):", e.getMessage());
    }
  }
View Full Code Here

@PrepareForTest(FinalDemo.class)
public class FinalDemoTest extends PowerMockTestCase {

  @Test
  public void testSay() throws Exception {
    FinalDemo tested = createMock(FinalDemo.class);
    String expected = "Hello altered World";
    expect(tested.say("hello")).andReturn("Hello altered World");
    replay(tested);

    String actual = tested.say("hello");

    verify(tested);
    AssertJUnit.assertEquals("Expected and actual did not match", expected, actual);

    // Should still be mocked by now.
    try {
      tested.say("world");
      fail("Should throw AssertionError!");
    } catch (AssertionError e) {
      assertEquals("\n  Unexpected method call FinalDemo.say(\"world\"):", e.getMessage());
    }
View Full Code Here

  }

  @Test
  public void testSayFinalNative() throws Exception {
    FinalDemo tested = createMock(FinalDemo.class);
    String expected = "Hello altered World";
    expect(tested.sayFinalNative("hello")).andReturn("Hello altered World");
    replay(tested);

    String actual = tested.sayFinalNative("hello");

    verify(tested);
    assertEquals("Expected and actual did not match", expected, actual);

    // Should still be mocked by now.
    try {
      tested.sayFinalNative("world");
      fail("Should throw AssertionError!");
    } catch (AssertionError e) {
      assertEquals("\n  Unexpected method call FinalDemo.sayFinalNative(\"world\"):", e.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of samples.finalmocking.FinalDemo

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.