use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class OgnlValueStackTest method reloadTestContainerConfiguration.
private void reloadTestContainerConfiguration(Boolean allowStaticMethod, Boolean allowStaticField) throws Exception {
loadConfigurationProviders(new StubConfigurationProvider() {
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
// undefined values then should be evaluated to false
if (props.containsKey(StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS)) {
props.remove(StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS);
}
if (props.containsKey(StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS)) {
props.remove(StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS);
}
if (allowStaticMethod != null) {
props.setProperty(StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS, "" + allowStaticMethod);
}
if (allowStaticField != null) {
props.setProperty(StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS, "" + allowStaticField);
}
}
});
ognlUtil = container.getInstance(OgnlUtil.class);
}
use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class PrefixBasedActionProxyFactoryTest method setUp.
@Override
public void setUp() throws Exception {
ConfigurationProvider[] providers = new ConfigurationProvider[] { new StrutsXmlConfigurationProvider("xwork-sample.xml"), new StubConfigurationProvider() {
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
builder.factory(ActionProxyFactory.class, "prefix1", new Factory() {
public Object create(Context context) throws Exception {
return new Prefix1Factory();
}
public Class type() {
return Prefix1Factory.class;
}
}, Scope.SINGLETON);
}
}, new StubConfigurationProvider() {
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
builder.factory(ActionProxyFactory.class, "prefix2", new Factory() {
public Object create(Context context) throws Exception {
return new Prefix2Factory();
}
public Class type() {
return Prefix2Factory.class;
}
}, Scope.SINGLETON);
}
} };
loadConfigurationProviders(providers);
factory = new PrefixBasedActionProxyFactory();
factory.setContainer(container);
}
use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class PropertiesConfigurationProviderTest method testRegister_NoLocale.
public void testRegister_NoLocale() {
ContainerBuilder builder = new ContainerBuilder();
builder.constant("foo", "bar");
PropertiesConfigurationProvider prov = new PropertiesConfigurationProvider();
prov.register(builder, new LocatableProperties());
Container container = builder.create(true);
String localeStr = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
assertNull(localeStr);
}
use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class SpringObjectFactoryTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
sac = new StaticApplicationContext();
loadConfigurationProviders(new StubConfigurationProvider() {
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
// No registered beans during initialization; They will be registered in each test, runtime.
props.setProperty("applicationContextPath", "com/opensymphony/xwork2/spring/emptyContext-spring.xml");
builder.factory(TextProvider.class, DummyTextProvider.class);
builder.factory(ObjectFactory.class, SpringObjectFactory.class);
}
});
objectFactory = (SpringObjectFactory) container.getInstance(ObjectFactory.class);
objectFactory.setApplicationContext(sac);
objectFactory.setAlwaysRespectAutowireStrategy(false);
}
use of com.opensymphony.xwork2.util.location.LocatableProperties in project struts by apache.
the class ConfigurationManagerTest method testDestroyConfiguration.
public void testDestroyConfiguration() throws Exception {
class State {
public boolean isDestroyed1 = false;
public boolean isDestroyed2 = false;
}
final State state = new State();
ConfigurationManager configurationManager = new ConfigurationManager(Container.DEFAULT_NAME);
configurationManager.addContainerProvider(new ConfigurationProvider() {
public void destroy() {
throw new RuntimeException("testing testing 123");
}
public void init(Configuration configuration) throws ConfigurationException {
}
public void loadPackages() throws ConfigurationException {
}
public boolean needsReload() {
return false;
}
public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
}
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
}
});
configurationManager.addContainerProvider(new ConfigurationProvider() {
public void destroy() {
state.isDestroyed1 = true;
}
public void init(Configuration configuration) throws ConfigurationException {
}
public void loadPackages() throws ConfigurationException {
}
public boolean needsReload() {
return false;
}
public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
}
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
}
});
configurationManager.addContainerProvider(new ConfigurationProvider() {
public void destroy() {
throw new RuntimeException("testing testing 123");
}
public void init(Configuration configuration) throws ConfigurationException {
}
public void loadPackages() throws ConfigurationException {
}
public boolean needsReload() {
return false;
}
public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
}
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
}
});
configurationManager.addContainerProvider(new ConfigurationProvider() {
public void destroy() {
state.isDestroyed2 = true;
}
public void init(Configuration configuration) throws ConfigurationException {
}
public void loadPackages() throws ConfigurationException {
}
public boolean needsReload() {
return false;
}
public void register(ContainerBuilder builder, Properties props) throws ConfigurationException {
}
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
}
});
assertFalse(state.isDestroyed1);
assertFalse(state.isDestroyed2);
configurationManager.clearContainerProviders();
assertTrue(state.isDestroyed1);
assertTrue(state.isDestroyed2);
}
Aggregations