java.lang.ExceptionInInitializerError
at com.google.gwt.i18n.client.DateTimeFormat.getDefaultDateTimeFormatInfo(DateTimeFormat.java:808)
at com.google.gwt.i18n.client.DateTimeFormat.getFormat(DateTimeFormat.java:488)
at com.google.gwt.i18n.client.DateTimeFormat.getLongDateTimeFormat(DateTimeFormat.java:690)
...
Caused by: java.lang.UnsupportedOperationException: ERROR:
GWT.create() is only usable in client code! It cannot be called, for
example, from server code. If you are running a unit test, check that
your test case extends GWTTestCase and that GWT.create() is not called
from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:91)
at com.google.gwt.i18n.client.LocaleInfo.<clinit>(LocaleInfo.java:36)
... 35 more
Is there a list of what I can not use in Tests since GWT.create
forbids it? This seems to be a reoccurring theme in GWT and I am
tired of writing code that subsequently needs to be yanked as it's not
testable.
Shawn
public static com.google.gwt.i18n.shared.DateTimeFormat createGwtDTFormat(String pattern) throws Exception
{
Constructor<com.google.gwt.i18n.shared.DateTimeFormat> c = com.google.gwt.i18n.shared.DateTimeFormat.class
.getDeclaredConstructor(String.class, DateTimeFormatInfo.class);
c.setAccessible(true);
return c.newInstance(pattern, new DateTimeFormatInfoImpl_en());
}