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));
}
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();
}
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();
}
}
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());
}
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();
}
}
Aggregations