You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2009/08/05 02:11:00 UTC
svn commit: r801037 - in
/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl:
ArithmeticTest.java ArrayAccessTest.java CacheTest.java Foo.java
MethodTest.java util/introspection/MethodKeyTest.java
Author: sebb
Date: Wed Aug 5 00:11:00 2009
New Revision: 801037
URL: http://svn.apache.org/viewvc?rev=801037&view=rev
Log:
Type safety fixes and explicit boxing
Modified:
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/CacheTest.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/Foo.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java
commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/util/introspection/MethodKeyTest.java
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java?rev=801037&r1=801036&r2=801037&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArithmeticTest.java Wed Aug 5 00:11:00 2009
@@ -122,7 +122,7 @@
*/
public void testDivideByZero() throws Exception {
JexlContext context = JexlHelper.createContext();
- Map vars = context.getVars();
+ Map<String, Object> vars = context.getVars();
vars.put("aByte", new Byte((byte) 1));
vars.put("aShort", new Short((short) 2));
vars.put("aInteger", new Integer(3));
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java?rev=801037&r1=801036&r2=801037&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/ArrayAccessTest.java Wed Aug 5 00:11:00 2009
@@ -54,7 +54,7 @@
* test List access
*/
- List l = new ArrayList();
+ List<Integer> l = new ArrayList<Integer>();
l.add(new Integer(1));
l.add(new Integer(2));
l.add(new Integer(3));
@@ -82,7 +82,7 @@
/*
* test map access
*/
- Map m = new HashMap();
+ Map<String, String> m = new HashMap<String, String>();
m.put("foo", "bar");
asserter.setVariable("map", m);
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/CacheTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/CacheTest.java?rev=801037&r1=801036&r2=801037&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/CacheTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/CacheTest.java Wed Aug 5 00:11:00 2009
@@ -127,11 +127,11 @@
}
public void setFlag(boolean b) {
- flag = b;
+ flag = Boolean.valueOf(b);
}
public boolean isFlag() {
- return flag;
+ return flag.booleanValue();
}
}
@@ -157,7 +157,7 @@
if ("value".equals(prop)) {
return value;
} else if ("flag".equals(prop)) {
- return flag;
+ return Boolean.valueOf(flag);
}
throw new RuntimeException("no such property");
}
@@ -428,8 +428,8 @@
vars.put("a1", "S1");
expected = "Cached" + mix + "@s#S0,s#S1";
} else if (x.value instanceof Integer) {
- vars.put("a0", 7);
- vars.put("a1", 9);
+ vars.put("a0", Integer.valueOf(7));
+ vars.put("a1", Integer.valueOf(9));
expected = "Cached" + mix + "@i#7,i#9";
} else {
fail("unexpected value type");
@@ -439,8 +439,8 @@
if (x.value instanceof Integer) {
try {
- vars.put("a0", (short) 17);
- vars.put("a1", (short) 19);
+ vars.put("a0", Short.valueOf((short) 17));
+ vars.put("a1", Short.valueOf((short) 19));
result = ambiguous.evaluate(jc);
fail("should have thrown an exception");
} catch (JexlException xany) {
@@ -452,7 +452,7 @@
vars.put("a0", "X0");
expected = "Cached" + mix + "@s#X0";
} else if (x.value instanceof Integer) {
- vars.put("a0", 5);
+ vars.put("a0", Integer.valueOf(5));
expected = "Cached" + mix + "@i#5";
} else {
fail("unexpected value type");
@@ -525,8 +525,8 @@
vars.put("a1", "S1");
expected = "CACHED@s#S0,s#S1";
} else if (x.value instanceof Integer) {
- vars.put("a0", 7);
- vars.put("a1", 9);
+ vars.put("a0", Integer.valueOf(7));
+ vars.put("a1", Integer.valueOf(9));
expected = "CACHED@i#7,i#9";
} else {
fail("unexpected value type");
@@ -538,7 +538,7 @@
vars.put("a0", "X0");
expected = "CACHED@s#X0";
} else if (x.value instanceof Integer) {
- vars.put("a0", 5);
+ vars.put("a0", Integer.valueOf(5));
expected = "CACHED@i#5";
} else {
fail("unexpected value type");
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/Foo.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/Foo.java?rev=801037&r1=801036&r2=801037&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/Foo.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/Foo.java Wed Aug 5 00:11:00 2009
@@ -61,9 +61,9 @@
return 5;
}
- public List getCheeseList()
+ public List<String> getCheeseList()
{
- ArrayList answer = new ArrayList();
+ ArrayList<String> answer = new ArrayList<String>();
answer.add("cheddar");
answer.add("edam");
answer.add("brie");
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java?rev=801037&r1=801036&r2=801037&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/MethodTest.java Wed Aug 5 00:11:00 2009
@@ -100,7 +100,7 @@
}
public void testTopLevelCall() throws Exception {
- java.util.Map funcs = new java.util.HashMap();
+ java.util.Map<String, Object> funcs = new java.util.HashMap<String, Object>();
funcs.put(null, new Functor());
JexlEngine JEXL = new JexlEngine();
JEXL.setFunctions(funcs);
@@ -122,7 +122,7 @@
}
public void testNamespaceCall() throws Exception {
- java.util.Map funcs = new java.util.HashMap();
+ java.util.Map<String, Object> funcs = new java.util.HashMap<String, Object>();
funcs.put("func", new Functor());
funcs.put("FUNC", Functor.class);
JexlEngine JEXL = new JexlEngine();
Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/util/introspection/MethodKeyTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/util/introspection/MethodKeyTest.java?rev=801037&r1=801036&r2=801037&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/util/introspection/MethodKeyTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl/util/introspection/MethodKeyTest.java Wed Aug 5 00:11:00 2009
@@ -21,7 +21,7 @@
*/
public class MethodKeyTest extends TestCase {
// A set of classes (most of them primitives)
- static Class[] PRIMS = {
+ static Class<?>[] PRIMS = {
Boolean.TYPE,
Byte.TYPE,
Character.TYPE,
@@ -82,7 +82,7 @@
static MethodKey[] keyList;
/** Creates & inserts a key into the byKey & byString map */
- static void setUpKey(String name, Class[] parms) {
+ static void setUpKey(String name, Class<?>[] parms) {
MethodKey key = new MethodKey(name, parms);
String str = key.toString();
byKey.put(key, str);
@@ -97,13 +97,13 @@
for (int m = 0; m < METHODS.length; ++m) {
String method = METHODS[m];
for (int p0 = 0; p0 < PRIMS.length; ++p0) {
- Class[] arg0 = {PRIMS[p0]};
+ Class<?>[] arg0 = {PRIMS[p0]};
setUpKey(method, arg0);
for (int p1 = 0; p1 < PRIMS.length; ++p1) {
- Class[] arg1 = {PRIMS[p0], PRIMS[p1]};
+ Class<?>[] arg1 = {PRIMS[p0], PRIMS[p1]};
setUpKey(method, arg1);
for (int p2 = 0; p2 < PRIMS.length; ++p2) {
- Class[] arg2 = {PRIMS[p0], PRIMS[p1], PRIMS[p2]};
+ Class<?>[] arg2 = {PRIMS[p0], PRIMS[p1], PRIMS[p2]};
setUpKey(method, arg2);
}
}
@@ -113,7 +113,7 @@
}
/** Builds a string key */
- String makeStringKey(String method, Class... params) {
+ String makeStringKey(String method, Class<?>... params) {
StringBuilder builder = new StringBuilder(method);
for(int p = 0; p < params.length; ++p) {
builder.append(ClassMap.MethodCache.primitiveClass(params[p]).getName());
@@ -122,19 +122,19 @@
}
/** Checks that a string key does exist */
- void checkStringKey(String method, Class... params) {
+ void checkStringKey(String method, Class<?>... params) {
String key = makeStringKey(method, params);
MethodKey out = byString.get(key);
assertTrue(out != null);
}
/** Builds a method key */
- MethodKey makeKey(String method, Class... params) {
+ MethodKey makeKey(String method, Class<?>... params) {
return new MethodKey(method, params);
}
/** Checks that a method key exists */
- void checkKey(String method, Class... params) {
+ void checkKey(String method, Class<?>... params) {
MethodKey key = makeKey(method, params);
String out = byKey.get(key);
assertTrue(out != null);