Here are the examples of the java api org.springframework.expression.Expression.getValueTypeDescriptor() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
54 Examples
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoGenericPropertyContainingGrowingList() {
List<String> property = new ArrayList<>();
this.property = property;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
try {
replacedertEquals("bar", expression.getValue(this));
} catch (EvaluationException ex) {
replacedertTrue(ex.getMessage().startsWith("EL1053E"));
}
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.parameterizedList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedList");
replacedertEquals("java.util.ArrayList<java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("parameterizedList[0]");
replacedertEquals(3, expression.getValue(this));
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoGenericPropertyContainingNullList() {
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.lang.Object", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
try {
replacedertEquals("bar", expression.getValue(this));
} catch (EvaluationException ex) {
replacedertTrue(ex.getMessage().startsWith("EL1027E"));
}
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoGenericPropertyContainingList() {
List<String> property = new ArrayList<>();
property.add("bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
replacedertEquals("bar", expression.getValue(this));
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoGenericPropertyContainingMapObject() {
Map<String, Map<String, String>> property = new HashMap<>();
Map<String, String> map = new HashMap<>();
map.put("foo", "bar");
property.put("property", map);
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
context.addPropertyAccessor(new MapAccessor());
context.setRootObject(property);
Expression expression = parser.parseExpression("property");
replacedertEquals("java.util.HashMap<?, ?>", expression.getValueTypeDescriptor(context).toString());
replacedertEquals(map, expression.getValue(context));
replacedertEquals(map, expression.getValue(context, Map.clreplaced));
expression = parser.parseExpression("property['foo']");
replacedertEquals("bar", expression.getValue(context));
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void resolveCollectionElementTypeNull() {
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listNotGeneric");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.List<?>", expression.getValueTypeDescriptor(this).toString());
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void emptyList() {
listOfScalarNotGeneric = new ArrayList();
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listOfScalarNotGeneric");
replacedertEquals("java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals("", expression.getValue(this, String.clreplaced));
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoGenericPropertyContainingArray() {
String[] property = new String[] { "bar" };
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.lang.String[]", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
replacedertEquals("bar", expression.getValue(this));
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoGenericPropertyContainingGrowingList2() {
List<String> property2 = new ArrayList<>();
this.property2 = property2;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property2");
replacedertEquals("java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property2, expression.getValue(this));
expression = parser.parseExpression("property2[0]");
try {
replacedertEquals("bar", expression.getValue(this));
} catch (EvaluationException ex) {
replacedertTrue(ex.getMessage().startsWith("EL1053E"));
}
}
19
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoGenericPropertyContainingMap() {
Map<String, String> property = new HashMap<>();
property.put("foo", "bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.HashMap<?, ?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
replacedertEquals(property, expression.getValue(this, Map.clreplaced));
expression = parser.parseExpression("property['foo']");
replacedertEquals("bar", expression.getValue(this));
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void indexIntoPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.parameterizedList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedList");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.ArrayList<java.lang.Integer>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("parameterizedList[0]");
replacedertThat(expression.getValue(this)).isEqualTo(3);
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void indexIntoGenericPropertyContainingList() {
List<String> property = new ArrayList<>();
property.add("bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("property[0]");
replacedertThat(expression.getValue(this)).isEqualTo("bar");
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void resolveCollectionElementTypeNull() {
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listNotGeneric");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.List<?>");
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void indexIntoGenericPropertyContainingGrowingList2() {
List<String> property2 = new ArrayList<>();
this.property2 = property2;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property2");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.ArrayList<?>");
replacedertThat(expression.getValue(this)).isEqualTo(property2);
expression = parser.parseExpression("property2[0]");
try {
replacedertThat(expression.getValue(this)).isEqualTo("bar");
} catch (EvaluationException ex) {
replacedertThat(ex.getMessage().startsWith("EL1053E")).isTrue();
}
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void indexIntoGenericPropertyContainingNullList() {
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.lang.Object");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("property[0]");
try {
replacedertThat(expression.getValue(this)).isEqualTo("bar");
} catch (EvaluationException ex) {
replacedertThat(ex.getMessage().startsWith("EL1027E")).isTrue();
}
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void indexIntoGenericPropertyContainingGrowingList() {
List<String> property = new ArrayList<>();
this.property = property;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("property[0]");
try {
replacedertThat(expression.getValue(this)).isEqualTo("bar");
} catch (EvaluationException ex) {
replacedertThat(ex.getMessage().startsWith("EL1053E")).isTrue();
}
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void indexIntoGenericPropertyContainingArray() {
String[] property = new String[] { "bar" };
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.lang.String[]");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("property[0]");
replacedertThat(expression.getValue(this)).isEqualTo("bar");
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void emptyList() {
listOfScalarNotGeneric = new ArrayList();
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listOfScalarNotGeneric");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.ArrayList<?>");
replacedertThat(expression.getValue(this, String.clreplaced)).isEqualTo("");
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoGenericPropertyContainingNullList() {
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.lang.Object", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
try {
replacedertEquals("bar", expression.getValue(this));
} catch (EvaluationException e) {
replacedertTrue(e.getMessage().startsWith("EL1027E"));
}
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoPropertyContainingList() {
List<Integer> property = new ArrayList<Integer>();
property.add(3);
this.parameterizedList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedList");
replacedertEquals("java.util.ArrayList<java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("parameterizedList[0]");
replacedertEquals(3, expression.getValue(this));
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoGenericPropertyContainingGrowingList() {
List<String> property = new ArrayList<String>();
this.property = property;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
try {
replacedertEquals("bar", expression.getValue(this));
} catch (EvaluationException e) {
replacedertTrue(e.getMessage().startsWith("EL1053E"));
}
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoGenericPropertyContainingMapObject() {
Map<String, Map<String, String>> property = new HashMap<String, Map<String, String>>();
Map<String, String> map = new HashMap<String, String>();
map.put("foo", "bar");
property.put("property", map);
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
context.addPropertyAccessor(new MapAccessor());
context.setRootObject(property);
Expression expression = parser.parseExpression("property");
replacedertEquals("java.util.HashMap<?, ?>", expression.getValueTypeDescriptor(context).toString());
replacedertEquals(map, expression.getValue(context));
replacedertEquals(map, expression.getValue(context, Map.clreplaced));
expression = parser.parseExpression("property['foo']");
replacedertEquals("bar", expression.getValue(context));
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoGenericPropertyContainingGrowingList2() {
List<String> property2 = new ArrayList<String>();
this.property2 = property2;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property2");
replacedertEquals("java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property2, expression.getValue(this));
expression = parser.parseExpression("property2[0]");
try {
replacedertEquals("bar", expression.getValue(this));
} catch (EvaluationException e) {
replacedertTrue(e.getMessage().startsWith("EL1053E"));
}
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoGenericPropertyContainingMap() {
Map<String, String> property = new HashMap<String, String>();
property.put("foo", "bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.HashMap<?, ?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
replacedertEquals(property, expression.getValue(this, Map.clreplaced));
expression = parser.parseExpression("property['foo']");
replacedertEquals("bar", expression.getValue(this));
}
19
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoGenericPropertyContainingList() {
List<String> property = new ArrayList<String>();
property.add("bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
replacedertEquals("bar", expression.getValue(this));
}
18
View Source File : TemplateExpressionParsingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void testCompositeStringExpression() throws Exception {
SpelExpressionParser parser = new SpelExpressionParser();
Expression ex = parser.parseExpression("hello ${'world'}", DEFAULT_TEMPLATE_PARSER_CONTEXT);
checkString("hello world", ex.getValue());
checkString("hello world", ex.getValue(String.clreplaced));
checkString("hello world", ex.getValue((Object) null, String.clreplaced));
checkString("hello world", ex.getValue(new Rooty()));
checkString("hello world", ex.getValue(new Rooty(), String.clreplaced));
EvaluationContext ctx = new StandardEvaluationContext();
checkString("hello world", ex.getValue(ctx));
checkString("hello world", ex.getValue(ctx, String.clreplaced));
checkString("hello world", ex.getValue(ctx, null, String.clreplaced));
checkString("hello world", ex.getValue(ctx, new Rooty()));
checkString("hello world", ex.getValue(ctx, new Rooty(), String.clreplaced));
checkString("hello world", ex.getValue(ctx, new Rooty(), String.clreplaced));
replacedertEquals("hello ${'world'}", ex.getExpressionString());
replacedertFalse(ex.isWritable(new StandardEvaluationContext()));
replacedertFalse(ex.isWritable(new Rooty()));
replacedertFalse(ex.isWritable(new StandardEvaluationContext(), new Rooty()));
replacedertEquals(String.clreplaced, ex.getValueType());
replacedertEquals(String.clreplaced, ex.getValueType(ctx));
replacedertEquals(String.clreplaced, ex.getValueTypeDescriptor().getType());
replacedertEquals(String.clreplaced, ex.getValueTypeDescriptor(ctx).getType());
replacedertEquals(String.clreplaced, ex.getValueType(new Rooty()));
replacedertEquals(String.clreplaced, ex.getValueType(ctx, new Rooty()));
replacedertEquals(String.clreplaced, ex.getValueTypeDescriptor(new Rooty()).getType());
replacedertEquals(String.clreplaced, ex.getValueTypeDescriptor(ctx, new Rooty()).getType());
try {
ex.setValue(ctx, null);
fail();
} catch (EvaluationException ee) {
// success
}
try {
ex.setValue((Object) null, null);
fail();
} catch (EvaluationException ee) {
// success
}
try {
ex.setValue(ctx, null, null);
fail();
} catch (EvaluationException ee) {
// success
}
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void indexIntoPropertyContainingListOfList() {
List<List<Integer>> property = new ArrayList<>();
property.add(Arrays.asList(3));
this.parameterizedListOfList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedListOfList[0]");
replacedertEquals("java.util.Arrays$ArrayList<java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property.get(0), expression.getValue(this));
expression = parser.parseExpression("parameterizedListOfList[0][0]");
replacedertEquals(3, expression.getValue(this));
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void setGenericPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
replacedertEquals(3, expression.getValue(this));
expression.setValue(this, "4");
replacedertEquals("4", expression.getValue(this));
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@SuppressWarnings("unchecked")
@Test
public void resolveMapKeyValueTypes() {
mapNotGeneric = new HashMap();
mapNotGeneric.put("baseAmount", 3.11);
mapNotGeneric.put("bonusAmount", 7.17);
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("mapNotGeneric");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.HashMap<?, ?>", expression.getValueTypeDescriptor(this).toString());
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@SuppressWarnings("unchecked")
@Test
public void resolveCollectionElementType() {
listNotGeneric = new ArrayList(2);
listNotGeneric.add(5);
listNotGeneric.add(6);
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listNotGeneric");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals("5,6", expression.getValue(this, String.clreplaced));
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void setPropertyContainingMapAutoGrow() {
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, false));
Expression expression = parser.parseExpression("parameterizedMap");
replacedertEquals("java.util.Map<java.lang.Integer, java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("parameterizedMap['9']");
replacedertEquals(null, expression.getValue(this));
expression.setValue(this, "37");
replacedertEquals(37, expression.getValue(this));
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void setPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.parameterizedList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedList");
replacedertEquals("java.util.ArrayList<java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("parameterizedList[0]");
replacedertEquals(3, expression.getValue(this));
expression.setValue(this, "4");
replacedertEquals(4, expression.getValue(this));
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void setPropertyContainingMap() {
Map<Integer, Integer> property = new HashMap<>();
property.put(9, 3);
this.parameterizedMap = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedMap");
replacedertEquals("java.util.HashMap<java.lang.Integer, java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("parameterizedMap['9']");
replacedertEquals(3, expression.getValue(this));
expression.setValue(this, "37");
replacedertEquals(37, expression.getValue(this));
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void setGenericPropertyContainingListAutogrow() {
List<Integer> property = new ArrayList<>();
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
try {
expression.setValue(this, "4");
} catch (EvaluationException ex) {
replacedertTrue(ex.getMessage().startsWith("EL1053E"));
}
}
18
View Source File : IndexingTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void setGenericPropertyContainingMap() {
Map<String, String> property = new HashMap<>();
property.put("foo", "bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.HashMap<?, ?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property['foo']");
replacedertEquals("bar", expression.getValue(this));
expression.setValue(this, "baz");
replacedertEquals("baz", expression.getValue(this));
}
18
View Source File : TemplateExpressionParsingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void testCompositeStringExpression() throws Exception {
SpelExpressionParser parser = new SpelExpressionParser();
Expression ex = parser.parseExpression("hello ${'world'}", DEFAULT_TEMPLATE_PARSER_CONTEXT);
replacedertThat(ex.getValue()).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(String.clreplaced)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue((Object) null, String.clreplaced)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(new Rooty())).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(new Rooty(), String.clreplaced)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
EvaluationContext ctx = new StandardEvaluationContext();
replacedertThat(ex.getValue(ctx)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(ctx, String.clreplaced)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(ctx, null, String.clreplaced)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(ctx, new Rooty())).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(ctx, new Rooty(), String.clreplaced)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getValue(ctx, new Rooty(), String.clreplaced)).isInstanceOf(String.clreplaced).isEqualTo("hello world");
replacedertThat(ex.getExpressionString()).isEqualTo("hello ${'world'}");
replacedertThat(ex.isWritable(new StandardEvaluationContext())).isFalse();
replacedertThat(ex.isWritable(new Rooty())).isFalse();
replacedertThat(ex.isWritable(new StandardEvaluationContext(), new Rooty())).isFalse();
replacedertThat(ex.getValueType()).isEqualTo(String.clreplaced);
replacedertThat(ex.getValueType(ctx)).isEqualTo(String.clreplaced);
replacedertThat(ex.getValueTypeDescriptor().getType()).isEqualTo(String.clreplaced);
replacedertThat(ex.getValueTypeDescriptor(ctx).getType()).isEqualTo(String.clreplaced);
replacedertThat(ex.getValueType(new Rooty())).isEqualTo(String.clreplaced);
replacedertThat(ex.getValueType(ctx, new Rooty())).isEqualTo(String.clreplaced);
replacedertThat(ex.getValueTypeDescriptor(new Rooty()).getType()).isEqualTo(String.clreplaced);
replacedertThat(ex.getValueTypeDescriptor(ctx, new Rooty()).getType()).isEqualTo(String.clreplaced);
replacedertThatExceptionOfType(EvaluationException.clreplaced).isThrownBy(() -> ex.setValue(ctx, null));
replacedertThatExceptionOfType(EvaluationException.clreplaced).isThrownBy(() -> ex.setValue((Object) null, null));
replacedertThatExceptionOfType(EvaluationException.clreplaced).isThrownBy(() -> ex.setValue(ctx, null, null));
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void indexIntoPropertyContainingListOfList() {
List<List<Integer>> property = new ArrayList<>();
property.add(Arrays.asList(3));
this.parameterizedListOfList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedListOfList[0]");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.Arrays$ArrayList<java.lang.Integer>");
replacedertThat(expression.getValue(this)).isEqualTo(property.get(0));
expression = parser.parseExpression("parameterizedListOfList[0][0]");
replacedertThat(expression.getValue(this)).isEqualTo(3);
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void setGenericPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("property[0]");
replacedertThat(expression.getValue(this)).isEqualTo(3);
expression.setValue(this, "4");
replacedertThat(expression.getValue(this)).isEqualTo("4");
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
@SuppressWarnings("unchecked")
public void indexIntoGenericPropertyContainingMap() {
Map<String, String> property = new HashMap<>();
property.put("foo", "bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.HashMap<?, ?>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
replacedertThat(expression.getValue(this, Map.clreplaced)).isEqualTo(property);
expression = parser.parseExpression("property['foo']");
replacedertThat(expression.getValue(this)).isEqualTo("bar");
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void setPropertyContainingMap() {
Map<Integer, Integer> property = new HashMap<>();
property.put(9, 3);
this.parameterizedMap = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedMap");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.HashMap<java.lang.Integer, java.lang.Integer>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("parameterizedMap['9']");
replacedertThat(expression.getValue(this)).isEqualTo(3);
expression.setValue(this, "37");
replacedertThat(expression.getValue(this)).isEqualTo(37);
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void setGenericPropertyContainingMap() {
Map<String, String> property = new HashMap<>();
property.put("foo", "bar");
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.HashMap<?, ?>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("property['foo']");
replacedertThat(expression.getValue(this)).isEqualTo("bar");
expression.setValue(this, "baz");
replacedertThat(expression.getValue(this)).isEqualTo("baz");
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void setPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.parameterizedList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedList");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.ArrayList<java.lang.Integer>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("parameterizedList[0]");
replacedertThat(expression.getValue(this)).isEqualTo(3);
expression.setValue(this, "4");
replacedertThat(expression.getValue(this)).isEqualTo(4);
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void setGenericPropertyContainingListAutogrow() {
List<Integer> property = new ArrayList<>();
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("property[0]");
try {
expression.setValue(this, "4");
} catch (EvaluationException ex) {
replacedertThat(ex.getMessage().startsWith("EL1053E")).isTrue();
}
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
@SuppressWarnings("unchecked")
public void indexIntoGenericPropertyContainingMapObject() {
Map<String, Map<String, String>> property = new HashMap<>();
Map<String, String> map = new HashMap<>();
map.put("foo", "bar");
property.put("property", map);
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
context.addPropertyAccessor(new MapAccessor());
context.setRootObject(property);
Expression expression = parser.parseExpression("property");
replacedertThat(expression.getValueTypeDescriptor(context).toString()).isEqualTo("java.util.HashMap<?, ?>");
replacedertThat(expression.getValue(context)).isEqualTo(map);
replacedertThat(expression.getValue(context, Map.clreplaced)).isEqualTo(map);
expression = parser.parseExpression("property['foo']");
replacedertThat(expression.getValue(context)).isEqualTo("bar");
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@SuppressWarnings("unchecked")
@Test
public void resolveMapKeyValueTypes() {
mapNotGeneric = new HashMap();
mapNotGeneric.put("baseAmount", 3.11);
mapNotGeneric.put("bonusAmount", 7.17);
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("mapNotGeneric");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.HashMap<?, ?>");
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@SuppressWarnings("unchecked")
@Test
public void resolveCollectionElementType() {
listNotGeneric = new ArrayList(2);
listNotGeneric.add(5);
listNotGeneric.add(6);
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listNotGeneric");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>");
replacedertThat(expression.getValue(this, String.clreplaced)).isEqualTo("5,6");
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void setPropertyContainingMapAutoGrow() {
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, false));
Expression expression = parser.parseExpression("parameterizedMap");
replacedertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.Map<java.lang.Integer, java.lang.Integer>");
replacedertThat(expression.getValue(this)).isEqualTo(property);
expression = parser.parseExpression("parameterizedMap['9']");
replacedertThat(expression.getValue(this)).isEqualTo(null);
expression.setValue(this, "37");
replacedertThat(expression.getValue(this)).isEqualTo(37);
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void setPropertyContainingMap() {
Map<Integer, Integer> property = new HashMap<Integer, Integer>();
property.put(9, 3);
this.parameterizedMap = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedMap");
replacedertEquals("java.util.HashMap<java.lang.Integer, java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("parameterizedMap['9']");
replacedertEquals(3, expression.getValue(this));
expression.setValue(this, "37");
replacedertEquals(37, expression.getValue(this));
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void setGenericPropertyContainingListAutogrow() {
List<Integer> property = new ArrayList<Integer>();
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
Expression expression = parser.parseExpression("property");
replacedertEquals("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.ArrayList<?>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property, expression.getValue(this));
expression = parser.parseExpression("property[0]");
try {
expression.setValue(this, "4");
} catch (EvaluationException e) {
replacedertTrue(e.getMessage().startsWith("EL1053E"));
}
}
18
View Source File : IndexingTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void indexIntoPropertyContainingListOfList() {
List<List<Integer>> property = new ArrayList<List<Integer>>();
property.add(Arrays.asList(3));
this.parameterizedListOfList = property;
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("parameterizedListOfList[0]");
replacedertEquals("java.util.Arrays$ArrayList<java.lang.Integer>", expression.getValueTypeDescriptor(this).toString());
replacedertEquals(property.get(0), expression.getValue(this));
expression = parser.parseExpression("parameterizedListOfList[0][0]");
replacedertEquals(3, expression.getValue(this));
}
See More Examples