Junit Tests and ErraiBus

Hi,

 

I followed your explanations under 'https://github.com/errai/errai/blob/master/errai-bus/src/test/java/org/jboss/errai/bus/client/tests/BusCommunicationTests.java', to perfrom a GWT Unit Tests with the usage of the erraibus.

All my tries are ended up in an error. It seems, that the ErraiBus could not be initialized propperly ??.

 

Find below the code of the test class and the resulting stacktrace. I set the parameter -Dorg.jboss.errai.bus.do_long_poll=false and the main and test dirs were added to the runtime path propperly.

Could you please  advice?

 

public class OnFieldSearchPresenterGWTTest extends AbstractErraiTest {

 

    @Override

    public String getModuleName() {

        return "net.xxxxx.tracking.tracking";

    }

   

   

   @Test

    public void bindTest(){

        testBasicRoundTrip() ;

    }

    

    public void testBasicRoundTrip() {

         runAfterInit(new Runnable() {

              public void run() {

                bus.subscribe("ShipmentResultReceiver", new MessageCallback() {

                      @Override

                       public void callback(Message message) {

                          List<Shipment> result = message.get(List.class, ShipmentServiceParts.RESULT);

                          retrieveShipments(result);

                      }

 

                  });

 

                MessageBuilder.createMessage()

                  .toSubject("ShipmentService") // (1)

                  .with(ShipmentServiceParts.ONEFIELDSEARCH, "lalala")

                  .noErrorHandling() // (3)

                  .sendNowWith(bus); // (4)

              }

            });

     }

    

     private void retrieveShipments(List<Shipment> result) {

              StringBuilder sb = new StringBuilder();

              sb.append("Found " + result.size() + " Shipments" + "\n\n");

              ListIterator<Shipment> lit = result.listIterator();

 

              while (lit.hasNext()) {

                     Shipment sh = lit.next();

                     sb.append(sh.toString() + "\n");

              }

            System.out.println(sb.toString());

        }

   

}

 

Stack trace

 

 

REMEMBER! Bus tests will not succeed if:

1. You do not run the unit tests with the flag: -Dorg.jboss.errai.bus.do_long_poll=false

2. You do not have the main and test source directories in the runtime classpath

Validating newly compiled units

   Ignored 5 units with compilation errors in first pass.

Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.

Starting http://172.20.108.99:64023/net.xxxxxxxxx.tracking.tracking.JUnit/junit-standards.html?gwt.codesvr=172.20.108.99:64019 on browser FF3

200 - GET /net.xxxxxxxxx.tracking.tracking.JUnit/junit-standards.html?gwt.codesvr=172.20.108.99:64019 (172.20.108.99) 2449 bytes

200 - GET /net.xxxxxxxxx.tracking.tracking.JUnit/net.xxxxxxxxx.tracking.tracking.JUnit.nocache.js (172.20.108.99) 8050 bytes

logging for HtmlUnit thread

   [WARN] Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://172.20.108.99:64023/net.xxxxxxxxx.tracking.tracking.JUnit/net.xxxxxxxxx.tracking.tracking.JUnit.nocache.js', but got 'application/x-javascript'.

200 - GET /net.xxxxxxxxx.tracking.tracking.JUnit/hosted.html?net_xxxxxxxxx_tracking_tracking_JUnit (172.20.108.99) 11757 bytes

Validating newly compiled units

   Ignored 5 units with compilation errors in first pass.

Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.

Module net.xxxxxxxxx.tracking.tracking.JUnit has been loaded

200 - POST /net.xxxxxxxxx.tracking.tracking.JUnit/junithost (172.20.108.99) 432 bytes

REMEMBER! Bus tests will not succeed if:

1. You do not run the unit tests with the flag: -Dorg.jboss.errai.bus.do_long_poll=false

2. You do not have the main and test source directories in the runtime classpath

All clients connected (Limiting future permutations to: gecko1_8)

set-up

GET()

[errai] wait for: org.jboss.errai.marshalling.client.api.MarshallerFramework

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/C:/Users/mkettler/.m2/repository/org/jboss/weld/servlet/weld-servlet/1.1.6.Final/weld-servlet-1.1.6.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/C:/Users/mkettler/.m2/repository/org/jboss/weld/servlet/weld-servlet/1.1.5.Final/weld-servlet-1.1.5.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory

   Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator

      Generating Marshallers Bootstrapper...

25.04.2012 15:55:03 org.jboss.errai.marshalling.rebind.MarshallerGeneratorFactory generate

INFO: generating marshalling class...

25.04.2012 15:55:04 org.jboss.errai.reflections.Reflections scan

INFO: Reflections took 686 ms to scan 15 urls, producing 368 keys and 1481 values

25.04.2012 15:55:05 org.jboss.errai.reflections.Reflections scan

INFO: Reflections took 384 ms to scan 15 urls, producing 368 keys and 1481 values

25.04.2012 15:55:05 org.jboss.errai.marshalling.rebind.MarshallerGeneratorFactory generate

INFO: generated marshalling class in 2140ms.

25.04.2012 15:55:06 org.jboss.errai.marshalling.rebind.MarshallersGenerator _generate

INFO: *** using temporary path: C:\Users\mkettler\AppData\Local\Temp\errai\d2fe90ffcffc23d4c19c6e2d4fb54421ba52b1de64a92641d3efe9255f18a4d\errai.marshalling\gen ***

