public class FakeSafeHtmlTemplatesMaker extends Object implements InvocationHandler
SafeHtmlTemplates
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 [].
Sample use:
interface MyTemplates extends SafeHtmlTemplates {
@Template("{0}: {2}")
SafeHtml messageWithLink(SafeHtml message, String url, String linkText,
String style);
}
public void testWithArgs() {
MyTemplates templates = FakeSafeHtmlTemplatesMaker.create(MyTemplates.class);
SafeHtml message = SafeHtmlUtils.fromString("message");
assertEquals("messageWithLink[message, url, link, style]",
templates.messageWithLink(message, "url", "link", "style").asString());
}
Constructor and Description |
---|
FakeSafeHtmlTemplatesMaker() |
public static <T extends SafeHtmlTemplates> T create(Class<T> templatesClass)
Copyright © 2016. All rights reserved.