ProxyController { @RequestMapping public void staticProxy(HttpServletRequest request, HttpServletResponse response) throws IOException, SystemException, PortalException { String requestURI = request.getRequestURI(); String portletId = getPortletId(requestURI); javax.portlet.PortletPreferences prefs = getPortletPreferencesByPortletId(portletId); String proxyContextPath = request.getContextPath() + "/p/" + portletId; Cache cache = cacheManager.getCache("default"); Cache.ValueWrapper valueWrapper = cache.get(requestURI); if(valueWrapper != null) { _log.info("Found object for '" + requestURI + "' from cache."); response.setContentType(getContentTypeByExtension(requestURI)); response.getWriter().print(valueWrapper.get()); response.flushBuffer(); return; } com.hannikkala.poc.delegate.controller.ProxyController.doProxyRequest(request, response, prefs.getValue("root", ""), proxyContextPath); }  @RequestMapping void staticProxy(HttpServletRequest request, HttpServletResponse response); static String getPortletId(String requestURI);  }
@Test public void testStaticProxy() throws Exception { mockServer.when(request("/path/to/angular.png")) .respond(response(TestUtil.getFileContents("website/angular.png")) .withHeader(new Header(HttpHeaders.Names.CONTENT_TYPE, "image/png"))); MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/js-portlet/p/portletId/path/to/angular.png"); request.setContextPath("/js-portlet"); proxyController.staticProxy(request, response); Assert.assertEquals("image/png", response.getHeader(HttpHeaders.Names.CONTENT_TYPE)); }