Search in sources :

Example 81 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class ConfigurationTest method testMultipleConfigProviders.

public void testMultipleConfigProviders() {
    configurationManager.addContainerProvider(new MockConfigurationProvider());
    try {
        configurationManager.reload();
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail();
    }
    RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration();
    // check that it has configuration from xml
    assertNotNull(configuration.getActionConfig("/foo/bar", "Bar"));
    // check that it has configuration from MockConfigurationProvider
    assertNotNull(configuration.getActionConfig("", MockConfigurationProvider.FOO_ACTION_NAME));
}
Also used : MockConfigurationProvider(com.opensymphony.xwork2.config.providers.MockConfigurationProvider)

Example 82 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class ConfigurationTest method testMultipleContainerProviders.

public void testMultipleContainerProviders() throws Exception {
    // to start from scratch
    configurationManager.destroyConfiguration();
    // to build basic configuration
    configurationManager.getConfiguration();
    Mock mockContainerProvider = new Mock(ContainerProvider.class);
    mockContainerProvider.expect("init", C.ANY_ARGS);
    mockContainerProvider.expect("register", C.ANY_ARGS);
    mockContainerProvider.matchAndReturn("equals", C.ANY_ARGS, false);
    mockContainerProvider.matchAndReturn("toString", "foo");
    mockContainerProvider.matchAndReturn("destroy", null);
    mockContainerProvider.expectAndReturn("needsReload", true);
    // the order of providers must be changed as just first is checked if reload is needed
    configurationManager.addContainerProvider((ContainerProvider) mockContainerProvider.proxy());
    XmlConfigurationProvider provider = new StrutsXmlConfigurationProvider("xwork-sample.xml");
    container.inject(provider);
    configurationManager.addContainerProvider(provider);
    Configuration config = null;
    try {
        config = configurationManager.getConfiguration();
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail();
    }
    RuntimeConfiguration configuration = config.getRuntimeConfiguration();
    // check that it has configuration from xml
    assertNotNull(configuration.getActionConfig("/foo/bar", "Bar"));
    mockContainerProvider.verify();
}
Also used : StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) XmlConfigurationProvider(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) Mock(com.mockobjects.dynamic.Mock)

Example 83 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class ConfigurationTest method testInterceptorParamInehritanceOverride.

public void testInterceptorParamInehritanceOverride() {
    try {
        ActionProxy proxy = actionProxyFactory.createActionProxy("/foo/bar", "TestInterceptorParamInehritanceOverride", null, null);
        assertEquals(1, proxy.getConfig().getInterceptors().size());
        MockInterceptor testInterceptor = (MockInterceptor) proxy.getConfig().getInterceptors().get(0).getInterceptor();
        assertEquals("foo123", testInterceptor.getExpectedFoo());
        proxy.execute();
        assertTrue(testInterceptor.isExecuted());
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) MockInterceptor(com.opensymphony.xwork2.mock.MockInterceptor)

Example 84 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class ConfigurationTest method testInitForPackageProviders.

public void testInitForPackageProviders() {
    loadConfigurationProviders(new StubConfigurationProvider() {

        @Override
        public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
            builder.factory(PackageProvider.class, "foo", MyPackageProvider.class);
        }
    });
    assertEquals(configuration, MyPackageProvider.getConfiguration());
}
Also used : ContainerBuilder(com.opensymphony.xwork2.inject.ContainerBuilder) StubConfigurationProvider(com.opensymphony.xwork2.test.StubConfigurationProvider) LocatableProperties(com.opensymphony.xwork2.util.location.LocatableProperties)

Example 85 with Foo

use of com.opensymphony.xwork2.util.Foo in project struts by apache.

the class ConfigurationTest method testMultipleInheritance.

public void testMultipleInheritance() {
    try {
        ActionProxy proxy;
        proxy = actionProxyFactory.createActionProxy("multipleInheritance", "test", null, null);
        assertNotNull(proxy);
        proxy = actionProxyFactory.createActionProxy("multipleInheritance", "Foo", null, null);
        assertNotNull(proxy);
        proxy = actionProxyFactory.createActionProxy("multipleInheritance", "testMultipleInheritance", null, null);
        assertNotNull(proxy);
        assertEquals(4, proxy.getConfig().getInterceptors().size());
        assertEquals(2, proxy.getConfig().getResults().size());
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy)

Aggregations

Foo (com.opensymphony.xwork2.util.Foo)53 HashMap (java.util.HashMap)32 ValueStack (com.opensymphony.xwork2.util.ValueStack)23 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)20 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)19 StrutsException (org.apache.struts2.StrutsException)19 OgnlException (ognl.OgnlException)18 IntrospectionException (java.beans.IntrospectionException)17 InappropriateExpressionException (ognl.InappropriateExpressionException)17 MethodFailedException (ognl.MethodFailedException)17 NoSuchPropertyException (ognl.NoSuchPropertyException)17 ActionProxy (com.opensymphony.xwork2.ActionProxy)16 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)9 ActionContext (com.opensymphony.xwork2.ActionContext)8 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)8 Bar (com.opensymphony.xwork2.util.Bar)8 Map (java.util.Map)8 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)7 ConversionData (com.opensymphony.xwork2.conversion.impl.ConversionData)7 StubValueStack (com.opensymphony.xwork2.StubValueStack)6