MockObject is a simple static utility class for creating mock objects for testing. The basic mock object is a implementation of an interface or an abstract class that can be used in a test case. The mock object throws an UnsupportedOperationException for every implemented method.
The mock object can also use a delegated implementation. This is a simple class that has methods that match the signature of the methods required. The method can do whatever is required for the test.
It is not recommended that these mock objects be used outside of a test environment.
Sample code:
Map map = MockObject.mock(Map.class, new Object() { public Object get(Object key) { assert "mouse".equals(key); return "xxx"; } }; myObject.doSomething(map);
Now assuming that the doSomething method does some form
of map.get("mouse")
the test should pass.