Package samples.suppressconstructor

Examples of samples.suppressconstructor.SuppressConstructorDemo


  }

  @Test
  public void testUnmockedWithConstructorAndAllowReplay() throws Exception {
    PowerMock.niceReplayAndVerify();
    SuppressConstructorDemo object = new SuppressConstructorDemo("Hello");
    PowerMock.replay(object);

    assertEquals("Hello", object.getMessage());

    PowerMock.verify(object);
  }
View Full Code Here


    PowerMock.verify(object);
  }

  @Test
  public void testUnmockedWithReplayCausesException() throws Exception {
    SuppressConstructorDemo object = new SuppressConstructorDemo("Hello");
    try {
      PowerMock.replay(object);
      fail("Replay should only work on mocks");
    } catch (RuntimeException e) {
      // ignore
View Full Code Here

     * This test makes sure that the real constructor has never been called.
     */
    @Test
    public void testSuppressConstructor() throws Exception {
        suppress(constructor(SuppressConstructorDemo.class));
        final SuppressConstructorDemo tested = new SuppressConstructorDemo("a message");
        assertNull("Message should have been null since we're skipping the execution of the constructor code.", tested.getMessage());
    }
View Full Code Here

     * called.
     */
    @Test
    public void testSuppressParentConstructor() throws Exception {
        suppress(constructor(SuppressConstructorSubclassDemo.class));
        final SuppressConstructorDemo tested = new SuppressConstructorDemo("a message");
        assertNull("Message should have been null since we're skipping the execution of the constructor code.", tested.getMessage());
    }
View Full Code Here

     * class under test at the same time as skipping constructor execution.
     */
    @Test
    public void testPartialMockingAndSuppressParentConstructor() throws Exception {
        suppress(constructor(SuppressConstructorSubclassDemo.class));
        final SuppressConstructorDemo tested = createPartialMock(SuppressConstructorDemo.class, "returnAMessage");
        final String expected = "Hello world!";
        expectPrivate(tested, "returnAMessage").andReturn(expected);
        replay(tested);

        final String actual = tested.getMyOwnMessage();

        verify(tested);

        assertEquals(expected, actual);

        assertNull("Message should have been null since we're skipping the execution of the constructor code.", tested.getMessage());
    }
View Full Code Here

     * This test makes sure that the real constructor has never been called.
     */
    @Test
    public void testSuppressConstructor() throws Exception {
        suppress(constructor(SuppressConstructorDemo.class));
        final SuppressConstructorDemo tested = new SuppressConstructorDemo("a message");
        assertNull("Message should have been null since we're skipping the execution of the constructor code.", tested.getMessage());
    }
View Full Code Here

     */
    @Test
    @Ignore("Doesn't work when using the Java agent")
    public void testSuppressParentConstructor() throws Exception {
        suppress(constructor(SuppressConstructorSubclassDemo.class));
        final SuppressConstructorDemo tested = new SuppressConstructorDemo("a message");
        assertNull("Message should have been null since we're skipping the execution of the constructor code.", tested.getMessage());
    }
View Full Code Here

TOP

Related Classes of samples.suppressconstructor.SuppressConstructorDemo

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.