public void testObjectIndexInSubclass() // throws OgnlException { SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]"); context ["ka"] = (new Test2()); Ognl.getValue(expression, context, "aksdj"); }
public virtual object evaluate(string expression) { try { Check.notNull(this.Fixture, "Root object is null"); Check.notNull(expression, "Expression to evaluate cannot be null"); return Ognl.getValue(expression, this.OgnlContext, this.Fixture); } catch (OgnlException ognlException) { throw ognlException.getReason(); } }
public void testMultipleObjectIndexMethodPairs() // throws OgnlException { SimpleNode expression = (SimpleNode)Ognl.parseExpression("#ka.sunk[#root]"); context ["ka"] = (new Test5()); try { Ognl.getValue(expression, context, "aksdj"); Assert.Fail(); } catch (OgnlException ex) { /* Should throw */ } }
public Results testExpression(bool compiled) // throws OgnlException { if (compiled) { context.Add("_compile", true); } else { context.Remove("_compile"); } Ognl.getValue(expression, context, root); startTest(); do { Ognl.getValue(expression, context, root); } while (!done()); return(endTest()); }
/*=================================================================== * Overridden methods * ===================================================================*/ protected internal virtual void runTest() // throws Exception { object testedResult = null; setUp(); try { SimpleNode expr; testedResult = expectedResult; expr = getExpression(); /* * PrintWriter writer = new PrintWriter(System.err); * System.err.println(expr.toString()); * expr.dump(writer, ""); * writer.flush(); */ Assert.IsTrue(isEqual(Ognl.getValue(expr, context, root), expectedResult)); if (hasSetValue) { testedResult = hasExpectedAfterSetResult ? expectedAfterSetResult : setValue; Ognl.setValue(expr, context, root, setValue); Assert.IsTrue(isEqual(Ognl.getValue(expr, context, root), testedResult)); } } catch (Exception ex) { if (testedResult is Type) { Assert.IsTrue(((Type)testedResult).IsAssignableFrom(ex.GetType())); } else { Console.WriteLine(ex); throw ex; } } }
public object Eval(string code, IDictionary <string, object> context) { object root = context; IDictionary dictContext = new DictionaryWrapper <string, object>(context); IDictionary variables = Ognl.addDefaultContext(root, TypeResolver, dictContext); try { object res = Ognl.getValue(code, variables, root); if (log.IsEnabledFor(LogEvent.Debug)) { log.Write( LogEvent.Debug, new{ Action = "getting value", Expression = code, Result = res, Context = context } ); } return(res); } catch (Exception ex) { log.Write( LogEvent.Error, new { Action = "getting value", Exception = ex, Expression = code, Context = context }); throw new Exception("OGNL code evaluation failed (" + code + "): " + ex.Message, ex); } }
public virtual object Evaluate(string expression) { Check.NotNull(Fixture, "Root object is null"); Check.NotNull(expression, "Expression to evaluate cannot be null"); return(Ognl.getValue(expression, OgnlContext, Fixture)); }
public void testPrivateField() // throws OgnlException { NUnit.Framework.Assert.AreEqual(Ognl.getValue("_privateProperty", context, this), _privateProperty); }
public void testPrivateAccessor() // throws OgnlException { NUnit.Framework.Assert.AreEqual(Ognl.getValue("privateProperty", context, this), getPrivateProperty()); }