Search in sources :

Example 11 with StrutsDefaultConfigurationProvider

use of com.opensymphony.xwork2.config.providers.StrutsDefaultConfigurationProvider in project struts by apache.

the class XmlConfigurationProviderGlobalResultInheritenceTest method testGlobalResultInheritenceTest.

public void testGlobalResultInheritenceTest() throws Exception {
    ConfigurationProvider provider = buildConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-global-result-inheritence.xml");
    ConfigurationManager configurationManager = new ConfigurationManager(Container.DEFAULT_NAME);
    configurationManager.addContainerProvider(new StrutsDefaultConfigurationProvider());
    configurationManager.addContainerProvider(provider);
    Configuration configuration = configurationManager.getConfiguration();
    ActionConfig parentActionConfig = configuration.getRuntimeConfiguration().getActionConfig("/base", "parentAction");
    ActionConfig anotherActionConfig = configuration.getRuntimeConfiguration().getActionConfig("/base", "anotherAction");
    ActionConfig childActionConfig = configuration.getRuntimeConfiguration().getActionConfig("/base", "childAction");
    ResultConfig parentResultConfig1 = parentActionConfig.getResults().get("mockResult1");
    ResultConfig parentResultConfig2 = parentActionConfig.getResults().get("mockResult2");
    ResultConfig anotherResultConfig1 = anotherActionConfig.getResults().get("mockResult1");
    ResultConfig anotherResultConfig2 = anotherActionConfig.getResults().get("mockResult2");
    ResultConfig childResultConfig1 = childActionConfig.getResults().get("mockResult1");
    ResultConfig childResultConfig2 = childActionConfig.getResults().get("mockResult2");
    System.out.println(parentResultConfig1.getParams().get("identity"));
    System.out.println(parentResultConfig2.getParams().get("identity"));
    System.out.println(anotherResultConfig1.getParams().get("identity"));
    System.out.println(anotherResultConfig2.getParams().get("identity"));
    System.out.println(childResultConfig1.getParams().get("identity"));
    System.out.println(childResultConfig2.getParams().get("identity"));
    assertFalse(parentResultConfig1 == anotherResultConfig1);
    assertFalse(parentResultConfig2 == anotherResultConfig2);
    assertFalse(parentResultConfig1 == childResultConfig1);
    assertTrue(parentResultConfig2 == childResultConfig2);
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) ResultConfig(com.opensymphony.xwork2.config.entities.ResultConfig) Configuration(com.opensymphony.xwork2.config.Configuration) ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) ConfigurationManager(com.opensymphony.xwork2.config.ConfigurationManager)

Aggregations

StrutsDefaultConfigurationProvider (com.opensymphony.xwork2.config.providers.StrutsDefaultConfigurationProvider)8 StrutsXmlConfigurationProvider (org.apache.struts2.config.StrutsXmlConfigurationProvider)6 OgnlValueStack (com.opensymphony.xwork2.ognl.OgnlValueStack)4 ValueStack (com.opensymphony.xwork2.util.ValueStack)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)3 ContainerProvider (com.opensymphony.xwork2.config.ContainerProvider)2 RuntimeConfiguration (com.opensymphony.xwork2.config.RuntimeConfiguration)2 InterceptorMapping (com.opensymphony.xwork2.config.entities.InterceptorMapping)2 DefaultConfiguration (com.opensymphony.xwork2.config.impl.DefaultConfiguration)2 Container (com.opensymphony.xwork2.inject.Container)2 DefaultFileManager (com.opensymphony.xwork2.util.fs.DefaultFileManager)2 DefaultFileManagerFactory (com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory)2 LocatableProperties (com.opensymphony.xwork2.util.location.LocatableProperties)2 Mock (com.mockobjects.dynamic.Mock)1 Configuration (com.opensymphony.xwork2.config.Configuration)1 ConfigurationManager (com.opensymphony.xwork2.config.ConfigurationManager)1 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)1 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)1