Search in sources :

Example 6 with UnknownHandler

use of com.opensymphony.xwork2.UnknownHandler in project struts by apache.

the class UnknownHandlerManagerTest method testEmptyStack.

public void testEmptyStack() throws ConfigurationException {
    final String filename = "com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack-empty.xml";
    ConfigurationProvider provider = buildConfigurationProvider(filename);
    loadConfigurationProviders(provider);
    configurationManager.reload();
    UnknownHandlerManager unknownHandlerManager = new DefaultUnknownHandlerManager();
    container.inject(unknownHandlerManager);
    List<UnknownHandler> unknownHandlers = unknownHandlerManager.getUnknownHandlers();
    assertNotNull(unknownHandlers);
    assertEquals(2, unknownHandlers.size());
    UnknownHandler uh1 = unknownHandlers.get(0);
    UnknownHandler uh2 = unknownHandlers.get(1);
    assertTrue(uh1 instanceof SomeUnknownHandler);
    assertTrue(uh2 instanceof SomeUnknownHandler);
}
Also used : DefaultUnknownHandlerManager(com.opensymphony.xwork2.DefaultUnknownHandlerManager) UnknownHandler(com.opensymphony.xwork2.UnknownHandler) SomeUnknownHandler(com.opensymphony.xwork2.config.providers.SomeUnknownHandler) ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) SomeUnknownHandler(com.opensymphony.xwork2.config.providers.SomeUnknownHandler) DefaultUnknownHandlerManager(com.opensymphony.xwork2.DefaultUnknownHandlerManager) UnknownHandlerManager(com.opensymphony.xwork2.UnknownHandlerManager)

Example 7 with UnknownHandler

use of com.opensymphony.xwork2.UnknownHandler in project struts by apache.

the class XmlConfigurationProviderUnknownHandlerStackTest method testStackWithElements.

public void testStackWithElements() throws ConfigurationException {
    final String filename = "com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack.xml";
    ConfigurationProvider provider = buildConfigurationProvider(filename);
    loadConfigurationProviders(provider);
    configurationManager.reload();
    List<UnknownHandlerConfig> unknownHandlerStack = configuration.getUnknownHandlerStack();
    assertNotNull(unknownHandlerStack);
    assertEquals(2, unknownHandlerStack.size());
    assertEquals("uh1", unknownHandlerStack.get(0).getName());
    assertEquals("uh2", unknownHandlerStack.get(1).getName());
    UnknownHandlerManager unknownHandlerManager = new DefaultUnknownHandlerManager();
    container.inject(unknownHandlerManager);
    assertTrue(unknownHandlerManager.hasUnknownHandlers());
}
Also used : UnknownHandlerConfig(com.opensymphony.xwork2.config.entities.UnknownHandlerConfig) DefaultUnknownHandlerManager(com.opensymphony.xwork2.DefaultUnknownHandlerManager) ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) DefaultUnknownHandlerManager(com.opensymphony.xwork2.DefaultUnknownHandlerManager) UnknownHandlerManager(com.opensymphony.xwork2.UnknownHandlerManager)

Aggregations

UnknownHandlerConfig (com.opensymphony.xwork2.config.entities.UnknownHandlerConfig)5 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)4 DefaultUnknownHandlerManager (com.opensymphony.xwork2.DefaultUnknownHandlerManager)3 UnknownHandlerManager (com.opensymphony.xwork2.UnknownHandlerManager)3 UnknownHandler (com.opensymphony.xwork2.UnknownHandler)2 BeanSelectionProvider (com.opensymphony.xwork2.config.BeanSelectionProvider)2 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)2 SomeUnknownHandler (com.opensymphony.xwork2.config.providers.SomeUnknownHandler)2 Location (com.opensymphony.xwork2.util.location.Location)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Configuration (com.opensymphony.xwork2.config.Configuration)1 LocatableFactory (com.opensymphony.xwork2.config.impl.LocatableFactory)1 Scope (com.opensymphony.xwork2.inject.Scope)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 BeanConfig (org.apache.struts2.config.entities.BeanConfig)1 ConstantConfig (org.apache.struts2.config.entities.ConstantConfig)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1