Search in sources :

Example 16 with WComponent

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

the class UicStats_Test method testGetUI.

/**
 * Test getUI.
 */
@Test
public void testGetUI() {
    WComponent resultComponent = stats.getUI();
    Assert.assertEquals("should return component from constructor", app, resultComponent);
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) Test(org.junit.Test)

Example 17 with WComponent

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

the class UicStats_Test method testGetWCTreeStats.

/**
 * Test getWCTreeStats.
 */
@Test
public void testGetWCTreeStats() {
    stats.analyseWC(app);
    Map<WComponent, Stat> resultStats = stats.getWCTreeStats(app);
    // label
    for (Map.Entry<WComponent, Stat> entry : resultStats.entrySet()) {
        WComponent comp = entry.getKey();
        Stat stat = entry.getValue();
        if (comp instanceof WLabel) {
            Assert.assertEquals("this should be the label created", label, comp);
            Assert.assertEquals("stat should have correct label name", label.getId(), stat.getName());
        } else if (comp instanceof WButton) {
            Assert.assertEquals("this should be the button in the app", button, comp);
            Assert.assertEquals("stat should have correct button name", button.getId(), stat.getName());
        } else if (comp instanceof WApplication) {
            Assert.assertEquals("this should be the app", app, comp);
            Assert.assertEquals("stat should have correct app name", app.getId(), stat.getName());
        }
    }
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) Stat(com.github.bordertech.wcomponents.monitor.UicStats.Stat) WApplication(com.github.bordertech.wcomponents.WApplication) WButton(com.github.bordertech.wcomponents.WButton) Map(java.util.Map) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 18 with WComponent

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

the class UIRegistryAmicableImpl_Test method testGetUINotRegisteredWComponent.

/**
 * Test getUI - nothing registered - but WComponent creatable from key.
 */
@Test
public void testGetUINotRegisteredWComponent() {
    final String key = "com.github.bordertech.wcomponents.WButton";
    UIRegistryAmicableImpl reg = new UIRegistryAmicableImpl();
    WComponent result = reg.getUI(key);
    Assert.assertTrue("should return an instantiated WComponent", result instanceof WComponent);
    Assert.assertTrue("the WComponent should be in the registry", reg.isRegistered(key));
    Assert.assertTrue("the WComponent should be locked", result.isLocked());
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Example 19 with WComponent

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

the class UIRegistryAmicableImpl_Test method testGetUINotRegisteredNotWComponent.

/**
 * Test getUI - nothing registered - class creatable from key - but not a WComponent.
 */
@Test
public void testGetUINotRegisteredNotWComponent() {
    final String key = "java.lang.String";
    final String expectedClassName = FatalErrorPage.class.getName();
    UIRegistryAmicableImpl reg = new UIRegistryAmicableImpl();
    WComponent result = reg.getUI(key);
    Assert.assertNotNull("should return a fatal error page - when no WComponentclass", result);
    Assert.assertEquals("should be of the expected type", expectedClassName, result.getClass().getName());
    Assert.assertFalse("should not be cached", reg.isRegistered(key));
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) DefaultWComponent(com.github.bordertech.wcomponents.DefaultWComponent) Test(org.junit.Test)

Example 20 with WComponent

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

the class UIRegistryAmicableImpl_Test method testGetUINotRegisteredNoClass.

/**
 * Test getUI - nothing registered - no class creatable from key - returns. FatalErrorPage
 */
@Test
public void testGetUINotRegisteredNoClass() {
    final String key = "NO_CLASS_BY_THIS_NAME";
    final String expectedClassName = FatalErrorPage.class.getName();
    UIRegistryAmicableImpl reg = new UIRegistryAmicableImpl();
    WComponent result = reg.getUI(key);
    Assert.assertNotNull("should return a fatal error page - when no class found", result);
    Assert.assertEquals("should be of the expected type", expectedClassName, result.getClass().getName());
    Assert.assertFalse("should not be cached", reg.isRegistered(key));
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) 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