Arthur,
  One of the things I commonly do when writing "non-GWT-specific" code
is to isolate GWT-specific code behind an abstract class or interface
and then inject different versions depending on application. One good
example is java.text.SimpleDateFormat vs GWT's DateTimeFormat.  I have
a DateFormatter interface with parse and format methods, and a
DateFormatterFactory that makes instances of DateFormatters (from
format strings). You can then inject manually (or with something like
GIN) versions of DateFormatterFactory, or mocked versions. This may
not work for everyone, but in my case, I have to do it, because
certain environments (like Android) are very finicky about loading the
GWT classes. For example, the Dalvik verifier, upon seeing a method
which references the GWT URL class, would try to load it, and even if
it were present, it might cause problems due to the native methods,
but sometimes you end up with some verification failure far down the
execution path because of transitivity (e.g. Foo references URL which
references another GWT class, which references another, etc)

-Ray

On Wed, Feb 18, 2009 at 3:21 PM, Arthur Kalmenson <[email protected]> wrote:
>
> Hello everyone,
>
> I have a fairly complex class that is almost entirely non-GWT specific
> aside from a single line that uses GWT's URL.decodeComponent method.
> While I rediscovered GWTMockUtilities and found EasyMock Class
> extension, I still can't think of any way to mock out the URL class.
> This is because the object is not instantiable (it's final) and it's a
> static method call.
>
> I'm not sure if there's some performance reason behind making it a
> final class and using static methods, but it does make testing a pain.
> It forces me to use GWTTestCase instead of TestNG to test that
> particular class because of the single line of code.
>
> P.S. Does anyone mind if I write a little guide in the GWT Group about
> using GWTMockUtilities with EasyMock?
>
> --
> Arthur Kalmenson
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to