use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class WApplicationRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
MockWEnvironment environment = new MockWEnvironment();
environment.setPostPath("WApplicationRendererTest.postPath");
WApplication application = new WApplication();
UIContext uic = createUIContext();
uic.setEnvironment(environment);
uic.setUI(application);
setActiveContext(uic);
application.setTitle(getMaliciousAttribute("ui:application"));
assertSafeContent(application);
uic.getEnvironment().getHiddenParameters().put(getMaliciousAttribute("ui:param"), "dummy");
uic.getEnvironment().getHiddenParameters().put("dummy", getMaliciousAttribute("ui:param"));
assertSafeContent(application);
}
use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class WApplicationRenderer_Test method testBasicRenderedFormat.
@Test
public void testBasicRenderedFormat() throws XpathException, IOException, SAXException {
// Basic component (no optional fields)
MockWEnvironment environment = new MockWEnvironment();
WApplication application = new WApplication();
environment.setPostPath("WApplicationRendererTest.postPath");
UIContext uic = createUIContext();
uic.setEnvironment(environment);
uic.setUI(application);
setActiveContext(uic);
assertSchemaMatch(application);
assertXpathEvaluatesTo(environment.getPostPath(), "//ui:application/@applicationUrl", application);
assertXpathEvaluatesTo(environment.getWServletPath(), "//ui:application/@ajaxUrl", application);
assertXpathNotExists("//ui:application/@defaultFocusId", application);
}
use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class WApplicationRenderer_Test method testRenderedFormatWithFocussedComponent.
@Test
public void testRenderedFormatWithFocussedComponent() throws XpathException, IOException, SAXException {
MockWEnvironment environment = new MockWEnvironment();
WApplication application = new WApplication();
environment.setPostPath("WApplicationRendererTest.postPath");
WTextField focussedComponent = new WTextField();
application.add(focussedComponent);
UIContext uic = createUIContext();
uic.setEnvironment(environment);
uic.setUI(application);
uic.setFocusRequired(true);
uic.setFocussed(focussedComponent);
setActiveContext(uic);
assertSchemaMatch(application);
assertXpathEvaluatesTo(environment.getPostPath(), "//ui:application/@applicationUrl", application);
assertXpathEvaluatesTo(WComponent.DEFAULT_APPLICATION_ID, "//ui:application/@id", application);
assertXpathEvaluatesTo(environment.getWServletPath(), "//ui:application/@ajaxUrl", application);
assertXpathEvaluatesTo(focussedComponent.getId(), "//ui:application/@defaultFocusId", application);
uic.setFocusRequired(false);
assertXpathNotExists("//ui:application/@defaultFocusId", application);
}
Aggregations