com.google.gwt.junit
Class FakeMessagesMaker
java.lang.Object
com.google.gwt.junit.FakeMessagesMaker
- All Implemented Interfaces:
- java.lang.reflect.InvocationHandler
public class FakeMessagesMaker
- extends java.lang.Object
- implements java.lang.reflect.InvocationHandler
Helper to make a fake implementation of any Messages interface via
reflection, for use in JUnit tests. (This will not work in GWTTestCase.) All
calls to the returned object return the method name followed by the passed
parameters as a list surrounded by [].
Note that the default message text is very consciously not made available
through the fake, to help tests ensure that specific translations of
localized text are not relied upon.
Sample use:
interface MyMessages extends Messages {
@DefaultMessage("Isn''t this the fakiest?")
@Description("A sample message to be tested.")
String myMessage();
}
public void testSimple() {
MyMessages messages = FakeMessagesMaker.create(MyMessages.class);
assertEquals("myMessage", messages.myMessage());
}
|
Method Summary |
static
|
create(java.lang.Class<T> messagesClass)
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FakeMessagesMaker
public FakeMessagesMaker()
create
public static <T extends Messages> T create(java.lang.Class<T> messagesClass)
invoke
public java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
- Specified by:
invoke in interface java.lang.reflect.InvocationHandler
- Throws:
java.lang.Throwable