public void testSetList() throws Exception { ChainingInterceptor foo = new ChainingInterceptor(); ChainingInterceptor foo2 = new ChainingInterceptor(); OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null); SimpleNode expression = (SimpleNode) Ognl.parseExpression("{'a','ruby','b','tom'}"); Ognl.getValue(expression, context, "aksdj"); final ValueStack stack = ActionContext.getContext().getValueStack(); Object result = Ognl.getValue(ognlUtil.compile("{\"foo\",'ruby','b','tom'}"), context, foo); foo.setIncludes((Collection) result); assertEquals(4, foo.getIncludes().size()); assertEquals("foo", foo.getIncludes().toArray()[0]); assertEquals("ruby", foo.getIncludes().toArray()[1]); assertEquals("b", "" + foo.getIncludes().toArray()[2]); assertEquals("tom", foo.getIncludes().toArray()[3]); Object result2 = Ognl.getValue(ognlUtil.compile("{\"foo\",'ruby','b','tom'}"), context, foo2); ognlUtil.setProperty("includes", result2, foo2, context); assertEquals(4, foo.getIncludes().size()); assertEquals("foo", foo.getIncludes().toArray()[0]); assertEquals("ruby", foo.getIncludes().toArray()[1]); assertEquals("b", "" + foo.getIncludes().toArray()[2]); assertEquals("tom", foo.getIncludes().toArray()[3]); result = ActionContext.getContext().getValueStack().findValue("{\"foo\",'ruby','b','tom'}"); foo.setIncludes((Collection) result); assertEquals(ArrayList.class, result.getClass()); assertEquals(4, foo.getIncludes().size()); assertEquals("foo", foo.getIncludes().toArray()[0]); assertEquals("ruby", foo.getIncludes().toArray()[1]); assertEquals("b", "" + foo.getIncludes().toArray()[2]); assertEquals("tom", foo.getIncludes().toArray()[3]); }
public void testCacheEnabled() throws OgnlException { OgnlUtil.setEnableExpressionCache("true"); Object expr0 = ognlUtil.compile("test"); Object expr2 = ognlUtil.compile("test"); assertSame(expr0, expr2); }