Hi David, I tried your example, but I have this error:
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. Stacktrace: java.lang.ExceptionInInitializerError at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:619) at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:612) at net.sf.cglib.proxy.Enhancer.registerCallbacks(Enhancer.java:581) at org.easymock.classextension.internal.ClassProxyFactory.createProxy(ClassProxyFactory.java:108) at org.easymock.internal.MocksControl.createMock(MocksControl.java:51) at org.easymock.classextension.EasyMock.createMock(EasyMock.java:46) at example.publico.client.SimpleTest.testSimple(SimpleTest.java:10) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) 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:85) at com.google.gwt.user.client.ui.UIObject.<clinit>(UIObject.java:140) ... 30 more On Wed, Aug 19, 2009 at 11:09 AM, davis <davisf...@zenoconsulting.biz>wrote: > > > > If your view interface return a TextBox you can't test the presenter with > > JUnit, you will need to use GWTTestCase. > > Sure you can: > > import static org.easymock.classextension.EasyMock.*; > import com.google.gwt.user.client.ui.TextBox; > > public class SomePresenterTestCase { > > private MyPresenter presenter; > private MyView view; > > @Test > public void testSomething() { > TextBox mockBox = createMock(TextBox.class); > MyView mockView = createMock(MyView.class); > presenter = new MyPresenter(mockView); > expect(mockView.getSomeTextBox()).andReturn(mockBox); > replay(mockView); > replay(mockBox); > TextBox box = presenter.getDisplay().getSomeTextBox(); > verify(mockView); > } > } > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---