TypeDescriptor cleanup and general polishing; fixed a number of bugs related to TypeDescriptor usage in client code across beans and spel packages

This commit is contained in:
Keith Donald
2011-01-05 05:49:33 +00:00
parent 74b5b7b56a
commit 39e0c29d19
33 changed files with 449 additions and 539 deletions

View File

@@ -26,7 +26,6 @@ import java.util.Map;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.EvaluationException;
@@ -247,7 +246,6 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
private static class FruitColourAccessor implements PropertyAccessor {
private static Map<String,Color> propertyMap = new HashMap<String,Color>();
private static TypeDescriptor mapElementTypeDescriptor = TypeDescriptor.valueOf(Color.class);
static {
propertyMap.put("banana",Color.yellow);
@@ -267,7 +265,7 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(propertyMap.get(name),mapElementTypeDescriptor);
return new TypedValue(propertyMap.get(name));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
@@ -306,7 +304,7 @@ public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(propertyMap.get(name),TypeDescriptor.valueOf(Color.class));
return new TypedValue(propertyMap.get(name));
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {

View File

@@ -127,7 +127,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
Assert.assertEquals(TypedValue.NULL,state.getRootContextObject());
((StandardEvaluationContext)state.getEvaluationContext()).setRootObject(null,TypeDescriptor.NULL);
((StandardEvaluationContext)state.getEvaluationContext()).setRootObject(null);
Assert.assertEquals(null,state.getRootContextObject().getValue());
}

View File

@@ -180,7 +180,7 @@ public class PropertyAccessTests extends ExpressionTestCase {
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
if (!name.equals("flibbles"))
throw new RuntimeException("Assertion Failed! name should be flibbles");
return new TypedValue(flibbles, TypeDescriptor.valueOf(String.class));
return new TypedValue(flibbles);
}
public void write(EvaluationContext context, Object target, String name, Object newValue)

View File

@@ -20,8 +20,8 @@ import java.lang.reflect.Method;
import java.util.List;
import junit.framework.Assert;
import org.junit.Test;
import org.junit.Test;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
@@ -222,7 +222,7 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(new Principal(),TypeDescriptor.valueOf(Principal.class));
return new TypedValue(new Principal());
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {
@@ -252,7 +252,7 @@ public class ScenariosForSpringSecurity extends ExpressionTestCase {
}
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
return new TypedValue(activePerson,TypeDescriptor.valueOf(Person.class));
return new TypedValue(activePerson);
}
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException {

View File

@@ -69,6 +69,9 @@ public class SpelDocumentationTests extends ExpressionTestCase {
public Inventor[] Members = new Inventor[1];
public List Members2 = new ArrayList();
public Map<String,Object> officers = new HashMap<String,Object>();
public List reverse = new ArrayList<Map<String, Object>>();
@SuppressWarnings("unchecked")
IEEE() {
officers.put("president",pupin);
@@ -77,6 +80,8 @@ public class SpelDocumentationTests extends ExpressionTestCase {
officers.put("advisors",linv);
Members2.add(tesla);
Members2.add(pupin);
reverse.add(officers);
}
public boolean isMember(String name) {
@@ -215,6 +220,9 @@ public class SpelDocumentationTests extends ExpressionTestCase {
parser.parseExpression("officers['advisors'][0].PlaceOfBirth.Country").setValue(societyContext, "Croatia");
Inventor i2 = parser.parseExpression("reverse[0]['advisors'][0]").getValue(societyContext,Inventor.class);
Assert.assertEquals("Nikola Tesla",i2.getName());
}
// 7.5.3