Search in sources :

Example 36 with MockHttpServletRequest

use of com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest in project wcomponents by BorderTech.

the class PlainLauncher_Test method testGetUINonWApplication.

@Test
public void testGetUINonWApplication() {
    Config.getInstance().setProperty(ConfigurationProperties.LDE_PLAINLAUNCHER_COMPONENT_TO_LAUNCH, MyTestComponent.class.getName());
    PlainLauncher plain = new PlainLauncher();
    WComponent ui1 = plain.getUI(new MockHttpServletRequest());
    Assert.assertTrue("Root UI should be a WApplication", ui1 instanceof WApplication);
    ui1 = ((WApplication) ui1).getChildAt(0);
    Assert.assertTrue("UI should be an instance of MyTestComponent", ui1 instanceof MyTestComponent);
    // Call getUI again, the same instance should be returned
    WComponent ui2 = ((WApplication) plain.getUI(new MockHttpServletRequest())).getChildAt(0);
    Assert.assertSame("Should have returned the same UI instance", ui1, ui2);
}
Also used : AbstractWComponent(com.github.bordertech.wcomponents.AbstractWComponent) WComponent(com.github.bordertech.wcomponents.WComponent) WApplication(com.github.bordertech.wcomponents.WApplication) MockHttpServletRequest(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest) Test(org.junit.Test)

Aggregations

MockHttpServletRequest (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest)36 Test (org.junit.Test)25 MockHttpServletResponse (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletResponse)13 MockHttpSession (com.github.bordertech.wcomponents.util.mock.servlet.MockHttpSession)13 MockServletConfig (com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig)9 WText (com.github.bordertech.wcomponents.WText)5 PrintWriter (java.io.PrintWriter)5 UIContext (com.github.bordertech.wcomponents.UIContext)4 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)4 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)4 ServletRequest (com.github.bordertech.wcomponents.servlet.ServletRequest)3 NullWriter (com.github.bordertech.wcomponents.util.NullWriter)3 AbstractWComponent (com.github.bordertech.wcomponents.AbstractWComponent)2 WComponent (com.github.bordertech.wcomponents.WComponent)2 InterceptorComponent (com.github.bordertech.wcomponents.container.InterceptorComponent)2 WServlet (com.github.bordertech.wcomponents.servlet.WServlet)2 WServletHelper (com.github.bordertech.wcomponents.servlet.WServlet.WServletHelper)2 MockRequest (com.github.bordertech.wcomponents.util.mock.MockRequest)2 StringWriter (java.io.StringWriter)2 Locale (java.util.Locale)2