Package samples.suppressmethod

Examples of samples.suppressmethod.SuppressMethod


  @Test(expected = ClassCastException.class)
  public void whenStubbingInstanceMethodWithWrongReturnTypeThenClasscastExceptionIsThrown() throws Exception {
    String illegalReturnType = "Hello";
    stub(method(SuppressMethod.class, "getFloat")).toReturn(illegalReturnType);
    SuppressMethod tested = new SuppressMethod();
    tested.getFloat();
  }
View Full Code Here


  @Test
  public void whenStubbingInstanceMethodToThrowExceptionTheMethodThrowsTheStubbedException() throws Exception {
    Exception expected = new Exception("message");
    stub(method(SuppressMethod.class, "getObject")).toThrow(expected);

    SuppressMethod tested = new SuppressMethod();

    try {
      tested.getObject();
      fail();
    } catch (Exception e) {
      assertEquals("message", e.getMessage());
    }
  }
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

  @Test(expected = ClassCastException.class)
  public void whenStubbingInstanceMethodWithWrongReturnTypeThenClasscastExceptionIsThrown() throws Exception {
    String illegalReturnType = "Hello";
    stub(method(SuppressMethod.class, "getFloat")).toReturn(illegalReturnType);
    SuppressMethod tested = new SuppressMethod();
    tested.getFloat();
  }
View Full Code Here

  @Test
  public void whenStubbingInstanceMethodToThrowExceptionTheMethodThrowsTheStubbedException() throws Exception {
    Exception expected = new Exception("message");
    stub(method(SuppressMethod.class, "getObject")).toThrow(expected);

    SuppressMethod tested = new SuppressMethod();

    try {
      tested.getObject();
      fail();
    } catch (Exception e) {
      assertEquals("message", e.getMessage());
    }
  }
View Full Code Here

  @Test(expected = ArrayStoreException.class)
  public void expectionThrowingMethodProxyWorksForJavaLangReflectMethods() throws Exception {
    replace(method(SuppressMethod.class, "getObject")).with(new ThrowingInvocationHandler());

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

  @Test(expected = ArrayStoreException.class)
  public void expectionThrowingMethodProxyWorksForMethodNames() throws Exception {
    replace(method(SuppressMethod.class, "getObject")).with(new ThrowingInvocationHandler());

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

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

    assertEquals("hello world", new SuppressMethod().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.