Hi Thomas -- my test is a pure JUnit test -- now a GwtUnitTest.

HasWidgets is an interface -- so the piece I am missing is how/why
EasyMock.createMock(HasWidgets.class) can somehow be instantiating
GWT.create() ?  I checked and double-checked the package namespace,
and it is definitely referencing an interface.

I never call GWT.create( ) in any of the code I am testing or the test
code itself.

To work around this, I just did this:

public MockHasWidgets implements HasWidgets {

   etc...
}

and use new MockHasWidgets() in my test cases.

On Tue, Sep 1, 2009 at 6:09 PM, Thomas Broyer<[email protected]> wrote:
>
>
>
> On 1 sep, 19:48, davis <[email protected]> wrote:
>> As far as I can tell, this should work:
>>
>> HasWidgets mockHasWidgets = org.easymock.EasyMock.createMock
>> (HasWidgets.class);
>>
>> since HasWidgets is an 
>> interface:http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/index.html
>>
>> ...but if you execute this, it promptly throws:
>>
>> 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.
>>
>> This usually happens when you execute any code in standard JUnit tests
>> that end up calling GWT.create( ) -- but this is an interface...what
>> am I missing here?
>
> EasyMock is only usable in pure Java, i.e. (to make it short) not in a
> GWTTestCase. If your code ultimately depends on GWT.create() (which
> EasyMock does not!), you can use GWTMockUtilities to make GWT.create()
> work (and simply return null).
>
> In a word, your GWT.create() issue is unrelated to the EasyMock line
> you quoted.
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to