test coverage. now > 95%
This commit is contained in:
@@ -55,6 +55,11 @@ public class SetValueTests extends ExpressionTestCase {
|
||||
setValue("inventions[0]", "Just the telephone");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorCase() {
|
||||
setValueExpectError("3=4", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetElementOfNull() {
|
||||
setValueExpectError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessages.CANNOT_INDEX_INTO_NULL_VALUE);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.EvaluationException;
|
||||
import org.springframework.expression.ExpressionException;
|
||||
import org.springframework.expression.ParseException;
|
||||
@@ -26,6 +27,7 @@ import org.springframework.expression.spel.SpelNode;
|
||||
import org.springframework.expression.spel.SpelParseException;
|
||||
import org.springframework.expression.spel.ast.OpAnd;
|
||||
import org.springframework.expression.spel.ast.OpOr;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
|
||||
|
||||
public class SpelParserTests {
|
||||
@@ -38,6 +40,23 @@ public class SpelParserTests {
|
||||
Assert.assertNotNull(expr.getAST());
|
||||
Assert.assertEquals(2,expr.getValue());
|
||||
Assert.assertEquals(Integer.class,expr.getValueType());
|
||||
Assert.assertEquals(2,expr.getAST().getValue(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueType() throws Exception {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
EvaluationContext ctx = new StandardEvaluationContext();
|
||||
Class c = parser.parse("2").getValueType();
|
||||
Assert.assertEquals(Integer.class,c);
|
||||
c = parser.parse("12").getValueType(ctx);
|
||||
Assert.assertEquals(Integer.class,c);
|
||||
c = parser.parse("null").getValueType();
|
||||
Assert.assertNull(c);
|
||||
c = parser.parse("null").getValueType(ctx);
|
||||
Assert.assertNull(c);
|
||||
Object o = parser.parse("null").getValue(ctx,Integer.class);
|
||||
Assert.assertNull(o);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user