use of com.opensymphony.xwork2.ognl.OgnlValueStack in project struts by apache.
the class OgnlValueStackTest method testFailOnErrorOnInheritedProperties.
public void testFailOnErrorOnInheritedProperties() {
// this shuld not fail as the property is defined on a parent class
OgnlValueStack vs = createValueStack();
Foo foo = new Foo();
BarJunior barjr = new BarJunior();
foo.setBarJunior(barjr);
vs.push(foo);
assertNull(barjr.getTitle());
vs.findValue("barJunior.title", true);
}
use of com.opensymphony.xwork2.ognl.OgnlValueStack in project struts by apache.
the class OgnlValueStackTest method testMapEntriesAvailableByKey.
public void testMapEntriesAvailableByKey() {
Foo foo = new Foo();
String title = "a title";
foo.setTitle(title);
OgnlValueStack vs = createValueStack();
vs.push(foo);
Map map = new HashMap();
String a_key = "a";
String a_value = "A";
map.put(a_key, a_value);
String b_key = "b";
String b_value = "B";
map.put(b_key, b_value);
vs.push(map);
assertEquals(title, vs.findValue("title"));
assertEquals(a_value, vs.findValue(a_key));
assertEquals(b_value, vs.findValue(b_key));
}
use of com.opensymphony.xwork2.ognl.OgnlValueStack in project struts by apache.
the class OgnlUtilTest method testSetBigIndexedValue.
/**
* XW-281
*/
public void testSetBigIndexedValue() {
ValueStack stack = ActionContext.getContext().getValueStack();
Map<String, Object> stackContext = stack.getContext();
stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.FALSE);
stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
User user = new User();
stack.push(user);
// indexed string w/ existing array
user.setList(new ArrayList<>());
String[] foo = new String[] { "asdf" };
((OgnlValueStack) stack).setDevMode("true");
try {
stack.setValue("list.1114778947765", foo);
fail("non-valid expression: list.1114778947765");
} catch (RuntimeException ex) {
// it's oke
}
try {
stack.setValue("1114778947765", foo);
fail("non-valid expression: 1114778947765");
} catch (RuntimeException ignore) {
}
try {
stack.setValue("1234", foo);
fail("non-valid expression: 1234");
} catch (RuntimeException ignore) {
}
((OgnlValueStack) stack).setDevMode("false");
try {
// Set dev mode false (above set now refused)
reloadTestContainerConfiguration(false, false);
} catch (Exception ex) {
fail("Unable to reload container configuration - exception: " + ex);
}
// Repeat stack/context set after retrieving updated stack
stack = ActionContext.getContext().getValueStack();
stackContext = stack.getContext();
stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.FALSE);
stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
stack.setValue("list.1114778947765", foo);
stack.setValue("1114778947765", foo);
stack.setValue("1234", foo);
}
Aggregations