use of com.opensymphony.xwork2.util.location.LocatableProperties 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.location.LocatableProperties in project struts by apache.
the class MockConfiguration method selfRegister.
public void selfRegister() {
// this cannot be done in the constructor, as it causes an infinite loop
builder.factory(Configuration.class, MockConfiguration.class, Scope.SINGLETON);
LocatableProperties props = new LocatableProperties();
new StrutsDefaultConfigurationProvider().register(builder, props);
builder.constant(StrutsConstants.STRUTS_DEVMODE, "false");
builder.constant(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
builder.constant(StrutsConstants.STRUTS_OGNL_ENABLE_EXPRESSION_CACHE, "true");
builder.constant(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, "false");
container = builder.create(true);
}
use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class DebugTagTest method setStrutsConstant.
/**
* Overwrite the Struts Constant and reload container
*/
private void setStrutsConstant(final Map<String, String> overwritePropeties) {
configurationManager.addContainerProvider(new StubConfigurationProvider() {
@Override
public boolean needsReload() {
return true;
}
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
for (Map.Entry<String, String> stringStringEntry : overwritePropeties.entrySet()) {
props.setProperty(stringStringEntry.getKey(), stringStringEntry.getValue(), null);
}
}
});
configurationManager.reload();
container = configurationManager.getConfiguration().getContainer();
stack.getActionContext().withContainer(container);
}
use of com.opensymphony.xwork2.util.location.LocatableProperties 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.util.location.LocatableProperties in project struts by apache.
the class PropertiesConfigurationProviderTest method testRegister_DifferentLocale.
public void testRegister_DifferentLocale() {
ContainerBuilder builder = new ContainerBuilder();
builder.constant("foo", "bar");
builder.constant("struts.locale", "de_DE");
PropertiesConfigurationProvider prov = new PropertiesConfigurationProvider();
prov.register(builder, new LocatableProperties());
Container container = builder.create(true);
String localeStr = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
Locale locale = LocaleUtils.toLocale(localeStr);
assertNotNull(locale);
assertEquals("DE", locale.getCountry());
assertEquals("de", locale.getLanguage());
}
Aggregations