title: GWTTestCase: JUnit Assertions within callback raises JavaScriptException
body: <p>So if I call any JUnit assertion which fails from inside a callback method I get this exception:</p>
  
  <pre><code>Mar 12, 2012 11:24:41 AM 
  
  com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl runJob
  SEVERE: Job run failed with unexpected RuntimeException: [object Class JavaObject] (injected script#14)
  net.sourceforge.htmlunit.corejs.javascript.JavaScriptException: [object Class JavaObject] (injected script#14)
      at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1062)
      at script(injected script:14)
      at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:845)
      at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
      at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429)
      at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:269)
      at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3162)
      at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
      at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:559)
      at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:181)
      at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:525)
      at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:64)
      at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:461)
      at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
      at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
      at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$2.run(XMLHttpRequest.java:467)
      at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runJob(JavaScriptJobManagerImpl.java:226)
      at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:307)
      at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor.run(JavaScriptExecutor.java:182)
      at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>A simple test that produces this:</p>
  
  <pre><code>public void testSimple() {
      MyPrgrmServiceAsync serv = GWT.create(MyPrgrmService.class);
      serv.search("some query", new AsyncCallback&lt;SearchResult&gt;() {
          public void onSuccess(SearchResult sr) {
              fail();
          }
  
          public void onFailure(Throwable caught) {
              fail(caught.toString());
          }
      });
  
      delayTestFinish(60000);
  }
  </code></pre>
  
  <p>When this test is run, it "passes" as far as the JUnit Runner is concerned with the green bar displayed in Eclipse, but obviously it's supposed to fail. The only indication that anything went wrong is the exception in the console. If I move the fail() outside the callback, it fails normally and indicates so. Additionally, assertions that resolve to true behave normally, so it seems the test simply doesn't know how to detect failures when they arise from within anonymous classes. Is there something I'm not understanding correctly about how to use JUnit assertions within callbacks/anonymous classes with respect to GWTTestCase? </p>