/** * Retrieves the default LayoutManager for the given component. This method must no longer be used, as it will only * ever return a web-xml renderer. * * @param component the component. * @return the LayoutManager for the given component. * * @deprecated use {@link #getRenderer(WComponent, RenderContext)}. */ @Deprecated public static Renderer getDefaultRenderer(final WComponent component) { LOG.warn("The getDefaultRenderer() method is deprecated. Do not obtain renderers directly."); return getRenderer(component, new WebXmlRenderContext(new PrintWriter(new NullWriter()))); }
/** * Retrieves the webxml renderer for the given component. * * @param component the component to retrieve the renderer for. * * @return the webxml renderer for the component */ public Renderer getWebXmlRenderer(final WComponent component) { return UIManager.getRenderer(component, new WebXmlRenderContext(new PrintWriter( new NullWriter()))); } }
PrintWriter printWriter = new PrintWriter(new NullWriter()); RenderContext renderContext = new WebXmlRenderContext(printWriter); WComponent component = null;
@Test public void testNotVisibleAfterPaint() { WPopup popup = new WPopup(); // Should default to not visible Assert.assertFalse("Popup should not be visible by default", popup.isVisible()); // Make visible popup.setLocked(true); setActiveContext(createUIContext()); popup.setVisible(true); // Check not visible after paint popup.paint(new WebXmlRenderContext(new PrintWriter(new NullWriter()))); Assert.assertFalse("Popup should not be visible after paint", popup.isVisible()); }
@Test public void testRenderingScaling() throws Exception { final RenderContext renderContext = new WebXmlRenderContext( new PrintWriter(new NullWriter()));
@Test public void testRenderingScalingWithInterceptorChain() throws Exception { final RenderContext renderContext = new WebXmlRenderContext( new PrintWriter(new NullWriter()));
/** * Invokes WComponent request processing, so that this test case can more closely match a production scenario. * * @param comp the component to invoke request processing on. * @param uic the user context to use. */ private void sendRequest(final WComponent comp, final UIContext uic) { PrintWriter writer = new PrintWriter(new NullWriter()); uic.setEnvironment(new WServlet.WServletEnvironment("", "http://localhost", "")); uic.setUI(comp); InterceptorComponent root = ServletUtil.createInterceptorChain(new MockHttpServletRequest()); root.attachUI(comp); Response response = new MockResponse(); root.attachResponse(response); setActiveContext(uic); MockRequest request = new MockRequest(); try { root.serviceRequest(request); root.preparePaint(request); root.paint(new WebXmlRenderContext(writer)); } finally { resetContext(); } }
ui.serviceRequest(new ServletRequest(new MockHttpServletRequest(session1))); ui.preparePaint(new ServletRequest(new MockHttpServletRequest(session1))); ui.paint(new WebXmlRenderContext(new PrintWriter(new NullWriter()))); ui.serviceRequest(new ServletRequest(new MockHttpServletRequest(session2))); ui.preparePaint(new ServletRequest(new MockHttpServletRequest(session2))); ui.paint(new WebXmlRenderContext(new PrintWriter(new NullWriter())));
/** * Invokes WComponent request processing, so that this test case can more closely match a production scenario. * * @param comp the component to invoke request processing on. * @param uic the user context to use. */ private void sendRequest(final WComponent comp, final UIContext uic) { PrintWriter writer = new PrintWriter(new NullWriter()); uic.setEnvironment(new WServlet.WServletEnvironment("", "http://localhost", "")); uic.setUI(comp); InterceptorComponent root = ServletUtil.createInterceptorChain(new MockHttpServletRequest()); root.attachUI(comp); Response response = new MockResponse(); root.attachResponse(response); setActiveContext(uic); MockRequest request = new MockRequest(); try { root.serviceRequest(request); root.preparePaint(request); root.paint(new WebXmlRenderContext(writer)); } finally { resetContext(); } }
getStep()); interceptor.paint(new WebXmlRenderContext(new PrintWriter(new NullWriter()))); Assert.assertEquals("Servlet step should have changed after paint", initialServletStep + 3, servletEnvironment.getStep()); servletEnvironment.getStep()); interceptor.paint(new WebXmlRenderContext(new PrintWriter(new NullWriter()))); Assert.assertEquals("Window step should have changed after paint", initialWindowStep + 3, window.getStep());