EasyMock example source code file (CallbackTest.java)
This example EasyMock source code file (CallbackTest.java) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
/*
* Copyright (c) 2001-2007 OFFIS, Tammo Freese.
* This program is made available under the terms of the MIT License.
*/
package org.easymock.tests2;
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
import org.easymock.IAnswer;
import org.easymock.tests.IMethods;
import org.junit.Before;
import org.junit.Test;
public class CallbackTest {
private IMethods mock;
private static class Callback<T> implements IAnswer {
private int callCount;
private T result;
public Callback(T result) {
this.result = result;
}
public void run() {
}
public int getCallCount() {
return callCount;
}
public T answer() throws Throwable {
callCount++;
return result;
}
}
@Before
public void setUp() {
mock = createStrictMock(IMethods.class);
}
@Test
public void callback() {
Callback<String> c1 = new Callback("1");
Callback<Object> c2 = new Callback
Other EasyMock examples (source code examples)
Here is a short list of links related to this EasyMock CallbackTest.java source code file: