private String testLocation(String base, String contextPath, String servletPath, String pathInfo)
      throws Exception {

    HttpServletRequest request = createNonIncludeRequest(base, contextPath, servletPath, pathInfo);
    // Set request into replay mode
    replay(request);

    String location =
        servlet.getService().getStaticFileLocation(servlet.createVaadinRequest(request));
    return location;
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    servlet = new VaadinServlet();

    // Workaround to avoid calling init and creating servlet config
    Field f = VaadinServlet.class.getDeclaredField("servletService");
    f.setAccessible(true);
    VaadinServletService service =
        new VaadinServletService(
            servlet, new DefaultDeploymentConfiguration(servlet.getClass(), new Properties()));
    service.init();
    f.set(servlet, service);
  }
예제 #3
0
 @Test
 public void testGetLastPathParameter() {
   Assert.assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com"));
   Assert.assertEquals(";a", VaadinServlet.getLastPathParameter("http://myhost.com;a"));
   Assert.assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/hello"));
   Assert.assertEquals(";b=c", VaadinServlet.getLastPathParameter("http://myhost.com/hello;b=c"));
   Assert.assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/hello/"));
   Assert.assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/hello;a/"));
   Assert.assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/hello;a=1/"));
   Assert.assertEquals(";b", VaadinServlet.getLastPathParameter("http://myhost.com/hello/;b"));
   Assert.assertEquals(";b=1", VaadinServlet.getLastPathParameter("http://myhost.com/hello/;b=1"));
   Assert.assertEquals(
       ";b=1,c=2", VaadinServlet.getLastPathParameter("http://myhost.com/hello/;b=1,c=2"));
   Assert.assertEquals(
       "", VaadinServlet.getLastPathParameter("http://myhost.com/hello/;b=1,c=2/"));
   Assert.assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/a;hello/;a/"));
   Assert.assertEquals("", VaadinServlet.getLastPathParameter("http://myhost.com/a;hello/;a=1/"));
   Assert.assertEquals(";b", VaadinServlet.getLastPathParameter("http://myhost.com/a;hello/;b"));
   Assert.assertEquals(
       ";b=1", VaadinServlet.getLastPathParameter("http://myhost.com/a;hello/;b=1"));
   Assert.assertEquals(
       ";b=1,c=2", VaadinServlet.getLastPathParameter("http://myhost.com/a;hello/;b=1,c=2"));
   Assert.assertEquals(
       "", VaadinServlet.getLastPathParameter("http://myhost.com/a;hello/;b=1,c=2/"));
 }