use of org.springframework.expression.common.LiteralExpression in project spring-framework by spring-projects.
the class LiteralExpressionTests method testSetValue.
@Test
public void testSetValue() {
try {
LiteralExpression lEx = new LiteralExpression("somevalue");
lEx.setValue(new StandardEvaluationContext(), "flibble");
fail("Should have got an exception that the value cannot be set");
} catch (EvaluationException ee) {
// success, not allowed - whilst here, check the expression value in the exception
assertEquals(ee.getExpressionString(), "somevalue");
}
try {
LiteralExpression lEx = new LiteralExpression("somevalue");
lEx.setValue(new Rooty(), "flibble");
fail("Should have got an exception that the value cannot be set");
} catch (EvaluationException ee) {
// success, not allowed - whilst here, check the expression value in the exception
assertEquals(ee.getExpressionString(), "somevalue");
}
try {
LiteralExpression lEx = new LiteralExpression("somevalue");
lEx.setValue(new StandardEvaluationContext(), new Rooty(), "flibble");
fail("Should have got an exception that the value cannot be set");
} catch (EvaluationException ee) {
// success, not allowed - whilst here, check the expression value in the exception
assertEquals(ee.getExpressionString(), "somevalue");
}
}
use of org.springframework.expression.common.LiteralExpression in project spring-framework by spring-projects.
the class LiteralExpressionTests method testGetValueType.
@Test
public void testGetValueType() throws Exception {
LiteralExpression lEx = new LiteralExpression("somevalue");
assertEquals(String.class, lEx.getValueType());
assertEquals(String.class, lEx.getValueType(new StandardEvaluationContext()));
assertEquals(String.class, lEx.getValueType(new Rooty()));
assertEquals(String.class, lEx.getValueType(new StandardEvaluationContext(), new Rooty()));
assertEquals(String.class, lEx.getValueTypeDescriptor().getType());
assertEquals(String.class, lEx.getValueTypeDescriptor(new StandardEvaluationContext()).getType());
assertEquals(String.class, lEx.getValueTypeDescriptor(new Rooty()).getType());
assertEquals(String.class, lEx.getValueTypeDescriptor(new StandardEvaluationContext(), new Rooty()).getType());
}
use of org.springframework.expression.common.LiteralExpression in project spring-framework by spring-projects.
the class LiteralExpressionTests method testGetValue.
@Test
public void testGetValue() throws Exception {
LiteralExpression lEx = new LiteralExpression("somevalue");
checkString("somevalue", lEx.getValue());
checkString("somevalue", lEx.getValue(String.class));
EvaluationContext ctx = new StandardEvaluationContext();
checkString("somevalue", lEx.getValue(ctx));
checkString("somevalue", lEx.getValue(ctx, String.class));
checkString("somevalue", lEx.getValue(new Rooty()));
checkString("somevalue", lEx.getValue(new Rooty(), String.class));
checkString("somevalue", lEx.getValue(ctx, new Rooty()));
checkString("somevalue", lEx.getValue(ctx, new Rooty(), String.class));
assertEquals("somevalue", lEx.getExpressionString());
assertFalse(lEx.isWritable(new StandardEvaluationContext()));
assertFalse(lEx.isWritable(new Rooty()));
assertFalse(lEx.isWritable(new StandardEvaluationContext(), new Rooty()));
}
Aggregations