JUnit Testing with the GWT Handler

4 views
Skip to first unread message

modnar

unread,
Apr 18, 2007, 12:52:38 PM4/18/07
to gwt-sl
I have an application which utilizes the GWT Handler. I would like to
be able to use JUnit to test these services to ensure that they are
functioning properly. In looking at running the GWTTestCase in hosted
mode for testing, I discovered that the GWTShellServlet is mapped to /
*. This will cause any and all *.rpc mappings to go to the
GWTShellServlet rather than the SpringDispatchServlet.

I was wondering if anyone had tried to configure this testing before
with any success, or if there were alternative suggestions.

Thanks in advance for your help.

George Georgovassilis

unread,
Apr 18, 2007, 2:57:26 PM4/18/07
to gwt...@googlegroups.com
Hello modnar

You can test your services with an XMLWebApplicationContext, which is the same way the gwt-sl unit tests do it and should be sufficient for unit testing. I think you are in fact referring to integration testing since you want to include your client code into the testing, which is of course far better when you want to invest limited time into developing tests.

You might also want to have a look at [1] where a possible solution is described.

[1] http://groups.google.com/group/gwt-sl/browse_thread/thread/341ea2873aecfa22

modnar

unread,
Apr 20, 2007, 4:37:24 PM4/20/07
to gwt-sl
George

Thanks for the reply.

I'd thought about using the XML file to execute the test but was
hoping to try and get it working using the GWTTestCase.

I looked at your link and I've gotten that working for my normal
development. However, for whatever reason when you lauch your
GWTTestCases from the JVM (either using the generated .launch file for
Eclipse or an Ant task) it uses the contained Tomcat instance for the
testing. I thought I would be smart and overwrite the web.xml, but
for whatever reason the tests absolutely will not execute unless the
shell is mapped to /*.

This may just be a limitation that there's no way around, but I wasn't
sure if anyone could offer any pointers.

I think my next step is to dig into GWTTestCase to try and see how
that is put together and if it's modifiable.

Thanks.


On Apr 18, 11:57 am, "George Georgovassilis"


<g.georgovassi...@gmail.com> wrote:
> Hello modnar
>
> You can test your services with an XMLWebApplicationContext, which is the
> same way the gwt-sl unit tests do it and should be sufficient for unit
> testing. I think you are in fact referring to integration testing since you
> want to include your client code into the testing, which is of course far
> better when you want to invest limited time into developing tests.
>
> You might also want to have a look at [1] where a possible solution is
> described.
>

> [1]http://groups.google.com/group/gwt-sl/browse_thread/thread/341ea2873a...

modnar

unread,
Apr 23, 2007, 2:29:26 PM4/23/07
to gwt-sl
Just in case anyone is curious, I was able to get this to work without
having to change any code.

Basically if you pay attention when your GWTTestCases are executed a /
tomcat directory is created. Inside that directory is this structure

/tomcat
/tomcat/webapps
/tomcat/webapps/ROOT
/tomcat/webapps/ROOT/WEB-INF
/tomcat/webapps/ROOT/WEB-INF/web.xml

That web.xml file contains a mapping of GWTShell to /*.

To get this to work you should:

1) Move the /ROOT directory to /shell
2) Add in your own web.xml and servlet.xml file to /ROOT/WEB-INF
3) Change your getModuleName() call in your GWTTestCase to be /shell/
<MODULE NAME>

This sounds kinda messy and it is, but by configuring all of this in
ANT tasks I was able to get it to work so that I can now perform these
integration tests.

On Apr 20, 1:37 pm, modnar <j...@modnar.net> wrote:
> George
>
> Thanks for the reply.
>

> I'd thought about using the XML file to execute thetestbut was


> hoping to try and get it working using the GWTTestCase.
>
> I looked at your link and I've gotten that working for my normal
> development. However, for whatever reason when you lauch your
> GWTTestCases from the JVM (either using the generated .launch file for

> Eclipse or anAnttask) it uses the contained Tomcat instance for the


> testing. I thought I would be smart and overwrite the web.xml, but
> for whatever reason the tests absolutely will not execute unless the
> shell is mapped to /*.
>
> This may just be a limitation that there's no way around, but I wasn't
> sure if anyone could offer any pointers.
>
> I think my next step is to dig into GWTTestCase to try and see how
> that is put together and if it's modifiable.
>
> Thanks.
>
> On Apr 18, 11:57 am, "George Georgovassilis"
>
> <g.georgovassi...@gmail.com> wrote:
> > Hello modnar
>

> > You cantestyour services with an XMLWebApplicationContext, which is the
> > same way thegwt-sl unit tests do it and should be sufficient for unit


> > testing. I think you are in fact referring to integration testing since you
> > want to include your client code into the testing, which is of course far
> > better when you want to invest limited time into developing tests.
>
> > You might also want to have a look at [1] where a possible solution is
> > described.
>
> > [1]http://groups.google.com/group/gwt-sl/browse_thread/thread/341ea2873a...
>
> > On 4/18/07, modnar <j...@modnar.net> wrote:
>

> > > I have an application which utilizes theGWTHandler. I would like to
> > > be able to use JUnit totestthese services to ensure that they are

George Georgovassilis

unread,
Apr 23, 2007, 3:56:19 PM4/23/07
to gwt...@googlegroups.com
Thank you for sharing!
Reply all
Reply to author
Forward
0 new messages