0

I have been using GwtTestCase for a while and am trying to test a simple RestyGwt client api. I have added the servlet to my gwt.xml class but am not able to get any logging from the servlet. It appears that the servlet is not being created.

Here is my simple servlet that I have tried to get some kind of information from, including just throwing a runtime exception.

public class JerseyTestServlet extends ServletContainer {

    {
        System.err.println("RUNNING JERESEY TEST SERVLET");
    }

    private static final long serialVersionUID = -7518118461257020639L;

    public JerseyTestServlet() {
        super(new RestApplication());

        System.out.println("RUNNING JERESEY TEST SERVLET");
        throw new RuntimeException("FOOO");
    }
}

The class does match the class name and package of the servlet.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='simulator'>

    <inherits name="com.testing.NgProductionClient"  />

    <servlet path='/rest' class='com.testing.JerseyTestServlet'/>
</module>

I want to get some kind of debugging information about the servlet when it starts up so I can troubleshoot path'ing problems as they arrise. Is it possible to get debugging information from the servlet inside a GwtTestCase?

Chris Hinshaw
  • 6,967
  • 2
  • 39
  • 65

1 Answers1

0

My mistake of course. The .gwt.xml file should contain the glob path for all the rest services so in my case it needed the /rest/* . Once I did this the rest service worked for my unit tests. Also I forgot that the servlet doesn't start by default unless you give it the options to load on default but I don't know how this is possible without the test framework using a web.xml. I am happy with the solution and it makes testing a Mock'd rest client very simple.

Chris Hinshaw
  • 6,967
  • 2
  • 39
  • 65