Search in sources :

Example 31 with ConfigurationProvider

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();
}
Also used : StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) XmlConfigurationProvider(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) MockConfigurationProvider(com.opensymphony.xwork2.config.providers.MockConfigurationProvider) ValueStack(com.opensymphony.xwork2.util.ValueStack) ValueStackFactory(com.opensymphony.xwork2.util.ValueStackFactory)

Example 32 with ConfigurationProvider

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);
}
Also used : StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider) XmlConfigurationProvider(com.opensymphony.xwork2.config.providers.XmlConfigurationProvider) StrutsXmlConfigurationProvider(org.apache.struts2.config.StrutsXmlConfigurationProvider)

Example 33 with 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;
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) Configuration(com.opensymphony.xwork2.config.Configuration) ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) DefaultActionInvocation(com.opensymphony.xwork2.DefaultActionInvocation) ActionInvocation(com.opensymphony.xwork2.ActionInvocation) ContainerBuilder(com.opensymphony.xwork2.inject.ContainerBuilder) DefaultActionInvocation(com.opensymphony.xwork2.DefaultActionInvocation) ContainerBuilder(com.opensymphony.xwork2.inject.ContainerBuilder) ConfigurationException(com.opensymphony.xwork2.config.ConfigurationException) LocatableProperties(com.opensymphony.xwork2.util.location.LocatableProperties)

Example 34 with ConfigurationProvider

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);
}
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 35 with ConfigurationProvider

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

Aggregations

ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)41 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)22 StrutsXmlConfigurationProvider (org.apache.struts2.config.StrutsXmlConfigurationProvider)21 Map (java.util.Map)12 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)11 XmlConfigurationProvider (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider)10 HashMap (java.util.HashMap)9 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)7 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)6 File (java.io.File)6 InterceptorMapping (com.opensymphony.xwork2.config.entities.InterceptorMapping)5 ContainerBuilder (com.opensymphony.xwork2.inject.ContainerBuilder)5 LocatableProperties (com.opensymphony.xwork2.util.location.LocatableProperties)5 InterceptorStackConfig (com.opensymphony.xwork2.config.entities.InterceptorStackConfig)4 MockResult (com.opensymphony.xwork2.mock.MockResult)4 DefaultUnknownHandlerManager (com.opensymphony.xwork2.DefaultUnknownHandlerManager)3 SimpleAction (com.opensymphony.xwork2.SimpleAction)3 UnknownHandlerManager (com.opensymphony.xwork2.UnknownHandlerManager)3 Configuration (com.opensymphony.xwork2.config.Configuration)3 RuntimeConfiguration (com.opensymphony.xwork2.config.RuntimeConfiguration)3