removed redundant test - there is no non-optimal reflection accessor to test now

This commit is contained in:
Andy Clement 2008-08-16 01:42:39 +00:00
parent 3987316e4c
commit 8730cde270
1 changed files with 24 additions and 40 deletions

View File

@ -20,7 +20,6 @@ import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.spel.reflection.ReflectionPropertyResolver;
import org.springframework.expression.spel.standard.StandardEvaluationContext;
/**
@ -38,24 +37,6 @@ public class PropertyAccessTests extends ExpressionTestCase {
evaluate("placeOfBirth.city", "SmilJan", String.class);
}
public void testSimpleAccess03() {
try {
ReflectionPropertyResolver.useResolverExecutorModel = false;
evaluate("name", "Nikola Tesla", String.class);
} finally {
ReflectionPropertyResolver.useResolverExecutorModel = true;
}
}
public void testSimpleAccess04() {
try {
ReflectionPropertyResolver.useResolverExecutorModel = false;
evaluate("placeOfBirth.city", "SmilJan", String.class);
} finally {
ReflectionPropertyResolver.useResolverExecutorModel = true;
}
}
public void testNonExistentPropertiesAndMethods() {
// madeup does not exist as a property
evaluateAndCheckError("madeup", SpelMessages.PROPERTY_OR_FIELD_NOT_FOUND, 0);
@ -74,24 +55,27 @@ public class PropertyAccessTests extends ExpressionTestCase {
}
public boolean canRead(EvaluationContext context, Object target, Object name) throws AccessException {
if (!(target instanceof String)) throw new RuntimeException("Assertion Failed! target should be String");
if (!(target instanceof String))
throw new RuntimeException("Assertion Failed! target should be String");
return (name.equals("flibbles"));
}
public boolean canWrite(EvaluationContext context, Object target, Object name) throws AccessException {
if (!(target instanceof String)) throw new RuntimeException("Assertion Failed! target should be String");
if (!(target instanceof String))
throw new RuntimeException("Assertion Failed! target should be String");
return (name.equals("flibbles"));
}
public Object read(EvaluationContext context, Object target, Object name) throws AccessException {
if (!name.equals("flibbles") ) throw new RuntimeException("Assertion Failed! name should be flibbles");
if (!name.equals("flibbles"))
throw new RuntimeException("Assertion Failed! name should be flibbles");
return flibbles;
}
public void write(EvaluationContext context, Object target, Object name, Object newValue)
throws AccessException {
if (!name.equals("flibbles") ) throw new RuntimeException("Assertion Failed! name should be flibbles");
if (!name.equals("flibbles"))
throw new RuntimeException("Assertion Failed! name should be flibbles");
try {
flibbles = (Integer) context.getTypeUtils().getTypeConverter().convertValue(newValue, Integer.class);
} catch (EvaluationException e) {
@ -124,13 +108,13 @@ public class PropertyAccessTests extends ExpressionTestCase {
i = (Integer) expr.getValue(ctx, Integer.class);
assertEquals((int) i, 99);
// Cannot set it to a string value
try {
expr.setValue(ctx, "not allowed");
fail("Should not have been allowed");
} catch (EvaluationException e) {
// success - message will be: EL1063E:(pos 20): A problem occurred whilst attempting to set the property 'flibbles': 'Cannot set flibbles to an object of type 'class java.lang.String''
// success - message will be: EL1063E:(pos 20): A problem occurred whilst attempting to set the property
// 'flibbles': 'Cannot set flibbles to an object of type 'class java.lang.String''
System.out.println(e.getMessage());
}
}