开发者

How to combine client-only and server-only code in an integration test?

I'm using a mechanism to pass bootstrapping information embedded in the host page (which is a servlet/jsp combination) from the server to the client. The bootstrapping information contains vital information that is required during client start up which saves one client/server round trip and therefore speeds up application start up.

I'm using Gson to serialize the bootstrapping information and inject it directly into a tag in the host page. The information is accessed on the client using JS Overlay Types. Because passing long values from JS to Java isn't supported by GWT I'm using a custom JsonSerializer which turns all longs/Longs into Strings.

All o开发者_Python百科f this works fine but it is a little fragile. Therefore I'd love to verify the correct behavior in an integration test which covers both the server and the client side components. This is where I ran into trouble: Gson (used in the server side component) isn't GWT compatible and JS Overlay Types obviously aren't Java compatible.

My question is: Is it possible to write a GWTTestCase which runs some parts of the code as pure Java (ie. on the integrated server)? If not, do you have any other recommendations on how to test this?

Thanks a lot! Michael


Write a servlet for you test using Gson, that you map using a <servlet path="…" class="…" /> tag in a gwt.xml (make one specifically for your tests that inherits the one from your application/production-module); then write a GWTTestCase for the client-side.

Have a look at how GWT tests itself (RequestBuilder, GWT-RPC, FormPanel), e.g. http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/http/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