use of org.springframework.expression.Expression in project spring-framework by spring-projects.
the class SpelCompilationPerformanceTests method compilingPropertyReferenceNestedMixedFieldGetter.
@Test
public void compilingPropertyReferenceNestedMixedFieldGetter() throws Exception {
long interpretedTotal = 0, compiledTotal = 0, stime, etime;
String interpretedResult = null, compiledResult = null;
TestClass2 testdata = new TestClass2();
Expression expression = parser.parseExpression("foo.baz.boo");
// warmup
for (int i = 0; i < count; i++) {
expression.getValue(testdata, String.class);
}
log("timing interpreted: ");
for (int i = 0; i < iterations; i++) {
stime = System.currentTimeMillis();
for (int j = 0; j < count; j++) {
interpretedResult = expression.getValue(testdata, String.class);
}
etime = System.currentTimeMillis();
long interpretedSpeed = (etime - stime);
interpretedTotal += interpretedSpeed;
log(interpretedSpeed + "ms ");
}
logln();
compile(expression);
log("timing compiled: ");
expression.getValue(testdata, String.class);
for (int i = 0; i < iterations; i++) {
stime = System.currentTimeMillis();
for (int j = 0; j < count; j++) {
compiledResult = expression.getValue(testdata, String.class);
}
etime = System.currentTimeMillis();
long compiledSpeed = (etime - stime);
compiledTotal += compiledSpeed;
log(compiledSpeed + "ms ");
}
logln();
assertEquals(interpretedResult, compiledResult);
reportPerformance("nested property reference (mixed field/getter)", interpretedTotal, compiledTotal);
}
use of org.springframework.expression.Expression in project spring-framework by spring-projects.
the class SpelCompilationPerformanceTests method compilingPropertyReferenceField.
@Test
public void compilingPropertyReferenceField() throws Exception {
long interpretedTotal = 0, compiledTotal = 0, stime, etime;
String interpretedResult = null, compiledResult = null;
TestClass2 testdata = new TestClass2();
Expression expression = parser.parseExpression("name");
// warmup
for (int i = 0; i < count; i++) {
expression.getValue(testdata, String.class);
}
log("timing interpreted: ");
for (int i = 0; i < iterations; i++) {
stime = System.currentTimeMillis();
for (int j = 0; j < count; j++) {
interpretedResult = expression.getValue(testdata, String.class);
}
etime = System.currentTimeMillis();
long interpretedSpeed = (etime - stime);
interpretedTotal += interpretedSpeed;
log(interpretedSpeed + "ms ");
}
logln();
compile(expression);
log("timing compiled: ");
expression.getValue(testdata, String.class);
for (int i = 0; i < iterations; i++) {
stime = System.currentTimeMillis();
for (int j = 0; j < count; j++) {
compiledResult = expression.getValue(testdata, String.class);
}
etime = System.currentTimeMillis();
long compiledSpeed = (etime - stime);
compiledTotal += compiledSpeed;
log(compiledSpeed + "ms ");
}
logln();
assertEquals(interpretedResult, compiledResult);
reportPerformance("property reference (field)", interpretedTotal, compiledTotal);
}
use of org.springframework.expression.Expression in project spring-framework by spring-projects.
the class SpelReproTests method SPR10328.
@Test
public void SPR10328() throws Exception {
thrown.expect(SpelParseException.class);
thrown.expectMessage("EL1071E: A required selection expression has not been specified");
Expression exp = parser.parseExpression("$[]");
exp.getValue(Arrays.asList("foo", "bar", "baz"));
}
use of org.springframework.expression.Expression in project spring-framework by spring-projects.
the class SpelReproTests method SPR9486_floatEqFloat.
@Test
public void SPR9486_floatEqFloat() {
Boolean expectedResult = 10.215f == 10.2109f;
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("10.215f == 10.2109f");
Boolean result = expression.getValue(context, null, Boolean.class);
assertEquals(expectedResult, result);
}
use of org.springframework.expression.Expression in project spring-framework by spring-projects.
the class SpelReproTests method SPR10210.
@Test
public void SPR10210() throws Exception {
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable("bridgeExample", new org.springframework.expression.spel.spr10210.D());
Expression parseExpression = parser.parseExpression("#bridgeExample.bridgeMethod()");
parseExpression.getValue(context);
}
Aggregations