Search in sources :

Example 91 with SystemException

use of com.github.bordertech.wcomponents.util.SystemException 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

SystemException (com.github.bordertech.wcomponents.util.SystemException)91 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)17 WComponent (com.github.bordertech.wcomponents.WComponent)15 UIContext (com.github.bordertech.wcomponents.UIContext)14 ComponentWithContext (com.github.bordertech.wcomponents.ComponentWithContext)10 Test (org.junit.Test)9 WebElement (org.openqa.selenium.WebElement)8 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)6 IOException (java.io.IOException)5 Select (org.openqa.selenium.support.ui.Select)5 Environment (com.github.bordertech.wcomponents.Environment)4 PrintWriter (java.io.PrintWriter)4 ArrayList (java.util.ArrayList)4 ActionEscape (com.github.bordertech.wcomponents.ActionEscape)3 Date (java.util.Date)3 List (java.util.List)3 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)3 AjaxOperation (com.github.bordertech.wcomponents.AjaxOperation)2 DefaultWComponent (com.github.bordertech.wcomponents.DefaultWComponent)2 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)2