@Test public void testTernaryOperator04() { Expression e = parser.parseExpression("1>2?3:4"); assertFalse(e.isWritable(context)); }
assertFalse("Should not be writable!",e.isWritable(lContext)); assertFalse("Should not be writable!",e.isWritable(lContext)); fail("Should have had an error because wibble does not really exist"); assertTrue("Should be writable!",e.isWritable(lContext)); assertFalse("Should not be writable!",e.isWritable(lContext)); assertFalse("Should not be writable!",e.isWritable(lContext)); fail("Should have had an error because wibble does not really exist"); assertFalse("Should not be writable!",e.isWritable(lContext)); fail("Should have had an error because wibble does not really exist");
@Test public void testAssign() throws Exception { StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext(); Expression e = parse("publicName='Andy'"); assertFalse(e.isWritable(eContext)); assertEquals("Andy",e.getValue(eContext)); }
/** * For use when coercion is happening during a setValue(). The expectedValue should be * the coerced form of the value. */ protected void setValue(String expression, Object value, Object expectedValue) { try { Expression e = parser.parseExpression(expression); if (e == null) { fail("Parser returned null for expression"); } if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, e); } StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); assertTrue("Expression is not writeable but should be", e.isWritable(lContext)); e.setValue(lContext, value); Object a = expectedValue; Object b = e.getValue(lContext); if (!a.equals(b)) { fail("Not the same: ["+a+"] type="+a.getClass()+" ["+b+"] type="+b.getClass()); // assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext)); } } catch (EvaluationException | ParseException ex) { ex.printStackTrace(); fail("Unexpected Exception: " + ex.getMessage()); } }
protected void setValue(String expression, Object value) { try { Expression e = parser.parseExpression(expression); if (e == null) { fail("Parser returned null for expression"); } if (DEBUG) { SpelUtilities.printAbstractSyntaxTree(System.out, e); } StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext(); assertTrue("Expression is not writeable but should be", e.isWritable(lContext)); e.setValue(lContext, value); assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext,value.getClass())); } catch (EvaluationException | ParseException ex) { ex.printStackTrace(); fail("Unexpected Exception: " + ex.getMessage()); } }
"' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType)); boolean isWritable = expr.isWritable(context); if (isWritable != shouldBeWritable) { if (shouldBeWritable)
checkString("hello world", ex.getValue(ctx, new Rooty(), String.class)); assertEquals("hello ${'world'}", ex.getExpressionString()); assertFalse(ex.isWritable(new StandardEvaluationContext())); assertFalse(ex.isWritable(new Rooty())); assertFalse(ex.isWritable(new StandardEvaluationContext(), new Rooty()));
public boolean isWritable(Object rootObject) throws EvaluationException { return this.resolveExpression().isWritable(rootObject); }
public boolean isWritable(EvaluationContext context) throws EvaluationException { return this.resolveExpression().isWritable(context); }
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException { return this.resolveExpression().isWritable(context, rootObject); }
public boolean isWritable(Object rootObject) throws EvaluationException { return this.resolveExpression().isWritable(rootObject); }
public boolean isWritable(EvaluationContext context) throws EvaluationException { return this.resolveExpression().isWritable(context); }
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException { return this.resolveExpression().isWritable(context, rootObject); }