use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class SessionTokenInterceptor_Test method setUp.
@Before
public void setUp() {
component = new MyBackingComponent();
interceptor = new SessionTokenInterceptor();
interceptor.setBackingComponent(component);
uic = new UIContextImpl();
uic.setUI(component);
uic.setEnvironment(new MockWEnvironment());
setActiveContext(uic);
request = new MockRequest();
}
use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class WrongStepServerInterceptor_Test method setUp.
@Before
public void setUp() {
component = new MyBackingComponent();
interceptor = new WrongStepServerInterceptor();
interceptor.setBackingComponent(component);
uic = new UIContextImpl();
uic.setUI(component);
uic.setEnvironment(new MockWEnvironment());
setActiveContext(uic);
request = new MockRequest();
// Default to GET method
request.setMethod("GET");
originalConfig = Config.getInstance();
}
use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class WApplicationRenderer_Test method testRenderedFormatWithHiddenFields.
@Test
public void testRenderedFormatWithHiddenFields() throws XpathException, IOException, SAXException {
MockWEnvironment environment = new MockWEnvironment();
environment.setPostPath("WApplicationRendererTest.postPath");
WApplication application = new WApplication();
UIContext uic = createUIContext();
uic.setEnvironment(environment);
uic.setUI(application);
setActiveContext(uic);
WLabel label = new WLabel("dummy");
application.add(label);
Map<String, String> hiddenParameters = new HashMap<>();
hiddenParameters.put("keyA", "valueA");
hiddenParameters.put("keyB", "valueB");
environment.setHiddenParameters(hiddenParameters);
assertSchemaMatch(application);
assertXpathEvaluatesTo(label.getText(), "normalize-space(//ui:application/ui:label)", application);
assertXpathEvaluatesTo("valueA", "//ui:application/ui:param[@name='keyA']/@value", application);
assertXpathEvaluatesTo("valueB", "//ui:application/ui:param[@name='keyB']/@value", application);
}
use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class WApplicationRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WApplication application = new WApplication();
MockWEnvironment environment = new MockWEnvironment();
UIContext uic = createUIContext();
uic.setEnvironment(environment);
setActiveContext(uic);
// Test with no unsavedChanges
assertSchemaMatch(application);
assertXpathEvaluatesTo(WComponent.DEFAULT_APPLICATION_ID, "//ui:application/@id", application);
assertXpathEvaluatesTo("", "//ui:application/@unsavedChanges", application);
// Test with unsavedChanges
application.setUnsavedChanges(true);
assertSchemaMatch(application);
assertXpathEvaluatesTo(WComponent.DEFAULT_APPLICATION_ID, "//ui:application/@id", application);
assertXpathEvaluatesTo("true", "//ui:application/@unsavedChanges", application);
}
use of com.github.bordertech.wcomponents.MockWEnvironment in project wcomponents by BorderTech.
the class WApplicationRenderer_Test method testDoPaintWithChildren.
@Test
public void testDoPaintWithChildren() throws IOException, SAXException, XpathException {
WApplication application = new WApplication();
WText text = new WText("test text");
WButton button = new WButton("button");
application.add(text);
application.add(button);
MockWEnvironment environment = new MockWEnvironment();
UIContext uic = createUIContext();
uic.setEnvironment(environment);
setActiveContext(uic);
application.setUnsavedChanges(true);
// Check Schema
assertSchemaMatch(application);
assertXpathEvaluatesTo(WComponent.DEFAULT_APPLICATION_ID, "//ui:application/@id", application);
assertXpathEvaluatesTo("true", "//ui:application/@unsavedChanges", application);
// Check Children
assertXpathEvaluatesTo("test text", "normalize-space(//ui:application/text()[1])", application);
assertXpathEvaluatesTo("1", "count(//ui:application/html:button)", application);
}
Aggregations