Search in sources :

Example 1 with WTimeoutWarning

use of com.github.bordertech.wcomponents.WTimeoutWarning in project wcomponents by BorderTech.

the class WTimeoutWarningRenderer method doRender.

/**
 * Paints the given WTimeoutWarning if the component's timeout period is greater than 0.
 *
 * @param component the WTimeoutWarning to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WTimeoutWarning warning = (WTimeoutWarning) component;
    XmlStringBuilder xml = renderContext.getWriter();
    final int timoutPeriod = warning.getTimeoutPeriod();
    if (timoutPeriod > 0) {
        xml.appendTagOpen("ui:session");
        xml.appendAttribute("timeout", String.valueOf(timoutPeriod));
        int warningPeriod = warning.getWarningPeriod();
        xml.appendOptionalAttribute("warn", warningPeriod > 0, warningPeriod);
        xml.appendEnd();
    }
}
Also used : WTimeoutWarning(com.github.bordertech.wcomponents.WTimeoutWarning) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 2 with WTimeoutWarning

use of com.github.bordertech.wcomponents.WTimeoutWarning in project wcomponents by BorderTech.

the class WTimeoutWarningRenderer_Test method testDoPaintWithBoth.

@Test
public void testDoPaintWithBoth() throws IOException, SAXException, XpathException {
    WTimeoutWarning warning = new WTimeoutWarning(3000, 300);
    assertXpathEvaluatesTo("3000", "//ui:session/@timeout", warning);
    assertXpathEvaluatesTo("300", "//ui:session/@warn", warning);
}
Also used : WTimeoutWarning(com.github.bordertech.wcomponents.WTimeoutWarning) Test(org.junit.Test)

Example 3 with WTimeoutWarning

use of com.github.bordertech.wcomponents.WTimeoutWarning in project wcomponents by BorderTech.

the class WTimeoutWarningRenderer_Test method testDoPaintWithZeroWarning.

/**
 * If warningPeriod is exactly ZERO the warn attribute is not output and the warning time is determined entirely in
 * the client layer.
 *
 * @throws IOException an exception
 * @throws SAXException an exception
 * @throws XpathException an exception
 */
@Test
public void testDoPaintWithZeroWarning() throws IOException, SAXException, XpathException {
    WTimeoutWarning warning = new WTimeoutWarning(3000, 0);
    assertXpathExists("//ui:session", warning);
    assertXpathNotExists("//ui:session/@warn", warning);
}
Also used : WTimeoutWarning(com.github.bordertech.wcomponents.WTimeoutWarning) Test(org.junit.Test)

Example 4 with WTimeoutWarning

use of com.github.bordertech.wcomponents.WTimeoutWarning in project wcomponents by BorderTech.

the class WTimeoutWarningRenderer_Test method testDoPaintWithMinusOne.

/**
 * WTimeoutWarning does not participate in the Request phase: it is a one-way instruction to the client. If the
 * timeout is set to -1 then the timeout warning is not rendered. This complies with the definition of a http
 * session timeout in which a value of -1 means that the session does not time out.
 *
 * @throws IOException an exception
 * @throws SAXException an exception
 * @throws XpathException an exception
 */
@Test
public void testDoPaintWithMinusOne() throws IOException, SAXException, XpathException {
    WTimeoutWarning warning = new WTimeoutWarning(3000, 300);
    warning.setTimeoutPeriod(-1);
    assertXpathNotExists("//ui:session", warning);
}
Also used : WTimeoutWarning(com.github.bordertech.wcomponents.WTimeoutWarning) Test(org.junit.Test)

Example 5 with WTimeoutWarning

use of com.github.bordertech.wcomponents.WTimeoutWarning in project wcomponents by BorderTech.

the class WTimeoutWarningRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WTimeoutWarning component = new WTimeoutWarning();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WTimeoutWarningRenderer);
}
Also used : WTimeoutWarning(com.github.bordertech.wcomponents.WTimeoutWarning) Test(org.junit.Test)

Aggregations

WTimeoutWarning (com.github.bordertech.wcomponents.WTimeoutWarning)6 Test (org.junit.Test)5 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1