25.04.2012 15:55:08 org.jboss.errai.marshalling.rebind.MarshallerGeneratorFactory generate

INFO: generating marshalling class...

25.04.2012 15:55:09 org.jboss.errai.marshalling.rebind.MarshallerGeneratorFactory generate

INFO: generated marshalling class in 534ms.

[errai] vote For: org.jboss.errai.marshalling.client.api.MarshallerFramework

[errai] wait for: org.jboss.errai.bus.client.framework.ClientMessageBusImpl

[errai] wait for: org.jboss.errai.bus.client.framework.RpcProxyLoader

DEBUG: Connecting Errai at URL out.65331-22649.erraiBus?z=0

[errai] sending initial handshake to remote bus

[WARN] 404 - POST /net.xxxxxxxxx.tracking.tracking.JUnit/out.65331-22649.erraiBus?z=1 (172.20.108.99) 1447 bytes

   Request headers

      Host: 172.20.108.99:64023

      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19

      Accept-Language: en-us

      Accept: */*

      Connection: Keep-Alive

      Referer: http://172.20.108.99:64023/net.xxxxxxxxx.tracking.tracking.JUnit/junit-standards.html?gwt.codesvr=172.20.108.99:64019

      Content-Type: application/json

      Content-Length: 82

      RemoteQueueID: 65331-22649

      phase: connection

   Response headers

      Content-Type: text/html; charset=iso-8859-1

      Content-Length: 1447

[errai] received response from initial handshake.

com.google.gwt.json.client.JSONException: Error parsing JSON: SyntaxError: Unexpected token: <

    at com.google.gwt.json.client.JSONParser.throwJSONException(JSONParser.java:91)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)

    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)

    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)

    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)

    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)

    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)

    at com.google.gwt.json.client.JSONParser.evaluate(JSONParser.java)

    at com.google.gwt.json.client.JSONParser.parse(JSONParser.java:213)

    at com.google.gwt.json.client.JSONParser.parseStrict(JSONParser.java:87)

    at org.jboss.errai.bus.client.json.JSONUtilCli.decodePayload(JSONUtilCli.java:61)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procPayload(ClientMessageBusImpl.java:1457)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1452)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$6(ClientMessageBusImpl.java:1451)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl$11.onResponseReceived(ClientMessageBusImpl.java:1156)

    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)

    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)

    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)

    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)

    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)

    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)

    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)

    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)

    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)

    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)

    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)

    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)

    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)

    at java.lang.Thread.run(Thread.java:662)

ERROR: Error delivering message into bus -- Additional Details: <html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>

<title>Error 404 NOT_FOUND</title>

</head>

<body><h2>HTTP ERROR: 404</h2><pre>NOT_FOUND</pre>

<p>RequestURI=/net.xxxxxxxxx.tracking.tracking.JUnit/out.65331-22649.erraiBus</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

<br/>                                               

 

</body>

</html>

 

com.google.gwt.json.client.JSONException: Error parsing JSON: SyntaxError: Unexpected token: <

    at com.google.gwt.json.client.JSONParser.throwJSONException(JSONParser.java:91)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)

    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)

    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)

    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)

    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)

    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)

    at com.google.gwt.json.client.JSONParser.evaluate(JSONParser.java)

    at com.google.gwt.json.client.JSONParser.parse(JSONParser.java:213)

    at com.google.gwt.json.client.JSONParser.parseStrict(JSONParser.java:87)

    at org.jboss.errai.bus.client.json.JSONUtilCli.decodePayload(JSONUtilCli.java:61)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procPayload(ClientMessageBusImpl.java:1457)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.procIncomingPayload(ClientMessageBusImpl.java:1452)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl.access$6(ClientMessageBusImpl.java:1451)

    at org.jboss.errai.bus.client.framework.ClientMessageBusImpl$11.onResponseReceived(ClientMessageBusImpl.java:1156)

    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)

    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)

    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)

    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)

    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)

    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)

    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)

    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)

    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)

    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)

    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)

    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)

    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)

    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)

    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)

    at java.lang.Thread.run(Thread.java:662)

25.04.2012 15:55:10 org.jboss.errai.bus.rebind.RpcProxyLoaderGenerator generate

INFO: nothing has changed. using cached rpc proxy loader class.

[errai] vote For: org.jboss.errai.bus.client.framework.RpcProxyLoader

[errai]   still waiting for -> [org.jboss.errai.bus.client.framework.ClientMessageBusImpl]

[WARN] 404 - GET /net.xxxxxxxxx.tracking.tracking.JUnit/in.65331-22649.erraiBus?z=2 (172.20.108.99) 1446 bytes

   Request headers

      Host: 172.20.108.99:64023

      User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19

      Accept-Language: en-us

      Accept: */*

      Connection: Keep-Alive

      Referer: http://172.20.108.99:64023/net.xxxxxxxxx.tracking.tracking.JUnit/junit-standards.html?gwt.codesvr=172.20.108.99:64019

      Content-Type: application/json

      RemoteQueueID: 65331-22649

   Response headers

      Content-Type: text/html; charset=iso-8859-1

      Content-Length: 1446

Unloading module net.xxxxxxxxx.tracking.tracking.JUnit (net.xxxxxxxxx.tracking.tracking.JUnit)

 

Thanks in advance.

David