Wednesday, July 17, 2013

Re: is code using DateTimeFormat not testable?

This can help test DateTimeFormat in server side

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


пятница, 23 сентября 2011 г., 17:25:53 UTC+6 пользователь Shawn написал:
I'm just trying to test my code that has DateTimeFormat in it.
However I see ...

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

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate