On Thursday, December 3, 2015 at 9:21:17 AM UTC+1, gau...@ainosoft.com wrote:
Hi everybody,I have a GWTTestCase that needs to fetch some JSON produced on the server and use in a test.Though I have unit tests to validate everything else I am trying to write an end to end test as a GWTTestCase since it will also allow me to debug my client side code.When I invoke a servlet after adding the servlet to my test module xml it reaches the servlet but bypasses all the filters etc.
It does not "bypass" the filters, given that it doesn't use your web.xml at all: there are no filters configured.
How can I make sure that that the entire filter / listener chain is invoked on the server side when I invoke the servlet ?
You can't. There's no way to configure filters for use in GWTTestCase.
You can however write a servlet for your test that will create and initialize your filter and your "real" servlet though. Something like:
public class TestServlet extends GenericServlet {
private Filter myFilter;
private Servlet myServlet;
@Override
public void init() throws ServletException {
myFilter = new MyFilter();
myFilter.init(getServletConfig());
myServlet = new MyServlet();
myServlet.init(getServletConfig());
}
@Override
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
myFilter.doFilter(request, response, new FilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
myServlet.service(request, response);
}
});
}
@Override
public void destroy() {
myServlet.destroy();
myServlet = null;
myFilter.destroy();
myFilter = null;
}
}
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment