diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/.settings/org.eclipse.pde.prefs b/bundles/org.eclipse.equinox.http.servlet.tests/.settings/org.eclipse.pde.prefs old mode 100755 new mode 100644 diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/about.html b/bundles/org.eclipse.equinox.http.servlet.tests/about.html index 164f781a8fd..8eee37d4705 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/about.html +++ b/bundles/org.eclipse.equinox.http.servlet.tests/about.html @@ -33,4 +33,4 @@

License

- \ No newline at end of file + diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestResource.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestResource.java index ec9a4f1a46a..1d5a16fa9d8 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestResource.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestResource.java @@ -38,7 +38,7 @@ public abstract class AbstractTestResource { public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { HttpService service = getHttpService(); String alias = getAlias(); - service.registerResources(alias, getName() , null); + service.registerResources(alias, getName(), null); } protected final String createDefaultAlias() { diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestServlet.java index 58fd6b31201..54316be0b07 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractTestServlet.java @@ -65,7 +65,8 @@ public void deactivate() { } @Override - protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected final void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { try (PrintWriter writer = response.getWriter()) { handleDoGet(request, writer); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestFilter.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestFilter.java index 9056fa85104..c4e830354fa 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestFilter.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestFilter.java @@ -40,13 +40,10 @@ public void destroy() { } @Override - public void doFilter( - ServletRequest request, ServletResponse response, - FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { - CharResponseWrapper charResponseWrapper = new CharResponseWrapper( - (HttpServletResponse) response); + CharResponseWrapper charResponseWrapper = new CharResponseWrapper((HttpServletResponse) response); chain.doFilter(request, charResponseWrapper); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestServlet.java index 5ca2d82d8e1..adb3b9b5d31 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb/AbstractWhiteboardTestServlet.java @@ -29,7 +29,8 @@ public class AbstractWhiteboardTestServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { try (PrintWriter writer = response.getWriter()) { handleDoGet(request, writer); } @@ -40,4 +41,4 @@ protected void handleDoGet(HttpServletRequest request, PrintWriter writer) throw writer.print(AbstractTestServlet.STATUS_OK); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage1.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage1.java index 2d2fef7b88d..b5f718bc276 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage1.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage1.java @@ -39,6 +39,7 @@ public class TestErrorPage1 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); @@ -47,7 +48,7 @@ public void activate(ComponentContext componentContext) { registrations.add(componentContext.getBundleContext().registerService(Servlet.class, this, servletProps)); Dictionary errorProps = new Hashtable<>(); errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "E1"); - errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, new String[] {"403", "404"}); + errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, new String[] { "403", "404" }); registrations.add(componentContext.getBundleContext().registerService(Servlet.class, errorServlet, errorProps)); } @@ -59,8 +60,7 @@ public void deactivate() { } @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendError(403); } @@ -69,9 +69,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { if (response.isCommitted()) { System.out.println("Problem?"); @@ -81,8 +79,8 @@ protected void service( PrintWriter writer = response.getWriter(); - String requestURI = (String)request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); - Integer status = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + String requestURI = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); + Integer status = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); writer.print(status + " ERROR : " + requestURI); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage2.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage2.java index 1d4acfd077d..e89c9453478 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage2.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage2.java @@ -42,6 +42,7 @@ public class TestErrorPage2 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); @@ -50,7 +51,8 @@ public void activate(ComponentContext componentContext) { registrations.add(componentContext.getBundleContext().registerService(Servlet.class, this, servletProps)); Dictionary errorProps = new Hashtable<>(); errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "E1"); - errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, new String[] {MyException.class.getName()}); + errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, + new String[] { MyException.class.getName() }); registrations.add(componentContext.getBundleContext().registerService(Servlet.class, errorServlet, errorProps)); } @@ -62,8 +64,7 @@ public void deactivate() { } @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws ServletException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException { throw new MyException(); } @@ -73,9 +74,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { if (response.isCommitted()) { System.out.println("Problem?"); @@ -85,8 +84,8 @@ protected void service( PrintWriter writer = response.getWriter(); - String requestURI = (String)request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); - String exception = (String)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE); + String requestURI = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); + String exception = (String) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE); writer.print(exception + " ERROR : " + requestURI); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage3.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage3.java index f188469dc26..90515d2d8db 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage3.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage3.java @@ -39,6 +39,7 @@ public class TestErrorPage3 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); @@ -59,8 +60,7 @@ public void deactivate() { } @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendError(400); } @@ -69,9 +69,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { if (response.isCommitted()) { System.out.println("Problem?"); @@ -81,8 +79,8 @@ protected void service( PrintWriter writer = response.getWriter(); - String requestURI = (String)request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); - Integer status = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + String requestURI = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); + Integer status = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); writer.print(status + " ERROR : " + requestURI); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage4.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage4.java index e721579c210..74d4c2fa017 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage4.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestErrorPage4.java @@ -39,6 +39,7 @@ public class TestErrorPage4 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); @@ -59,8 +60,7 @@ public void deactivate() { } @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setStatus(401); @@ -71,9 +71,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { if (response.isCommitted()) { System.out.println("Problem?"); @@ -83,8 +81,8 @@ protected void service( PrintWriter writer = response.getWriter(); - String requestURI = (String)request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); - Integer status = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + String requestURI = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); + Integer status = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); writer.print(status + " ERROR : " + requestURI); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter1.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter1.java index 5d5de637baf..9a625654ffa 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter1.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter1.java @@ -36,14 +36,14 @@ public class TestFilter1 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(regexAlias(), this, null, null); service.registerFilter(regexAlias(), f1, new Hashtable<>(), null); } @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(regexAlias()); service.unregisterFilter(f1); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter10.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter10.java index dd63c5b1b09..f2d276e0b47 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter10.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter10.java @@ -37,6 +37,7 @@ public class TestFilter10 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter12.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter12.java index 9dd44869274..df5f46e613b 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter12.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter12.java @@ -38,6 +38,7 @@ public class TestFilter12 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter13.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter13.java index e8d90d98e3b..be7ec5346db 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter13.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter13.java @@ -37,6 +37,7 @@ public class TestFilter13 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter2.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter2.java index c418fe0cda9..845bcc93731 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter2.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter2.java @@ -36,7 +36,7 @@ public class TestFilter2 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(regexAlias(), this, null, null); service.registerFilter(regexAlias(), f1, new Hashtable<>(), null); service.registerFilter(regexAlias(), f2, new Hashtable<>(), null); @@ -44,7 +44,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(regexAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter3.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter3.java index 4353bc2bb23..3ce2832dd98 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter3.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter3.java @@ -36,7 +36,7 @@ public class TestFilter3 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(regexAlias(), this, null, null); service.registerFilter(regexAlias(), f1, new Hashtable<>(), null); service.registerFilter(regexAlias(), f2, new Hashtable<>(), null); @@ -45,7 +45,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(regexAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter4.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter4.java index 8f20a3dd90b..64a91b1cb16 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter4.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter4.java @@ -36,7 +36,7 @@ public class TestFilter4 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(regexAlias(), this, null, null); service.registerFilter(regexAlias(), f1, new Hashtable<>(), null); service.registerFilter(regexAlias(), f2, new Hashtable<>(), null); @@ -47,7 +47,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(regexAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter5.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter5.java index 6c80898e3b6..cd48d86ea4a 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter5.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter5.java @@ -36,14 +36,14 @@ public class TestFilter5 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(extensionAlias(), this, null, null); service.registerFilter(extensionAlias(), f1, new Hashtable<>(), null); } @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(extensionAlias()); service.unregisterFilter(f1); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter6.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter6.java index ff8a89793dc..c21ce1960c1 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter6.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter6.java @@ -36,7 +36,7 @@ public class TestFilter6 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(extensionAlias(), this, null, null); service.registerFilter(extensionAlias(), f1, new Hashtable<>(), null); service.registerFilter(extensionAlias(), f2, new Hashtable<>(), null); @@ -44,7 +44,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(extensionAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter7.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter7.java index 7b5c6eaf1dc..b647663d028 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter7.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter7.java @@ -36,7 +36,7 @@ public class TestFilter7 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(extensionAlias(), this, null, null); service.registerFilter(extensionAlias(), f1, new Hashtable<>(), null); service.registerFilter(extensionAlias(), f2, new Hashtable<>(), null); @@ -45,7 +45,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(extensionAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter8.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter8.java index ee67ec91e0e..41c5042909d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter8.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter8.java @@ -36,7 +36,7 @@ public class TestFilter8 extends AbstractTestServlet { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.registerServlet(extensionAlias(), this, null, null); service.registerFilter(extensionAlias(), f1, new Hashtable<>(), null); service.registerFilter(extensionAlias(), f2, new Hashtable<>(), null); @@ -47,7 +47,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(extensionAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter9.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter9.java index 685bfb88d9d..df89fa8ad04 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter9.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestFilter9.java @@ -38,6 +38,7 @@ public class TestFilter9 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); @@ -57,7 +58,6 @@ public void deactivate() { } } - @Override protected void handleDoGet(HttpServletRequest request, PrintWriter writer) { writer.print('a'); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource2.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource2.java index 59b55c9f3a2..11e4cc4d0fc 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource2.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource2.java @@ -32,8 +32,8 @@ public class TestResource2 extends AbstractTestResource { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); - service.registerResources(regexAlias(), getName() , null); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); + service.registerResources(regexAlias(), getName(), null); service.registerFilter(regexAlias(), f1, new Hashtable<>(), null); service.registerFilter(regexAlias(), f2, new Hashtable<>(), null); service.registerFilter(regexAlias(), f3, new Hashtable<>(), null); @@ -41,7 +41,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(regexAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource3.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource3.java index 3b96d1d38b5..a5af569914f 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource3.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource3.java @@ -29,12 +29,14 @@ */ public class TestResource3 extends AbstractTestResource { private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary resourceProps = new Hashtable<>(); resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, regexAlias()); resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, getName()); - registrations.add(componentContext.getBundleContext().registerService(TestResource3.class, this, resourceProps)); + registrations + .add(componentContext.getBundleContext().registerService(TestResource3.class, this, resourceProps)); } @Override diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource4.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource4.java index bea7be44652..b186811fefd 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource4.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource4.java @@ -32,8 +32,8 @@ public class TestResource4 extends AbstractTestResource { @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); - service.registerResources(regexAlias(), getName() , null); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); + service.registerResources(regexAlias(), getName(), null); service.registerFilter(regexAlias(), f1, new Hashtable<>(), null); service.registerFilter(regexAlias(), f2, new Hashtable<>(), null); Hashtable hashtable = new Hashtable<>(); @@ -43,7 +43,7 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override public void deactivate() { - ExtendedHttpService service = (ExtendedHttpService)getHttpService(); + ExtendedHttpService service = (ExtendedHttpService) getHttpService(); service.unregister(regexAlias()); service.unregisterFilter(f1); service.unregisterFilter(f2); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource5.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource5.java index 18b93e1a159..708fb65f960 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource5.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestResource5.java @@ -34,12 +34,14 @@ public class TestResource5 extends AbstractTestResource { private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary resourceProps = new Hashtable<>(); resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, regexAlias()); resourceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, getName()); - registrations.add(componentContext.getBundleContext().registerService(TestResource5.class, this, resourceProps)); + registrations + .add(componentContext.getBundleContext().registerService(TestResource5.class, this, resourceProps)); Dictionary filterProps = new Hashtable<>(); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet10.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet10.java index ccecb91ea1d..2ea1506cc81 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet10.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet10.java @@ -32,13 +32,12 @@ public class TestServlet10 extends AbstractTestServlet { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { ServletContext servletContext = getServletContext(); - try (InputStream in = servletContext.getResourceAsStream( - "/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt"); + try (InputStream in = servletContext + .getResourceAsStream("/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt"); OutputStream out = response.getOutputStream()) { byte[] buffer = new byte[2048]; int bytesRead; diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet11.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet11.java index 1c823c8d7bc..7455e22a43a 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet11.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet11.java @@ -32,15 +32,14 @@ public class TestServlet11 extends AbstractTestServlet { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { ServletContext servletContext = getServletContext(); ClassLoader classLoader = servletContext.getClassLoader(); - try (InputStream in = classLoader.getResourceAsStream( - "/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt"); + try (InputStream in = classLoader + .getResourceAsStream("/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt"); OutputStream out = response.getOutputStream()) { byte[] buffer = new byte[2048]; int bytesRead; diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet2.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet2.java index 1ab5bf05f73..0c0d2ff5674 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet2.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet2.java @@ -30,7 +30,7 @@ public class TestServlet2 extends AbstractTestServlet { private int getEffectiveMajorVersion() { ServletContext context = getServletContext(); return context.getEffectiveMajorVersion(); // This is a Servlet 4.0 API. - + } @Override diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet3.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet3.java index 7eb7810c4ae..64deb3dd65d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet3.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet3.java @@ -32,10 +32,12 @@ public class TestServlet3 extends AbstractTestServlet { @Override protected void handleDoGet(HttpServletRequest request, PrintWriter writer) throws ServletException, IOException { - String expected = "Equinox"; //$NON-NLS-1$ + String expected = "Equinox"; //$NON-NLS-1$ try { - // Not a terribly useful test, but previous test assumed we could call setComment on a SessionCookieConfig - // after ServletContext initialization. This is not allowed by the servlet specification. + // Not a terribly useful test, but previous test assumed we could call + // setComment on a SessionCookieConfig + // after ServletContext initialization. This is not allowed by the servlet + // specification. // Just verifying that an ISE is thrown now. setSessionCookieConfigComment(expected); writer.print(AbstractTestServlet.STATUS_ERROR); @@ -43,10 +45,10 @@ protected void handleDoGet(HttpServletRequest request, PrintWriter writer) throw super.handleDoGet(request, writer); } } - + private void setSessionCookieConfigComment(String comment) { ServletContext context = getServletContext(); - SessionCookieConfig cookieConfig = context.getSessionCookieConfig(); // This is a Servlet 3.0 API. + SessionCookieConfig cookieConfig = context.getSessionCookieConfig(); // This is a Servlet 3.0 API. cookieConfig.setComment(comment); } } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet9.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet9.java index a07d44ebef9..21579b41473 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet9.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServlet9.java @@ -36,6 +36,7 @@ public class TestServlet9 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final DispatchTo dispatchTo = new DispatchTo(); + @Override public void activate(ComponentContext componentContext) throws ServletException, NamespaceException { HttpService service = getHttpService(); @@ -47,10 +48,10 @@ public void activate(ComponentContext componentContext) throws ServletException, @Override protected void service(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { - RequestDispatcher requestDispatcher = - request.getServletContext().getNamedDispatcher(DispatchTo.class.getName()); + RequestDispatcher requestDispatcher = request.getServletContext() + .getNamedDispatcher(DispatchTo.class.getName()); requestDispatcher.include(request, response); } @@ -62,10 +63,11 @@ protected void handleDoGet(HttpServletRequest request, PrintWriter writer) { class DispatchTo extends AbstractTestServlet { private static final long serialVersionUID = 1L; + @Override protected void handleDoGet(HttpServletRequest request, PrintWriter writer) { writer.print(TestServlet9.this.getProperties().get(Constants.SERVICE_DESCRIPTION)); } - + } } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper1.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper1.java index 3b3a635fcfb..a2437c9c398 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper1.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper1.java @@ -13,7 +13,8 @@ public class TestServletContextHelper1 extends ServletContextHelper { public void activate(ComponentContext componentContext) { - delegate = new ServletContextHelper(componentContext.getBundleContext().getBundle()) {}; + delegate = new ServletContextHelper(componentContext.getBundleContext().getBundle()) { + }; } @Override @@ -58,4 +59,4 @@ public String getRealPath(String path) { private ServletContextHelper delegate; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper10.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper10.java index d82d550bcd6..f6e79dd55fa 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper10.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/TestServletContextHelper10.java @@ -40,27 +40,32 @@ public class TestServletContextHelper10 extends AbstractTestServlet { private static final long serialVersionUID = 1L; private final Collection> registrations = new ArrayList<>(); + @Override public void activate(ComponentContext componentContext) { Dictionary servletProps = new Hashtable<>(); servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, regexAlias()); - servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(componentContext.getBundleContext().registerService(Servlet.class, this, servletProps)); Dictionary filterProps = new Hashtable<>(); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, regexAlias()); - filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(componentContext.getBundleContext().registerService(Filter.class, f1, filterProps)); BundleContext bundleContext = componentContext.getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) {}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(componentContext.getBundleContext().registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations.add(componentContext.getBundleContext().registerService(ServletContextHelper.class, + servletContextHelper, contextProps)); } @Override diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt index 2e65efe2a14..78981922613 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt @@ -1 +1 @@ -a \ No newline at end of file +a diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/BaseFilter.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/BaseFilter.java index 9bc0ec062fd..7c090d3b0d1 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/BaseFilter.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/BaseFilter.java @@ -42,13 +42,10 @@ public void destroy() { } @Override - public void doFilter( - ServletRequest request, ServletResponse response, - FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { - CharResponseWrapper charResponseWrapper = new CharResponseWrapper( - (HttpServletResponse) response); + CharResponseWrapper charResponseWrapper = new CharResponseWrapper((HttpServletResponse) response); chain.doFilter(request, charResponseWrapper); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/CharResponseWrapper.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/CharResponseWrapper.java index 8fa4ad29733..f1a313f11d5 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/CharResponseWrapper.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/util/CharResponseWrapper.java @@ -25,10 +25,10 @@ /** * @author Raymond Augé */ -public class CharResponseWrapper extends HttpServletResponseWrapper { +public class CharResponseWrapper extends HttpServletResponseWrapper { private CharArrayWriter output; - public CharResponseWrapper(HttpServletResponse response){ + public CharResponseWrapper(HttpServletResponse response) { super(response); output = new CharArrayWriter(); } @@ -56,7 +56,7 @@ public void setWriteListener(WriteListener writeListener) { } @Override - public PrintWriter getWriter(){ + public PrintWriter getWriter() { return new PrintWriter(output); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t1/WBServlet1.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t1/WBServlet1.java index 6b104a3221e..050ac337397 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t1/WBServlet1.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t1/WBServlet1.java @@ -31,4 +31,4 @@ protected void handleDoGet(HttpServletRequest request, PrintWriter writer) { writer.print('a'); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t2/WBServlet2.java b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t2/WBServlet2.java index 44cfd3f01ab..c5fb799baa5 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t2/WBServlet2.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/bundles_src/tb1/org/eclipse/equinox/http/servlet/tests/wb/t2/WBServlet2.java @@ -31,4 +31,4 @@ protected void handleDoGet(HttpServletRequest request, PrintWriter writer) { writer.print('a'); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/1/test b/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/1/test index 56a6051ca2b..d00491fd7e5 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/1/test +++ b/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/1/test @@ -1 +1 @@ -1 \ No newline at end of file +1 diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/2/test b/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/2/test index d8263ee9860..0cfbf08886f 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/2/test +++ b/bundles/org.eclipse.equinox.http.servlet.tests/http.context.test/2/test @@ -1 +1 @@ -2 \ No newline at end of file +2 diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java index bcabe7ba1c2..a969d1eea81 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java @@ -63,53 +63,26 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ - AuthenticationTest.class, - DispatchingTest.class, - PreprocessorTestCase.class, - ServletTest.class, - Test_140_11_3.class, - Test_140_2_17to22.class, - Test_140_2_26to27.class, - Test_140_2_39to41.class, - Test_140_2_6_getResourcePaths.class, - Test_140_4_11to13.class, - Test_140_4_14to15.class, - Test_140_4_16.class, - Test_140_4_17to22.class, - Test_140_4_1_22to23.class, - Test_140_4_26to31.class, - Test_140_4_42to44.class, - Test_140_4_9.class, - Test_140_6_1.class, - Test_140_6_20to21_commonProperties.class, - Test_140_7_validation.class, - Test_140_9_ServletContextDTO_custom_listener.class, - Test_140_9_ServletContextDTO_default_listener.class, - Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_bindUsingContextSelect.class, - Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_tieGoesToOldest.class, - Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type.class, - Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED.class, - Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate.class, - Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ERROR_PAGE_4xx.class, - Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ERROR_PAGE_exception.class, - Test_table_140_5_HTTP_WHITEBOARD_FILTER_DISPATCHER_error.class, - Test_table_140_5_HTTP_WHITEBOARD_FILTER_DISPATCHER_request.class, - Test_table_140_5_HTTP_WHITEBOARD_FILTER_PATTERN.class, - Test_table_140_5_HTTP_WHITEBOARD_FILTER_REGEX.class, - Test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation.class, - TestHttpServiceAndErrorPage.class, - TestHttpServiceAndNamedServlet.class, - TestUpload.class, - TestUploadWithParameter.class, - ContextHelperCustomizerTests.class, - Bug500783_Test.class, - Bug562843_Test.class, - Bug562843_2_Test.class, - Bug564747_Test.class, - Bug562440_Test.class, - Bug569406_Test.class -}) +@SuiteClasses({ AuthenticationTest.class, DispatchingTest.class, PreprocessorTestCase.class, ServletTest.class, + Test_140_11_3.class, Test_140_2_17to22.class, Test_140_2_26to27.class, Test_140_2_39to41.class, + Test_140_2_6_getResourcePaths.class, Test_140_4_11to13.class, Test_140_4_14to15.class, Test_140_4_16.class, + Test_140_4_17to22.class, Test_140_4_1_22to23.class, Test_140_4_26to31.class, Test_140_4_42to44.class, + Test_140_4_9.class, Test_140_6_1.class, Test_140_6_20to21_commonProperties.class, Test_140_7_validation.class, + Test_140_9_ServletContextDTO_custom_listener.class, Test_140_9_ServletContextDTO_default_listener.class, + Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_bindUsingContextSelect.class, + Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_tieGoesToOldest.class, + Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type.class, + Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED.class, + Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate.class, + Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ERROR_PAGE_4xx.class, + Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ERROR_PAGE_exception.class, + Test_table_140_5_HTTP_WHITEBOARD_FILTER_DISPATCHER_error.class, + Test_table_140_5_HTTP_WHITEBOARD_FILTER_DISPATCHER_request.class, + Test_table_140_5_HTTP_WHITEBOARD_FILTER_PATTERN.class, Test_table_140_5_HTTP_WHITEBOARD_FILTER_REGEX.class, + Test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation.class, TestHttpServiceAndErrorPage.class, + TestHttpServiceAndNamedServlet.class, TestUpload.class, TestUploadWithParameter.class, + ContextHelperCustomizerTests.class, Bug500783_Test.class, Bug562843_Test.class, Bug562843_2_Test.class, + Bug564747_Test.class, Bug562440_Test.class, Bug569406_Test.class }) public class AllTests { // see @SuiteClasses } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java index dbf2a03965c..fa195a9ba18 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/BaseTest.java @@ -81,7 +81,7 @@ public class BaseTest { - public static final String DEFAULT = HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME; + public static final String DEFAULT = HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME; @Before public void setUp() throws Exception { @@ -97,34 +97,32 @@ public void setUp() throws Exception { advisor = new BundleAdvisor(bundleContext); stopJetty(); startBundles(); - runtimeTracker = new ServiceTracker<>(bundleContext, HttpServiceRuntime.class, new ServiceTrackerCustomizer>() { - - @Override - public ServiceReference addingService( - ServiceReference reference) { - final Object obj = reference - .getProperty(Constants.SERVICE_CHANGECOUNT); - if (obj != null) { - httpRuntimeChangeCount.set(Long.valueOf(obj.toString())); - } - return reference; - } - - @Override - public void modifiedService( - ServiceReference reference, - ServiceReference service) { - addingService(reference); - } - - @Override - public void removedService( - ServiceReference reference, - ServiceReference service) { - httpRuntimeChangeCount.set(-1); - } - - }); + runtimeTracker = new ServiceTracker<>(bundleContext, HttpServiceRuntime.class, + new ServiceTrackerCustomizer>() { + + @Override + public ServiceReference addingService( + ServiceReference reference) { + final Object obj = reference.getProperty(Constants.SERVICE_CHANGECOUNT); + if (obj != null) { + httpRuntimeChangeCount.set(Long.valueOf(obj.toString())); + } + return reference; + } + + @Override + public void modifiedService(ServiceReference reference, + ServiceReference service) { + addingService(reference); + } + + @Override + public void removedService(ServiceReference reference, + ServiceReference service) { + httpRuntimeChangeCount.set(-1); + } + + }); runtimeTracker.open(); runtimeTracker.waitForService(100); startJetty(); @@ -145,8 +143,7 @@ public void tearDown() throws Exception { for (ServiceRegistration serviceRegistration : registrations) { try { serviceRegistration.unregister(); - } - catch (Exception e) { + } catch (Exception e) { // ignore } } @@ -157,7 +154,8 @@ protected String doRequest(String action, Map params) throws IOE return doRequestGetResponse(action, params).get("responseBody").get(0); } - protected Map> doRequestGetResponse(String action, Map params) throws IOException { + protected Map> doRequestGetResponse(String action, Map params) + throws IOException { StringBuilder requestInfo = new StringBuilder(PROTOTYPE); requestInfo.append(action); if (!params.isEmpty()) { @@ -221,12 +219,10 @@ protected String getProperty(String key) { protected List getStringPlus(String key, ServiceReference ref) { Object property = ref.getProperty(key); if (String.class.isInstance(property)) { - return Collections.singletonList((String)property); - } - else if (String[].class.isInstance(property)) { - return Arrays.asList((String[])property); - } - else if (Collection.class.isInstance(property)) { + return Collections.singletonList((String) property); + } else if (String[].class.isInstance(property)) { + return Arrays.asList((String[]) property); + } else if (Collection.class.isInstance(property)) { List list = new ArrayList<>(); for (Object o : ((Collection) property)) { if (o instanceof String) { @@ -266,8 +262,9 @@ protected void startJetty() throws Exception { requestAdvisor = new ServletRequestAdvisor(port, contextPath); } - protected void startJettyWithSSL(String port, String ksPath, String ksPassword, String keyPassword) throws Exception { - if(port == null) { + protected void startJettyWithSSL(String port, String ksPath, String ksPassword, String keyPassword) + throws Exception { + if (port == null) { throw new IllegalArgumentException("Port cannot be null"); } if (ksPath == null) { @@ -280,10 +277,10 @@ protected void startJettyWithSSL(String port, String ksPath, String ksPassword, setJettyProperty(JettyConstants.SSL_KEYSTORE, ksPath); - if(ksPassword != null) { + if (ksPassword != null) { setJettyProperty(JettyConstants.SSL_PASSWORD, ksPassword); } - if(keyPassword != null) { + if (keyPassword != null) { setJettyProperty(JettyConstants.SSL_KEYPASSWORD, keyPassword); } @@ -331,8 +328,8 @@ protected FailedServletDTO[] getFailedServletDTOs() { } protected HttpServiceRuntime getHttpServiceRuntime() { - ServiceReference serviceReference = - getBundleContext().getServiceReference(HttpServiceRuntime.class); + ServiceReference serviceReference = getBundleContext() + .getServiceReference(HttpServiceRuntime.class); assertNotNull(serviceReference); @@ -519,8 +516,7 @@ protected long waitForRegistration(final long previousCount) { return waitForRegistration(previousCount, 100); } - protected long waitForRegistration(final long previousCount, - int maxAttempts) { + protected long waitForRegistration(final long previousCount, int maxAttempts) { while (this.httpRuntimeChangeCount.longValue() == previousCount) { if (maxAttempts <= 0) { throw new IllegalStateException("Max attempts exceeded"); @@ -539,16 +535,14 @@ protected long getHttpRuntimeChangeCount() { return httpRuntimeChangeCount.longValue(); } - protected void registerDummyServletInHttpService() - throws ServletException, NamespaceException { + protected void registerDummyServletInHttpService() throws ServletException, NamespaceException { final String path = "/tesths"; final HttpService service = this.getHttpService(); service.registerServlet(path, new HttpServlet() { private static final long serialVersionUID = 1L; @Override - protected void doGet(HttpServletRequest req, - HttpServletResponse resp) throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.getWriter().print("helloworld"); resp.flushBuffer(); } @@ -560,11 +554,9 @@ protected void unregisterDummyServletFromHttpService() { } protected ServletContextDTO getServletContextDTOForDummyServlet() { - for (final ServletContextDTO dto : this.getHttpServiceRuntime() - .getRuntimeDTO().servletContextDTOs) { + for (final ServletContextDTO dto : this.getHttpServiceRuntime().getRuntimeDTO().servletContextDTOs) { for (final ServletDTO sd : dto.servletDTOs) { - if (sd.patterns.length > 0 - && "/tesths".equals(sd.patterns[0])) { + if (sd.patterns.length > 0 && "/tesths".equals(sd.patterns[0])) { return dto; } } @@ -573,8 +565,7 @@ protected ServletContextDTO getServletContextDTOForDummyServlet() { return null; } - protected FailedErrorPageDTO getFailedErrorPageDTOByException( - String exception) { + protected FailedErrorPageDTO getFailedErrorPageDTOByException(String exception) { for (FailedErrorPageDTO failedErrorPageDTO : getFailedErrorPageDTOs()) { for (String ex : failedErrorPageDTO.exceptions) { if (exception.equals(ex)) { @@ -586,10 +577,8 @@ protected FailedErrorPageDTO getFailedErrorPageDTOByException( return null; } - protected ErrorPageDTO getErrorPageDTOByException(String context, - String exception) { - ServletContextDTO servletContextDTO = getServletContextDTOByName( - context); + protected ErrorPageDTO getErrorPageDTOByException(String context, String exception) { + ServletContextDTO servletContextDTO = getServletContextDTOByName(context); if (servletContextDTO == null) { return null; @@ -606,7 +595,7 @@ protected ErrorPageDTO getErrorPageDTOByException(String context, return null; } - final AtomicLong httpRuntimeChangeCount = new AtomicLong(-1); + final AtomicLong httpRuntimeChangeCount = new AtomicLong(-1); protected static final String PROTOTYPE = "prototype/"; protected static final String CONFIGURE = "configure"; @@ -626,9 +615,7 @@ protected ErrorPageDTO getErrorPageDTOByException(String context, protected static final String TEST_BUNDLE_1 = "tb1"; protected static final String TEST_BUNDLE_2 = "tb2"; - protected static final String[] BUNDLES = new String[] { - EQUINOX_DS_BUNDLE - }; + protected static final String[] BUNDLES = new String[] { EQUINOX_DS_BUNDLE }; protected BundleInstaller installer; protected BundleAdvisor advisor; @@ -639,7 +626,8 @@ protected ErrorPageDTO getErrorPageDTOByException(String context, protected static class TestFilter implements Filter { AtomicInteger called = new AtomicInteger(0); - public TestFilter() {} + public TestFilter() { + } @Override public void init(FilterConfig filterConfig) { @@ -675,9 +663,11 @@ protected static class TestServletContextHelperFactory implements ServiceFactory static class TestServletContextHelper extends ServletContextHelper { public TestServletContextHelper(Bundle bundle) { super(bundle); - }} + } + } - public TestServletContextHelperFactory() {} + public TestServletContextHelperFactory() { + } @Override public ServletContextHelper getService(Bundle bundle, ServiceRegistration registration) { @@ -722,7 +712,7 @@ public String getContextPathPrefix(ServiceReference helper } - protected static class ErrorServlet extends HttpServlet{ + protected static class ErrorServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final String errorCode; @@ -732,9 +722,7 @@ public ErrorServlet(String errorCode) { } @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { if (response.isCommitted()) { System.out.println("Problem?"); @@ -744,8 +732,8 @@ protected void service( PrintWriter writer = response.getWriter(); - String requestURI = (String)request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); - Integer status = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + String requestURI = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI); + Integer status = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); writer.print(errorCode + " : " + status + " : ERROR : " + requestURI); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/AuthenticationTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/AuthenticationTest.java index 8edb555d672..ddd1e699744 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/AuthenticationTest.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/AuthenticationTest.java @@ -53,7 +53,8 @@ public void test_forwardSecurity() throws Exception { // request with auth and forward -> servlet invoked requestAdvisor.request("context1/servlet?forward=true&auth=true"); assertEquals(6, callStack.size()); - assertEquals(Arrays.asList("handle1", "servlet/context1", "handle1", "servlet/context1", "finish1", "finish1"), callStack); + assertEquals(Arrays.asList("handle1", "servlet/context1", "handle1", "servlet/context1", "finish1", "finish1"), + callStack); callStack.clear(); } @@ -78,86 +79,74 @@ public void test_handleFinishSecurity() throws Exception { assertEquals(Arrays.asList("handle2", "servlet/context2", "finish2"), callStack); } - private static final String AUTH_PAR = "auth"; + private static final String AUTH_PAR = "auth"; - private static final String REC_PAR = "rec"; + private static final String REC_PAR = "rec"; private void setup(final List callStack) { final BundleContext context = getBundleContext(); // setup context 1 - final Dictionary ctx1Props = new Hashtable<>(); + final Dictionary ctx1Props = new Hashtable<>(); ctx1Props.put(HTTP_WHITEBOARD_CONTEXT_NAME, "context1"); ctx1Props.put(HTTP_WHITEBOARD_CONTEXT_PATH, "/context1"); - registrations.add(context.registerService( - ServletContextHelper.class, - new ServletContextHelper() { + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { - @Override - public boolean handleSecurity(final HttpServletRequest request, final HttpServletResponse response) { + @Override + public boolean handleSecurity(final HttpServletRequest request, final HttpServletResponse response) { - if (request.getParameter(AUTH_PAR) != null) { - callStack.add("handle1"); - return true; - } - return false; + if (request.getParameter(AUTH_PAR) != null) { + callStack.add("handle1"); + return true; } + return false; + } - @Override - public void finishSecurity(final HttpServletRequest request, final HttpServletResponse response) { - callStack.add("finish1"); - } + @Override + public void finishSecurity(final HttpServletRequest request, final HttpServletResponse response) { + callStack.add("finish1"); + } - }, - ctx1Props) - ); + }, ctx1Props)); // setup context 2 - final Dictionary ctx2Props = new Hashtable<>(); + final Dictionary ctx2Props = new Hashtable<>(); ctx2Props.put(HTTP_WHITEBOARD_CONTEXT_NAME, "context2"); ctx2Props.put(HTTP_WHITEBOARD_CONTEXT_PATH, "/context2"); - registrations.add(context.registerService( - ServletContextHelper.class, - new ServletContextHelper() { + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { - @Override - public boolean handleSecurity(final HttpServletRequest request, final HttpServletResponse response) { + @Override + public boolean handleSecurity(final HttpServletRequest request, final HttpServletResponse response) { - callStack.add("handle2"); - return true; - } + callStack.add("handle2"); + return true; + } - @Override - public void finishSecurity(final HttpServletRequest request, final HttpServletResponse response) { - callStack.add("finish2"); - } + @Override + public void finishSecurity(final HttpServletRequest request, final HttpServletResponse response) { + callStack.add("finish2"); + } - }, - ctx2Props) - ); + }, ctx2Props)); // servlet for both contexts @SuppressWarnings("serial") class AServlet extends HttpServlet { @Override - protected void service(HttpServletRequest request, - HttpServletResponse response) - throws ServletException, IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { callStack.add("servlet" + request.getContextPath()); - if (request.getContextPath().equals("/context1") - && request.getAttribute(REC_PAR) == null) { + if (request.getContextPath().equals("/context1") && request.getAttribute(REC_PAR) == null) { if (request.getParameter("forward") != null) { request.setAttribute(REC_PAR, "true"); - request.getRequestDispatcher("/servlet") - .forward(request, response); + request.getRequestDispatcher("/servlet").forward(request, response); return; } else if (request.getParameter("include") != null) { request.setAttribute(REC_PAR, "true"); - request.getRequestDispatcher("/servlet") - .include(request, response); + request.getRequestDispatcher("/servlet").include(request, response); } else if (request.getParameter("throw") != null) { callStack.add("throw"); throw new ServletException("throw"); @@ -168,9 +157,9 @@ protected void service(HttpServletRequest request, } - final Dictionary servletProps = new Hashtable<>(); + final Dictionary servletProps = new Hashtable<>(); - servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] {"/servlet"}); + servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] { "/servlet" }); servletProps.put(HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HTTP_WHITEBOARD_CONTEXT_NAME + "=context1)"); registrations.add(context.registerService(Servlet.class, new AServlet(), servletProps)); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug500783_Test.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug500783_Test.java index 34e16f4a32b..78bd54b1182 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug500783_Test.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug500783_Test.java @@ -63,24 +63,20 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I } } in.close(); - StringBuffer sb = new StringBuffer() - .append(contentLength); + StringBuffer sb = new StringBuffer().append(contentLength); for (Entry entry : req.getParameterMap().entrySet()) { - sb.append("|") - .append(entry.getKey()) - .append("=") - .append(Arrays.toString(entry.getValue())); + sb.append("|").append(entry.getKey()).append("=").append(Arrays.toString(entry.getValue())); } - sb.append("|") - .append(bytesRead); + sb.append("|").append(bytesRead); Writer out = resp.getWriter(); Reader rdr = new StringReader(sb.toString()); while (true) { int ch = rdr.read(); - if (ch == -1) break; + if (ch == -1) + break; out.write(ch); } out.close(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562440_Test.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562440_Test.java index 5308705e7b1..12b92cc3670 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562440_Test.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562440_Test.java @@ -43,8 +43,7 @@ public void test_ServletGetStatus() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (error.get()) { resp.sendError(404); } @@ -76,9 +75,7 @@ public void test_ServletFlushBuffer() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.sendError(404, "NOT FOUND"); if (flushBuffer.get()) { diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java index 29cd1049735..262a5251168 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java @@ -26,10 +26,9 @@ public void test_Bug562843_testEncodedSpace() throws Exception { final AtomicReference pathInfo = new AtomicReference<>(); Servlet servlet = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { requestURI.set(req.getRequestURI()); servletPath.set(req.getServletPath()); pathInfo.set(req.getPathInfo()); @@ -49,7 +48,6 @@ protected void doGet( Assert.assertEquals("/topic .html", pathInfo.get()); } - @Test public void test_Bug562843_testEncodedPercentSign() throws Exception { final AtomicReference requestURI = new AtomicReference<>(); @@ -57,10 +55,9 @@ public void test_Bug562843_testEncodedPercentSign() throws Exception { final AtomicReference pathInfo = new AtomicReference<>(); Servlet servlet = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { requestURI.set(req.getRequestURI()); servletPath.set(req.getServletPath()); pathInfo.set(req.getPathInfo()); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_Test.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_Test.java index 8cc2a8a113a..6601fa14cc1 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_Test.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_Test.java @@ -25,10 +25,9 @@ public void test_Bug562843() throws Exception { final AtomicReference pathInfo = new AtomicReference<>(); Servlet servlet = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { requestURI.set(req.getRequestURI()); servletPath.set(req.getServletPath()); pathInfo.set(req.getPathInfo()); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug564747_Test.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug564747_Test.java index 6c415af55e8..fd844fec694 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug564747_Test.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug564747_Test.java @@ -38,9 +38,7 @@ public void test() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write(req.getQueryString()); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug569406_Test.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug569406_Test.java index cce183e539a..77f2ad393e3 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug569406_Test.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug569406_Test.java @@ -25,10 +25,9 @@ public void test_Bug562843_Encode_Space() throws Exception { final AtomicReference pathInfo = new AtomicReference<>(); Servlet servlet = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { requestURI.set(req.getRequestURI()); servletPath.set(req.getServletPath()); pathInfo.set(req.getPathInfo()); @@ -54,10 +53,9 @@ public void test_Bug562843_Encode_Slash() throws Exception { final AtomicReference pathInfo = new AtomicReference<>(); Servlet servlet = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { requestURI.set(req.getRequestURI()); servletPath.set(req.getServletPath()); pathInfo.set(req.getPathInfo()); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ContextHelperCustomizerTests.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ContextHelperCustomizerTests.java index 0a5f71dca1e..da0abf46bb0 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ContextHelperCustomizerTests.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ContextHelperCustomizerTests.java @@ -47,14 +47,14 @@ public class ContextHelperCustomizerTests extends BaseTest { private ServiceReference httpServiceReference; private HttpService httpService; private BundleContext context; - + @Before public void begin() { - httpServiceReference = getBundleContext().getServiceReference(HttpService.class); + httpServiceReference = getBundleContext().getServiceReference(HttpService.class); context = httpServiceReference.getBundle().getBundleContext(); httpService = context.getService(httpServiceReference); } - + @After public void end() { context.ungetService(httpServiceReference); @@ -64,20 +64,22 @@ public void end() { public void testCreateDefaultHttpContextCreatesNewServletContextHelper() { HttpContext context1 = httpService.createDefaultHttpContext(); HttpContext context2 = httpService.createDefaultHttpContext(); - Assert.assertNotEquals(context1, context2); + Assert.assertNotEquals(context1, context2); } - + @Test public void testServletContextHelpersNotHiddenWhenRegisteredUsingConsumingContext() { ServiceRegistration helperReg = null; ServiceRegistration findHookReg = null; - + try { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "context1"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/context1"); - //register a ServletContextHelper using the consuming bundle context "org.eclipse.equinox.http.servlet" - helperReg = context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties); + // register a ServletContextHelper using the consuming bundle context + // "org.eclipse.equinox.http.servlet" + helperReg = context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties); FindHook findHook = (bundleContext, name, filter, allServices, references) -> { @@ -100,10 +102,12 @@ public void testServletContextHelpersNotHiddenWhenRegisteredUsingConsumingContex properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(osgi.http.whiteboard.context.name=context1)"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(osgi.http.whiteboard.context.name=context1)"); context.registerService(ServletContextListener.class, new MockSCL(sc1), properties); - //ServletContextHelpers registered using the consuming context should not be hidden + // ServletContextHelpers registered using the consuming context should not be + // hidden assertNotNull(sc1.get()); } finally { if (helperReg != null) { @@ -111,29 +115,32 @@ public void testServletContextHelpersNotHiddenWhenRegisteredUsingConsumingContex } if (findHookReg != null) { findHookReg.unregister(); - } + } } - + } - + @Test public void testWBServletContextPathCustomizerContextPrefix() throws Exception { ServiceRegistration pathAdaptorReg = null; ServiceRegistration helperReg = null; ServiceRegistration servlet = null; ServiceRegistration findHookReg = null; - + try { Dictionary helperProps = new Hashtable<>(); - helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName()); + helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, + "testContext" + testName.getMethodName()); helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/helperContext"); helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); - helperReg = context.registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); + helperReg = context.registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), + helperProps); - //Pass the context path prefix paramater - ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", testName.getMethodName()); + // Pass the context path prefix paramater + ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", + testName.getMethodName()); pathAdaptorReg = context.registerService(ContextPathCustomizer.class, pathAdaptor, null); - + FindHook findHook = (bundleContext, name, filter, allServices, references) -> { if (bundleContext != context) { @@ -151,14 +158,16 @@ public void testWBServletContextPathCustomizerContextPrefix() throws Exception { }; findHookReg = context.registerService(FindHook.class, findHook, null); - - //Register a servlet service with a matching context helper + + // Register a servlet service with a matching context helper BaseServlet baseServlet = new BaseServlet("content"); - Dictionary serviceProps = new Hashtable<>(); + Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/servlet"); - serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")"); + serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + + testName.getMethodName() + ")"); servlet = context.registerService(Servlet.class, baseServlet, serviceProps); - + String actual = requestAdvisor.request("testPrefix/helperContext/servlet"); Assert.assertEquals("content", actual); } finally { @@ -173,28 +182,33 @@ public void testWBServletContextPathCustomizerContextPrefix() throws Exception { } if (findHookReg != null) { findHookReg.unregister(); - } - } + } + } } - + @Test public void testWBServletContextPathCustomizerDefaultFilter() throws Exception { ServiceRegistration pathAdaptorReg = null; ServiceRegistration helperReg = null; ServiceRegistration servlet = null; ServiceRegistration findHookReg = null; - + try { Dictionary helperProps = new Hashtable<>(); - helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName()); + helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, + "testContext" + testName.getMethodName()); helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/helperContext"); helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); - helperReg = context.registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); + helperReg = context.registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), + helperProps); - //Pass the filter parameter - ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor("(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")", null, testName.getMethodName()); + // Pass the filter parameter + ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor( + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + + testName.getMethodName() + ")", + null, testName.getMethodName()); pathAdaptorReg = context.registerService(ContextPathCustomizer.class, pathAdaptor, null); - + FindHook findHook = (bundleContext, name, filter, allServices, references) -> { if (bundleContext != context) { @@ -212,15 +226,15 @@ public void testWBServletContextPathCustomizerDefaultFilter() throws Exception { }; findHookReg = context.registerService(FindHook.class, findHook, null); - - //Register a servlet service with a matching context helper + + // Register a servlet service with a matching context helper BaseServlet baseServlet = new BaseServlet("content"); - Dictionary serviceProps = new Hashtable<>(); + Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/servlet"); - //Filter property + // Filter property serviceProps.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); servlet = context.registerService(Servlet.class, baseServlet, serviceProps); - + String actual = requestAdvisor.request("helperContext/servlet"); Assert.assertEquals("content", actual); } finally { @@ -235,29 +249,30 @@ public void testWBServletContextPathCustomizerDefaultFilter() throws Exception { } if (findHookReg != null) { findHookReg.unregister(); - } - } + } + } } - + @Test public void testLegacyServletContextPathCustomizerContextPrefix() throws Exception { ServiceRegistration pathAdaptorReg = null; ServiceRegistration findHookReg = null; - + try { - //Pass the context path prefix paramater - ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", testName.getMethodName()) { - + // Pass the context path prefix paramater + ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", + testName.getMethodName()) { + @Override public String getContextPathPrefix(ServiceReference helper) { if (Boolean.TRUE.equals(helper.getProperty("equinox.legacy.context.helper"))) { return contextPrefix; } return null; - } + } }; pathAdaptorReg = context.registerService(ContextPathCustomizer.class, pathAdaptor, null); - + FindHook findHook = (bundleContext, name, filter, allServices, references) -> { if (bundleContext != context) { @@ -275,10 +290,10 @@ public String getContextPathPrefix(ServiceReference helper }; findHookReg = context.registerService(FindHook.class, findHook, null); - //Register a servlet service using HttpService + // Register a servlet service using HttpService BaseServlet baseServlet = new BaseServlet("content"); httpService.registerServlet("/servlet", baseServlet, null, null); - + String actual = requestAdvisor.request("testPrefix/servlet"); Assert.assertEquals("content", actual); } finally { @@ -292,5 +307,3 @@ public String getContextPathPrefix(ServiceReference helper } } } - - diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java index c5d08eb83e4..55718b44e0f 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java @@ -72,8 +72,7 @@ public void test_crossContextDispatch1() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { StringWriter writer = new StringWriter(); @@ -91,11 +90,13 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); String response = requestAdvisor.request("a/s1/d"); @@ -118,16 +119,19 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("a/s1/d?p=1"); @@ -150,9 +154,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { response.getWriter().write('b'); @@ -166,22 +169,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -206,9 +214,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { response.getWriter().write('b'); @@ -222,22 +229,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.FORWARD.toString(),DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.FORWARD.toString(), DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -272,21 +284,25 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet2, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s3/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("c1/s1/i1?p1=1"); @@ -329,26 +345,31 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet2, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s3/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet3, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s4/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("c1/s1/i1?p1=1"); @@ -362,9 +383,8 @@ public void test_forwardNamedParameterAggregationAndPrecedence() throws Exceptio private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { ServletContext servletContext = getServletContext(); @@ -377,9 +397,7 @@ protected void doGet( private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write(String.valueOf(req.getQueryString())); @@ -395,17 +413,20 @@ protected void doGet( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); registrations.add(getBundleContext().registerService(Servlet.class, sA, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s2"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); registrations.add(getBundleContext().registerService(Servlet.class, sB, props)); @@ -420,9 +441,8 @@ public void test_forwardNamed() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { ServletContext servletContext = getServletContext(); @@ -435,17 +455,20 @@ protected void doGet( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); registrations.add(getBundleContext().registerService(Servlet.class, sA, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s2"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); @@ -460,9 +483,8 @@ public void test_forwardParameterAggregationAndPrecedence() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { RequestDispatcher requestDispatcher = req.getRequestDispatcher("/Servlet13B/a?p=3&p=4"); @@ -473,14 +495,12 @@ protected void doGet( private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write(req.getQueryString()); writer.write("|"); - writer.write((String)req.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING)); + writer.write((String) req.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING)); writer.write("|"); writer.write(req.getParameter("p")); writer.write("|"); @@ -518,16 +538,19 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("a/s1/d?p=1"); @@ -550,9 +573,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { write(response.getOutputStream(), "b"); @@ -566,22 +588,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -606,9 +633,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { write(response.getOutputStream(), "b"); @@ -622,22 +648,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.FORWARD.toString(),DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.FORWARD.toString(), DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -654,10 +685,9 @@ public void test_includeBasic() throws Exception { @Override protected void service(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { - RequestDispatcher requestDispatcher = - request.getRequestDispatcher("/S8/target"); + RequestDispatcher requestDispatcher = request.getRequestDispatcher("/S8/target"); requestDispatcher.include(request, response); } @@ -668,8 +698,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().print("s8target"); } @@ -701,16 +730,19 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("a/s1/d?p=1"); @@ -733,9 +765,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { response.getWriter().write('b'); @@ -749,22 +780,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -789,9 +825,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { response.getWriter().write('b'); @@ -805,22 +840,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.INCLUDE.toString(), DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.INCLUDE.toString(), DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -855,21 +895,25 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet2, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s3/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("c1/s1/i1?p1=1"); @@ -912,26 +956,31 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet2, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s3/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet3, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s4/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("c1/s1/i1?p1=1"); @@ -945,9 +994,8 @@ public void test_includeNamedParameterAggregationAndPrecedence() throws Exceptio private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { ServletContext servletContext = getServletContext(); @@ -960,9 +1008,7 @@ protected void doGet( private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write(req.getQueryString()); @@ -978,17 +1024,20 @@ protected void doGet( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); registrations.add(getBundleContext().registerService(Servlet.class, sA, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s2"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); registrations.add(getBundleContext().registerService(Servlet.class, sB, props)); @@ -1003,9 +1052,8 @@ public void test_includeNamed() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { ServletContext servletContext = getServletContext(); @@ -1018,17 +1066,20 @@ protected void doGet( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "c1"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/c1"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); registrations.add(getBundleContext().registerService(Servlet.class, sA, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "s2"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=c1)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); @@ -1043,9 +1094,8 @@ public void test_includeParameterAggregationAndPrecedence() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { RequestDispatcher requestDispatcher = req.getRequestDispatcher("/Servlet13B/a?p=3&p=4"); @@ -1056,14 +1106,12 @@ protected void doGet( private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write(req.getQueryString()); writer.write("|"); - writer.write((String)req.getAttribute(RequestDispatcher.INCLUDE_QUERY_STRING)); + writer.write((String) req.getAttribute(RequestDispatcher.INCLUDE_QUERY_STRING)); writer.write("|"); writer.write(req.getParameter("p")); writer.write("|"); @@ -1101,16 +1149,19 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); String response = requestAdvisor.request("a/s1/d?p=1"); @@ -1133,9 +1184,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { write(response.getOutputStream(), "b"); @@ -1149,22 +1199,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -1189,9 +1244,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) TestFilter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { write(response.getOutputStream(), "b"); @@ -1205,22 +1259,27 @@ public void doFilter( Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() {}, props)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s2/*"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(Servlet.class, new DispatchResultServlet(), props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F1"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, new String[] {DispatcherType.INCLUDE.toString(), DispatcherType.REQUEST.toString()}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, + new String[] { DispatcherType.INCLUDE.toString(), DispatcherType.REQUEST.toString() }); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); @@ -1236,9 +1295,7 @@ public void test_Bug479115() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { final AtomicReference results = new AtomicReference<>(); @@ -1260,8 +1317,7 @@ public void run() { try { thread.join(); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { throw new IOException(ie); } @@ -1288,8 +1344,8 @@ public void run() { public void test_headers_include() throws Exception { SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); format.setTimeZone(TimeZone.getTimeZone("GMT")); - final long date1 = System.currentTimeMillis() - (1000*60*60*24*365*30); - final long date2 = System.currentTimeMillis() - (1000*60*60*24*365*40); + final long date1 = System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 365 * 30); + final long date2 = System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 365 * 40); Servlet servlet1 = new BaseServlet() { private static final long serialVersionUID = 1L; @@ -1298,7 +1354,7 @@ public void test_headers_include() throws Exception { protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.addCookie(new Cookie("foo","bar")); + response.addCookie(new Cookie("foo", "bar")); response.addDateHeader("X-date", date1); response.addHeader("X-colour", "blue"); response.addIntHeader("X-size", 20); @@ -1318,7 +1374,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) @Override protected void service(HttpServletRequest request, HttpServletResponse response) { - response.addCookie(new Cookie("foo","baz")); + response.addCookie(new Cookie("foo", "baz")); response.addDateHeader("X-date", date2); response.addHeader("X-colour", "green"); response.addIntHeader("X-size", 30); @@ -1362,8 +1418,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) public void test_headers_forward() throws Exception { SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH); format.setTimeZone(TimeZone.getTimeZone("GMT")); - final long date1 = System.currentTimeMillis() - (1000*60*60*24*365*30); - final long date2 = System.currentTimeMillis() - (1000*60*60*24*365*40); + final long date1 = System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 365 * 30); + final long date2 = System.currentTimeMillis() - (1000 * 60 * 60 * 24 * 365 * 40); Servlet servlet1 = new BaseServlet() { private static final long serialVersionUID = 1L; @@ -1372,7 +1428,7 @@ public void test_headers_forward() throws Exception { protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.addCookie(new Cookie("foo","bar")); + response.addCookie(new Cookie("foo", "bar")); response.addDateHeader("X-date", date1); response.addHeader("X-colour", "blue"); response.addIntHeader("X-size", 20); @@ -1392,7 +1448,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) @Override protected void service(HttpServletRequest request, HttpServletResponse response) { - response.addCookie(new Cookie("foo","baz")); + response.addCookie(new Cookie("foo", "baz")); response.addDateHeader("X-date", date2); response.addHeader("X-colour", "green"); response.addIntHeader("X-size", 30); @@ -1415,7 +1471,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Map> response = requestAdvisor.request("s1", null); // On Java 18 the order changed on the client for headers with multiple values. - int multiValueIdx = new Version(18, 0 ,0).compareTo(getJavaVersion()) > 0 ? 0 : 1; + int multiValueIdx = new Version(18, 0, 0).compareTo(getJavaVersion()) > 0 ? 0 : 1; Assert.assertNotNull(response.get("Set-Cookie")); Assert.assertEquals("foo=baz", response.get("Set-Cookie").get(multiValueIdx)); Assert.assertNotNull(response.get("X-date")); @@ -1438,11 +1494,17 @@ private Version getJavaVersion() { Bundle system = getBundleContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION); BundleWiring systemWiring = system.adapt(BundleWiring.class); @SuppressWarnings("unchecked") - List versions = systemWiring.getCapabilities(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE). // - stream().filter(c -> c.getAttributes().get(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE).equals("JavaSE")) // - .findFirst().map(c -> (List) c.getAttributes().get(ExecutionEnvironmentNamespace.CAPABILITY_VERSION_ATTRIBUTE)).get(); + List versions = systemWiring + .getCapabilities(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE). // + stream() + .filter(c -> c.getAttributes().get(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE) + .equals("JavaSE")) // + .findFirst().map(c -> (List) c.getAttributes() + .get(ExecutionEnvironmentNamespace.CAPABILITY_VERSION_ATTRIBUTE)) + .get(); return versions.get(versions.size() - 1); } + // Bug 493583 @Test public void test_streamed_response_outputstream() throws Exception { @@ -1453,7 +1515,7 @@ public void test_streamed_response_outputstream() throws Exception { @Override protected void service(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { response.setContentType("text/event-stream"); response.setCharacterEncoding("UTF-8"); @@ -1462,8 +1524,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) for (int i = 1; i <= 10; ++i) { try { Thread.sleep(interval); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ServletException(e); } @@ -1514,8 +1575,8 @@ public void handle(Map eventMap) { handler.close(); Assert.assertTrue( - "The interval between events was too short. It means that the response was not properly streamed.", - result.get()); + "The interval between events was too short. It means that the response was not properly streamed.", + result.get()); Assert.assertEquals(10, counter.get()); } @@ -1529,7 +1590,7 @@ public void test_streamed_response_writer() throws Exception { @Override protected void service(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { response.setContentType("text/event-stream"); response.setCharacterEncoding("UTF-8"); @@ -1538,8 +1599,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) for (int i = 1; i <= 10; ++i) { try { Thread.sleep(interval); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new ServletException(e); } @@ -1590,8 +1650,8 @@ public void handle(Map eventMap) { handler.close(); Assert.assertTrue( - "The interval between events was too short. It means that the response was not properly streamed.", - result.get()); + "The interval between events was too short. It means that the response was not properly streamed.", + result.get()); Assert.assertEquals(10, counter.get()); } @@ -1601,9 +1661,7 @@ public void test_Bug497510_1() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { String requestURI = req.getRequestURI(); @@ -1630,9 +1688,7 @@ public void test_Bug497510_2() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - final HttpServletRequest req, final HttpServletResponse resp) - throws IOException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { String requestURI = req.getRequestURI(); @@ -1652,4 +1708,4 @@ protected void doGet( Assert.assertEquals("/Bug%20497510/a%20b%20c", result); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/PreprocessorTestCase.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/PreprocessorTestCase.java index e1642c8e91b..e058badeb3f 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/PreprocessorTestCase.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/PreprocessorTestCase.java @@ -46,26 +46,18 @@ public class PreprocessorTestCase extends BaseTest { @Test public void testPreprocessorInitParameters() { - Dictionary properties = new Hashtable<>(); - properties - .put(HttpWhiteboardConstants.HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX - + "param1", "value1"); - properties - .put(HttpWhiteboardConstants.HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX - + "param2", "value2"); - properties - .put(HttpWhiteboardConstants.HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX - + "param3", 345l); + Dictionary properties = new Hashtable<>(); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX + "param1", "value1"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX + "param2", "value2"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX + "param3", 345l); long before = this.getHttpRuntimeChangeCount(); - final ServiceRegistration reg = getBundleContext() - .registerService(Preprocessor.class, new MockPreprocessor(), - properties); + final ServiceRegistration reg = getBundleContext().registerService(Preprocessor.class, + new MockPreprocessor(), properties); registrations.add(reg); this.waitForRegistration(before); - final PreprocessorDTO[] dtos = this.getHttpServiceRuntime() - .getRuntimeDTO().preprocessorDTOs; + final PreprocessorDTO[] dtos = this.getHttpServiceRuntime().getRuntimeDTO().preprocessorDTOs; assertEquals(1, dtos.length); assertTrue(dtos[0].initParams.containsKey("param1")); @@ -77,22 +69,20 @@ public void testPreprocessorInitParameters() { @Test public void testPreprocessorRanking() throws Exception { // register preprocessor with ranking -5 - Dictionary properties = new Hashtable<>(); + Dictionary properties = new Hashtable<>(); properties.put(Constants.SERVICE_RANKING, -5); long before = this.getHttpRuntimeChangeCount(); - registrations - .add(getBundleContext().registerService(Preprocessor.class.getName(), - new MockPreprocessor().around("d"), properties)); + registrations.add(getBundleContext().registerService(Preprocessor.class.getName(), + new MockPreprocessor().around("d"), properties)); before = this.waitForRegistration(before); // register preprocessor with ranking 8 properties = new Hashtable<>(); properties.put(Constants.SERVICE_RANKING, 8); - registrations - .add(getBundleContext().registerService(Preprocessor.class.getName(), - new MockPreprocessor().around("a"), properties)); + registrations.add(getBundleContext().registerService(Preprocessor.class.getName(), + new MockPreprocessor().around("a"), properties)); before = this.waitForRegistration(before); // register preprocessor with invalid ranking @@ -100,30 +90,26 @@ public void testPreprocessorRanking() throws Exception { properties.put(Constants.SERVICE_RANKING, 3L); // this is invalid -> // ranking = 0 - registrations - .add(getBundleContext().registerService(Preprocessor.class.getName(), - new MockPreprocessor().around("b"), properties)); + registrations.add(getBundleContext().registerService(Preprocessor.class.getName(), + new MockPreprocessor().around("b"), properties)); before = this.waitForRegistration(before); // register preprocessor with no ranking properties = new Hashtable<>(); - registrations - .add(getBundleContext().registerService(Preprocessor.class.getName(), - new MockPreprocessor().around("c"), properties)); + registrations.add(getBundleContext().registerService(Preprocessor.class.getName(), + new MockPreprocessor().around("c"), properties)); before = this.waitForRegistration(before); // check that we have four preprocessors - final PreprocessorDTO[] dtos = this.getHttpServiceRuntime() - .getRuntimeDTO().preprocessorDTOs; + final PreprocessorDTO[] dtos = this.getHttpServiceRuntime().getRuntimeDTO().preprocessorDTOs; assertEquals(4, dtos.length); // register endpoint properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, - "/available"); - registrations.add(getBundleContext().registerService( - Servlet.class, new MockServlet().content("hello"), properties)); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/available"); + registrations + .add(getBundleContext().registerService(Servlet.class, new MockServlet().content("hello"), properties)); assertEquals("abcdhellodcba", requestAdvisor.request("available")); } @@ -137,58 +123,53 @@ public void testPreprocessorInvocation() throws Exception { // register preprocessor final List filterActions = new ArrayList<>(); long before = this.getHttpRuntimeChangeCount(); - registrations.add(getBundleContext().registerService( - Preprocessor.class.getName(), new MockPreprocessor() { + registrations.add(getBundleContext().registerService(Preprocessor.class.getName(), new MockPreprocessor() { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + filterActions.add("a"); + super.doFilter(request, new HttpServletResponseWrapper((HttpServletResponse) response) { + + private boolean hasStatus = false; + + private void addStatus(final int sc) { + if (!hasStatus) { + hasStatus = true; + filterActions.add(String.valueOf(sc)); + } + } @Override - public void doFilter(ServletRequest request, - ServletResponse response, FilterChain chain) - throws IOException, ServletException { - filterActions.add("a"); - super.doFilter(request, new HttpServletResponseWrapper( - (HttpServletResponse) response) { - - private boolean hasStatus = false; - - private void addStatus(final int sc) { - if (!hasStatus) { - hasStatus = true; - filterActions.add(String.valueOf(sc)); - } - } - - @Override - public void setStatus(int sc) { - addStatus(sc); - super.setStatus(sc); - } - - @Override - public void sendError(int sc, String msg) - throws IOException { - addStatus(sc); - super.sendError(sc, msg); - } - - @Override - public void sendError(int sc) throws IOException { - addStatus(sc); - super.sendError(sc); - } - - }, chain); - filterActions.add("b"); + public void setStatus(int sc) { + addStatus(sc); + super.setStatus(sc); } - }, null)); + @Override + public void sendError(int sc, String msg) throws IOException { + addStatus(sc); + super.sendError(sc, msg); + } + + @Override + public void sendError(int sc) throws IOException { + addStatus(sc); + super.sendError(sc); + } + + }, chain); + filterActions.add("b"); + } + + }, null)); before = this.waitForRegistration(before); // register endpoint - Dictionary properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, - "/available"); - registrations.add(getBundleContext().registerService( - Servlet.class, new MockServlet().content("hello"), properties)); + Dictionary properties = new Hashtable<>(); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/available"); + registrations + .add(getBundleContext().registerService(Servlet.class, new MockServlet().content("hello"), properties)); assertEquals("hello", requestAdvisor.request("available")); assertEquals(2, filterActions.size()); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java index 7e5925d55a1..493e7af3b74 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java @@ -152,16 +152,14 @@ public void test_ErrorPage1() throws Exception { try { bundle.start(); response = requestAdvisor.request("TestErrorPage1/a", null); - } - finally { + } finally { uninstallBundle(bundle); } String responseCode = response.get("responseCode").get(0); actual = response.get("responseBody").get(0); assertEquals("403", responseCode); - Assert.assertTrue( - "Expected <" + expected + "*> but got <" + actual + ">", actual.startsWith(expected)); + Assert.assertTrue("Expected <" + expected + "*> but got <" + actual + ">", actual.startsWith(expected)); } @Test @@ -173,16 +171,14 @@ public void test_ErrorPage2() throws Exception { try { bundle.start(); response = requestAdvisor.request("TestErrorPage2/a", null); - } - finally { + } finally { uninstallBundle(bundle); } String responseCode = response.get("responseCode").get(0); actual = response.get("responseBody").get(0); assertEquals("500", responseCode); - Assert.assertTrue( - "Expected <" + expected + "*> but got <" + actual + ">", actual.startsWith(expected)); + Assert.assertTrue("Expected <" + expected + "*> but got <" + actual + ">", actual.startsWith(expected)); } @Test @@ -194,8 +190,7 @@ public void test_ErrorPage3() throws Exception { try { bundle.start(); response = requestAdvisor.request("TestErrorPage3/a", null); - } - finally { + } finally { uninstallBundle(bundle); } String responseCode = response.get("responseCode").get(0); @@ -217,8 +212,7 @@ public void test_ErrorPage4() throws Exception { try { bundle.start(); response = requestAdvisor.request("TestErrorPage4/a", null); - } - finally { + } finally { uninstallBundle(bundle); } String responseCode = response.get("responseCode").get(0); @@ -244,21 +238,22 @@ public void test_ErrorPage5() throws Exception { errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "E5.5xx"); errorProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, "5xx"); registrations.add(getBundleContext().registerService(Servlet.class, new ErrorServlet("5xx"), errorProps)); - for(String expectedCode: Arrays.asList("400", "450", "499", "500", "550", "599")) { - Map> response = doRequestGetResponse(ERROR, Collections.singletonMap(TEST_ERROR_CODE, expectedCode)); + for (String expectedCode : Arrays.asList("400", "450", "499", "500", "550", "599")) { + Map> response = doRequestGetResponse(ERROR, + Collections.singletonMap(TEST_ERROR_CODE, expectedCode)); String expectedResponse = expectedCode.charAt(0) + "xx : " + expectedCode + " : ERROR"; String actualCode = response.get("responseCode").get(0); String actualResponse = response.get("responseBody").get(0); assertEquals(expectedCode, actualCode); - Assert.assertTrue( - "Expected <" + expectedResponse + "*> but got <" + actualResponse + ">", actualResponse.startsWith(expectedResponse)); + Assert.assertTrue("Expected <" + expectedResponse + "*> but got <" + actualResponse + ">", + actualResponse.startsWith(expectedResponse)); } } /** - * This test should also not hit the error servlet as we've only set the - * status. As per the Servlet spec this should not trigger error handling. + * This test should also not hit the error servlet as we've only set the status. + * As per the Servlet spec this should not trigger error handling. */ @Test public void test_ErrorPage6() throws Exception { @@ -266,9 +261,7 @@ public void test_ErrorPage6() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().write("Hello!"); response.setStatus(444); @@ -295,8 +288,8 @@ protected void service( } /** - * This test should also not hit the error servlet as we've only set the - * status. As per the Servlet spec this should not trigger error handling. + * This test should also not hit the error servlet as we've only set the status. + * As per the Servlet spec this should not trigger error handling. */ @Test public void test_ErrorPage7() throws Exception { @@ -306,14 +299,11 @@ public void test_ErrorPage7() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setStatus(status); - PrintWriter printWriter = new PrintWriter( - resp.getOutputStream()); + PrintWriter printWriter = new PrintWriter(resp.getOutputStream()); printWriter.println("{"); printWriter.println("error: 'An error message',"); @@ -331,7 +321,8 @@ protected void doGet( props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "E7.error"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, String.valueOf(status)); - registrations.add(getBundleContext().registerService(Servlet.class, new ErrorServlet(String.valueOf(status)), props)); + registrations.add( + getBundleContext().registerService(Servlet.class, new ErrorServlet(String.valueOf(status)), props)); Map> response = requestAdvisor.request("TestErrorPage7/a", null); @@ -348,8 +339,7 @@ public void test_ErrorPage8() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) { throw new RuntimeException(); } @@ -379,9 +369,7 @@ public void test_ErrorPage9() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { throw new IOException(); } @@ -411,9 +399,7 @@ public void test_ErrorPage10() { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.getWriter().write("some output"); resp.flushBuffer(); @@ -429,8 +415,7 @@ protected void doGet( try { requestAdvisor.request("TestErrorPage10/a"); - } - catch (Exception e) { + } catch (Exception e) { Assert.assertTrue(e instanceof IOException); return; @@ -445,9 +430,7 @@ public void test_ErrorPage11() { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.sendError(403); resp.getOutputStream().flush(); @@ -735,16 +718,20 @@ public void test_Filter19() throws Exception { @Test public void test_Filter20() throws Exception { - // Make sure legacy filter registrations match against all controllers that are for legacy HttpContext - // Make sure legacy filter registrations match as if they are prefix matching with wildcards + // Make sure legacy filter registrations match against all controllers that are + // for legacy HttpContext + // Make sure legacy filter registrations match as if they are prefix matching + // with wildcards String expected = "a"; TestFilter testFilter1 = new TestFilter(); TestFilter testFilter2 = new TestFilter(); Servlet testServlet = new BaseServlet(expected); - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); extendedHttpService.registerFilter("/hello", testFilter1, null, extendedHttpService.createDefaultHttpContext()); - extendedHttpService.registerFilter("/hello/*", testFilter2, null, extendedHttpService.createDefaultHttpContext()); - extendedHttpService.registerServlet("/hello", testServlet, null, extendedHttpService.createDefaultHttpContext()); + extendedHttpService.registerFilter("/hello/*", testFilter2, null, + extendedHttpService.createDefaultHttpContext()); + extendedHttpService.registerServlet("/hello", testServlet, null, + extendedHttpService.createDefaultHttpContext()); String actual = requestAdvisor.request("hello"); assertEquals(expected, actual); @@ -794,7 +781,8 @@ public void test_Filter21() throws Exception { Assert.assertTrue("testFilter2 did not get called.", testFilter2.getCalled()); } - public void basicFilterTest22( String servlet1Pattern, String servlet2Pattern, String filterPattern, String expected, String[] dispatchers ) throws Exception { + public void basicFilterTest22(String servlet1Pattern, String servlet2Pattern, String filterPattern, String expected, + String[] dispatchers) throws Exception { final AtomicReference httpServletRequestWrapper = new AtomicReference<>(); final AtomicReference httpServletResponseWrapper = new AtomicReference<>(); @@ -812,9 +800,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { if ((httpServletRequestWrapper.get() != null) && !request.equals(httpServletRequestWrapper.get())) { throw new ServletException("not the same request"); @@ -831,9 +818,8 @@ protected void service( Filter filter = new TestFilter() { @Override - public void doFilter( - ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { response.getWriter().write('b'); @@ -868,62 +854,66 @@ public void doFilter( @Test public void test_Filter22a() throws Exception { - basicFilterTest22 ( "/f22/*", "*.jsp", "/f22/*", "a", new String[] {"REQUEST"} ); + basicFilterTest22("/f22/*", "*.jsp", "/f22/*", "a", new String[] { "REQUEST" }); } @Test public void test_Filter22b() throws Exception { - basicFilterTest22 ( "/*", "*.jsp", "/*", "a", new String[] {"REQUEST"} ); + basicFilterTest22("/*", "*.jsp", "/*", "a", new String[] { "REQUEST" }); } @Test public void test_Filter22c() throws Exception { - basicFilterTest22 ( "/f22/*", "*.jsp", "*.jsp", "a", new String[] {"REQUEST"} ); + basicFilterTest22("/f22/*", "*.jsp", "*.jsp", "a", new String[] { "REQUEST" }); } @Test public void test_Filter22d() throws Exception { - basicFilterTest22 ( "/f22/*", "*.jsp", "/f22/*", "bab", new String[] {"FORWARD"} ); + basicFilterTest22("/f22/*", "*.jsp", "/f22/*", "bab", new String[] { "FORWARD" }); } @Test public void test_Filter22e() throws Exception { - basicFilterTest22 ( "/*", "*.jsp", "/*", "bab", new String[] {"FORWARD"} ); + basicFilterTest22("/*", "*.jsp", "/*", "bab", new String[] { "FORWARD" }); } @Test public void test_Filter22f() throws Exception { - basicFilterTest22 ( "/f22/*", "*.jsp", "*.jsp", "bab", new String[] {"FORWARD"} ); + basicFilterTest22("/f22/*", "*.jsp", "*.jsp", "bab", new String[] { "FORWARD" }); } @Test public void test_Filter22g() throws Exception { - basicFilterTest22 ( "/f22/*", "*.jsp", "/f22/*", "bab", new String[] {"REQUEST", "FORWARD"} ); + basicFilterTest22("/f22/*", "*.jsp", "/f22/*", "bab", new String[] { "REQUEST", "FORWARD" }); } @Test public void test_Filter22h() throws Exception { - basicFilterTest22 ( "/*", "*.jsp", "/*", "bab", new String[] {"REQUEST", "FORWARD"} ); + basicFilterTest22("/*", "*.jsp", "/*", "bab", new String[] { "REQUEST", "FORWARD" }); } @Test public void test_Filter22i() throws Exception { - basicFilterTest22 ( "/f22/*", "*.jsp", "*.jsp", "bab", new String[] {"REQUEST", "FORWARD"} ); + basicFilterTest22("/f22/*", "*.jsp", "*.jsp", "bab", new String[] { "REQUEST", "FORWARD" }); } @Test public void test_Filter23a() throws Exception { - // Make sure legacy filter registrations match as if they are prefix matching with extension matching + // Make sure legacy filter registrations match as if they are prefix matching + // with extension matching String expected = "a"; TestFilter testFilter1 = new TestFilter(); TestFilter testFilter2 = new TestFilter(); TestFilter testFilter3 = new TestFilter(); Servlet testServlet = new BaseServlet(expected); - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); extendedHttpService.registerFilter("*.ext", testFilter1, null, extendedHttpService.createDefaultHttpContext()); - extendedHttpService.registerFilter("/hello/*.ext", testFilter2, null, extendedHttpService.createDefaultHttpContext()); - extendedHttpService.registerFilter("/hello/test/*.ext", testFilter3, null, extendedHttpService.createDefaultHttpContext()); - extendedHttpService.registerServlet("/hello", testServlet, null, extendedHttpService.createDefaultHttpContext()); + extendedHttpService.registerFilter("/hello/*.ext", testFilter2, null, + extendedHttpService.createDefaultHttpContext()); + extendedHttpService.registerFilter("/hello/test/*.ext", testFilter3, null, + extendedHttpService.createDefaultHttpContext()); + extendedHttpService.registerServlet("/hello", testServlet, null, + extendedHttpService.createDefaultHttpContext()); String actual = requestAdvisor.request("hello/test/request"); assertEquals(expected, actual); @@ -943,12 +933,13 @@ public void test_Filter23a() throws Exception { @Test public void test_Filter23b() throws Exception { - // Make sure legacy filter registrations match as if they are prefix matching wildcard, but make sure the prefix is checked + // Make sure legacy filter registrations match as if they are prefix matching + // wildcard, but make sure the prefix is checked String expected = "a"; TestFilter testFilter1 = new TestFilter(); TestFilter testFilter2 = new TestFilter(); Servlet testServlet = new BaseServlet(expected); - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); extendedHttpService.registerFilter("/", testFilter1, null, extendedHttpService.createDefaultHttpContext()); extendedHttpService.registerFilter("/hello", testFilter2, null, extendedHttpService.createDefaultHttpContext()); extendedHttpService.registerServlet("/", testServlet, null, extendedHttpService.createDefaultHttpContext()); @@ -966,15 +957,19 @@ public void test_Filter23b() throws Exception { @Test public void test_Filter23c() throws Exception { - // Test WB servlet with default servlet pattern "/" and filter matching against it. + // Test WB servlet with default servlet pattern "/" and filter matching against + // it. String expected = "a"; TestFilter testFilter1 = new TestFilter(); TestFilter testFilter2 = new TestFilter(); Servlet testServlet = new BaseServlet(expected); - registrations.add(getBundleContext().registerService(Filter.class, testFilter1, new Hashtable<>(Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*")))); - registrations.add(getBundleContext().registerService(Filter.class, testFilter2, new Hashtable<>(Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/hello/*")))); - registrations.add(getBundleContext().registerService(Servlet.class, testServlet, new Hashtable<>(Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/")))); + registrations.add(getBundleContext().registerService(Filter.class, testFilter1, new Hashtable<>( + Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*")))); + registrations.add(getBundleContext().registerService(Filter.class, testFilter2, new Hashtable<>( + Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/hello/*")))); + registrations.add(getBundleContext().registerService(Servlet.class, testServlet, new Hashtable<>( + Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/")))); String actual = requestAdvisor.request("hello_test/request"); assertEquals(expected, actual); @@ -997,9 +992,12 @@ public void test_Filter24() throws Exception { TestFilter testFilter1 = new TestFilter(); Servlet testServlet = new BaseServlet(expected); - ServiceRegistration filterReg = getBundleContext().registerService(Filter.class, testFilter1, new Hashtable<>(Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/hello/*"))); + ServiceRegistration filterReg = getBundleContext().registerService(Filter.class, testFilter1, + new Hashtable<>( + Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/hello/*"))); try { - registrations.add(getBundleContext().registerService(Servlet.class, testServlet, new Hashtable<>(Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/hello/*")))); + registrations.add(getBundleContext().registerService(Servlet.class, testServlet, new Hashtable<>( + Collections.singletonMap(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/hello/*")))); String actual = requestAdvisor.request("hello/request"); assertEquals(expected, actual); @@ -1023,12 +1021,10 @@ public void test_Filter24() throws Exception { public void test_Registration1() throws Exception { String expected = "Alias cannot be null"; try { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); - extendedHttpService.registerServlet( - null, new BaseServlet(), null, null); - } - catch(IllegalArgumentException iae) { + extendedHttpService.registerServlet(null, new BaseServlet(), null, null); + } catch (IllegalArgumentException iae) { assertEquals(expected, iae.getMessage()); return; @@ -1042,12 +1038,10 @@ public void test_Registration2() throws Exception { String pattern = "blah"; String expected = "Invalid pattern '" + pattern + "'"; try { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); - extendedHttpService.registerServlet( - pattern, new BaseServlet(), null, null); - } - catch(IllegalArgumentException iae) { + extendedHttpService.registerServlet(pattern, new BaseServlet(), null, null); + } catch (IllegalArgumentException iae) { assertEquals(expected, iae.getMessage()); return; @@ -1061,12 +1055,10 @@ public void test_Registration3() throws Exception { String pattern = "/blah/"; String expected = "Invalid pattern '" + pattern + "'"; try { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); - extendedHttpService.registerServlet( - pattern, new BaseServlet(), null, null); - } - catch(IllegalArgumentException iae) { + extendedHttpService.registerServlet(pattern, new BaseServlet(), null, null); + } catch (IllegalArgumentException iae) { assertEquals(expected, iae.getMessage()); return; @@ -1080,14 +1072,11 @@ public void test_Registration4() throws Exception { String pattern = "/blah"; String expected = "Pattern already in use: " + pattern; try { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); - extendedHttpService.registerServlet( - pattern, new BaseServlet(), null, null); - extendedHttpService.registerServlet( - pattern, new BaseServlet(), null, null); - } - catch(NamespaceException ne) { + extendedHttpService.registerServlet(pattern, new BaseServlet(), null, null); + extendedHttpService.registerServlet(pattern, new BaseServlet(), null, null); + } catch (NamespaceException ne) { assertEquals(expected, ne.getMessage()); return; @@ -1101,12 +1090,10 @@ public void test_Registration5() throws Exception { String alias = "/blah"; String expected = "Servlet cannot be null"; try { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); - extendedHttpService.registerServlet( - alias, null, null, null); - } - catch(IllegalArgumentException iae) { + extendedHttpService.registerServlet(alias, null, null, null); + } catch (IllegalArgumentException iae) { assertEquals(expected, iae.getMessage()); return; @@ -1119,14 +1106,13 @@ public void test_Registration5() throws Exception { public void test_Registration6() throws Exception { String expected = "Servlet has already been registered:"; try { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); Servlet servlet = new BaseServlet(); extendedHttpService.registerServlet("/blah1", servlet, null, null); extendedHttpService.registerServlet("/blah2", servlet, null, null); - } - catch(ServletException se) { + } catch (ServletException se) { Assert.assertTrue(se.getMessage().startsWith(expected)); return; @@ -1137,7 +1123,7 @@ public void test_Registration6() throws Exception { @Test public void test_unregister() throws Exception { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); Servlet servlet = new BaseServlet(); Filter filter = new TestFilter(); @@ -1153,7 +1139,7 @@ public void test_unregister() throws Exception { @Test public void test_Registration11() throws Exception { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); Servlet servlet = new BaseServlet(); @@ -1161,8 +1147,8 @@ public void test_Registration11() throws Exception { BundleContext bundleContext = getBundleContext(); - ServiceReference serviceReference = - bundleContext.getServiceReference(HttpServiceRuntime.class); + ServiceReference serviceReference = bundleContext + .getServiceReference(HttpServiceRuntime.class); HttpServiceRuntime runtime = bundleContext.getService(serviceReference); RuntimeDTO runtimeDTO = runtime.getRuntimeDTO(); @@ -1188,8 +1174,8 @@ public void test_Registration12() throws Exception { bundle.start(); BundleContext bundleContext = getBundleContext(); - ServiceReference serviceReference = - bundleContext.getServiceReference(HttpServiceRuntime.class); + ServiceReference serviceReference = bundleContext + .getServiceReference(HttpServiceRuntime.class); HttpServiceRuntime runtime = bundleContext.getService(serviceReference); RuntimeDTO runtimeDTO = runtime.getRuntimeDTO(); @@ -1199,22 +1185,21 @@ public void test_Registration12() throws Exception { ServletContextDTO servletContextDTO = servletContextDTOs[0]; Assert.assertNotNull(servletContextDTO.name); - } - finally { + } finally { uninstallBundle(bundle); } } @Test public void test_Registration13() throws Exception { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); extendedHttpService.registerResources("/blah1", "/foo", null); BundleContext bundleContext = getBundleContext(); - ServiceReference serviceReference = - bundleContext.getServiceReference(HttpServiceRuntime.class); + ServiceReference serviceReference = bundleContext + .getServiceReference(HttpServiceRuntime.class); HttpServiceRuntime runtime = bundleContext.getService(serviceReference); RuntimeDTO runtimeDTO = runtime.getRuntimeDTO(); @@ -1243,12 +1228,12 @@ public void init(ServletConfig config) throws ServletException { } }; - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); try { extendedHttpService.registerServlet("/foo", initError, null, null); fail("Expected an init failure."); } catch (ServletException e) { - //expected + // expected assertEquals("Wrong exception message.", "Init error.", e.getMessage()); } } @@ -1264,12 +1249,12 @@ public void init(ServletConfig config) { } }; - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); try { extendedHttpService.registerServlet("/foo", initError, null, null); fail("Expected an init failure."); } catch (IllegalStateException e) { - //expected + // expected assertEquals("Wrong exception message.", "Init error.", e.getMessage()); } } @@ -1293,12 +1278,12 @@ public void destroy() { // nothing } }; - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); try { extendedHttpService.registerFilter("/foo", initError, null, null); fail("Expected an init failure."); } catch (IllegalStateException e) { - //expected + // expected assertEquals("Wrong exception message.", "Init error.", e.getMessage()); } } @@ -1322,12 +1307,12 @@ public void destroy() { // nothing } }; - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); try { extendedHttpService.registerFilter("/foo", initError, null, null); fail("Expected an init failure."); } catch (ServletException e) { - //expected + // expected assertEquals("Wrong exception message.", "Init error.", e.getMessage()); } } @@ -1342,7 +1327,7 @@ public void test_Registration18_WhiteboardServletByNameOnly() throws Exception { @Override protected void service(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { request.getServletContext().getNamedDispatcher(servletName).forward(request, response); } @@ -1373,8 +1358,8 @@ public void init(FilterConfig filterConfig) { } @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, - ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { filterTCCL.add(Thread.currentThread().getContextClassLoader().getClass().getName()); chain.doFilter(request, response); } @@ -1414,7 +1399,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) Thread.currentThread().setContextClassLoader(dummy); String expected = dummy.getClass().getName(); String actual = null; - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); try { extendedHttpService.registerFilter("/tccl", tcclFilter, null, null); extendedHttpService.registerServlet("/tccl", tcclServlet, null, null); @@ -1490,12 +1475,13 @@ protected void service(HttpServletRequest request, HttpServletResponse response) servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/sessions"); String actual = null; CookieHandler previous = CookieHandler.getDefault(); - CookieHandler.setDefault(new CookieManager( null, CookiePolicy.ACCEPT_ALL ) ); + CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); try { servletReg = getBundleContext().registerService(Servlet.class, sessionServlet, servletProps); Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, listenerProps); + sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, + listenerProps); sessionCreated.set(false); valueBound.set(false); @@ -1568,7 +1554,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/sessions"); String actual = null; CookieHandler previous = CookieHandler.getDefault(); - CookieHandler.setDefault(new CookieManager( null, CookiePolicy.ACCEPT_ALL ) ); + CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); try { servletReg = getBundleContext().registerService(Servlet.class, sessionServlet, servletProps); @@ -1606,8 +1592,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) @Test public void test_Sessions03_HttpSessionInvalidator() throws Exception { - ServiceTracker sessionInvalidatorTracker = - new ServiceTracker<>(getBundleContext(), HttpSessionInvalidator.class, null); + ServiceTracker sessionInvalidatorTracker = new ServiceTracker<>( + getBundleContext(), HttpSessionInvalidator.class, null); sessionInvalidatorTracker.open(); HttpSessionInvalidator invalidator = sessionInvalidatorTracker.waitForService(100); @@ -1663,12 +1649,13 @@ protected void service(HttpServletRequest request, HttpServletResponse response) servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/sessions"); String actual = null; CookieHandler previous = CookieHandler.getDefault(); - CookieHandler.setDefault(new CookieManager( null, CookiePolicy.ACCEPT_ALL ) ); + CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); try { servletReg = getBundleContext().registerService(Servlet.class, sessionServlet, servletProps); Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, listenerProps); + sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, + listenerProps); sessionCreated.set(false); valueBound.set(false); @@ -1783,7 +1770,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) servletReg = getBundleContext().registerService(Servlet.class, sessionServlet, servletProps); Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, listenerProps); + sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, + listenerProps); sessionCreated.set(false); valueBound.set(false); @@ -1866,7 +1854,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) servletReg = getBundleContext().registerService(Servlet.class, sessionServlet, servletProps); Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, listenerProps); + sessionListenerReg = getBundleContext().registerService(HttpSessionListener.class, sessionListener, + listenerProps); // call the servet 10 times, we should get 10 sessions for (int i = 0; i < 10; i++) { @@ -1890,7 +1879,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) @Test public void test_Resource1() throws Exception { - String expected = "a"; + String expected = "a\n"; String actual; Bundle bundle = installBundle(TEST_BUNDLE_1); try { @@ -1904,7 +1893,7 @@ public void test_Resource1() throws Exception { @Test public void test_Resource2() throws Exception { - String expected = "cbdadbc"; + String expected = "cbda\ndbc"; String actual; Bundle bundle = installBundle(TEST_BUNDLE_1); try { @@ -1918,7 +1907,7 @@ public void test_Resource2() throws Exception { @Test public void test_Resource3() throws Exception { - String expected = "a"; + String expected = "a\n"; String actual; Bundle bundle = installBundle(TEST_BUNDLE_1); try { @@ -1932,7 +1921,7 @@ public void test_Resource3() throws Exception { @Test public void test_Resource4() throws Exception { - String expected = "dcbabcd"; + String expected = "dcba\nbcd"; String actual; Bundle bundle = installBundle(TEST_BUNDLE_1); try { @@ -1946,7 +1935,7 @@ public void test_Resource4() throws Exception { @Test public void test_Resource5() throws Exception { - String expected = "dcbabcd"; + String expected = "dcba\nbcd"; String actual; Bundle bundle = installBundle(TEST_BUNDLE_1); try { @@ -1965,7 +1954,7 @@ public void test_ResourceAliasNormal() throws Exception { extendedHttpService.registerResources("/testalias", "/org/eclipse/equinox/http/servlet/tests", null); String actual = requestAdvisor.request("testalias/resource2.txt"); - assertEquals("Wrong value.", "test", actual); + assertEquals("Wrong value.", "test\n", actual); } @Test @@ -1975,7 +1964,7 @@ public void test_ResourceAliasSlash() throws Exception { extendedHttpService.registerResources("/", "/org/eclipse/equinox/http/servlet/tests", null); String actual = requestAdvisor.request("resource2.txt"); - assertEquals("Wrong value.", "test", actual); + assertEquals("Wrong value.", "test\n", actual); } @Test @@ -2054,6 +2043,7 @@ public String getMimeType(String filename) { } return null; } + @Override public boolean rangeableContentType(String contentType, String userAgent) { return userAgent.contains("Foo") && contentType.startsWith("video/"); @@ -2088,7 +2078,8 @@ public void test_Runtime() throws Exception { BundleContext bundleContext = getBundleContext(); - ServiceReference serviceReference = bundleContext.getServiceReference(HttpServiceRuntime.class); + ServiceReference serviceReference = bundleContext + .getServiceReference(HttpServiceRuntime.class); HttpServiceRuntime runtime = bundleContext.getService(serviceReference); Assert.assertNotNull(runtime); @@ -2218,7 +2209,7 @@ public void test_Servlet9() throws Exception { @Test public void test_Servlet10() throws Exception { - String expected = "a"; + String expected = "a\n"; String actual; Bundle bundle = installBundle(TEST_BUNDLE_1); try { @@ -2232,7 +2223,7 @@ public void test_Servlet10() throws Exception { @Test public void test_Servlet11() throws Exception { - String expected = "a"; + String expected = "a\n"; String actual; Bundle bundle = installBundle(TEST_BUNDLE_1); try { @@ -2250,8 +2241,7 @@ public void test_Servlet12() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().write('a'); } @@ -2262,8 +2252,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().write('b'); } @@ -2286,9 +2275,7 @@ public void test_Servlet13() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write(req.getQueryString()); @@ -2315,8 +2302,7 @@ public void test_ServletExactMatchPrecidence() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().write('a'); } @@ -2327,8 +2313,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().write('b'); } @@ -2365,7 +2350,7 @@ public void test_Servlet16() throws Exception { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { Part part = req.getPart("file"); Assert.assertNotNull(part); @@ -2396,7 +2381,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) Map> result = requestAdvisor.upload("Servlet16/do", map); assertEquals("200", result.get("responseCode").get(0)); - assertEquals("resource1.txt|text/plain|25", result.get("responseBody").get(0)); + assertEquals("resource1.txt|text/plain|26", result.get("responseBody").get(0)); } @Test @@ -2406,7 +2391,7 @@ public void test_Servlet16_notEnabled() throws Exception { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { req.getPart("file"); } @@ -2433,7 +2418,7 @@ public void test_Servlet16_fileuploadWithLocation() throws Exception { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { Part part = req.getPart("file"); Assert.assertNotNull(part); @@ -2442,7 +2427,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) String contentType = part.getContentType(); long size = part.getSize(); - File tempDir = (File)getServletContext().getAttribute(ServletContext.TEMPDIR); + File tempDir = (File) getServletContext().getAttribute(ServletContext.TEMPDIR); File location = new File(tempDir, "file-upload-test"); File[] listFiles = location.listFiles(); @@ -2471,7 +2456,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) Map> result = requestAdvisor.upload("Servlet16/do", map); assertEquals("200", result.get("responseCode").get(0)); - assertEquals("resource1.txt|text/plain|25|0", result.get("responseBody").get(0)); + assertEquals("resource1.txt|text/plain|26|0", result.get("responseBody").get(0)); } @Test @@ -2481,7 +2466,7 @@ public void test_Servlet16_fileuploadWithLocationAndThreshold() throws Exception @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { Part part = req.getPart("file"); Assert.assertNotNull(part); @@ -2490,7 +2475,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) String contentType = part.getContentType(); long size = part.getSize(); - File tempDir = (File)getServletContext().getAttribute(ServletContext.TEMPDIR); + File tempDir = (File) getServletContext().getAttribute(ServletContext.TEMPDIR); File location = new File(tempDir, "file-upload-test"); File[] listFiles = location.listFiles(); @@ -2520,7 +2505,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) Map> result = requestAdvisor.upload("Servlet16/do", map); assertEquals("200", result.get("responseCode").get(0)); - assertEquals("resource1.txt|text/plain|25|1", result.get("responseBody").get(0)); + assertEquals("resource1.txt|text/plain|26|1", result.get("responseBody").get(0)); } @Test @@ -2530,7 +2515,7 @@ public void test_Servlet16_fileuploadWithLocationMaxFileSize() throws Exception @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { req.getPart("file"); } @@ -2561,7 +2546,7 @@ public void test_Servlet16_fileuploadWithLocationMaxRequestSize() throws Excepti @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { req.getPart("file"); } @@ -2572,7 +2557,8 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Servlet16/*"); props.put("equinox.http.multipartSupported", Boolean.TRUE); props.put("equinox.http.whiteboard.servlet.multipart.location", "file-upload-test"); - // Note the actual uploaded file size is 25bytes, but you also need room for the rest of the headers + // Note the actual uploaded file size is 25bytes, but you also need room for the + // rest of the headers props.put("equinox.http.whiteboard.servlet.multipart.maxRequestSize", 26L); registrations.add(getBundleContext().registerService(Servlet.class, servlet, props)); @@ -2636,8 +2622,7 @@ public void test_Servlet18() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { // get a resource that is imported URL url = request.getServletContext().getResource("org/osgi/service/http/HttpService.class"); response.getWriter().write(url == null ? "null" : url.getProtocol()); @@ -2651,7 +2636,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) httpService.registerServlet("/testDefaultHttpContextResource", sA, null, httpContext); - // just making sure bundleresource protocol is used as proof that Bundle.getResource was called + // just making sure bundleresource protocol is used as proof that + // Bundle.getResource was called assertEquals("bundleresource", requestAdvisor.request("testDefaultHttpContextResource")); } @@ -2661,8 +2647,7 @@ public void test_commonsFileUpload() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { boolean isMultipart = ServletFileUpload.isMultipartContent(req); Assert.assertTrue(isMultipart); @@ -2721,8 +2706,7 @@ public void test_PathEncodings_Bug540970() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); @@ -2737,10 +2721,14 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) Map> map = new HashMap<>(); - Map> result = requestAdvisor.request("Servlet16/NEEO-a5056097%2Fdevice%2Fapt-neeo_io%3Avirtual%3A6jzOoAtL%2FTemperature_GF_Living%2Fnone%2F1%2Fdirectory%2Factor/default", map); + Map> result = requestAdvisor.request( + "Servlet16/NEEO-a5056097%2Fdevice%2Fapt-neeo_io%3Avirtual%3A6jzOoAtL%2FTemperature_GF_Living%2Fnone%2F1%2Fdirectory%2Factor/default", + map); assertEquals("200", result.get("responseCode").get(0)); - assertEquals("/Servlet16/NEEO-a5056097%2Fdevice%2Fapt-neeo_io%3Avirtual%3A6jzOoAtL%2FTemperature_GF_Living%2Fnone%2F1%2Fdirectory%2Factor/default", result.get("responseBody").get(0)); + assertEquals( + "/Servlet16/NEEO-a5056097%2Fdevice%2Fapt-neeo_io%3Avirtual%3A6jzOoAtL%2FTemperature_GF_Living%2Fnone%2F1%2Fdirectory%2Factor/default", + result.get("responseBody").get(0)); } @Test @@ -2785,8 +2773,7 @@ public void test_ServletContext2() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) { + protected void service(HttpServletRequest request, HttpServletResponse response) { getServletContext().setAttribute("name", null); } @@ -2810,6 +2797,7 @@ public void testServletContextUnsupportedOperations() { final AtomicReference contextHolder = new AtomicReference<>(); Servlet unsupportedServlet = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override public void init(ServletConfig config) { contextHolder.set(config.getServletContext()); @@ -2830,7 +2818,7 @@ public void init(ServletConfig config) { } ServletContext context = contextHolder.get(); assertNotNull("Null context.", context); - for(Method m : getUnsupportedMethods()) { + for (Method m : getUnsupportedMethods()) { checkMethod(m, context); } } @@ -2855,9 +2843,11 @@ private void checkMethod(Method m, ServletContext context) throws RuntimeExcepti static private List getUnsupportedMethods() { List methods = new ArrayList<>(); Class contextClass = ServletContext.class; - for(Method m : contextClass.getMethods()) { + for (Method m : contextClass.getMethods()) { String name = m.getName(); - if (name.equals("addFilter") || name.equals("addListener") || name.equals("addServlet") || name.equals("createFilter") || name.equals("createListener") || name.equals("createServlet") || name.equals("declareRoles")) { + if (name.equals("addFilter") || name.equals("addListener") || name.equals("addServlet") + || name.equals("createFilter") || name.equals("createListener") || name.equals("createServlet") + || name.equals("declareRoles")) { methods.add(m); } } @@ -2869,34 +2859,44 @@ public void test_ServletContextHelper1() { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Dictionary contextProps = new Hashtable<>(); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); - servletContextHelper = new ServletContextHelper(bundle){}; + servletContextHelper = new ServletContextHelper(bundle) { + }; contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "test.sch.one"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); - servletContextHelper = new ServletContextHelper(bundle){}; + servletContextHelper = new ServletContextHelper(bundle) { + }; contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/test-sch2"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); - servletContextHelper = new ServletContextHelper(bundle){}; + servletContextHelper = new ServletContextHelper(bundle) { + }; contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "Test SCH 3!"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/test-sch3"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); - servletContextHelper = new ServletContextHelper(bundle){}; + servletContextHelper = new ServletContextHelper(bundle) { + }; contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "test.sch.four"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "test$sch$4"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); - ServiceReference serviceReference = - bundleContext.getServiceReference(HttpServiceRuntime.class); + ServiceReference serviceReference = bundleContext + .getServiceReference(HttpServiceRuntime.class); HttpServiceRuntime runtime = bundleContext.getService(serviceReference); RuntimeDTO runtimeDTO = runtime.getRuntimeDTO(); @@ -2918,7 +2918,8 @@ public void test_ServletContextHelper7() throws Exception { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Servlet s1 = new BaseServlet("a"); Collection> registrations = new ArrayList<>(); @@ -2926,19 +2927,20 @@ public void test_ServletContextHelper7() throws Exception { Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); Dictionary servletProps = new Hashtable<>(); servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1"); - servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(bundleContext.registerService(Servlet.class, s1, servletProps)); String actual = requestAdvisor.request("s1"); assertEquals(expected, actual); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -2951,7 +2953,8 @@ public void test_ServletContextHelper8() throws Exception { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Servlet s1 = new BaseServlet("b"); Collection> registrations = new ArrayList<>(); @@ -2959,19 +2962,20 @@ public void test_ServletContextHelper8() throws Exception { Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); Dictionary servletProps = new Hashtable<>(); servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1"); - servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(bundleContext.registerService(Servlet.class, s1, servletProps)); String actual = requestAdvisor.request("a/s1"); assertEquals(expected, actual); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -2986,7 +2990,8 @@ public void test_ServletContextHelper9() throws Exception { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Servlet s1 = new BaseServlet(expected1); Servlet s2 = new BaseServlet(expected2); @@ -2995,7 +3000,8 @@ public void test_ServletContextHelper9() throws Exception { Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); Dictionary servletProps1 = new Hashtable<>(); servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); @@ -3005,7 +3011,8 @@ public void test_ServletContextHelper9() throws Exception { Dictionary servletProps2 = new Hashtable<>(); servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s"); - servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(bundleContext.registerService(Servlet.class, s2, servletProps2)); String actual = requestAdvisor.request("s"); @@ -3015,8 +3022,7 @@ public void test_ServletContextHelper9() throws Exception { actual = requestAdvisor.request("a/s"); assertEquals(expected2, actual); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3030,10 +3036,10 @@ public void test_ServletContextHelperVisibility() throws Exception { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Servlet s1 = new BaseServlet(expected1); - Collection> registrations = new ArrayList<>(); try { // register a hook that hides the helper from the registering bundle @@ -3042,7 +3048,8 @@ public void test_ServletContextHelperVisibility() throws Exception { @Override public void find(BundleContext context, String name, String filter, boolean allServices, Collection> references) { - if (ServletContextHelper.class.getName().equals(name) && context.getBundle().equals(getBundleContext().getBundle())) { + if (ServletContextHelper.class.getName().equals(name) + && context.getBundle().equals(getBundleContext().getBundle())) { references.clear(); } } @@ -3051,12 +3058,14 @@ public void find(BundleContext context, String name, String filter, boolean allS Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); Dictionary servletProps2 = new Hashtable<>(); servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s"); - servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + servletProps2.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(bundleContext.registerService(Servlet.class, s1, servletProps2)); try { @@ -3096,11 +3105,10 @@ public void test_ServletContextHelper11() throws Exception { getHttpService().registerResources("/" + HTTP_CONTEXT_TEST_ROOT + "/1", "", ctx1); getHttpService().registerResources("/" + HTTP_CONTEXT_TEST_ROOT + "/2", "", ctx2); actual = requestAdvisor.request(HTTP_CONTEXT_TEST_ROOT + "/1/test"); - assertEquals("1", actual); + assertEquals("1\n", actual); actual = requestAdvisor.request(HTTP_CONTEXT_TEST_ROOT + "/2/test"); - assertEquals("2", actual); - } - finally { + assertEquals("2\n", actual); + } finally { try { getHttpService().unregister("/" + HTTP_CONTEXT_TEST_ROOT + "/1"); getHttpService().unregister("/" + HTTP_CONTEXT_TEST_ROOT + "/2"); @@ -3117,14 +3125,13 @@ public void test_ServletContextHelper12() throws Exception { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Servlet s1 = new HttpServlet() { private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { StringBuilder builder = new StringBuilder(); builder.append(request.getServletContext().getInitParameter("a")).append(','); @@ -3141,20 +3148,22 @@ protected void service( contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX + "a", "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX + "b", "b"); - contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX + "c", Integer.valueOf(1)); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX + "c", + Integer.valueOf(1)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); Dictionary servletProps1 = new Hashtable<>(); servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s"); - servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(bundleContext.registerService(Servlet.class, s1, servletProps1)); String actual = requestAdvisor.request("a/s"); assertEquals(expected1, actual); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3166,8 +3175,9 @@ public void test_ServletContextHelper13() throws Exception { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - // test that the helper handlesecurity is called before the filter by setting an attribute on the request - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){ + // test that the helper handlesecurity is called before the filter by setting an + // attribute on the request + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { @Override public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException { @@ -3198,6 +3208,7 @@ public void destroy() { }; Servlet s1 = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override public void service(ServletRequest req, ServletResponse res) throws IOException { res.getWriter().print(req.getAttribute(testName.getMethodName() + ".fromFilter")); @@ -3210,24 +3221,26 @@ public void service(ServletRequest req, ServletResponse res) throws IOException Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); Dictionary filterProps = new Hashtable<>(); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, "/*"); - filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(bundleContext.registerService(Filter.class, f1, filterProps)); Dictionary servletProps = new Hashtable<>(); servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s1"); - servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + servletProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(bundleContext.registerService(Servlet.class, s1, servletProps)); String actual = requestAdvisor.request("s1"); assertEquals(Boolean.TRUE.toString(), actual); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3239,8 +3252,10 @@ public void test_ServletContextHelper14_uniqueTempDirs() throws Exception { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelperA = new ServletContextHelper(bundle){}; - ServletContextHelper servletContextHelperB = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelperA = new ServletContextHelper(bundle) { + }; + ServletContextHelper servletContextHelperB = new ServletContextHelper(bundle) { + }; Collection> registrations = new ArrayList<>(); try { @@ -3248,10 +3263,10 @@ public void test_ServletContextHelper14_uniqueTempDirs() throws Exception { Servlet servletA = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - fileA.set((File)getServletContext().getAttribute(ServletContext.TEMPDIR)); + protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { + fileA.set((File) getServletContext().getAttribute(ServletContext.TEMPDIR)); new File(fileA.get(), "test").createNewFile(); } }; @@ -3259,9 +3274,11 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelperA, contextProps)); + registrations.add( + bundleContext.registerService(ServletContextHelper.class, servletContextHelperA, contextProps)); Dictionary props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "SA"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/SA"); registrations.add(getBundleContext().registerService(Servlet.class, servletA, props)); @@ -3273,12 +3290,12 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "b"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/b"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelperB, contextProps)); + registrations.add( + bundleContext.registerService(ServletContextHelper.class, servletContextHelperB, contextProps)); Assert.assertNotNull(fileA.get()); Assert.assertTrue(new File(fileA.get(), "test").exists()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3290,15 +3307,15 @@ public void test_ServletContextHelper15_fullContextPath_include() throws Excepti try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", "/foo"); - } - finally { + } finally { startJetty(); } BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelperA = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelperA = new ServletContextHelper(bundle) { + }; Collection> registrations = new ArrayList<>(); try { @@ -3306,32 +3323,37 @@ public void test_ServletContextHelper15_fullContextPath_include() throws Excepti Servlet servletA = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { RequestDispatcher rd = req.getRequestDispatcher("/foo/a/SB"); rd.include(req, resp); } }; Servlet servletB = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) { - path.set((String)req.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH)); + path.set((String) req.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH)); } }; Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelperA, contextProps)); + registrations.add( + bundleContext.registerService(ServletContextHelper.class, servletContextHelperA, contextProps)); Dictionary props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "SA"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/SA"); registrations.add(getBundleContext().registerService(Servlet.class, servletA, props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "SB"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/SB"); registrations.add(getBundleContext().registerService(Servlet.class, servletB, props)); @@ -3339,16 +3361,14 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { requestAdvisor.request("a/SA"); assertEquals("/foo/a", path.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", ""); - } - finally { + } finally { startJetty(); } } @@ -3359,15 +3379,15 @@ public void test_ServletContextHelper15_fullContextPath_forward() throws Excepti try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", "/foo"); - } - finally { + } finally { startJetty(); } BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelperA = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelperA = new ServletContextHelper(bundle) { + }; Collection> registrations = new ArrayList<>(); try { @@ -3375,32 +3395,37 @@ public void test_ServletContextHelper15_fullContextPath_forward() throws Excepti Servlet servletA = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) - throws IOException, ServletException { + throws IOException, ServletException { RequestDispatcher rd = req.getRequestDispatcher("/foo/a/SB"); rd.forward(req, resp); } }; Servlet servletB = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) { - path.set((String)req.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH)); + path.set((String) req.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH)); } }; Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelperA, contextProps)); + registrations.add( + bundleContext.registerService(ServletContextHelper.class, servletContextHelperA, contextProps)); Dictionary props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "SA"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/SA"); registrations.add(getBundleContext().registerService(Servlet.class, servletA, props)); props = new Hashtable<>(); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "SB"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/SB"); registrations.add(getBundleContext().registerService(Servlet.class, servletB, props)); @@ -3408,16 +3433,14 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { requestAdvisor.request("a/SA"); assertEquals("/foo/a", path.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", ""); - } - finally { + } finally { startJetty(); } } @@ -3428,8 +3451,7 @@ public void test_getRequestURI_trailingSlash1() throws Exception { try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", "/foo"); - } - finally { + } finally { startJetty(); } @@ -3439,6 +3461,7 @@ public void test_getRequestURI_trailingSlash1() throws Exception { Servlet servletA = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) { getRequestURI.set(req.getRequestURI()); @@ -3447,7 +3470,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "SA"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] {"/*", "/"}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] { "/*", "/" }); registrations.add(getBundleContext().registerService(Servlet.class, servletA, props)); props = new Hashtable<>(); @@ -3462,16 +3485,14 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { // by appending a slash first. requestAdvisor.request(""); assertEquals("/foo/", getRequestURI.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", ""); - } - finally { + } finally { startJetty(); } } @@ -3482,8 +3503,7 @@ public void test_getRequestURI_trailingSlash2() throws Exception { try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", "/foo"); - } - finally { + } finally { startJetty(); } @@ -3493,6 +3513,7 @@ public void test_getRequestURI_trailingSlash2() throws Exception { Servlet servletA = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) { HttpSession session = req.getSession(); @@ -3522,16 +3543,14 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { // by appending a slash first. requestAdvisor.request("" + sessionPostfix); assertEquals("/foo/" + sessionPostfix, getRequestURI.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } try { stopJetty(); System.setProperty("org.eclipse.equinox.http.jetty.context.path", ""); - } - finally { + } finally { startJetty(); } } @@ -3545,6 +3564,7 @@ public void test_getRequestURI_trailingSlash3() throws Exception { Servlet servletA = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) { getRequestURI.set(req.getRequestURI()); @@ -3553,7 +3573,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { Dictionary props = new Hashtable<>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "SA"); - props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] {"/*", "/"}); + props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] { "/*", "/" }); registrations.add(getBundleContext().registerService(Servlet.class, servletA, props)); props = new Hashtable<>(); @@ -3567,8 +3587,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { // by appending a slash first. requestAdvisor.request(""); assertEquals("/", getRequestURI.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3583,6 +3602,7 @@ public void test_getRequestURI_trailingSlash4() throws Exception { Servlet servletA = new HttpServlet() { private static final long serialVersionUID = 1L; + @Override protected void service(HttpServletRequest req, HttpServletResponse resp) { HttpSession session = req.getSession(); @@ -3612,8 +3632,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { // by appending a slash first. requestAdvisor.request("" + sessionPostfix); assertEquals("/" + sessionPostfix, getRequestURI.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3622,15 +3641,14 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) { @Test public void test_Listener1() { - BaseServletContextListener scl1 = - new BaseServletContextListener(); + BaseServletContextListener scl1 = new BaseServletContextListener(); Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - ServiceRegistration registration = getBundleContext().registerService(ServletContextListener.class, scl1, listenerProps); + ServiceRegistration registration = getBundleContext() + .registerService(ServletContextListener.class, scl1, listenerProps); registration.unregister(); - Assert.assertTrue(scl1.initialized.get()); Assert.assertTrue(scl1.destroyed.get()); } @@ -3640,26 +3658,28 @@ public void test_Listener2() { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; Collection> registrations = new ArrayList<>(); try { Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); - BaseServletContextListener scl1 = - new BaseServletContextListener(); + BaseServletContextListener scl1 = new BaseServletContextListener(); Dictionary listenerProps = new Hashtable<>(); - listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - ServiceRegistration registration = getBundleContext().registerService(ServletContextListener.class, scl1, listenerProps); + ServiceRegistration registration = getBundleContext() + .registerService(ServletContextListener.class, scl1, listenerProps); registration.unregister(); Assert.assertTrue(scl1.initialized.get()); Assert.assertTrue(scl1.destroyed.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3671,23 +3691,25 @@ public void test_Listener3() { BundleContext bundleContext = getBundleContext(); Bundle bundle = bundleContext.getBundle(); - ServletContextHelper servletContextHelper = new ServletContextHelper(bundle){}; + ServletContextHelper servletContextHelper = new ServletContextHelper(bundle) { + }; BaseServletContextListener scl1 = new BaseServletContextListener(); Collection> registrations = new ArrayList<>(); try { Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); + registrations + .add(bundleContext.registerService(ServletContextHelper.class, servletContextHelper, contextProps)); Dictionary listenerProps = new Hashtable<>(); - listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); registrations.add(bundleContext.registerService(ServletContextListener.class, scl1, listenerProps)); Assert.assertTrue(scl1.initialized.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3698,15 +3720,15 @@ public void test_Listener3() { @Test public void test_Listener4() throws Exception { - BaseServletContextAttributeListener scal1 = - new BaseServletContextAttributeListener(); + BaseServletContextAttributeListener scal1 = new BaseServletContextAttributeListener(); Servlet s1 = new BaseServlet("a"); Collection> registrations = new ArrayList<>(); try { Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - registrations.add(getBundleContext().registerService(ServletContextAttributeListener.class, scal1, listenerProps)); + registrations.add( + getBundleContext().registerService(ServletContextAttributeListener.class, scal1, listenerProps)); Dictionary servletProps1 = new Hashtable<>(); servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); @@ -3731,8 +3753,7 @@ public void test_Listener4() throws Exception { Assert.assertTrue(scal1.replaced.get()); Assert.assertTrue(scal1.removed.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3761,8 +3782,7 @@ public void test_Listener5() throws Exception { Assert.assertTrue(srl1.initialized.get()); Assert.assertTrue(srl1.destroyed.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3780,7 +3800,8 @@ public void test_Listener6() throws Exception { try { Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - registrations.add(getBundleContext().registerService(ServletRequestAttributeListener.class, sral1, listenerProps)); + registrations.add( + getBundleContext().registerService(ServletRequestAttributeListener.class, sral1, listenerProps)); Dictionary servletProps1 = new Hashtable<>(); servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); @@ -3792,8 +3813,7 @@ public void test_Listener6() throws Exception { Assert.assertTrue(sral1.added.get()); Assert.assertTrue(sral1.replaced.get()); Assert.assertTrue(sral1.removed.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3803,8 +3823,7 @@ public void test_Listener6() throws Exception { @Test public void test_Listener7() throws Exception { - BaseHttpSessionAttributeListener hsal1 = - new BaseHttpSessionAttributeListener(); + BaseHttpSessionAttributeListener hsal1 = new BaseHttpSessionAttributeListener(); Servlet s1 = new BaseServlet("test_Listener7"); @@ -3812,7 +3831,8 @@ public void test_Listener7() throws Exception { try { Dictionary listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - registrations.add(getBundleContext().registerService(HttpSessionAttributeListener.class, hsal1, listenerProps)); + registrations + .add(getBundleContext().registerService(HttpSessionAttributeListener.class, hsal1, listenerProps)); Dictionary servletProps1 = new Hashtable<>(); servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S1"); @@ -3854,8 +3874,7 @@ public void test_Listener7() throws Exception { Assert.assertTrue(hsal1.added.get()); Assert.assertTrue(hsal1.replaced.get()); Assert.assertTrue(hsal1.removed.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3882,8 +3901,7 @@ public void test_Listener8() throws Exception { requestAdvisor.request("s"); Assert.assertTrue(hsil1.changed.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3896,9 +3914,8 @@ public void test_Listener9() throws Exception { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { RequestDispatcher requestDispatcher = req.getRequestDispatcher("/s9B"); @@ -3909,9 +3926,7 @@ protected void doGet( private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter writer = resp.getWriter(); writer.write("S9 included"); @@ -3940,8 +3955,7 @@ protected void doGet( assertEquals(0, srl1.number.get()); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -3965,11 +3979,13 @@ public void test_Listener10() { Dictionary contextProps = new Hashtable<>(); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); contextProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper(){}, contextProps)); + registrations.add(getBundleContext().registerService(ServletContextHelper.class, new ServletContextHelper() { + }, contextProps)); listenerProps = new Hashtable<>(); listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); + listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=a)"); registrations.add(getBundleContext().registerService(ServletContextListener.class, scl3, listenerProps)); ServletContext servletContext1 = scl1.servletContext; @@ -4032,9 +4048,7 @@ public void sessionCreated(HttpSessionEvent se) { private static final long serialVersionUID = 1L; @Override - protected void doGet( - HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { HttpSession session = req.getSession(); sessionReference.set(session); @@ -4062,15 +4076,14 @@ protected void doGet( String result = requestAdvisor.request("s11"); assertEquals("S11 requested", result); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } } - //Emulate session expiration to check sessionListener - //is only called once (when unregister) + // Emulate session expiration to check sessionListener + // is only called once (when unregister) HttpSession session = sessionReference.get(); session.invalidate(); @@ -4093,8 +4106,7 @@ public void test_Async1() throws Exception { String output1 = requestAdvisor.request("s"); Assert.assertTrue(output1, output1.endsWith("test_Listener8")); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -4163,13 +4175,12 @@ public void test_BufferedOutput() throws Exception { servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s9"); registrations.add(getBundleContext().registerService(Servlet.class, new BufferedServlet(), servletProps1)); - Map> response = requestAdvisor.request( - "s9", Collections.>emptyMap()); + Map> response = requestAdvisor.request("s9", + Collections.>emptyMap()); String responseCode = response.get("responseCode").get(0); assertEquals("200", responseCode); - } - finally { + } finally { for (ServiceRegistration registration : registrations) { registration.unregister(); } @@ -4177,33 +4188,33 @@ public void test_BufferedOutput() throws Exception { } @Test - public void testWBServletChangeInitParams() throws Exception{ + public void testWBServletChangeInitParams() throws Exception { BundleContext bundleContext = getBundleContext(); Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/prototype/*"); TestServletPrototype testDriver = new TestServletPrototype(bundleContext); registrations.add(bundleContext.registerService(Servlet.class, testDriver, serviceProps)); - String actual; + String actual; - Map params = new HashMap<>(); - params.put(TEST_PROTOTYPE_NAME, testName.getMethodName()); - params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName()); - params.put(STATUS_PARAM, testName.getMethodName()); - actual = doRequest(CONFIGURE, params); - assertEquals(testName.getMethodName(), actual); - actual = requestAdvisor.request(testName.getMethodName()); - assertEquals(testName.getMethodName(), actual); + Map params = new HashMap<>(); + params.put(TEST_PROTOTYPE_NAME, testName.getMethodName()); + params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName()); + params.put(STATUS_PARAM, testName.getMethodName()); + actual = doRequest(CONFIGURE, params); + assertEquals(testName.getMethodName(), actual); + actual = requestAdvisor.request(testName.getMethodName()); + assertEquals(testName.getMethodName(), actual); - // change the init param - params.put(STATUS_PARAM, "changed"); - doRequest(CONFIGURE, params); - actual = requestAdvisor.request(testName.getMethodName()); - assertEquals("changed", actual); + // change the init param + params.put(STATUS_PARAM, "changed"); + doRequest(CONFIGURE, params); + actual = requestAdvisor.request(testName.getMethodName()); + assertEquals("changed", actual); } @Test - public void testWBServletChangePattern() throws Exception{ + public void testWBServletChangePattern() throws Exception { BundleContext bundleContext = getBundleContext(); Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/prototype/*"); @@ -4229,7 +4240,7 @@ public void testWBServletChangePattern() throws Exception{ } @Test - public void testWBServletChangeRanking() throws Exception{ + public void testWBServletChangeRanking() throws Exception { BundleContext bundleContext = getBundleContext(); Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/prototype/*"); @@ -4275,7 +4286,7 @@ public void testWBServletChangeRanking() throws Exception{ } @Test - public void testWBServletDefaultContextAdaptor1() throws Exception{ + public void testWBServletDefaultContextAdaptor1() throws Exception { BundleContext bundleContext = getBundleContext(); Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/prototype/*"); @@ -4286,7 +4297,8 @@ public void testWBServletDefaultContextAdaptor1() throws Exception{ helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName()); helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/testContext"); helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); - ServiceRegistration helperReg = getBundleContext().registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); + ServiceRegistration helperReg = getBundleContext() + .registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); ServiceRegistration pathAdaptorReg = null; try { @@ -4301,7 +4313,10 @@ public void testWBServletDefaultContextAdaptor1() throws Exception{ actual = requestAdvisor.request(testName.getMethodName()); assertEquals(testName.getMethodName(), actual); - ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor("(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")", null, testName.getMethodName()); + ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor( + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + + testName.getMethodName() + ")", + null, testName.getMethodName()); pathAdaptorReg = getBundleContext().registerService(ContextPathCustomizer.class, pathAdaptor, null); actual = requestAdvisor.request("testContext/" + testName.getMethodName()); @@ -4322,7 +4337,7 @@ public void testWBServletDefaultContextAdaptor1() throws Exception{ } @Test - public void testWBServletDefaultContextAdaptor2() throws Exception{ + public void testWBServletDefaultContextAdaptor2() throws Exception { BundleContext bundleContext = getBundleContext(); Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/prototype/*"); @@ -4333,14 +4348,17 @@ public void testWBServletDefaultContextAdaptor2() throws Exception{ helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName()); helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/testContext"); helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); - ServiceRegistration helperReg = getBundleContext().registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); + ServiceRegistration helperReg = getBundleContext() + .registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); ServiceRegistration pathAdaptorReg = null; try { Map params = new HashMap<>(); params.put(TEST_PROTOTYPE_NAME, testName.getMethodName()); params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName()); - params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")"); + params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + + testName.getMethodName() + ")"); params.put(STATUS_PARAM, testName.getMethodName()); params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); String actual = doRequest(CONFIGURE, params); @@ -4349,7 +4367,8 @@ public void testWBServletDefaultContextAdaptor2() throws Exception{ actual = requestAdvisor.request("testContext/" + testName.getMethodName()); assertEquals(testName.getMethodName(), actual); - ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", testName.getMethodName()); + ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", + testName.getMethodName()); pathAdaptorReg = getBundleContext().registerService(ContextPathCustomizer.class, pathAdaptor, null); actual = requestAdvisor.request("testPrefix/testContext/" + testName.getMethodName()); @@ -4370,26 +4389,30 @@ public void testWBServletDefaultContextAdaptor2() throws Exception{ } @Test - public void testWBServletDefaultContextAdaptor3() throws Exception{ + public void testWBServletDefaultContextAdaptor3() throws Exception { BundleContext bundleContext = getBundleContext(); Dictionary serviceProps = new Hashtable<>(); serviceProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/prototype/*"); TestServletPrototype testDriver = new TestServletPrototype(bundleContext); registrations.add(bundleContext.registerService(Servlet.class, testDriver, serviceProps)); - // test the ContextPathCustomizer with a ServletContextHelper that has a '/' context path + // test the ContextPathCustomizer with a ServletContextHelper that has a '/' + // context path Dictionary helperProps = new Hashtable<>(); helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "testContext" + testName.getMethodName()); helperProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/"); helperProps.put(TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); - ServiceRegistration helperReg = getBundleContext().registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); + ServiceRegistration helperReg = getBundleContext() + .registerService(ServletContextHelper.class, new TestServletContextHelperFactory(), helperProps); ServiceRegistration pathAdaptorReg = null; try { Map params = new HashMap<>(); params.put(TEST_PROTOTYPE_NAME, testName.getMethodName()); params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, '/' + testName.getMethodName()); - params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + testName.getMethodName() + ")"); + params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + "testContext" + + testName.getMethodName() + ")"); params.put(STATUS_PARAM, testName.getMethodName()); params.put("servlet.init." + TEST_PATH_CUSTOMIZER_NAME, testName.getMethodName()); String actual = doRequest(CONFIGURE, params); @@ -4398,7 +4421,8 @@ public void testWBServletDefaultContextAdaptor3() throws Exception{ actual = requestAdvisor.request(testName.getMethodName()); assertEquals(testName.getMethodName(), actual); - ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", testName.getMethodName()); + ContextPathCustomizer pathAdaptor = new TestContextPathAdaptor(null, "testPrefix", + testName.getMethodName()); pathAdaptorReg = getBundleContext().registerService(ContextPathCustomizer.class, pathAdaptor, null); actual = requestAdvisor.request("testPrefix/" + testName.getMethodName()); @@ -4420,7 +4444,7 @@ public void testWBServletDefaultContextAdaptor3() throws Exception{ @Test public void testHttpContextSetUser() throws ServletException, NamespaceException, IOException { - ExtendedHttpService extendedHttpService = (ExtendedHttpService)getHttpService(); + ExtendedHttpService extendedHttpService = (ExtendedHttpService) getHttpService(); HttpContext testContext = new HttpContext() { @@ -4445,8 +4469,7 @@ public String getMimeType(String name) { private static final long serialVersionUID = 1L; @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.print("USER: " + req.getRemoteUser() + " AUTH_TYPE: " + req.getAuthType()); @@ -4476,7 +4499,7 @@ public void testHTTPSEndpoint() throws Exception { bundle.start(); String actual = requestAdvisor.requestHttps("TestServlet10"); - assertEquals("Expected output not found", "a", actual); + assertEquals("Expected output not found", "a\n", actual); } finally { uninstallBundle(bundle); stopJettyWithSSL(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndErrorPage.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndErrorPage.java index 2e0f499c1a7..7f60389be6d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndErrorPage.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndErrorPage.java @@ -40,37 +40,24 @@ public void testHttpServiceAndErrorPage() throws Exception { try { final String name1 = "testname1"; final String name2 = "testname2"; - Dictionary properties = new Hashtable<>(); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, - name1); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, - "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY - + "=*)"); + Dictionary properties = new Hashtable<>(); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, name1); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY + "=*)"); long before = getHttpRuntimeChangeCount(); - registrations.add(getBundleContext().registerService( - Servlet.class, new MockServlet(), properties)); + registrations.add(getBundleContext().registerService(Servlet.class, new MockServlet(), properties)); before = waitForRegistration(before); properties = new Hashtable<>(); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, - name2); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, - "/" + name2); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, - "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY - + "=*)"); - registrations.add(getBundleContext().registerService( - Servlet.class, new MockServlet(), properties)); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, name2); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/" + name2); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY + "=*)"); + registrations.add(getBundleContext().registerService(Servlet.class, new MockServlet(), properties)); before = waitForRegistration(before); assertNull(getFailedErrorPageDTOByException(name1)); - assertNotNull("" + getHttpServiceRuntime().getRuntimeDTO(), - getFailedErrorPageDTOByException(name2)); + assertNotNull("" + getHttpServiceRuntime().getRuntimeDTO(), getFailedErrorPageDTOByException(name2)); final ServletContextDTO scDTO = getServletContextDTOForDummyServlet(); assertNotNull(getErrorPageDTOByException(scDTO.name, name1)); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndNamedServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndNamedServlet.java index 5251ec7915f..00a1d969f92 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndNamedServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestHttpServiceAndNamedServlet.java @@ -31,8 +31,8 @@ public class TestHttpServiceAndNamedServlet extends BaseTest { /** - * Registration of named servlet with http service (allowed) and named - * servlet and pattern with http service (not allowed) + * Registration of named servlet with http service (allowed) and named servlet + * and pattern with http service (not allowed) */ @Test public void testHttpServiceAndNamedServlet() throws Exception { @@ -40,35 +40,24 @@ public void testHttpServiceAndNamedServlet() throws Exception { try { final String name1 = "testname1"; final String name2 = "testname2"; - Dictionary properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, - name1); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, - "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY - + "=*)"); + Dictionary properties = new Hashtable<>(); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, name1); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY + "=*)"); long before = getHttpRuntimeChangeCount(); - registrations.add(getBundleContext().registerService( - Servlet.class, new MockServlet(), properties)); + registrations.add(getBundleContext().registerService(Servlet.class, new MockServlet(), properties)); before = waitForRegistration(before); properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, - name2); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, - "/" + name2); - properties.put( - HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, - "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY - + "=*)"); - registrations.add(getBundleContext().registerService( - Servlet.class, new MockServlet(), properties)); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, name2); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/" + name2); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(" + HttpWhiteboardConstants.HTTP_SERVICE_CONTEXT_PROPERTY + "=*)"); + registrations.add(getBundleContext().registerService(Servlet.class, new MockServlet(), properties)); before = waitForRegistration(before); assertNull(getFailedServletDTOByName(name1)); - assertNotNull("" + getHttpServiceRuntime().getRuntimeDTO(), - getFailedServletDTOByName(name2)); + assertNotNull("" + getHttpServiceRuntime().getRuntimeDTO(), getFailedServletDTOByName(name2)); final ServletContextDTO scDTO = getServletContextDTOForDummyServlet(); assertNotNull(getServletDTOByName(scDTO.name, name1)); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUpload.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUpload.java index ef537440c39..f0d64f19547 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUpload.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUpload.java @@ -47,28 +47,25 @@ public class TestUpload extends BaseTest { @Test public void testUpload() throws Exception { final CountDownLatch receivedLatch = new CountDownLatch(1); - final Map contents = new HashMap<>(); + final Map contents = new HashMap<>(); setupUploadServlet(receivedLatch, contents); postContent(getClass().getResource("resource1.txt"), 201); assertTrue(receivedLatch.await(5, TimeUnit.SECONDS)); assertEquals(1, contents.size()); - assertEquals(25L, (long) contents.get("text.txt")); + assertEquals(26L, (long) contents.get("text.txt")); } - private void setupUploadServlet(final CountDownLatch receivedLatch, - final Map contents) { - final Dictionary servletProps = new Hashtable<>(); + private void setupUploadServlet(final CountDownLatch receivedLatch, final Map contents) { + final Dictionary servletProps = new Hashtable<>(); servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, "/post"); - servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED, - Boolean.TRUE); + servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED, Boolean.TRUE); servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE, 1024L); @SuppressWarnings("serial") final Servlet uploadServlet = new HttpServlet() { @Override - protected void doPost(HttpServletRequest req, - HttpServletResponse resp) + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { try { final Collection parts = req.getParts(); @@ -84,8 +81,7 @@ protected void doPost(HttpServletRequest req, }; long before = this.getHttpRuntimeChangeCount(); - registrations.add(getBundleContext().registerService( - Servlet.class.getName(), uploadServlet, servletProps)); + registrations.add(getBundleContext().registerService(Servlet.class.getName(), uploadServlet, servletProps)); this.waitForRegistration(before); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java index cacc02e4188..a7339e28441 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/TestUploadWithParameter.java @@ -48,21 +48,21 @@ import org.junit.Test; public class TestUploadWithParameter extends BaseTest { - + @Test public void testUploadWithParameter() throws Exception { final CountDownLatch receivedLatch = new CountDownLatch(1); final HashMap contents = new HashMap<>(); final HashMap contentsByKey = new HashMap<>(); setupUploadWithParameterServlet(receivedLatch, contents, contentsByKey); - + postContentWithParameter(getClass().getResource("resource1.txt"), 201); assertTrue(receivedLatch.await(5, TimeUnit.SECONDS)); assertEquals(2, contents.size()); assertEquals("Test", contents.get("single")); assertNotNull(contents.get("multi")); assertTrue(contents.get("multi") instanceof List); - + @SuppressWarnings("unchecked") List multi = (List) contents.get("multi"); assertEquals(3, multi.size()); @@ -74,32 +74,35 @@ public void testUploadWithParameter() throws Exception { assertEquals("Test", contentsByKey.get("single")); assertEquals("One", contentsByKey.get("multi")); } - - private void setupUploadWithParameterServlet(CountDownLatch receivedLatch, Map contents, Map contentsByKey) { - final Dictionary servletProps = new Hashtable<>(); + + private void setupUploadWithParameterServlet(CountDownLatch receivedLatch, Map contents, + Map contentsByKey) { + final Dictionary servletProps = new Hashtable<>(); servletProps.put(HTTP_WHITEBOARD_SERVLET_PATTERN, "/post"); servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED, Boolean.TRUE); servletProps.put(HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE, 1024L); - + @SuppressWarnings("serial") final Servlet uploadServlet = new HttpServlet() { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { - + try { // check if the multi values are sent as post parameter in the multipart request ArrayList collected = new ArrayList<>(); for (Part supportPart : req.getParts()) { if (supportPart.getName().equals("multi")) { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(supportPart.getInputStream()))) { + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(supportPart.getInputStream()))) { List collect = reader.lines().collect(Collectors.toList()); if (collect != null && !collect.isEmpty()) { collected.addAll(collect); } } } else if (supportPart.getName().equals("single")) { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(supportPart.getInputStream()))) { + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(supportPart.getInputStream()))) { contents.put("single", reader.readLine()); } } @@ -107,25 +110,26 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) if (!collected.isEmpty()) { contents.put("multi", collected); } - - try (BufferedReader reader = new BufferedReader(new InputStreamReader(req.getPart("single").getInputStream()))) { + + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(req.getPart("single").getInputStream()))) { contentsByKey.put("single", reader.readLine()); } - try (BufferedReader reader = new BufferedReader(new InputStreamReader(req.getPart("multi").getInputStream()))) { + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(req.getPart("multi").getInputStream()))) { contentsByKey.put("multi", reader.readLine()); } - + resp.setStatus(201); } finally { receivedLatch.countDown(); } - + } }; - + long before = this.getHttpRuntimeChangeCount(); - registrations.add(getBundleContext().registerService( - Servlet.class.getName(), uploadServlet, servletProps)); + registrations.add(getBundleContext().registerService(Servlet.class.getName(), uploadServlet, servletProps)); this.waitForRegistration(before); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_11_3.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_11_3.java index 5920ec86b95..9958ed610f7 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_11_3.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_11_3.java @@ -31,8 +31,8 @@ public class Test_140_11_3 extends BaseTest { - public static final String SERVICE_NAMESPACE = "osgi.service"; - public static final String CAPABILITY_OBJECTCLASS_ATTRIBUTE = "objectClass"; + public static final String SERVICE_NAMESPACE = "osgi.service"; + public static final String CAPABILITY_OBJECTCLASS_ATTRIBUTE = "objectClass"; @Test public void test_140_11_3() { diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_17to22.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_17to22.java index 556fd04541a..4a90fb83f55 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_17to22.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_17to22.java @@ -61,7 +61,8 @@ public void test_140_2_17to22() { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - ServiceRegistration serviceRegistration = context.registerService(ServletContextListener.class, new MockSCL(sc1), properties); + ServiceRegistration serviceRegistration = context + .registerService(ServletContextListener.class, new MockSCL(sc1), properties); registrations.add(serviceRegistration); assertNull(sc1.get()); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_26to27.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_26to27.java index 36331a88bf9..38b56e4aff1 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_26to27.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_26to27.java @@ -43,25 +43,31 @@ public void test_140_2_26to27() { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "foo"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/foo"); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "foobar"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/foo"); properties.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE)); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(osgi.http.whiteboard.context.name=foo)"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(osgi.http.whiteboard.context.name=foo)"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "first"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/bar/someServlet"); - registrations.add(context.registerService(Servlet.class, new HttpServlet() {}, properties)); + registrations.add(context.registerService(Servlet.class, new HttpServlet() { + }, properties)); properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(osgi.http.whiteboard.context.name=foobar)"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(osgi.http.whiteboard.context.name=foobar)"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "second"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/bar/someServlet"); - registrations.add(context.registerService(Servlet.class, new HttpServlet() {}, properties)); + registrations.add(context.registerService(Servlet.class, new HttpServlet() { + }, properties)); ServletContextDTO servletContextDTO = getServletContextDTOByName("foobar"); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_39to41.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_39to41.java index ef323f2bd6e..7a22a22744b 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_39to41.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_39to41.java @@ -38,20 +38,20 @@ public void test_140_2_39to41() { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "foo"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/foo"); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "foo"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/foo/bar"); properties.put(Constants.SERVICE_RANKING, Integer.valueOf(1000)); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); FailedServletContextDTO failedServletContextDTO = getFailedServletContextDTOByName("foo"); assertNotNull(failedServletContextDTO); - assertEquals( - DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, - failedServletContextDTO.failureReason); + assertEquals(DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, failedServletContextDTO.failureReason); } } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_6_getResourcePaths.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_6_getResourcePaths.java index 3d6cc2a0e43..ecedf904258 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_6_getResourcePaths.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_2_6_getResourcePaths.java @@ -61,7 +61,8 @@ public Set getResourcePaths(String path) { properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(osgi.http.whiteboard.context.name=context1)"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(osgi.http.whiteboard.context.name=context1)"); registrations.add(context.registerService(ServletContextListener.class, new MockSCL(sc1), properties)); ServletContext servletContext = sc1.get(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_11to13.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_11to13.java index 0660e0b67e2..f646e57f0a7 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_11to13.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_11to13.java @@ -46,8 +46,7 @@ public void test_140_4_11to13() throws Exception { Servlet servlet = new HttpServlet() { @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { invoked.set(true); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_14to15.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_14to15.java index 2726da59a8e..31948c02b64 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_14to15.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_14to15.java @@ -46,8 +46,7 @@ public void test_140_4_14to15() throws Exception { Servlet servlet = new HttpServlet() { @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { invoked.set(true); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_16.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_16.java index 151e9dffb39..d34455c2fe7 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_16.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_16.java @@ -45,8 +45,7 @@ public void test_140_4_16() throws Exception { Servlet servlet = new HttpServlet() { @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { invoked.set(true); @@ -61,7 +60,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) }; Dictionary properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] {"/a", "/fee/fi/foo/fum"}); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, + new String[] { "/a", "/fee/fi/foo/fum" }); registrations.add(context.registerService(Servlet.class, servlet, properties)); assertEquals(":/a:", requestAdvisor.request("a")); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_17to22.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_17to22.java index 4a94a73598c..c9aa55d170e 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_17to22.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_17to22.java @@ -46,20 +46,20 @@ public AServlet(String content) { } @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().write(content); } - private final String content; + private final String content; } Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "a"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/a"); - ServiceRegistration srA = getBundleContext().registerService(Servlet.class, new AServlet("a"), properties); + ServiceRegistration srA = getBundleContext().registerService(Servlet.class, new AServlet("a"), + properties); registrations.add(srA); assertEquals("a", requestAdvisor.request("a")); @@ -67,7 +67,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "b"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/a"); - ServiceRegistration srB = getBundleContext().registerService(Servlet.class, new AServlet("b"), properties); + ServiceRegistration srB = getBundleContext().registerService(Servlet.class, new AServlet("b"), + properties); registrations.add(srB); assertEquals("a", requestAdvisor.request("a")); @@ -75,12 +76,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) FailedServletDTO failedServletDTO = getFailedServletDTOByName("b"); assertNotNull(failedServletDTO); - assertEquals( - DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, - failedServletDTO.failureReason); - assertEquals( - getServiceId(srB), - failedServletDTO.serviceId); + assertEquals(DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, failedServletDTO.failureReason); + assertEquals(getServiceId(srB), failedServletDTO.serviceId); properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "c"); @@ -93,12 +90,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) failedServletDTO = getFailedServletDTOByName("a"); assertNotNull(failedServletDTO); - assertEquals( - DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, - failedServletDTO.failureReason); - assertEquals( - getServiceId(srA), - failedServletDTO.serviceId); + assertEquals(DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, failedServletDTO.failureReason); + assertEquals(getServiceId(srA), failedServletDTO.serviceId); } } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_1_22to23.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_1_22to23.java index 3e9daeeb46c..1950e793095 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_1_22to23.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_1_22to23.java @@ -68,7 +68,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response) properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "b"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, HttpServletResponse.SC_BAD_GATEWAY + ""); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE, + HttpServletResponse.SC_BAD_GATEWAY + ""); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/b"); registrations.add(getBundleContext().registerService(Servlet.class, new BServlet(), properties)); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_26to31.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_26to31.java index 74ee6c92ce0..94a501240ec 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_26to31.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_26to31.java @@ -50,20 +50,20 @@ public AServlet(String content) { } @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.getWriter().write(content); } - private final String content; + private final String content; } Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "a"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/a"); - //properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(osgi.http.whiteboard.context.name=org_eclipse_equinox_http_servlet_internal_HttpServiceImpl_DefaultHttpContext-0)"); + // properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + // "(osgi.http.whiteboard.context.name=org_eclipse_equinox_http_servlet_internal_HttpServiceImpl_DefaultHttpContext-0)"); properties.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE); ServiceRegistration srA = context.registerService(Servlet.class, new AServlet("a"), properties); registrations.add(srA); @@ -73,9 +73,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) assertNotNull(requestInfoDTO); assertNotNull(requestInfoDTO.servletDTO); assertEquals("a", requestInfoDTO.servletDTO.name); - assertEquals( - getServiceId(srA), - requestInfoDTO.servletDTO.serviceId); + assertEquals(getServiceId(srA), requestInfoDTO.servletDTO.serviceId); assertEquals("a", requestAdvisor.request("a")); HttpService httpService = getHttpService(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_9.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_9.java index a89cada4ef3..84344cfd851 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_9.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_4_9.java @@ -44,8 +44,7 @@ public void test_140_4_9() throws Exception { Servlet servlet = new HttpServlet() { @Override - protected void service(HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { invoked.set(true); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_1.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_1.java index 8dc15b95888..49f5e303e1c 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_1.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_1.java @@ -46,7 +46,8 @@ public void test_140_6_1() throws Exception { properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, "/*"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, "/org/eclipse/equinox/http/servlet/tests"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, + "/org/eclipse/equinox/http/servlet/tests"); ServiceRegistration sr = context.registerService(Object.class, new Object(), properties); registrations.add(sr); @@ -54,20 +55,16 @@ public void test_140_6_1() throws Exception { assertNotNull(failedResourceDTO); assertEquals(DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, failedResourceDTO.failureReason); - ResourceDTO resourceDTO = getResourceDTOByServiceId( - DEFAULT, - getServiceId(sr)); + ResourceDTO resourceDTO = getResourceDTOByServiceId(DEFAULT, getServiceId(sr)); assertNull(resourceDTO); assertEquals("b", requestAdvisor.request("index.txt")); properties.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE); sr.setProperties(properties); - resourceDTO = getResourceDTOByServiceId( - DEFAULT, - getServiceId(sr)); + resourceDTO = getResourceDTOByServiceId(DEFAULT, getServiceId(sr)); assertNotNull(resourceDTO); - assertEquals("a", requestAdvisor.request("index.txt")); + assertEquals("a\n", requestAdvisor.request("index.txt")); failedResourceDTO = getFailedResourceDTOByServiceId(getServiceId(sr)); assertNull(failedResourceDTO); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_20to21_commonProperties.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_20to21_commonProperties.java index 25b543d227a..1d2c81d8f89 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_20to21_commonProperties.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_6_20to21_commonProperties.java @@ -38,8 +38,10 @@ public void test_140_6_20to21_commonProperties() throws Exception { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, "/other.txt"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, "/org/eclipse/equinox/http/servlet/tests/index.txt"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(osgi.http.whiteboard.context.name=foo)"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, + "/org/eclipse/equinox/http/servlet/tests/index.txt"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(osgi.http.whiteboard.context.name=foo)"); ServiceRegistration sr = context.registerService(Object.class, new Object(), properties); registrations.add(sr); @@ -47,9 +49,7 @@ public void test_140_6_20to21_commonProperties() throws Exception { assertNotNull(failedResourceDTO); assertEquals(DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING, failedResourceDTO.failureReason); - ResourceDTO resourceDTO = getResourceDTOByServiceId( - DEFAULT, - getServiceId(sr)); + ResourceDTO resourceDTO = getResourceDTOByServiceId(DEFAULT, getServiceId(sr)); assertNull(resourceDTO); assertEquals("404", requestAdvisor.request("other.txt", null).get("responseCode").get(0)); @@ -60,9 +60,7 @@ public void test_140_6_20to21_commonProperties() throws Exception { failedResourceDTO = getFailedResourceDTOByServiceId(getServiceId(sr)); assertNull(failedResourceDTO); - resourceDTO = getResourceDTOByServiceId( - DEFAULT, - getServiceId(sr)); + resourceDTO = getResourceDTOByServiceId(DEFAULT, getServiceId(sr)); assertNull(resourceDTO); assertEquals("404", requestAdvisor.request("other.txt", null).get("responseCode").get(0)); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_7_validation.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_7_validation.java index d6bceafd359..42917b00f3d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_7_validation.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_7_validation.java @@ -42,8 +42,8 @@ public void test_140_7_validation() { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); - ServiceRegistration sr = context.registerService( - ServletContextListener.class, new MockSCL(new AtomicReference<>()), properties); + ServiceRegistration sr = context.registerService(ServletContextListener.class, + new MockSCL(new AtomicReference<>()), properties); registrations.add(sr); ListenerDTO listenerDTO = getListenerDTOByServiceId(DEFAULT, getServiceId(sr)); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_9_ServletContextDTO_custom_listener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_9_ServletContextDTO_custom_listener.java index f8d8d13ecbf..a484d34c5ad 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_9_ServletContextDTO_custom_listener.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_140_9_ServletContextDTO_custom_listener.java @@ -41,7 +41,8 @@ public void test_140_9_ServletContextDTO_custom_listener() { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "a"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/a"); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); ServletContextDTO servletContextDTO = getServletContextDTOByName("a"); assertNotNull(servletContextDTO); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_bindUsingContextSelect.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_bindUsingContextSelect.java index 74379279344..ffd1aaf7ff7 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_bindUsingContextSelect.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_bindUsingContextSelect.java @@ -40,12 +40,14 @@ public void test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_bindUsingContextSelect Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, contextName); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/context1"); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); AtomicReference sc1 = new AtomicReference<>(); properties = new Hashtable<>(); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(osgi.http.whiteboard.context.name=" + contextName + ")"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, + "(osgi.http.whiteboard.context.name=" + contextName + ")"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true"); registrations.add(context.registerService(ServletContextListener.class, new MockSCL(sc1), properties)); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_tieGoesToOldest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_tieGoesToOldest.java index 99494b80046..a3d8ead8d64 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_tieGoesToOldest.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_tieGoesToOldest.java @@ -42,13 +42,15 @@ public void test_table_140_1_HTTP_WHITEBOARD_CONTEXT_NAME_tieGoesToOldest() { properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, DEFAULT); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, contextPath); properties.put(Constants.SERVICE_RANKING, Integer.valueOf(1000)); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, DEFAULT); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/otherContext"); properties.put(Constants.SERVICE_RANKING, Integer.valueOf(1000)); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); AtomicReference sc1 = new AtomicReference<>(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type.java index fd566da8781..0eec4bdf669 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type.java @@ -39,7 +39,8 @@ public void test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type() { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, "context"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, Boolean.FALSE); - registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() {}, properties)); + registrations.add(context.registerService(ServletContextHelper.class, new ServletContextHelper() { + }, properties)); HttpServiceRuntime httpServiceRuntime = getHttpServiceRuntime(); @@ -49,9 +50,7 @@ public void test_table_140_1_HTTP_WHITEBOARD_CONTEXT_PATH_type() { assertNotNull(failedServletContextDTOs); assertEquals(1, failedServletContextDTOs.length); - assertEquals( - DTOConstants.FAILURE_REASON_VALIDATION_FAILED, - failedServletContextDTOs[0].failureReason); + assertEquals(DTOConstants.FAILURE_REASON_VALIDATION_FAILED, failedServletContextDTOs[0].failureReason); } } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED.java index 46ec475f2fa..3c344e05e1d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED.java @@ -49,7 +49,7 @@ public void test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED() throws Ex @SuppressWarnings("serial") class AServlet extends HttpServlet { - final ExecutorService executor = Executors.newCachedThreadPool(); + final ExecutorService executor = Executors.newCachedThreadPool(); @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) { diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate.java index fadc77fcf42..21731b9f9a9 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate.java @@ -40,7 +40,8 @@ public void test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate() Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, "blah"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/a"); - registrations.add(context.registerService(Servlet.class, new HttpServlet() {}, properties)); + registrations.add(context.registerService(Servlet.class, new HttpServlet() { + }, properties)); RequestInfoDTO requestInfoDTO = calculateRequestInfoDTO("/a"); @@ -51,7 +52,8 @@ public void test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate() properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, "true"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/b"); - registrations.add(context.registerService(Servlet.class, new HttpServlet() {}, properties)); + registrations.add(context.registerService(Servlet.class, new HttpServlet() { + }, properties)); requestInfoDTO = calculateRequestInfoDTO("/b"); @@ -62,7 +64,8 @@ public void test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate() properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, "false"); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/c"); - registrations.add(context.registerService(Servlet.class, new HttpServlet() {}, properties)); + registrations.add(context.registerService(Servlet.class, new HttpServlet() { + }, properties)); requestInfoDTO = calculateRequestInfoDTO("/c"); @@ -73,7 +76,8 @@ public void test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate() properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED, 234l); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/d"); - registrations.add(context.registerService(Servlet.class, new HttpServlet() {}, properties)); + registrations.add(context.registerService(Servlet.class, new HttpServlet() { + }, properties)); requestInfoDTO = calculateRequestInfoDTO("/d"); @@ -83,7 +87,8 @@ public void test_table_140_4_HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED_validate() properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/e"); - registrations.add(context.registerService(Servlet.class, new HttpServlet() {}, properties)); + registrations.add(context.registerService(Servlet.class, new HttpServlet() { + }, properties)); requestInfoDTO = calculateRequestInfoDTO("/e"); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_PATTERN.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_PATTERN.java index 9f5d76d5f76..3e074d4c025 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_PATTERN.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_PATTERN.java @@ -43,7 +43,7 @@ public void test_table_140_5_HTTP_WHITEBOARD_FILTER_PATTERN() throws Exception { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "a"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] {"", "/"}); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] { "", "/" }); registrations.add(context.registerService(Servlet.class, new MockServlet().content("a"), properties)); properties = new Hashtable<>(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_REGEX.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_REGEX.java index f91f12df256..e536d83f724 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_REGEX.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_5_HTTP_WHITEBOARD_FILTER_REGEX.java @@ -45,7 +45,7 @@ public void test_table_140_5_HTTP_WHITEBOARD_FILTER_REGEX() throws Exception { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "a"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] {"", "/"}); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, new String[] { "", "/" }); registrations.add(context.registerService(Servlet.class, new MockServlet().content("a"), properties)); properties = new Hashtable<>(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation.java index 9bd6bc4d054..977de3733dc 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation.java @@ -38,7 +38,8 @@ public void test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation() { Dictionary properties = new Hashtable<>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, 34l); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, "/org/eclipse/equinox/http/servlet/tests"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, + "/org/eclipse/equinox/http/servlet/tests"); ServiceRegistration sr = context.registerService(Object.class, new Object(), properties); registrations.add(sr); @@ -55,23 +56,22 @@ public void test_table_140_6_HTTP_WHITEBOARD_RESOURCE_validation() { assertEquals(DTOConstants.FAILURE_REASON_VALIDATION_FAILED, failedResourceDTO.failureReason); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, "/*"); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, new String[] {"/a", "/b"}); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, new String[] { "/a", "/b" }); sr.setProperties(properties); failedResourceDTO = getFailedResourceDTOByServiceId(getServiceId(sr)); assertNotNull(failedResourceDTO); assertEquals(DTOConstants.FAILURE_REASON_VALIDATION_FAILED, failedResourceDTO.failureReason); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, new String[] {"/a", "/b"}); - properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, "/org/eclipse/equinox/http/servlet/tests/index.txt"); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN, new String[] { "/a", "/b" }); + properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX, + "/org/eclipse/equinox/http/servlet/tests/index.txt"); sr.setProperties(properties); failedResourceDTO = getFailedResourceDTOByServiceId(getServiceId(sr)); assertNull(failedResourceDTO); - ResourceDTO resourceDTO = getResourceDTOByServiceId( - DEFAULT, - getServiceId(sr)); + ResourceDTO resourceDTO = getResourceDTOByServiceId(DEFAULT, getServiceId(sr)); assertNotNull(resourceDTO); assertEquals(2, resourceDTO.patterns.length); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java index 533cdd8b128..8ed094cfc22 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java @@ -23,14 +23,14 @@ */ public class BundleAdvisor extends Object { private final BundleContext bundleContext; - + public BundleAdvisor(BundleContext bundleContext) { super(); if (bundleContext == null) throw new IllegalArgumentException("bundleContext must not be null"); //$NON-NLS-1$ this.bundleContext = bundleContext; } - + private Bundle getBundle(String symbolicName) { if (symbolicName == null) throw new IllegalArgumentException("symbolicName must not be null"); //$NON-NLS-1$ @@ -38,18 +38,18 @@ private Bundle getBundle(String symbolicName) { Bundle[] bundles = context.getBundles(); for (Bundle bundle : bundles) { String bsn = bundle.getSymbolicName(); - boolean match = symbolicName.equals(bsn); + boolean match = symbolicName.equals(bsn); if (match) { return bundle; } } throw new IllegalArgumentException("Failed to find bundle: " + symbolicName); //$NON-NLS-1$ } - + private BundleContext getBundleContext() { return bundleContext; } - + public void startBundle(String symbolicName) throws BundleException { Bundle bundle = getBundle(symbolicName); int state = bundle.getState(); @@ -58,7 +58,7 @@ public void startBundle(String symbolicName) throws BundleException { } bundle.start(Bundle.START_TRANSIENT); } - + public void stopBundle(String symbolicName) throws BundleException { Bundle bundle = getBundle(symbolicName); bundle.stop(); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleInstaller.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleInstaller.java index 60604b68e21..47303060507 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleInstaller.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleInstaller.java @@ -36,7 +36,9 @@ public class BundleInstaller { public BundleInstaller(String bundlesRoot, BundleContext context) throws InvalidSyntaxException { this.context = context; rootLocation = bundlesRoot; - converter = new ServiceTracker<>(context, context.createFilter("(&(objectClass=" + URLConverter.class.getName() + ")(protocol=bundleentry))"), null); + converter = new ServiceTracker<>(context, + context.createFilter("(&(objectClass=" + URLConverter.class.getName() + ")(protocol=bundleentry))"), + null); converter.open(); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/index.txt b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/index.txt index 2e65efe2a14..78981922613 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/index.txt +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/index.txt @@ -1 +1 @@ -a \ No newline at end of file +a diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource1.txt b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource1.txt index d16f7afbcda..44d6874ff36 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource1.txt +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource1.txt @@ -1,3 +1,3 @@ a -Do NOT edit this File! \ No newline at end of file +Do NOT edit this File! diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt index 30d74d25844..9daeafb9864 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt @@ -1 +1 @@ -test \ No newline at end of file +test diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/AsyncOutputServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/AsyncOutputServlet.java index 691cac5ce19..1b9d4373c58 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/AsyncOutputServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/AsyncOutputServlet.java @@ -34,10 +34,9 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO resp.flushBuffer(); AsyncContext async = req.startAsync(req, resp); ServletOutputStream out = resp.getOutputStream(); - out.setWriteListener(new AsyncWriter( - async, - Integer.parseInt(req.getParameter("iterations") == null ? "1" : req.getParameter("iterations")), - Boolean.parseBoolean(req.getParameter("bytes")))); + out.setWriteListener(new AsyncWriter(async, + Integer.parseInt(req.getParameter("iterations") == null ? "1" : req.getParameter("iterations")), + Boolean.parseBoolean(req.getParameter("bytes")))); } private class AsyncWriter implements WriteListener { diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseAsyncServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseAsyncServlet.java index 383b5862785..a27972cf540 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseAsyncServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseAsyncServlet.java @@ -29,8 +29,7 @@ public class BaseAsyncServlet extends BaseServlet { private static final long serialVersionUID = 1L; - ScheduledThreadPoolExecutor executor = - (ScheduledThreadPoolExecutor)Executors.newScheduledThreadPool(4); + ScheduledThreadPoolExecutor executor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(4); public BaseAsyncServlet() { super(); @@ -41,8 +40,7 @@ public BaseAsyncServlet(String content) { } @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) { + protected void service(HttpServletRequest request, HttpServletResponse response) { AsyncContext asyncContext = request.startAsync(request, response); @@ -62,14 +60,12 @@ public void run() { writer.print(Thread.currentThread().getName()); writer.print(" - "); writer.print(content); - } - catch (IOException ioe) { + } catch (IOException ioe) { ioe.printStackTrace(); - } - finally { + } finally { asyncContext.complete(); } } } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseChangeSessionIdServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseChangeSessionIdServlet.java index f9ca47edcfa..6f6553d35ba 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseChangeSessionIdServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseChangeSessionIdServlet.java @@ -19,7 +19,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - public class BaseChangeSessionIdServlet extends BaseServlet { private static final long serialVersionUID = 1L; @@ -28,9 +27,7 @@ public BaseChangeSessionIdServlet(String content) { } @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { request.getSession(true); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpContext.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpContext.java index 848f1a83b5d..66a9b1d464d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpContext.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpContext.java @@ -27,16 +27,14 @@ public class BaseHttpContext implements HttpContext { private final String resourceRoot; private final Bundle bundle; - public BaseHttpContext(boolean handleSecurity, String resourceRoot, - Bundle bundle) { + public BaseHttpContext(boolean handleSecurity, String resourceRoot, Bundle bundle) { this.handleSecurity = handleSecurity; this.resourceRoot = resourceRoot; this.bundle = bundle; } @Override - public boolean handleSecurity(HttpServletRequest request, - HttpServletResponse response) { + public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) { return handleSecurity; } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpSessionAttributeListener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpSessionAttributeListener.java index a7b6eed22be..66c1df2cc48 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpSessionAttributeListener.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseHttpSessionAttributeListener.java @@ -22,8 +22,7 @@ /** * @author Raymond Augé */ -public class BaseHttpSessionAttributeListener - implements HttpSessionAttributeListener { +public class BaseHttpSessionAttributeListener implements HttpSessionAttributeListener { public AtomicBoolean added = new AtomicBoolean(false); public AtomicBoolean replaced = new AtomicBoolean(false); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServlet.java index 495a41ef0e4..0680faeee91 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServlet.java @@ -41,9 +41,8 @@ public BaseServlet(String content) { @SuppressWarnings("unused") @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { request.setAttribute(ATTRIBUTE, content); request.setAttribute(ATTRIBUTE, "replaced"); @@ -53,11 +52,9 @@ protected void service( if (servletContext.getAttribute(ATTRIBUTE) == null) { servletContext.setAttribute(ATTRIBUTE, content); - } - else if (servletContext.getAttribute(ATTRIBUTE).equals(content)) { + } else if (servletContext.getAttribute(ATTRIBUTE).equals(content)) { servletContext.setAttribute(ATTRIBUTE, "replaced"); - } - else { + } else { servletContext.removeAttribute(ATTRIBUTE); } @@ -65,11 +62,9 @@ else if (servletContext.getAttribute(ATTRIBUTE).equals(content)) { if (session.getAttribute(ATTRIBUTE) == null) { session.setAttribute(ATTRIBUTE, content); - } - else if (session.getAttribute(ATTRIBUTE).equals(content)) { + } else if (session.getAttribute(ATTRIBUTE).equals(content)) { session.setAttribute(ATTRIBUTE, "replaced"); - } - else { + } else { session.removeAttribute(ATTRIBUTE); } @@ -78,4 +73,4 @@ else if (session.getAttribute(ATTRIBUTE).equals(content)) { protected String content; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextAttributeListener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextAttributeListener.java index f5f44629dd3..c8504f12e17 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextAttributeListener.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextAttributeListener.java @@ -22,8 +22,7 @@ /** * @author Raymond Augé */ -public class BaseServletContextAttributeListener - implements ServletContextAttributeListener { +public class BaseServletContextAttributeListener implements ServletContextAttributeListener { public AtomicBoolean added = new AtomicBoolean(false); public AtomicBoolean replaced = new AtomicBoolean(false); @@ -44,4 +43,4 @@ public void attributeReplaced(ServletContextAttributeEvent arg0) { replaced.set(true); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextListener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextListener.java index fa2e7778c81..0b5f4329a1d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextListener.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletContextListener.java @@ -40,4 +40,4 @@ public void contextInitialized(ServletContextEvent servletContextEvent) { servletContext = servletContextEvent.getServletContext(); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestAttributeListener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestAttributeListener.java index 07fafb08356..ec83708b9ae 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestAttributeListener.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestAttributeListener.java @@ -22,8 +22,7 @@ /** * @author Raymond Augé */ -public class BaseServletRequestAttributeListener - implements ServletRequestAttributeListener { +public class BaseServletRequestAttributeListener implements ServletRequestAttributeListener { public AtomicBoolean added = new AtomicBoolean(false); public AtomicBoolean replaced = new AtomicBoolean(false); @@ -44,4 +43,4 @@ public void attributeReplaced(ServletRequestAttributeEvent arg0) { replaced.set(true); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java index 4d302479a0a..5b736138b86 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java @@ -42,4 +42,4 @@ public void requestInitialized(ServletRequestEvent arg0) { number.incrementAndGet(); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BufferedServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BufferedServlet.java index 472c24caf13..ea0fd4fdfd1 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BufferedServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BufferedServlet.java @@ -27,11 +27,9 @@ public class BufferedServlet extends HttpServlet { static final char[] value = String.format("%01023d", 1).toCharArray(); @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { - response.setContentType( "text/html" ); + response.setContentType("text/html"); response.setBufferSize(value.length); PrintWriter writer = response.getWriter(); @@ -46,4 +44,4 @@ protected void service( writer.print(value); } -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java index a45b51eef94..79631d1d1c6 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/DispatchResultServlet.java @@ -27,9 +27,7 @@ public class DispatchResultServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override - protected void service( - HttpServletRequest request, HttpServletResponse response) - throws IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { StringWriter writer = new StringWriter(); @@ -54,8 +52,7 @@ protected void service( writer.write(String.valueOf(request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI))); writer.write("|"); writer.write(String.valueOf(request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH))); - } - else if (request.getDispatcherType() == DispatcherType.FORWARD) { + } else if (request.getDispatcherType() == DispatcherType.FORWARD) { writer.write(String.valueOf(request.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH))); writer.write("|"); writer.write(String.valueOf(request.getAttribute(RequestDispatcher.FORWARD_PATH_INFO))); @@ -69,8 +66,7 @@ else if (request.getDispatcherType() == DispatcherType.FORWARD) { try { response.getWriter().write(writer.toString()); - } - catch (IllegalStateException ise) { + } catch (IllegalStateException ise) { response.getOutputStream().write(writer.toString().getBytes(StandardCharsets.UTF_8)); } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/EventHandler.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/EventHandler.java index f728a25c427..07cdf4bf17d 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/EventHandler.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/EventHandler.java @@ -62,8 +62,7 @@ public void open(final InputStream inputStream) { // ignore comment lines continue; - } - else if (colon < 0) { + } else if (colon < 0) { // No colon? Entire line must be treated as the key with blank value eventMap.put(current, ""); @@ -86,15 +85,12 @@ else if (colon < 0) { eventMap.put(key, value); } - } - catch (IOException e1) { + } catch (IOException e1) { e1.printStackTrace(); - } - finally { + } finally { try { inputStream.close(); - } - catch (IOException e2) { + } catch (IOException e2) { e2.printStackTrace(); } } @@ -111,4 +107,4 @@ else if (colon < 0) { private Thread thread; -} \ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockFilter.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockFilter.java index 4655fb8dd43..1564fa8a153 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockFilter.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockFilter.java @@ -65,7 +65,7 @@ public MockFilter before(String before) { return this; } - private String after; - private String before; + private String after; + private String before; } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockServlet.java index 86a4c02bb1c..e207516b08c 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/MockServlet.java @@ -25,7 +25,8 @@ public class MockServlet extends HttpServlet { @Override - protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void service(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { if (content != null) { response.getWriter().write(content); } @@ -54,8 +55,7 @@ public MockServlet error(int code, String errorMessage) { } public MockServlet exception(Exception exception) { - if (!(exception instanceof ServletException) && - !(exception instanceof IOException)) { + if (!(exception instanceof ServletException) && !(exception instanceof IOException)) { this.exception = new ServletException(exception); } @@ -64,9 +64,9 @@ public MockServlet exception(Exception exception) { return this; } - private Integer code; - private String content; - private String errorMessage; + private Integer code; + private String content; + private String errorMessage; private Exception exception; } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java index 3d02350feb7..ee238ff6dbe 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/ServletRequestAdvisor.java @@ -69,8 +69,7 @@ public ServletRequestAdvisor(String port, String contextPath, String ksPath, Str public ServletRequestAdvisor(String port, String contextPath, String ksPath, String ksPassword, int timeout) { super(); - if (port == null) - { + if (port == null) { throw new IllegalArgumentException("port must not be null"); //$NON-NLS-1$ } this.port = port; @@ -125,14 +124,14 @@ public String request(String value) throws IOException { log("Requesting " + spec); //$NON-NLS-1$ URL url = new URL(spec); - HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setInstanceFollowRedirects(false); connection.setConnectTimeout(timeout); connection.setReadTimeout(timeout); connection.connect(); - try (InputStream stream = connection.getInputStream()){ + try (InputStream stream = connection.getInputStream()) { return drain(stream); } } @@ -144,7 +143,7 @@ public String requestHttps(String value) throws Exception { SSLContext sslContext = SSLContext.getInstance("SSL"); initializeSSLContext(sslContext, ksPath, ksPassword); - HttpsURLConnection httpsConn = (HttpsURLConnection)url.openConnection(); + HttpsURLConnection httpsConn = (HttpsURLConnection) url.openConnection(); httpsConn.setSSLSocketFactory(sslContext.getSocketFactory()); httpsConn.setRequestMethod("GET"); httpsConn.setDoOutput(false); @@ -153,7 +152,7 @@ public String requestHttps(String value) throws Exception { httpsConn.setReadTimeout(timeout); httpsConn.connect(); - assertEquals("Request to the url " + spec + " was not successful", 200 , httpsConn.getResponseCode()); + assertEquals("Request to the url " + spec + " was not successful", 200, httpsConn.getResponseCode()); try (InputStream stream = httpsConn.getInputStream()) { return drain(stream); } @@ -166,7 +165,7 @@ private void initializeSSLContext(SSLContext sslContext, String ksPath, String k File ksFile = new File(ksPath); KeyStore keyStore = KeyStore.getInstance("JKS"); - try(InputStream ksStream = new FileInputStream(ksFile)){ + try (InputStream ksStream = new FileInputStream(ksFile)) { keyStore.load(ksStream, ksPassword.toCharArray()); kmFactory.init(keyStore, ksPassword.toCharArray()); keyManagers = kmFactory.getKeyManagers(); @@ -187,12 +186,12 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers() { } @Override - public void checkClientTrusted( - java.security.cert.X509Certificate[] certs, String authType) {} + public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } @Override - public void checkServerTrusted( - java.security.cert.X509Certificate[] certs, String authType) {} + public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { + } } }; return trustAllCerts; @@ -202,15 +201,15 @@ public Map> request(String value, Map> String spec = createUrlSpec(value); log("Requesting " + spec); //$NON-NLS-1$ URL url = new URL(spec); - HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setInstanceFollowRedirects(false); connection.setConnectTimeout(timeout); connection.setReadTimeout(timeout); if (headers != null) { - for(Map.Entry> entry : headers.entrySet()) { - for(String entryValue : entry.getValue()) { + for (Map.Entry> entry : headers.entrySet()) { + for (String entryValue : entry.getValue()) { connection.setRequestProperty(entry.getKey(), entryValue); } } @@ -225,15 +224,14 @@ public Map> request(String value, Map> if (responseCode >= 400) { stream = connection.getErrorStream(); - } - else { + } else { stream = connection.getInputStream(); } try { String drainedStream = drain(stream); map.put("responseBody", Arrays.asList(drainedStream)); - } catch (IOException e){ + } catch (IOException e) { map.put("responseBody", Arrays.asList(e.getMessage())); } finally { stream.close(); @@ -241,22 +239,23 @@ public Map> request(String value, Map> return map; } - public Map> eventSource(String value, Map> headers, final EventHandler handler) throws IOException { + public Map> eventSource(String value, Map> headers, + final EventHandler handler) throws IOException { String spec = createUrlSpec(value); log("Requesting " + spec); //$NON-NLS-1$ URL url = new URL(spec); - HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setChunkedStreamingMode(0); connection.setDoOutput(true); - //connection.setRequestProperty("Connection", "Close"); + // connection.setRequestProperty("Connection", "Close"); connection.setInstanceFollowRedirects(false); connection.setConnectTimeout(timeout); connection.setReadTimeout(timeout); if (headers != null) { - for(Map.Entry> entry : headers.entrySet()) { - for(String entryValue : entry.getValue()) { + for (Map.Entry> entry : headers.entrySet()) { + for (String entryValue : entry.getValue()) { connection.setRequestProperty(entry.getKey(), entryValue); } } @@ -271,8 +270,7 @@ public Map> eventSource(String value, Map= 400) { stream = connection.getErrorStream(); - } - else { + } else { stream = connection.getInputStream(); } @@ -284,12 +282,13 @@ public Map> eventSource(String value, Map> upload(String value, Map> headers) throws IOException { return upload(value, headers, null); } - - public Map> upload(String value, Map> headers, Map formFields) throws IOException { + + public Map> upload(String value, Map> headers, + Map formFields) throws IOException { String spec = createUrlSpec(value); log("Requesting " + spec); //$NON-NLS-1$ URL url = new URL(spec); - HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setInstanceFollowRedirects(false); connection.setConnectTimeout(timeout); @@ -298,29 +297,26 @@ public Map> upload(String value, Map> if (headers != null) { if (headers.containsKey("method")) { - String method = (String)headers.remove("method").get(0); + String method = (String) headers.remove("method").get(0); connection.setRequestMethod(method); } - for(Map.Entry> entry : headers.entrySet()) { - for(Object entryValue : entry.getValue()) { + for (Map.Entry> entry : headers.entrySet()) { + for (Object entryValue : entry.getValue()) { if (entryValue instanceof String) { if (entry.getKey().equals("x-www-form-urlencoded")) { - postFormURLEncoded(connection, (String)entryValue); - } - else { + postFormURLEncoded(connection, (String) entryValue); + } else { String property = connection.getRequestProperty(entry.getKey()); if (property == null) { - connection.setRequestProperty(entry.getKey(), (String)entryValue); + connection.setRequestProperty(entry.getKey(), (String) entryValue); } else { connection.setRequestProperty(entry.getKey(), property + "," + entryValue); } } - } - else if (entryValue instanceof URL) { - uploadFileConnection(connection, entry.getKey(), (URL)entryValue, formFields); - } - else { + } else if (entryValue instanceof URL) { + uploadFileConnection(connection, entry.getKey(), (URL) entryValue, formFields); + } else { throw new IllegalArgumentException("only supports strings and files"); } } @@ -336,8 +332,7 @@ else if (entryValue instanceof URL) { if (responseCode >= 400) { stream = connection.getErrorStream(); - } - else { + } else { stream = connection.getInputStream(); } @@ -349,24 +344,24 @@ else if (entryValue instanceof URL) { } } - private void postFormURLEncoded(HttpURLConnection connection, String param) - throws IOException { + private void postFormURLEncoded(HttpURLConnection connection, String param) throws IOException { byte[] bytes = param.getBytes(StandardCharsets.UTF_8); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - //connection.setRequestProperty("Content-Length", Integer.toString(bytes.length)); + // connection.setRequestProperty("Content-Length", + // Integer.toString(bytes.length)); - try(DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) { + try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) { wr.write(bytes); wr.flush(); } } @SuppressWarnings({ "unchecked", "rawtypes" }) - private void uploadFileConnection(HttpURLConnection connection, String param, URL file, Map formFields) - throws IOException { + private void uploadFileConnection(HttpURLConnection connection, String param, URL file, + Map formFields) throws IOException { String fileName = file.getPath(); fileName = fileName.substring(fileName.lastIndexOf("/") + 1); @@ -384,7 +379,7 @@ private void uploadFileConnection(HttpURLConnection connection, String param, UR if (formFields != null) { formFields.entrySet().forEach(entry -> { if (entry.getValue() instanceof Collection) { - ((Collection)entry.getValue()).forEach(value -> { + ((Collection) entry.getValue()).forEach(value -> { writer.append("--" + boundary); writer.append(CRLF); writer.append("Content-Disposition: form-data; name=\"" + entry.getKey() + "\""); @@ -410,7 +405,7 @@ private void uploadFileConnection(HttpURLConnection connection, String param, UR } }); } - + writer.append("--" + boundary); writer.append(CRLF); writer.append("Content-Disposition: form-data; name=\""); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestServletPrototype.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestServletPrototype.java index 86c0e57a828..232fe831afb 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestServletPrototype.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestServletPrototype.java @@ -54,24 +54,26 @@ protected void service(HttpServletRequest request, HttpServletResponse response) try { handleDoGet(request, response, writer); - } - finally { - //writer.close(); + } finally { + // writer.close(); } } class Factory implements PrototypeServiceFactory { final AtomicReference> registration = new AtomicReference<>(); + @Override public Servlet getService(Bundle bundle, ServiceRegistration registration) { - String name = (String) registration.getReference().getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME); + String name = (String) registration.getReference() + .getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME); lastGetName.set(name); return new TestWBServlet(); } @Override public void ungetService(Bundle bundle, ServiceRegistration registration, Servlet service) { - String name = (String) registration.getReference().getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME); + String name = (String) registration.getReference() + .getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME); lastUngetName.set(name); } @@ -96,7 +98,8 @@ public void unregister() { } - protected void handleDoGet(HttpServletRequest request, HttpServletResponse response, PrintWriter writer) throws IOException { + protected void handleDoGet(HttpServletRequest request, HttpServletResponse response, PrintWriter writer) + throws IOException { String pathInfo = request.getPathInfo(); if ("/lastGet".equals(pathInfo)) { writer.print(lastGetName.getAndSet(null)); diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestWBServlet.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestWBServlet.java index a084b705c94..92013098e5f 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestWBServlet.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/TestWBServlet.java @@ -25,7 +25,7 @@ public class TestWBServlet extends HttpServlet { private static final long serialVersionUID = 1L; public static final String STATUS_PARAM = "status"; - + private final AtomicReference status = new AtomicReference<>("none"); private final AtomicBoolean destroyed = new AtomicBoolean(false);