コード例 #1
0
  public void testForThrowable() throws Throwable {
    NullPointerException exception = new NullPointerException();
    Answer<Object> answer = AnswerFactory.forThrowable(exception);

    try {
      answer.answer(null);
      fail("should have thrown exception");
    } catch (NullPointerException expected) {
      assertSame(exception, expected);
    }
  }
コード例 #2
0
 public void testForOnSuccess_noCallbackProvided() throws Throwable {
   Answer<Object> answer = AnswerFactory.forOnSuccess(42);
   Object[] args = {14, "Hallo"};
   try {
     answer.answer(args);
     fail("should have thrown exception");
   } catch (IllegalArgumentException expected) {
     assertEquals(
         "No com.google.gwt.user.client.rpc.AsyncCallback object as last argument provided",
         expected.getMessage());
   }
 }
コード例 #3
0
  public void testForOnSuccess() throws Throwable {
    @SuppressWarnings("unchecked")
    AsyncCallback<Object> callback = EasyMock.createMock(AsyncCallback.class);
    callback.onSuccess(42);
    EasyMock.replay(callback);

    Answer<Object> answer = AnswerFactory.forOnSuccess(42);
    Object[] args = {14, "Hallo", callback};

    answer.answer(args);

    EasyMock.verify(callback);
  }
コード例 #4
0
  public void testForOnFailure() throws Throwable {
    Throwable throwable = new Exception();
    @SuppressWarnings("unchecked")
    AsyncCallback<Object> callback = EasyMock.createMock(AsyncCallback.class);
    callback.onFailure(throwable);
    EasyMock.replay(callback);

    Answer<Object> answer = AnswerFactory.forOnFailure(throwable);
    Object[] args = {14, "Hallo", callback};

    answer.answer(args);

    EasyMock.verify(callback);
  }
コード例 #5
0
 public void testForValue_object() throws Throwable {
   Object obj = new Object();
   Answer<Object> answer = AnswerFactory.forValue(obj);
   assertSame(obj, answer.answer(null));
 }
コード例 #6
0
 public void testForValue_primitive() throws Throwable {
   Answer<Object> answer = AnswerFactory.forValue(42);
   assertEquals(42, answer.answer(null));
 }
コード例 #7
0
 public void testForValue_null() throws Throwable {
   Answer<Object> answer = AnswerFactory.forValue(null);
   assertNull(answer.answer(null));
 }