use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WTextRenderer_Test method testEncodeText.
@Test
public void testEncodeText() throws IOException, SAXException, XpathException {
String value = "T1<b>T2</b>T3";
String encoded = WebUtilities.encode(value);
WText text = new WText();
text.setText(value);
// Encoded (default)
String xml = toXHtml(text);
Assert.assertTrue("XML should have encoded text", xml.contains(encoded));
// Not encoded
text.setEncodeText(false);
xml = toXHtml(text);
Assert.assertTrue("XML should have not encoded text", xml.contains(value));
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WTextRenderer_Test method testDoPaintWhenEmpty.
@Test
public void testDoPaintWhenEmpty() throws IOException, SAXException, XpathException {
WText text = new WText();
String xml = toXHtml(text);
Assert.assertEquals("Text output should be empty by default", "", xml);
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WTextRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WText text = new WText();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(text) instanceof WTextRenderer);
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WServlet_Test method testSubSessionsEnabledNoSSID.
@Test
public void testSubSessionsEnabledNoSSID() throws ServletException, IOException {
Config.getInstance().setProperty(ConfigurationProperties.SERVLET_ENABLE_SUBSESSIONS, "true");
MyWServlet servlet = new MyWServlet(new WText("test"));
servlet.init(new MockServletConfig());
MockHttpSession session = new MockHttpSession();
servlet.service(new MockHttpServletRequest(session), new MockHttpServletResponse());
Assert.assertEquals("Incorrect invocation count", 1, servlet.lastInvocationCount);
// No SSID should trigger a new subsession
servlet.service(new MockHttpServletRequest(session), new MockHttpServletResponse());
Assert.assertEquals("Incorrect invocation count", 1, servlet.lastInvocationCount);
}
use of com.github.bordertech.wcomponents.WText in project wcomponents by BorderTech.
the class WServlet_Test method testHttpMethodTypes.
@Test
public void testHttpMethodTypes() throws ServletException, IOException {
MyWServlet servlet = new MyWServlet(new WText("test"));
servlet.init(new MockServletConfig());
MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI("http://localhost/foo");
MockHttpServletResponse response = new MockHttpServletResponse();
request.setMethod("GET");
servlet.service(request, response);
Assert.assertEquals("Incorrect status code", 200, response.getStatus());
Assert.assertTrue("Should have written content", response.getOutput().length > 0);
response = new MockHttpServletResponse();
request.setMethod("POST");
servlet.service(request, response);
Assert.assertEquals("Incorrect status code", 200, response.getStatus());
Assert.assertTrue("Should have written content", response.getOutput().length > 0);
response = new MockHttpServletResponse();
request.setMethod("HEAD");
servlet.service(request, response);
Assert.assertEquals("Incorrect status code", 200, response.getStatus());
Assert.assertNull("Should not have written any content for HEAD request", response.getOutput());
response = new MockHttpServletResponse();
request.setMethod("DELETE");
servlet.service(request, response);
Assert.assertEquals("Incorrect status code", 501, response.getStatus());
Assert.assertNull("Should not have written any content for HEAD request", response.getOutput());
}
Aggregations