use of com.github.bordertech.wcomponents.WApplication in project wcomponents by BorderTech.
the class WApplicationRenderer_Test method testRendererTracking.
@Test
public void testRendererTracking() throws IOException, SAXException, XpathException {
// No tracking
WApplication application = new WApplication();
assertSchemaMatch(application);
assertXpathNotExists("//ui:application/ui:analytic", application);
// Want to test with "tracking details set"
Configuration originalConfig = Config.getInstance();
Configuration config = Config.copyConfiguration(originalConfig);
config.setProperty(ConfigurationProperties.TRACKING_CLIENT_ID, "CID");
config.setProperty(ConfigurationProperties.TRACKING_APPLICATION_NAME, "APPL");
config.setProperty(ConfigurationProperties.TRACKING_COOKIE_DOMAIN, "CD");
config.setProperty(ConfigurationProperties.TRACKING_DATA_COLLECTION_DOMAIN, "DCD");
Config.setConfiguration(config);
try {
assertSchemaMatch(application);
assertXpathEvaluatesTo("CID", "//ui:application/ui:analytic/@clientId", application);
assertXpathEvaluatesTo("APPL", "//ui:application/ui:analytic/@name", application);
assertXpathEvaluatesTo("CD", "//ui:application/ui:analytic/@cd", application);
assertXpathEvaluatesTo("DCD", "//ui:application/ui:analytic/@dcd", application);
} finally {
// Remove overrides
Config.setConfiguration(originalConfig);
}
}
use of com.github.bordertech.wcomponents.WApplication 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.WApplication 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);
}
use of com.github.bordertech.wcomponents.WApplication in project wcomponents by BorderTech.
the class PlainLauncher method getUI.
/**
* This method has been overridden to load a WComponent from parameters.
*
* @param httpServletRequest the servlet request being handled.
* @return the top-level WComponent for this servlet.
*/
@Override
public synchronized WComponent getUI(final Object httpServletRequest) {
String configuredUIClassName = getComponentToLaunchClassName();
if (sharedUI == null || !Util.equals(configuredUIClassName, uiClassName)) {
uiClassName = configuredUIClassName;
WComponent ui = createUI();
if (ui instanceof WApplication) {
sharedUI = (WApplication) ui;
} else {
LOG.warn("Top-level component should be a WApplication." + " Creating WApplication wrapper...");
sharedUI = new WApplication();
ui.setLocked(false);
sharedUI.add(ui);
sharedUI.setLocked(true);
}
if (ConfigurationProperties.getLdeServerShowMemoryProfile()) {
ProfileContainer profiler = new ProfileContainer();
sharedUI.setLocked(false);
sharedUI.add(profiler);
sharedUI.setLocked(true);
}
}
return sharedUI;
}
use of com.github.bordertech.wcomponents.WApplication 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);
}
Aggregations