Search in sources :

Example 96 with WComponent

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

the class InterceptorComponent_Test method testGetName.

@Test
public void testGetName() {
    WComponent backing = new WLabel();
    setActiveContext(createUIContext());
    InterceptorComponent interceptor = new InterceptorComponent(backing);
    Assert.assertEquals("Incorrect name returned", backing.getName(), interceptor.getName());
    interceptor = new InterceptorComponent(interceptor);
    Assert.assertEquals("Incorrect name returned for nested interceptor", backing.getName(), interceptor.getName());
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 97 with WComponent

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

the class InterceptorComponent_Test method testGetUI.

@Test
public void testGetUI() {
    WComponent backing = new WLabel();
    InterceptorComponent interceptor = new InterceptorComponent(backing);
    Assert.assertSame("Incorrect backing component returned", backing, interceptor.getUI());
    // Test nested interceptors
    interceptor = new InterceptorComponent(interceptor);
    Assert.assertSame("Incorrect backing component returned", backing, interceptor.getUI());
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 98 with WComponent

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

the class UicStats_Test method testGetWCsAnalysedForSpecificApp.

/**
 * Test getWCsAnalysed - when one has been analysed.
 */
@Test
public void testGetWCsAnalysedForSpecificApp() {
    stats.analyseWC(app);
    int expectedLoopCount = 1;
    int loopCount = 0;
    for (Iterator<WComponent> resultWcs = stats.getWCsAnalysed(); resultWcs.hasNext(); loopCount++) {
        WComponent resultComponent = resultWcs.next();
        Assert.assertEquals("the analysed component should be app", app, resultComponent);
    }
    Assert.assertEquals("there should be only one analysed components", expectedLoopCount, loopCount);
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) Test(org.junit.Test)

Example 99 with WComponent

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

the class UicStats_Test method testGetWCsAnalysedForAllRoots.

/**
 * Test getWCsAnalysed - when all rootWcs have been analysed.
 */
@Test
public void testGetWCsAnalysedForAllRoots() {
    stats.analyseAllRootWCs();
    int expectedLoopCount = 1;
    int loopCount = 0;
    for (Iterator<WComponent> resultWcs = stats.getWCsAnalysed(); resultWcs.hasNext(); loopCount++) {
        WComponent resultComponent = resultWcs.next();
        Assert.assertEquals("the analysed component should be app", app, resultComponent);
    }
    Assert.assertEquals("there should be only one analysed components", expectedLoopCount, loopCount);
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) Test(org.junit.Test)

Example 100 with WComponent

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

the class UIRegistryAmicableImpl_Test method testRegisterFail.

/**
 * Test register - exception on register with key already in use.
 */
@Test
public void testRegisterFail() {
    final String key = "test123";
    WComponent component = new DefaultWComponent();
    UIRegistryAmicableImpl reg = new UIRegistryAmicableImpl();
    reg.register(key, component);
    try {
        reg.register(key, component);
        Assert.fail("attempted registration with key already used should have thrown an exception");
    } catch (SystemException e) {
        String expectedMessage = "Cannot re-register a component. Key = " + key;
        Assert.assertEquals("exceptions hould have contained message expected", expectedMessage, e.getMessage());
    }
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) SystemException(com.github.bordertech.wcomponents.util.SystemException) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Aggregations

WComponent (com.github.bordertech.wcomponents.WComponent)107 Test (org.junit.Test)35 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)30 UIContext (com.github.bordertech.wcomponents.UIContext)20 SystemException (com.github.bordertech.wcomponents.util.SystemException)16 DefaultWComponent (com.github.bordertech.wcomponents.DefaultWComponent)14 ComponentWithContext (com.github.bordertech.wcomponents.ComponentWithContext)8 WApplication (com.github.bordertech.wcomponents.WApplication)8 WLabel (com.github.bordertech.wcomponents.WLabel)8 AbstractWComponent (com.github.bordertech.wcomponents.AbstractWComponent)7 IOException (java.io.IOException)6 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)5 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)5 PrintWriter (java.io.PrintWriter)5 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 Size (com.github.bordertech.wcomponents.Size)4 WRepeater (com.github.bordertech.wcomponents.WRepeater)4 WText (com.github.bordertech.wcomponents.WText)4 WTextField (com.github.bordertech.wcomponents.WTextField)4