In my opinion, your question is extremely relevant > is code using DateTimeFormat not testable?
I found your thread here because I converted some code from SimpleDateFormat to gwt DateTimeFormat. And this provoked the error when running the tests java.lang.NullPointerException at com.google.gwt.i18n.client.LocaleInfo.ensureDateTimeFormatInfo(LocaleInfo.java: 201) at com.google.gwt.i18n.client.LocaleInfo.getDateTimeFormatInfo(LocaleInfo.java: 159) at com.google.gwt.i18n.client.DateTimeFormat.getDefaultDateTimeFormatInfo(DateTimeFormat.java: 808) at com.google.gwt.i18n.client.DateTimeFormat.getFormat(DateTimeFormat.java: 625) What is the best practice for having testable code to convert strings to Date? I am looking for code that works both in client and in JUnit tests On Sep 23, 1:25 pm, Shawn Brown <big.coffee.lo...@gmail.com> wrote: > I'm just trying to test my code that hasDateTimeFormatin it. > However I see ... > > java.lang.ExceptionInInitializerError > at > com.google.gwt.i18n.client.DateTimeFormat.getDefaultDateTimeFormatInfo(Date > TimeFormat.java:808) > at > com.google.gwt.i18n.client.DateTimeFormat.getFormat(DateTimeFormat.java:488 ) > at > com.google.gwt.i18n.client.DateTimeFormat.getLongDateTimeFormat(DateTimeFor > mat.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 post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.