use of com.github.bordertech.wcomponents.UIContextImpl 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.UIContextImpl in project wcomponents by BorderTech.
the class TargetableInterceptor_Test method setUp.
@Before
public void setUp() {
UIContext uic = new UIContextImpl();
WPanel root = new WPanel();
originalUI = new WLabel();
targetUI = new TargetableWLabel();
root.add(originalUI);
root.add(targetUI);
uic.setUI(root);
setActiveContext(uic);
interceptor = new TargetableInterceptor();
interceptor.setBackingComponent(originalUI);
}
use of com.github.bordertech.wcomponents.UIContextImpl 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.UIContextImpl in project wcomponents by BorderTech.
the class ProfileContainer_Test method testAfterPaint.
/**
* Test afterPaint.
*/
@Test
public void testAfterPaint() {
ProfileContainer app = new ProfileContainer();
app.setLocked(true);
UIContext uic = new UIContextImpl();
uic.setUI(app);
setActiveContext(uic);
WButton button = new WButton("PUSH");
app.add(button);
WLabel label = new WLabel("HERE");
app.add(label);
StringWriter outStr = new StringWriter();
PrintWriter writer = new PrintWriter(outStr);
RenderContext renderContext = new WebXmlRenderContext(writer);
app.afterPaint(renderContext);
// expecting 1 root class, 3 components, class names as shown, profiler
// class
String profileLine0 = PROFILER_UIC_HEADER;
String profileLine1 = PROFILER_LINE1.replaceAll("<<NUM_ROOTS>>", "1");
String profileLine2 = PROFILER_LINE2.replaceAll("<<NUM_COMPONENTS>>", "4");
String profileLine31 = PROFILER_LINE3.replaceAll("<<CLASS_NAME>>", "com.github.bordertech.wcomponents.WButton");
String profileLine32 = PROFILER_LINE3.replaceAll("<<CLASS_NAME>>", "com.github.bordertech.wcomponents.monitor.ProfileContainer");
String profileLine33 = PROFILER_LINE3.replaceAll("<<CLASS_NAME>>", "com.github.bordertech.wcomponents.WLabel");
String profileLine4 = PROFILER_PROFILE_HEADER.replaceAll("<<CLASS_NAME>>", "com.github.bordertech.wcomponents.monitor.ProfileContainer");
String[] expectedResults = { profileLine0, profileLine1, profileLine2, profileLine31, profileLine32, profileLine33, profileLine4 };
String result = outStr.toString();
for (int i = 0; i < expectedResults.length; i++) {
Assert.assertTrue("result should contain substring " + i + " ", result.indexOf(expectedResults[i]) != -1);
}
}
use of com.github.bordertech.wcomponents.UIContextImpl in project wcomponents by BorderTech.
the class UicStatsAsHtml_Test method testWriter.
/**
* Test writer.
*/
@Test
public void testWriter() {
// Set up a mock UI to test
WApplication app = new WApplication();
app.setLocked(true);
UIContext uic = new UIContextImpl();
uic.setUI(app);
setActiveContext(uic);
WButton button = new WButton("PUSH");
app.add(button);
WLabel label = new WLabel("HERE");
app.add(label);
// Run the UIStats extract
UicStats stats = new UicStats(uic);
stats.analyseWC(app);
StringWriter outStr = new StringWriter();
PrintWriter writer = new PrintWriter(outStr);
UicStatsAsHtml.write(writer, stats);
// expecting 1 root class, 3 components, class names as shown
String uicStatsHtml1 = UICSTATS_HTML1.replaceAll("<<NUM_ROOTS>>", "1");
String uicStatsHtml2 = UICSTATS_HTML2.replaceAll("<<NUM_COMPONENTS>>", "4");
String uicStatsHtml31 = UICSTATS_HTML3.replaceAll("<<CLASS_NAME>>", "com.github.bordertech.wcomponents.WApplication");
String uicStatsHtml32 = UICSTATS_HTML3.replaceAll("<<CLASS_NAME>>", "com.github.bordertech.wcomponents.WButton");
String uicStatsHtml33 = UICSTATS_HTML3.replaceAll("<<CLASS_NAME>>", "com.github.bordertech.wcomponents.WLabel");
String[] expectedResults = { uicStatsHtml1, uicStatsHtml2, uicStatsHtml31, uicStatsHtml32, uicStatsHtml33 };
String result = outStr.toString();
for (int i = 0; i < expectedResults.length; i++) {
Assert.assertTrue("result should contain substring " + i + " ", result.indexOf(expectedResults[i]) != -1);
}
}
Aggregations