use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class LocaleAwareTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-test-beans.xml");
container.inject(configurationProvider);
loadConfigurationProviders(configurationProvider, new MockConfigurationProvider());
ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
stack.getActionContext().withContainer(container);
ActionContext.of(stack.getContext()).bind();
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class ProxyInvocationTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// ensure we're using the default configuration, not simple config
XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("xwork-proxyinvoke.xml");
container.inject(configurationProvider);
loadConfigurationProviders(configurationProvider);
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class AnnotationValidationConfigurationBuilderTest method createValidationManager.
private AnnotationActionValidatorManager createValidationManager(final Class<? extends ActionSupport> actionClass, Locale locale) throws Exception {
loadConfigurationProviders(new ConfigurationProvider() {
public void destroy() {
}
public void init(Configuration configuration) throws ConfigurationException {
configuration.addPackageConfig("default", new PackageConfig.Builder("default").addActionConfig("annotation", new ActionConfig.Builder("", "annotation", actionClass.getName()).build()).build());
}
public boolean needsReload() {
return false;
}
public void loadPackages() throws ConfigurationException {
}
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
builder.constant(StrutsConstants.STRUTS_DEVMODE, true);
}
});
// ActionContext is destroyed during rebuilding configuration
ActionContext.getContext().withLocale(locale);
ActionInvocation invocation = new DefaultActionInvocation(ActionContext.getContext().getContextMap(), true);
container.inject(invocation);
invocation.init(actionProxyFactory.createActionProxy("", "annotation", null, ActionContext.getContext().getContextMap()));
AnnotationActionValidatorManager manager = new AnnotationActionValidatorManager();
container.inject(manager);
ValidatorFactory vf = container.getInstance(ValidatorFactory.class);
vf.registerValidator("myValidator", MyValidator.class.getName());
return manager;
}
use of com.opensymphony.xwork2.config.ConfigurationProvider in project struts by apache.
the class UnknownHandlerManagerTest method testStack.
public void testStack() throws ConfigurationException {
final String filename = "com/opensymphony/xwork2/config/providers/xwork-unknownhandler-stack.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);
}
use of com.opensymphony.xwork2.config.ConfigurationProvider 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);
}
Aggregations