Package samples.suppressmethod

Examples of samples.suppressmethod.SuppressMethod


    @Test
    @Ignore("Doesn't work atm")
    public void testSuppressMethodInParentOnly() throws Exception {
        suppress(method(SuppressMethodParent.class, "myMethod"));

        SuppressMethod tested = new SuppressMethod();
        // Should not cause an NPE when suppressing code.
        assertEquals(20, tested.myMethod());
    }
View Full Code Here


    @Test
    public void suppressSingleMethodExample() throws Exception {
        suppress(method(SuppressMethod.class, "getObject"));

        assertNull(new SuppressMethod().getObject());
    }
View Full Code Here

    @Test
    public void suppressMultipleMethodsExample1() throws Exception {
        suppress(methods(SuppressMethod.class, "getObject", "getInt"));

        assertNull(new SuppressMethod().getObject());
        assertEquals(0, new SuppressMethod().getInt());
    }
View Full Code Here

    @Test
    public void suppressMultipleMethodsExample2() throws Exception {
        suppress(methods(method(SuppressMethod.class, "getObject"), method(SuppressMethod.class, "getInt")));

        assertNull(new SuppressMethod().getObject());
        assertEquals(0, new SuppressMethod().getInt());
    }
View Full Code Here

    @Test
    public void suppressAllMethodsExample() throws Exception {
        suppress(methodsDeclaredIn(SuppressMethod.class));

        final SuppressMethod tested = new SuppressMethod();

        assertNull(tested.getObject());
        assertNull(SuppressMethod.getObjectStatic());
        assertEquals(0, tested.getByte());
    }
View Full Code Here

    @Test
    public void stubSingleMethodExample() throws Exception {
        final String expectedReturnValue = "new";
        stub(method(SuppressMethod.class, "getObject")).toReturn(expectedReturnValue);

        final SuppressMethod tested = new SuppressMethod();
        assertEquals(expectedReturnValue, tested.getObject());
        assertEquals(expectedReturnValue, tested.getObject());
    }
View Full Code Here

    @Test
    public void changingReturnValueExample() throws Exception {
        replace(method(SuppressMethod.class, "getObjectWithArgument")).with(new ReturnValueChangingInvocationHandler());

        final SuppressMethod tested = new SuppressMethod();

        assertThat(tested.getObjectWithArgument("don't do anything"), is(instanceOf(Object.class)));
        assertEquals("hello world", tested.getObjectWithArgument("make it a string"));
    }
View Full Code Here

  @Test
  public void whenStubbingInstanceMethodTheMethodReturnsTheStubbedValue() throws Exception {
    String expectedValue = "Hello";
    stub(method(SuppressMethod.class, "getObject")).toReturn(expectedValue);

    SuppressMethod tested = new SuppressMethod();

    assertEquals(expectedValue, tested.getObject());
    assertEquals(expectedValue, tested.getObject());
  }
View Full Code Here

  @Test
  public void whenStubbingInstanceMethodWithPrimiteValueTheMethodReturnsTheStubbedValue() throws Exception {
    float expectedValue = 4;
    stub(method(SuppressMethod.class, "getFloat")).toReturn(expectedValue);

    SuppressMethod tested = new SuppressMethod();

    assertEquals(expectedValue, tested.getFloat(), 0.0f);
    assertEquals(expectedValue, tested.getFloat(), 0.0f);
  }
View Full Code Here

  @Test
  public void whenStubbingInstanceMethodByPassingTheMethodTheMethodReturnsTheStubbedValue() throws Exception {
    String expected = "Hello";
    stub(method(SuppressMethod.class, "getObject")).toReturn(expected);

    SuppressMethod tested = new SuppressMethod();

    assertEquals(expected, tested.getObject());
    assertEquals(expected, tested.getObject());
  }
View Full Code Here

TOP

Related Classes of samples.suppressmethod.SuppressMethod

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.