public class

FakeMessagesMaker

extends Object
implements InvocationHandler
java.lang.Object
   ↳ com.google.gwt.junit.FakeMessagesMaker

Class Overview

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());
 }
 

Summary

Public Constructors
FakeMessagesMaker()
Public Methods
static <T extends Messages> T create(Class<T> messagesClass)
Object invoke(Object proxy, Method method, Object[] args)
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.reflect.InvocationHandler

Public Constructors

public FakeMessagesMaker ()

Public Methods

public static T create (Class<T> messagesClass)

public Object invoke (Object proxy, Method method, Object[] args)

Throws
Throwable