Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java Sat Jan 28 19:21:08 2017 @@ -145,9 +145,9 @@ public class ClassMap populateMethodCacheWith(methodCache, classToReflect); } Class [] interfaces = classToReflect.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) + for (Class anInterface : interfaces) { - populateMethodCacheWithInterface(methodCache, interfaces[i]); + populateMethodCacheWithInterface(methodCache, anInterface); } } // return the already initialized cache @@ -162,9 +162,9 @@ public class ClassMap populateMethodCacheWith(methodCache, iface); } Class[] supers = iface.getInterfaces(); - for (int i=0; i < supers.length; i++) + for (Class aSuper : supers) { - populateMethodCacheWithInterface(methodCache, supers[i]); + populateMethodCacheWithInterface(methodCache, aSuper); } } @@ -178,12 +178,12 @@ public class ClassMap try { Method[] methods = classToReflect.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) + for (Method method : methods) { - int modifiers = methods[i].getModifiers(); + int modifiers = method.getModifiers(); if (Modifier.isPublic(modifiers)) { - methodCache.put(methods[i]); + methodCache.put(method); } } } @@ -327,7 +327,7 @@ public class ClassMap StringBuilder methodKey = new StringBuilder((args+1)*16).append(method.getName()); - for (int j = 0; j < args; j++) + for (Class parameterType : parameterTypes) { /* * If the argument type is primitive then we want @@ -339,13 +339,12 @@ public class ClassMap * primitives (boolean, byte, char, double, float, int, long, short) * known to Java. So it should never return null for the key passed in. */ - if (parameterTypes[j].isPrimitive()) + if (parameterType.isPrimitive()) { - methodKey.append((String) convertPrimitives.get(parameterTypes[j])); - } - else + methodKey.append((String) convertPrimitives.get(parameterType)); + } else { - methodKey.append(parameterTypes[j].getName()); + methodKey.append(parameterType.getName()); } } @@ -362,9 +361,8 @@ public class ClassMap StringBuilder methodKey = new StringBuilder((args+1)*16).append(method); - for (int j = 0; j < args; j++) + for (Object arg : params) { - Object arg = params[j]; if (arg == null) { methodKey.append(NULL_ARG);
Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandler.java Sat Jan 28 19:21:08 2017 @@ -23,7 +23,7 @@ package org.apache.velocity.util.introsp * A conversion handler adds admissible conversions between Java types whenever Velocity introspection has to map * VTL methods and property accessors to Java methods. * Both methods must be consistent: <code>getNeededConverter</code> must not return <code>null</code> whenever - * <code>isExplicitelyConvertible</code> returned true with the same arguments. + * <code>isExplicitlyConvertible</code> returned true with the same arguments. * * @author <a href="mailto:claude.bris...@gmail.com">Claude Brisson</a> * @version $Id: ConversionHandler.java $ @@ -39,7 +39,7 @@ public interface ConversionHandler * @return null if no conversion is needed, or the appropriate Converter object * @since 2.0 */ - public boolean isExplicitlyConvertible(Class formal, Class actual, boolean possibleVarArg); + boolean isExplicitlyConvertible(Class formal, Class actual, boolean possibleVarArg); /** * Returns the appropriate Converter object needed for an explicit conversion @@ -50,7 +50,7 @@ public interface ConversionHandler * @return null if no conversion is needed, or the appropriate Converter object * @since 2.0 */ - public Converter getNeededConverter(final Class formal, final Class actual); + Converter getNeededConverter(final Class formal, final Class actual); /** * Add the given converter to the handler. Implementation should be thread-safe. @@ -60,5 +60,5 @@ public interface ConversionHandler * @param converter converter * @since 2.0 */ - public void addConverter(Class formal, Class actual, Converter converter); + void addConverter(Class formal, Class actual, Converter converter); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ConversionHandlerImpl.java Sat Jan 28 19:21:08 2017 @@ -71,7 +71,7 @@ public class ConversionHandlerImpl imple static { - standardConverterMap = new HashMap<Pair<? extends Class, ? extends Class>, Converter>(); + standardConverterMap = new HashMap<>(); cacheMiss = new Converter<Object>() { @@ -122,7 +122,7 @@ public class ConversionHandlerImpl imple @Override public Boolean convert(Object o) { - return o == null ? null : ((Character) o).charValue() != 0; + return o == null ? null : (Character) o != 0; } }; standardConverterMap.put(new Pair<>(Boolean.class, Character.class), charToBoolean); @@ -418,7 +418,7 @@ public class ConversionHandlerImpl imple @Override public Byte convert(Object o) { - return o == null ? null : ((Boolean)o).booleanValue() ? (byte)1 : (byte)0; + return o == null ? null : (Boolean) o ? (byte)1 : (byte)0; } }; standardConverterMap.put(new Pair<>(Byte.class, Boolean.class), booleanToByte); @@ -432,7 +432,7 @@ public class ConversionHandlerImpl imple @Override public Short convert(Object o) { - return o == null ? null : ((Boolean)o).booleanValue() ? (short)1 : (short)0; + return o == null ? null : (Boolean) o ? (short)1 : (short)0; } }; standardConverterMap.put(new Pair<>(Short.class, Boolean.class), booleanToShort); @@ -446,7 +446,7 @@ public class ConversionHandlerImpl imple @Override public Integer convert(Object o) { - return o == null ? null : ((Boolean)o).booleanValue() ? (Integer)1 : (Integer)0; + return o == null ? null : (Boolean) o ? (Integer)1 : (Integer)0; } }; standardConverterMap.put(new Pair<>(Integer.class, Boolean.class), booleanToInteger); @@ -460,7 +460,7 @@ public class ConversionHandlerImpl imple @Override public Long convert(Object o) { - return o == null ? null : ((Boolean)o).booleanValue() ? 1L : 0L; + return o == null ? null : (Boolean) o ? 1L : 0L; } }; standardConverterMap.put(new Pair<>(Long.class, Boolean.class), booleanToLong); @@ -484,7 +484,7 @@ public class ConversionHandlerImpl imple */ public ConversionHandlerImpl() { - converterCacheMap = new ConcurrentHashMap<Pair<? extends Class, ? extends Class>, Converter>(); + converterCacheMap = new ConcurrentHashMap<>(); } /** Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectionUtils.java Sat Jan 28 19:21:08 2017 @@ -44,7 +44,7 @@ public class IntrospectionUtils static { - boxingMap = new HashMap<Class, Class>(); + boxingMap = new HashMap<>(); boxingMap.put(Boolean.TYPE, Boolean.class); boxingMap.put(Character.TYPE, Character.class); boxingMap.put(Byte.TYPE, Byte.class); @@ -54,8 +54,8 @@ public class IntrospectionUtils boxingMap.put(Float.TYPE, Float.class); boxingMap.put(Double.TYPE, Double.class); - unboxingMap = new HashMap<Class, Class>(); - for (Map.Entry<Class,Class> entry : (Set<Map.Entry<Class,Class>>)boxingMap.entrySet()) + unboxingMap = new HashMap<>(); + for (Map.Entry<Class,Class> entry : boxingMap.entrySet()) { unboxingMap.put(entry.getValue(), entry.getKey()); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/MethodMap.java Sat Jan 28 19:21:08 2017 @@ -155,7 +155,7 @@ public class MethodMap return getBestMatch(methodList, classes); } - private Method getBestMatch(List methods, Class[] args) + private Method getBestMatch(List<Method> methods, Class[] args) { List equivalentMatches = null; Method bestMatch = null; @@ -166,9 +166,8 @@ public class MethodMap { unboxedArgs[i] = IntrospectionUtils.getUnboxedClass(args[i]); } - for (Iterator i = methods.iterator(); i.hasNext(); ) + for (Method method : methods) { - Method method = (Method)i.next(); if (isApplicable(method, args)) { if (bestMatch == null) @@ -176,8 +175,7 @@ public class MethodMap bestMatch = method; bestMatchTypes = method.getParameterTypes(); bestMatchComp = compare(bestMatchTypes, unboxedArgs); - } - else + } else { Class[] methodTypes = method.getParameterTypes(); switch (compare(methodTypes, bestMatchTypes)) @@ -195,14 +193,13 @@ public class MethodMap bestMatch = method; bestMatchTypes = methodTypes; bestMatchComp = compare(bestMatchTypes, unboxedArgs); - } - else + } else { /* have to beat all other ambiguous ones... */ int ambiguities = equivalentMatches.size(); for (int a = 0; a < ambiguities; a++) { - Method other = (Method)equivalentMatches.get(a); + Method other = (Method) equivalentMatches.get(a); switch (compare(methodTypes, other.getParameterTypes())) { case MORE_SPECIFIC: Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorControl.java Sat Jan 28 19:21:08 2017 @@ -37,6 +37,6 @@ public interface SecureIntrospectorContr * * @return true if method may be called on object */ - public boolean checkObjectExecutePermission(Class clazz, String method); + boolean checkObjectExecutePermission(Class clazz, String method); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.java Sat Jan 28 19:21:08 2017 @@ -134,17 +134,17 @@ public class SecureIntrospectorImpl exte int dotPos = className.lastIndexOf('.'); String packageName = (dotPos == -1) ? "" : className.substring(0, dotPos); - for (int i = 0, size = badPackages.length; i < size; i++) + for (String badPackage : badPackages) { - if (packageName.equals(badPackages[i])) + if (packageName.equals(badPackage)) { return false; } } - for (int i = 0, size = badClasses.length; i < size; i++) + for (String badClass : badClasses) { - if (className.equals(badClasses[i])) + if (className.equals(badClass)) { return false; } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Uberspect.java Sat Jan 28 19:21:08 2017 @@ -33,7 +33,7 @@ public interface Uberspect /** * Initializer - will be called before use */ - public void init(); + void init(); /** * To support iteratives - #foreach() @@ -41,7 +41,7 @@ public interface Uberspect * @param info * @return An Iterator. */ - public Iterator getIterator(Object obj, Info info); + Iterator getIterator(Object obj, Info info); /** * Returns a general method, corresponding to $foo.bar( $woogie ) @@ -51,7 +51,7 @@ public interface Uberspect * @param info * @return A Velocity Method. */ - public VelMethod getMethod(Object obj, String method, Object[] args, Info info); + VelMethod getMethod(Object obj, String method, Object[] args, Info info); /** * Property getter - returns VelPropertyGet appropos for #set($foo = $bar.woogie) @@ -60,7 +60,7 @@ public interface Uberspect * @param info * @return A Velocity Getter. */ - public VelPropertyGet getPropertyGet(Object obj, String identifier, Info info); + VelPropertyGet getPropertyGet(Object obj, String identifier, Info info); /** * Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir") @@ -70,5 +70,5 @@ public interface Uberspect * @param info * @return A Velocity Setter. */ - public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info info); + VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info info); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java Sat Jan 28 19:21:08 2017 @@ -524,10 +524,10 @@ public class UberspectImpl implements Ub Class last = formal[formal.length - 1]; // if the last arg is an array, then // we consider this a varargs method - this.isVarArg = Boolean.valueOf(last.isArray()); + this.isVarArg = last.isArray(); } } - return isVarArg.booleanValue(); + return isVarArg; } /** @@ -580,10 +580,7 @@ public class UberspectImpl implements Ub // put all into a new actual array of the appropriate size Object[] newActual = new Object[index + 1]; - for (int i = 0; i < index; i++) - { - newActual[i] = actual[i]; - } + System.arraycopy(actual, 0, newActual, 0, index); newActual[index] = lastActual; // replace the old actual array Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelMethod.java Sat Jan 28 19:21:08 2017 @@ -41,7 +41,7 @@ public interface VelMethod * @return The resulting object. * @throws IllegalAccessException, InvocationTargetException */ - public Object invoke(Object o, Object[] params) + Object invoke(Object o, Object[] params) throws IllegalAccessException, InvocationTargetException; /** @@ -50,24 +50,24 @@ public interface VelMethod * * @return true if can be reused for this class, false if not */ - public boolean isCacheable(); + boolean isCacheable(); /** * returns the method name used * @return The method name used */ - public String getMethodName(); + String getMethodName(); /** * returns the underlying Method * @return the method * @since 2.0 */ - public Method getMethod(); + Method getMethod(); /** * returns the return type of the method invoked * @return The return type of the method invoked */ - public Class getReturnType(); + Class getReturnType(); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertyGet.java Sat Jan 28 19:21:08 2017 @@ -37,7 +37,7 @@ public interface VelPropertyGet * @return The resulting Object. * @throws Exception */ - public Object invoke(Object o) throws Exception; + Object invoke(Object o) throws Exception; /** * specifies if this VelPropertyGet is cacheable and able to be @@ -45,11 +45,11 @@ public interface VelPropertyGet * * @return true if can be reused for this class, false if not */ - public boolean isCacheable(); + boolean isCacheable(); /** * returns the method name used to return this 'property' * @return The method name used to return this 'property' */ - public String getMethodName(); + String getMethodName(); } Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/VelPropertySet.java Sat Jan 28 19:21:08 2017 @@ -38,7 +38,7 @@ public interface VelPropertySet * @return the value returned from the set operation (impl specific) * @throws Exception */ - public Object invoke(Object o, Object arg) throws Exception; + Object invoke(Object o, Object arg) throws Exception; /** * specifies if this VelPropertySet is cacheable and able to be @@ -46,11 +46,11 @@ public interface VelPropertySet * * @return true if can be reused for this class, false if not */ - public boolean isCacheable(); + boolean isCacheable(); /** * returns the method name used to set this 'property' * @return The method name used to set this 'property' */ - public String getMethodName(); + String getMethodName(); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArithmeticTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArithmeticTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArithmeticTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArithmeticTestCase.java Sat Jan 28 19:21:08 2017 @@ -48,17 +48,17 @@ public class ArithmeticTestCase extends public void testAdd() { - addHelper (new Integer(10), new Short( (short)20), 30, Integer.class); - addHelper (new Byte((byte)10), new Short( (short)20), 30, Short.class); - addHelper (new Float(10), new Short( (short)20), 30, Float.class); - addHelper (new Byte((byte)10), new Double( 20), 30, Double.class); - addHelper (BigInteger.valueOf(10), new Integer( 20), 30, BigInteger.class); - addHelper (new Integer( 20), BigDecimal.valueOf(10), 30, BigDecimal.class); + addHelper (10, (short) 20, 30, Integer.class); + addHelper ((byte) 10, (short) 20, 30, Short.class); + addHelper (10f, (short) 20, 30, Float.class); + addHelper ((byte) 10, 20d, 30, Double.class); + addHelper (BigInteger.valueOf(10), 20, 30, BigInteger.class); + addHelper (20, BigDecimal.valueOf(10), 30, BigDecimal.class); // Test overflow - addHelper (new Integer(Integer.MAX_VALUE), new Short( (short)20), (double)Integer.MAX_VALUE+20, Long.class); - addHelper (new Integer (20), new Long(Long.MAX_VALUE), (double)Long.MAX_VALUE+20, BigInteger.class); - addHelper (new Integer (-20), new Long(Long.MIN_VALUE), (double)Long.MIN_VALUE-20, BigInteger.class); + addHelper (Integer.MAX_VALUE, (short) 20, (double)Integer.MAX_VALUE+20, Long.class); + addHelper (20, Long.MAX_VALUE, (double)Long.MAX_VALUE+20, BigInteger.class); + addHelper (-20, Long.MIN_VALUE, (double)Long.MIN_VALUE-20, BigInteger.class); } private void addHelper (Number n1, Number n2, double expectedResult, Class expectedResultType) @@ -70,17 +70,17 @@ public class ArithmeticTestCase extends public void testSubtract() { - subtractHelper (new Integer(100), new Short( (short)20), 80, Integer.class); - subtractHelper (new Byte((byte)100), new Short( (short)20), 80, Short.class); - subtractHelper (new Float(100), new Short( (short)20), 80, Float.class); - subtractHelper (new Byte((byte)100), new Double( 20), 80, Double.class); - subtractHelper (BigInteger.valueOf(100), new Integer( 20), 80, BigInteger.class); - subtractHelper (new Integer( 100), BigDecimal.valueOf(20), 80, BigDecimal.class); + subtractHelper (100, (short) 20, 80, Integer.class); + subtractHelper ((byte) 100, (short) 20, 80, Short.class); + subtractHelper (100f, (short) 20, 80, Float.class); + subtractHelper ((byte) 100, 20d, 80, Double.class); + subtractHelper (BigInteger.valueOf(100), 20, 80, BigInteger.class); + subtractHelper (100, BigDecimal.valueOf(20), 80, BigDecimal.class); // Test overflow - subtractHelper (new Integer(Integer.MIN_VALUE), new Short( (short)20), (double)Integer.MIN_VALUE-20, Long.class); - subtractHelper(new Integer(-20), new Long(Long.MAX_VALUE), -20d - (double) Long.MAX_VALUE, BigInteger.class); - subtractHelper(new Integer(Integer.MAX_VALUE), new Long(Long.MIN_VALUE), (double) Long.MAX_VALUE + (double) Integer.MAX_VALUE, BigInteger.class); + subtractHelper (Integer.MIN_VALUE, (short) 20, (double)Integer.MIN_VALUE-20, Long.class); + subtractHelper(-20, Long.MAX_VALUE, -20d - (double) Long.MAX_VALUE, BigInteger.class); + subtractHelper(Integer.MAX_VALUE, Long.MIN_VALUE, (double) Long.MAX_VALUE + (double) Integer.MAX_VALUE, BigInteger.class); } private void subtractHelper (Number n1, Number n2, double expectedResult, Class expectedResultType) @@ -92,18 +92,18 @@ public class ArithmeticTestCase extends public void testMultiply() { - multiplyHelper (new Integer(10), new Short( (short)20), 200, Integer.class); - multiplyHelper (new Byte((byte)100), new Short( (short)20), 2000, Short.class); - multiplyHelper (new Byte((byte)100), new Short( (short)2000), 200000, Integer.class); - multiplyHelper (new Float(100), new Short( (short)20), 2000, Float.class); - multiplyHelper (new Byte((byte)100), new Double( 20), 2000, Double.class); - multiplyHelper (BigInteger.valueOf(100), new Integer( 20), 2000, BigInteger.class); - multiplyHelper (new Integer( 100), BigDecimal.valueOf(20), 2000, BigDecimal.class); + multiplyHelper (10, (short) 20, 200, Integer.class); + multiplyHelper ((byte) 100, (short) 20, 2000, Short.class); + multiplyHelper ((byte) 100, (short) 2000, 200000, Integer.class); + multiplyHelper (100f, (short) 20, 2000, Float.class); + multiplyHelper ((byte) 100, 20d, 2000, Double.class); + multiplyHelper (BigInteger.valueOf(100), 20, 2000, BigInteger.class); + multiplyHelper (100, BigDecimal.valueOf(20), 2000, BigDecimal.class); // Test overflow - multiplyHelper (new Integer(Integer.MAX_VALUE), new Short( (short)10), (double)Integer.MAX_VALUE*10d, Long.class); - multiplyHelper(new Integer(Integer.MAX_VALUE), new Short((short) -10), (double) Integer.MAX_VALUE * -10d, Long.class); - multiplyHelper(new Integer(20), new Long(Long.MAX_VALUE), 20d * (double) Long.MAX_VALUE, BigInteger.class); + multiplyHelper (Integer.MAX_VALUE, (short) 10, (double)Integer.MAX_VALUE*10d, Long.class); + multiplyHelper(Integer.MAX_VALUE, (short) -10, (double) Integer.MAX_VALUE * -10d, Long.class); + multiplyHelper(20, Long.MAX_VALUE, 20d * (double) Long.MAX_VALUE, BigInteger.class); } private void multiplyHelper (Number n1, Number n2, double expectedResult, Class expectedResultType) @@ -115,13 +115,13 @@ public class ArithmeticTestCase extends public void testDivide() { - divideHelper (new Integer(10), new Short( (short)2), 5, Integer.class); - divideHelper (new Byte((byte)10), new Short( (short)2), 5, Short.class); - divideHelper (BigInteger.valueOf(10), new Short( (short)2), 5, BigInteger.class); - divideHelper (new Integer(10), new Short( (short)4), 2, Integer.class); - divideHelper (new Integer(10), new Float( 2.5f), 4, Float.class); - divideHelper(new Integer(10), new Double(2.5), 4, Double.class); - divideHelper(new Integer(10), new BigDecimal(2.5), 4, BigDecimal.class); + divideHelper (10, (short) 2, 5, Integer.class); + divideHelper ((byte) 10, (short) 2, 5, Short.class); + divideHelper (BigInteger.valueOf(10), (short) 2, 5, BigInteger.class); + divideHelper (10, (short) 4, 2, Integer.class); + divideHelper (10, 2.5f, 4, Float.class); + divideHelper(10, 2.5, 4, Double.class); + divideHelper(10, new BigDecimal(2.5), 4, BigDecimal.class); } private void divideHelper (Number n1, Number n2, double expectedResult, Class expectedResultType) @@ -133,14 +133,14 @@ public class ArithmeticTestCase extends public void testModulo() { - moduloHelper (new Integer(10), new Short( (short)2), 0, Integer.class); - moduloHelper (new Byte((byte)10), new Short( (short)3), 1, Short.class); - moduloHelper(BigInteger.valueOf(10), new Short((short) 4), 2, BigInteger.class); - moduloHelper(new Integer(10), new Float(5.5f), 4.5, Float.class); + moduloHelper (10, (short) 2, 0, Integer.class); + moduloHelper ((byte) 10, (short) 3, 1, Short.class); + moduloHelper(BigInteger.valueOf(10), (short) 4, 2, BigInteger.class); + moduloHelper(10, 5.5f, 4.5, Float.class); try { - moduloHelper (new Integer(10), new BigDecimal( 2.5), 4, BigDecimal.class); + moduloHelper (10, new BigDecimal( 2.5), 4, BigDecimal.class); fail ("Modulo with BigDecimal is not allowed! Should have thrown an ArithmeticException."); } catch( ArithmeticException e) @@ -158,12 +158,12 @@ public class ArithmeticTestCase extends public void testCompare() { - compareHelper (new Integer(10), new Short( (short)10), 0); - compareHelper (new Integer(10), new Short( (short)11), -1); - compareHelper (BigInteger.valueOf(10), new Short( (short)11), -1); - compareHelper (new Byte((byte)10), new Short( (short)3), 1); - compareHelper(new Float(10), new Short((short) 11), -1); - compareHelper(new Double(10), new Short((short) 11), -1); + compareHelper (10, (short) 10, 0); + compareHelper (10, (short) 11, -1); + compareHelper (BigInteger.valueOf(10), (short) 11, -1); + compareHelper ((byte) 10, (short) 3, 1); + compareHelper(10f, (short) 11, -1); + compareHelper(10d, (short) 11, -1); } private void compareHelper (Number n1, Number n2, int expectedResult) @@ -174,13 +174,13 @@ public class ArithmeticTestCase extends public void testNegate() { - negateHelper(new Byte((byte) 1), -1, Byte.class); - negateHelper(new Short((short) 1), -1, Short.class); - negateHelper(new Integer(1), -1, Integer.class); - negateHelper(new Long(1), -1, Long.class); + negateHelper((byte) 1, -1, Byte.class); + negateHelper((short) 1, -1, Short.class); + negateHelper(1, -1, Integer.class); + negateHelper(1L, -1, Long.class); negateHelper(BigInteger.valueOf(1), -1, BigInteger.class); negateHelper(BigDecimal.valueOf(1), -1, BigDecimal.class); - negateHelper(new Long(Long.MIN_VALUE), BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.valueOf(1)).doubleValue(), BigInteger.class); + negateHelper(Long.MIN_VALUE, BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.valueOf(1)).doubleValue(), BigInteger.class); } private void negateHelper(Number n, double expectedResult, Class expectedResultType) @@ -231,13 +231,13 @@ public class ArithmeticTestCase extends */ public void testIsZero() { - assertTrue (MathUtils.isZero (new Integer (0))); - assertTrue (!MathUtils.isZero (new Integer (1))); - assertTrue (!MathUtils.isZero (new Integer (-1))); - - assertTrue (MathUtils.isZero (new Float (0f))); - assertTrue (!MathUtils.isZero (new Float (0.00001f))); - assertTrue (!MathUtils.isZero (new Float (-0.00001f))); + assertTrue (MathUtils.isZero (0)); + assertTrue (!MathUtils.isZero (1)); + assertTrue (!MathUtils.isZero (-1)); + + assertTrue (MathUtils.isZero (0f)); + assertTrue (!MathUtils.isZero (0.00001f)); + assertTrue (!MathUtils.isZero (-0.00001f)); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArrayMethodsTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArrayMethodsTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArrayMethodsTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ArrayMethodsTestCase.java Sat Jan 28 19:21:08 2017 @@ -47,7 +47,7 @@ public class ArrayMethodsTestCase extend // test an array of primitive ints array = new int[] { 1, 3, 7 }; - checkResults(array, new Integer(11), false); + checkResults(array, 11, false); // test an array of mixed objects, including null array = new Object[] { new Double(2.2), null }; @@ -122,7 +122,7 @@ public class ArrayMethodsTestCase extend { // put the index in the context, so we can try // both an explicit index and a reference index - context.put("index", new Integer(i)); + context.put("index", i); Object value = Array.get(array, i); String get = "get($index)"; Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java Sat Jan 28 19:21:08 2017 @@ -534,7 +534,7 @@ public abstract class BaseTestCase exten * @param s The base file name. * @return The test case name. */ - protected static final String getTestCaseName(String s) + protected static String getTestCaseName(String s) { StringBuilder name = new StringBuilder(); name.append(Character.toTitleCase(s.charAt(0))); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BuiltInEventHandlerTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BuiltInEventHandlerTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BuiltInEventHandlerTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BuiltInEventHandlerTestCase.java Sat Jan 28 19:21:08 2017 @@ -338,28 +338,28 @@ public class BuiltInEventHandlerTestCase writer = new StringWriter(); ve1.evaluate(context, writer, "test", "$list.get(0)"); String result = writer.toString(); - assertTrue(result.indexOf("IndexOutOfBoundsException") != -1); - assertTrue(result.indexOf("Index: 0, Size: 0") != -1); - assertTrue(result.indexOf("at test (line 1, column 7)") == -1); - assertTrue(result.indexOf("rangeCheck") == -1); + assertTrue(result.contains("IndexOutOfBoundsException")); + assertTrue(result.contains("Index: 0, Size: 0")); + assertTrue(!result.contains("at test (line 1, column 7)")); + assertTrue(!result.contains("rangeCheck")); // exception, message and template info writer = new StringWriter(); ve2.evaluate(context,writer,"test","$list.get(0)"); - result = writer.toString();; - assertTrue(result.indexOf("IndexOutOfBoundsException") != -1); - assertTrue(result.indexOf("Index: 0, Size: 0") != -1); - assertTrue(result.indexOf("at test (line 1, column 7)") != -1); - assertTrue(result.indexOf("rangeCheck") == -1); + result = writer.toString(); + assertTrue(result.contains("IndexOutOfBoundsException")); + assertTrue(result.contains("Index: 0, Size: 0")); + assertTrue(result.contains("at test (line 1, column 7)")); + assertTrue(!result.contains("rangeCheck")); // exception, message and stack trace writer = new StringWriter(); ve3.evaluate(context,writer,"test","$list.get(0)"); - result = writer.toString();; - assertTrue(result.indexOf("IndexOutOfBoundsException") != -1); - assertTrue(result.indexOf("Index: 0, Size: 0") != -1); - assertTrue(result.indexOf("at test (line 1, column 7)") == -1); - assertTrue(result.indexOf("rangeCheck") != -1); + result = writer.toString(); + assertTrue(result.contains("IndexOutOfBoundsException")); + assertTrue(result.contains("Index: 0, Size: 0")); + assertTrue(!result.contains("at test (line 1, column 7)")); + assertTrue(result.contains("rangeCheck")); log("PrintException handler successful."); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/CommonsExtPropTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/CommonsExtPropTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/CommonsExtPropTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/CommonsExtPropTestCase.java Sat Jan 28 19:21:08 2017 @@ -101,7 +101,7 @@ public class CommonsExtPropTestCase exte result.write("\n\n"); message(result, "Testing getBoolean(key) ..."); - result.write(new Boolean(c.getBoolean("config.boolean.value")).toString()); + result.write(Boolean.valueOf(c.getBoolean("config.boolean.value")).toString()); result.write("\n\n"); message(result, "Testing getByte(key) ..."); @@ -159,9 +159,9 @@ public class CommonsExtPropTestCase exte private void showVector(FileWriter result, Vector v) throws Exception { - for (int j = 0; j < v.size(); j++) + for (Object aV : v) { - result.write((String) v.get(j)); + result.write((String) aV); result.write("\n"); } result.write("\n"); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EvaluateTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EvaluateTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EvaluateTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EvaluateTestCase.java Sat Jan 28 19:21:08 2017 @@ -244,19 +244,18 @@ public class EvaluateTestCase extends Ba * @param basefilename * @throws Exception */ - private void testFile(String basefilename, Map properties) + private void testFile(String basefilename, Map<String, Object> properties) throws Exception { info("Test file: "+basefilename); VelocityEngine ve = engine; ve.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); - for (Iterator i = properties.keySet().iterator(); i.hasNext();) + for (String key : properties.keySet()) { - String key = (String) i.next(); String value = (String) properties.get(key); ve.addProperty(key, value); - info("Add property: "+key+" = "+value); + info("Add property: " + key + " = " + value); } ve.init(); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ForeachTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ForeachTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ForeachTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ForeachTestCase.java Sat Jan 28 19:21:08 2017 @@ -47,7 +47,7 @@ public class ForeachTestCase extends Bas { // Limit the loop to three iterations. engine.setProperty(RuntimeConstants.MAX_NUMBER_LOOPS, - new Integer(3)); + 3); assertEvalEquals("1 2 3 ", "#foreach ($item in [1..10])$item #end"); } @@ -60,7 +60,7 @@ public class ForeachTestCase extends Bas throws Exception { List col = new ArrayList(); - col.add(new Integer(100)); + col.add(100); col.add("STRVALUE"); context.put("helper", new ForeachMethodCallHelper()); context.put("col", col); @@ -125,8 +125,8 @@ public class ForeachTestCase extends Bas public MyIterable() { foo = new ArrayList(); - foo.add(new Integer(1)); - foo.add(new Long(2)); + foo.add(1); + foo.add(2L); foo.add("3"); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IncludeErrorTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IncludeErrorTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IncludeErrorTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IncludeErrorTestCase.java Sat Jan 28 19:21:08 2017 @@ -100,10 +100,9 @@ public class IncludeErrorTestCase extend throws Exception { Context context = new VelocityContext(); - StringWriter writer = new StringWriter(); Template template = ve.getTemplate(templateName, "UTF-8"); - try + try (StringWriter writer = new StringWriter()) { template.merge(context, writer); writer.flush(); @@ -113,10 +112,6 @@ public class IncludeErrorTestCase extend { assertTrue(exceptionClass.isAssignableFrom(E.getClass())); } - finally - { - writer.close(); - } } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IndexTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IndexTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IndexTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IndexTestCase.java Sat Jan 28 19:21:08 2017 @@ -47,9 +47,9 @@ public class IndexTestCase extends BaseT context.put("str", str); ArrayList alist = new ArrayList(); - alist.add(new Integer(1)); - alist.add(new Integer(2)); - alist.add(new Integer(3)); + alist.add(1); + alist.add(2); + alist.add(3); alist.add(a); alist.add(null); context.put("alist", alist); @@ -143,7 +143,7 @@ public class IndexTestCase extends BaseT public String get(Boolean bool) { - if (bool.booleanValue()) + if (bool) return "BIG TRUE"; else return "BIG FALSE"; Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InfoTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InfoTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InfoTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InfoTestCase.java Sat Jan 28 19:21:08 2017 @@ -88,13 +88,12 @@ public class InfoTestCase extends BaseTe int expectedLine, int expectedCol) throws Exception { Context context = new VelocityContext(); - StringWriter writer = new StringWriter(); Template template = ve.getTemplate(templateName, "UTF-8"); Info info = null; context.put("main", this); - try + try (StringWriter writer = new StringWriter()) { template.merge(context, writer); writer.flush(); @@ -104,10 +103,6 @@ public class InfoTestCase extends BaseTe { info = E.getInfo(); } - finally - { - writer.close(); - } assertInfoEqual(info, templateName, expectedLine, expectedCol); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/Introspector3TestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/Introspector3TestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/Introspector3TestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/Introspector3TestCase.java Sat Jan 28 19:21:08 2017 @@ -60,11 +60,11 @@ public class Introspector3TestCase exten * string integer */ - Object[] listIntInt = { new ArrayList(), new Integer(1), new Integer(2) }; - Object[] listLongList = { new ArrayList(), new Long(1), new ArrayList() }; - Object[] intInt = { new Integer(1), new Integer(2) }; - Object[] longInt = { new Long(1), new Integer(2) }; - Object[] longLong = { new Long(1), new Long(2) }; + Object[] listIntInt = { new ArrayList(), 1, 2}; + Object[] listLongList = { new ArrayList(), 1L, new ArrayList() }; + Object[] intInt = {1, 2}; + Object[] longInt = {1L, 2}; + Object[] longLong = {1L, 2L}; Introspector introspector = new Introspector(log); method = introspector.getMethod( @@ -105,7 +105,7 @@ public class Introspector3TestCase exten * test invocation with nulls */ - Object [] oa = {null, new Integer(0)}; + Object [] oa = {null, 0}; method = introspector.getMethod( MethodProvider.class, "lll", oa ); result = (String) method.invoke(mp, oa); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IntrospectorTestCase.java Sat Jan 28 19:21:08 2017 @@ -74,7 +74,7 @@ public class IntrospectorTestCase extend throws Exception { // Test boolean primitive. - Object[] booleanParams = { new Boolean(true) }; + Object[] booleanParams = {Boolean.TRUE}; String type = "boolean"; Method method = introspector.getMethod( MethodProvider.class, type + "Method", booleanParams); @@ -100,7 +100,7 @@ public class IntrospectorTestCase extend throws Exception { // Test char primitive. - Object[] characterParams = { new Character('a') }; + Object[] characterParams = {'a'}; String type = "character"; Method method = introspector.getMethod( MethodProvider.class, type + "Method", characterParams); @@ -114,7 +114,7 @@ public class IntrospectorTestCase extend { // Test double primitive. - Object[] doubleParams = { new Double((double)1) }; + Object[] doubleParams = {(double) 1}; String type = "double"; Method method = introspector.getMethod( MethodProvider.class, type + "Method", doubleParams); @@ -128,7 +128,7 @@ public class IntrospectorTestCase extend { // Test float primitive. - Object[] floatParams = { new Float((float)1) }; + Object[] floatParams = {(float) 1}; String type = "float"; Method method = introspector.getMethod( MethodProvider.class, type + "Method", floatParams); @@ -142,7 +142,7 @@ public class IntrospectorTestCase extend { // Test integer primitive. - Object[] integerParams = { new Integer((int)1) }; + Object[] integerParams = {(int) 1}; String type = "integer"; Method method = introspector.getMethod( MethodProvider.class, type + "Method", integerParams); @@ -156,7 +156,7 @@ public class IntrospectorTestCase extend { // Test long primitive. - Object[] longParams = { new Long((long)1) }; + Object[] longParams = {(long) 1}; String type = "long"; Method method = introspector.getMethod( MethodProvider.class, type + "Method", longParams); @@ -169,7 +169,7 @@ public class IntrospectorTestCase extend throws Exception { // Test short primitive. - Object[] shortParams = { new Short((short)1) }; + Object[] shortParams = {(short) 1}; String type = "short"; Method method = introspector.getMethod( MethodProvider.class, type + "Method", shortParams); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InvalidEventHandlerTestCase.java Sat Jan 28 19:21:08 2017 @@ -188,8 +188,8 @@ extends TestCase throws Exception { VelocityContext context = new VelocityContext(vc); - context.put("a1", new Integer(5)); - context.put("a4", new Integer(5)); + context.put("a1", 5); + context.put("a4", 5); context.put("b1","abc"); String s; @@ -223,8 +223,8 @@ extends TestCase throws Exception { VelocityContext context = new VelocityContext(vc); - context.put("a1",new Integer(5)); - context.put("a4",new Integer(5)); + context.put("a1", 5); + context.put("a4", 5); context.put("b1","abc"); String s; @@ -277,8 +277,8 @@ extends TestCase String result; VelocityContext context = new VelocityContext(vc); - context.put("a1",new Integer(5)); - context.put("a4",new Integer(5)); + context.put("a1", 5); + context.put("a4", 5); context.put("b1","abc"); // normal - should be no calls to handler @@ -489,76 +489,61 @@ extends TestCase if (rs == null) fail ("Event handler not initialized!"); - // good object, bad property - if (reference.equals("$a1.foobar")) + switch (reference) { - assertEquals(new Integer(5),object); - assertEquals("foobar",property); - throw new RuntimeException("expected exception"); - } - - // bad object, bad property - else if (reference.equals("$a2")) - { - assertNull(object); - assertNull(property); - throw new RuntimeException("expected exception"); - } - - // bad object, no property - else if (reference.equals("$a3")) - { - assertNull(object); - assertNull(property); - throw new RuntimeException("expected exception"); - } - - // good object, bad property; change the value - else if (reference.equals("$a4.foobar")) - { - assertEquals(new Integer(5),object); - assertEquals("foobar",property); - return "zzz"; - } - - // bad object, bad method -- fail on the object - else if (reference.equals("$zz")) - { - assertNull(object); - assertNull(property); - throw new RuntimeException("expected exception"); - } - - // pass q1 through - else if (reference.equals("$q1")) - { - - } - - - else if (reference.equals("$tree.x")) - { - assertEquals("x",property); - } - - else if (reference.equals("$tree.field.x")) - { - assertEquals("x",property); - } - - else if (reference.equals("$tree.child.y")) - { - assertEquals("y",property); - } - - else if (reference.equals("$tree.child.Field.y")) - { - assertEquals("y",property); - } - - else - { - fail("invalidGetMethod: unexpected reference: " + reference); + // good object, bad property + case "$a1.foobar": + assertEquals(new Integer(5), object); + assertEquals("foobar", property); + throw new RuntimeException("expected exception"); + + // bad object, bad property + case "$a2": + assertNull(object); + assertNull(property); + throw new RuntimeException("expected exception"); + + + // bad object, no property + case "$a3": + assertNull(object); + assertNull(property); + throw new RuntimeException("expected exception"); + + + // good object, bad property; change the value + case "$a4.foobar": + assertEquals(new Integer(5), object); + assertEquals("foobar", property); + return "zzz"; + + + // bad object, bad method -- fail on the object + case "$zz": + assertNull(object); + assertNull(property); + throw new RuntimeException("expected exception"); + + + // pass q1 through + case "$q1": + + break; + case "$tree.x": + assertEquals("x", property); + break; + case "$tree.field.x": + assertEquals("x", property); + break; + case "$tree.child.y": + assertEquals("y", property); + break; + case "$tree.child.Field.y": + assertEquals("y", property); + break; + default: + fail("invalidGetMethod: unexpected reference: " + reference); + break; } return null; } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodCacheKeyTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodCacheKeyTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodCacheKeyTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodCacheKeyTestCase.java Sat Jan 28 19:21:08 2017 @@ -81,7 +81,7 @@ public class MethodCacheKeyTestCase exte { assertTrue(mck.equals(mck)); assertTrue(!mck.equals(null)); - assertTrue(!mck.equals((ASTMethod.MethodCacheKey) null)); + assertTrue(!mck.equals(null)); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java Sat Jan 28 19:21:08 2017 @@ -110,7 +110,7 @@ public class MethodInvocationExceptionTe if( t instanceof Exception) { - log(" exception = " + ( (Exception) t).getMessage() ); + log(" exception = " + t.getMessage() ); } } } @@ -147,7 +147,7 @@ public class MethodInvocationExceptionTe if( t instanceof Exception) { - log(" exception = " + ( (Exception) t).getMessage() ); + log(" exception = " + t.getMessage() ); } } } @@ -179,7 +179,7 @@ public class MethodInvocationExceptionTe if( t instanceof Exception) { - log(" exception = " + ( (Exception) t).getMessage() ); + log(" exception = " + t.getMessage() ); } } } @@ -210,7 +210,7 @@ public class MethodInvocationExceptionTe if( t instanceof Exception) { - log(" exception = " + ( (Exception) t).getMessage() ); + log(" exception = " + t.getMessage() ); } } } @@ -248,7 +248,7 @@ public class MethodInvocationExceptionTe if( t instanceof Exception) { - log(" exception = " + ( (Exception) t).getMessage() ); + log(" exception = " + t.getMessage() ); } } catch( Exception e) Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodOverloadingTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodOverloadingTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodOverloadingTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodOverloadingTestCase.java Sat Jan 28 19:21:08 2017 @@ -102,7 +102,7 @@ public class MethodOverloadingTestCase e */ testFile("single"); - assertTrue(logData.indexOf("IllegalArgumentException") == -1); + assertTrue(!logData.contains("IllegalArgumentException")); } public void testParsedMethodOverloading() @@ -113,7 +113,7 @@ public class MethodOverloadingTestCase e */ testFile("main"); - assertTrue(logData.indexOf("IllegalArgumentException") == -1); + assertTrue(!logData.contains("IllegalArgumentException")); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MiscTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MiscTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MiscTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MiscTestCase.java Sat Jan 28 19:21:08 2017 @@ -25,9 +25,6 @@ import org.apache.velocity.runtime.Runti import org.apache.commons.lang3.StringUtils; -import java.util.ArrayList; -import java.util.List; - /** * Test case for any miscellaneous stuff. If it isn't big, and doesn't fit * anywhere else, it goes here Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/NumberMethodCallsTestCase.java Sat Jan 28 19:21:08 2017 @@ -84,10 +84,10 @@ public class NumberMethodCallsTestCase e // numbers for context vc.put("AByte",new Byte("10")); vc.put("AShort",new Short("10")); - vc.put("AInteger",new Integer(10)); - vc.put("ALong",new Long(10)); - vc.put("ADouble",new Double(10)); - vc.put("AFloat",new Float(10)); + vc.put("AInteger", 10); + vc.put("ALong", 10L); + vc.put("ADouble", 10d); + vc.put("AFloat", 10f); vc.put("ABigDecimal",new BigDecimal(10)); vc.put("ABigInteger",new BigInteger("10")); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseWithMacroLibsTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseWithMacroLibsTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseWithMacroLibsTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseWithMacroLibsTestCase.java Sat Jan 28 19:21:08 2017 @@ -191,8 +191,8 @@ public class ParseWithMacroLibsTestCase VelocityEngine ve = new VelocityEngine(); ve.setProperty( Velocity.VM_PERM_INLINE_LOCAL, Boolean.TRUE); ve.setProperty("velocimacro.permissions.allow.inline.to.replace.global", - new Boolean(local)); - ve.setProperty("file.resource.loader.cache", new Boolean(cache)); + local); + ve.setProperty("file.resource.loader.cache", cache); ve.setProperty( Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "file"); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java Sat Jan 28 19:21:08 2017 @@ -124,7 +124,7 @@ public class ParserTestCase extends Test } /** - * Test to see if don't tolerage passing word tokens in anything but the + * Test to see if don't tolerate passing word tokens in anything but the * 0th arg to #macro() and the 1th arg to foreach() */ public void testArgs() Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/RenderVelocityTemplateTest.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/RenderVelocityTemplateTest.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/RenderVelocityTemplateTest.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/RenderVelocityTemplateTest.java Sat Jan 28 19:21:08 2017 @@ -91,7 +91,7 @@ public class RenderVelocityTemplateTest static class ExceptionHandler implements Thread.UncaughtExceptionHandler { - List<Throwable> errors = new ArrayList<Throwable>(); + List<Throwable> errors = new ArrayList<>(); public void uncaughtException(Thread t, Throwable e) { @@ -126,7 +126,7 @@ public class RenderVelocityTemplateTest int nthreads = 4; ExceptionHandler eh = new ExceptionHandler(); - List<Thread> threads = new ArrayList<Thread>(nthreads); + List<Thread> threads = new ArrayList<>(nthreads); for (int i = 0; i < nthreads; ++i) { Thread t = new RunMultipleEvals(); @@ -148,8 +148,7 @@ public class RenderVelocityTemplateTest { // Rethrow the first failing exception. System.out.println("Failed " + eh.errors.size() + " out of " + nthreads + " template evaluations"); - Throwable t = eh.errors.get(0); - throw t; + throw eh.errors.get(0); } } } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java Sat Jan 28 19:21:08 2017 @@ -115,9 +115,6 @@ public class ResourceLoaderInstanceTestC public void testResourceLoaderInstance () throws Exception { -//caveman hacks to get gump to give more info -try -{ assureResultsDirectoryExists(RESULTS_DIR); Template template = RuntimeSingleton.getTemplate( @@ -126,8 +123,6 @@ try FileOutputStream fos = new FileOutputStream ( getFileName(RESULTS_DIR, "testfile", RESULT_FILE_EXT)); -//caveman hack to get gump to give more info -System.out.println("All needed files exist"); Writer writer = new BufferedWriter(new OutputStreamWriter(fos)); @@ -140,13 +135,6 @@ System.out.println("All needed files exi template.merge(context, writer); writer.flush(); writer.close(); -} -catch (Exception e) -{ - System.out.println("Log was: "+logger.getLog()); - System.out.println(e); - e.printStackTrace(); -} if ( !isMatch(RESULTS_DIR, COMPARE_DIR, "testfile", RESULT_FILE_EXT, CMP_FILE_EXT) ) @@ -159,9 +147,6 @@ catch (Exception e) "----Expected----\n"+ compare + "----------------"; -//caveman hack to get gump to give more info -System.out.println(msg); -System.out.println("Log was: "+logger.getLog()); fail(msg); } } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/SecureIntrospectionTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/SecureIntrospectionTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/SecureIntrospectionTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/SecureIntrospectionTestCase.java Sat Jan 28 19:21:08 2017 @@ -116,16 +116,16 @@ public class SecureIntrospectionTestCase try { - for (int i=0; i < templateStrings.length; i++) + for (String templateString : templateStrings) { - if (shouldeval && !doesStringEvaluate(ve,c,templateStrings[i])) + if (shouldeval && !doesStringEvaluate(ve, c, templateString)) { - fail ("Should have evaluated: " + templateStrings[i]); + fail("Should have evaluated: " + templateString); } - if (!shouldeval && doesStringEvaluate(ve,c,templateStrings[i])) + if (!shouldeval && doesStringEvaluate(ve, c, templateString)) { - fail ("Should not have evaluated: " + templateStrings[i]); + fail("Should not have evaluated: " + templateString); } } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictCompareTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictCompareTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictCompareTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictCompareTestCase.java Sat Jan 28 19:21:08 2017 @@ -39,7 +39,7 @@ public class StrictCompareTestCase exten engine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, Boolean.TRUE); context.put("NULL", null); context.put("a", "abc"); - context.put("b", new Integer(3)); + context.put("b", 3); context.put("TRUE", Boolean.TRUE); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictMathTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictMathTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictMathTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StrictMathTestCase.java Sat Jan 28 19:21:08 2017 @@ -36,8 +36,8 @@ public class StrictMathTestCase extends { super.setUp(); engine.setProperty(RuntimeConstants.STRICT_MATH, Boolean.TRUE); - context.put("num", new Integer(5)); - context.put("zero", new Integer(0)); + context.put("num", 5); + context.put("zero", 0); } protected void assertNullMathEx(String operation) Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java Sat Jan 28 19:21:08 2017 @@ -123,7 +123,7 @@ public class StringResourceLoaderTestCas Writer writer = new BufferedWriter(new OutputStreamWriter(fos)); VelocityContext context = new VelocityContext(); - context.put("first", new Integer(1)); + context.put("first", 1); context.put("second", "two"); template1.merge(context, writer); @@ -170,7 +170,7 @@ public class StringResourceLoaderTestCas Writer writer = new BufferedWriter(new OutputStreamWriter(fos)); VelocityContext context = new VelocityContext(); - context.put("first", new Integer(1)); + context.put("first", 1); context.put("second", "two"); template.merge(context, writer); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestBase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestBase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestBase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestBase.java Sat Jan 28 19:21:08 2017 @@ -32,53 +32,53 @@ public interface TemplateTestBase * Directory relative to the distribution root, where the * values to compare test results to are stored. */ - public static final String TEST_COMPARE_DIR = System.getProperty("test.compare.dir"); + String TEST_COMPARE_DIR = System.getProperty("test.compare.dir"); /** * Directory relative to the distribution root, where the * test cases should put their output */ - public static final String TEST_RESULT_DIR = System.getProperty("test.result.dir"); + String TEST_RESULT_DIR = System.getProperty("test.result.dir"); /** * VTL file extension. */ - public final static String TMPL_FILE_EXT = "vm"; + String TMPL_FILE_EXT = "vm"; /** * Comparison file extension. */ - public final static String CMP_FILE_EXT = "cmp"; + String CMP_FILE_EXT = "cmp"; /** * Comparison file extension. */ - public final static String RESULT_FILE_EXT = "res"; + String RESULT_FILE_EXT = "res"; /** * Path for templates. This property will override the * value in the default velocity properties file. */ - public final static String FILE_RESOURCE_LOADER_PATH = + String FILE_RESOURCE_LOADER_PATH = TEST_COMPARE_DIR + "/templates"; /** * Properties file that lists which template tests to run. */ - public final static String TEST_CASE_PROPERTIES = + String TEST_CASE_PROPERTIES = FILE_RESOURCE_LOADER_PATH + "/templates.properties"; /** * Results relative to the build directory. */ - public final static String RESULT_DIR = + String RESULT_DIR = TEST_RESULT_DIR + "/templates"; /** * Results relative to the build directory. */ - public final static String COMPARE_DIR = + String COMPARE_DIR = FILE_RESOURCE_LOADER_PATH + "/compare"; } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java Sat Jan 28 19:21:08 2017 @@ -176,10 +176,10 @@ public class TemplateTestCase extends Ba context.put("intarr", intarr ); // Add some Numbers - context.put ("int1", new Integer (1000)); - context.put ("long1", new Long (10000000000l)); - context.put ("float1", new Float (1000.1234)); - context.put ("double1", new Double (10000000000d)); + context.put ("int1", 1000); + context.put ("long1", 10000000000l); + context.put ("float1", 1000.1234f); + context.put ("double1", 10000000000d); // Add a TemplateNumber context.put ("templatenumber1", new TestNumber (999.125)); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java Sat Jan 28 19:21:08 2017 @@ -88,7 +88,7 @@ public class TemplateTestSuite extends T * @param nbr The template test number to return a property key for. * @return The property key. */ - private static final String getTemplateTestKey(int nbr) + private static String getTemplateTestKey(int nbr) { return ("test.template." + nbr); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java Sat Jan 28 19:21:08 2017 @@ -55,7 +55,7 @@ public class URLResourceLoaderTimeoutTes super.setUp(); engine.setProperty("resource.loader", "url"); engine.setProperty("url.resource.loader.instance", loader); - engine.setProperty("url.resource.loader.timeout", new Integer(timeout)); + engine.setProperty("url.resource.loader.timeout", timeout); // actual instance of logger logger.on(); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VarargMethodsTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VarargMethodsTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VarargMethodsTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VarargMethodsTestCase.java Sat Jan 28 19:21:08 2017 @@ -38,7 +38,7 @@ public class VarargMethodsTestCase exten context.put("objects", new Object[] { this, VelocityContext.class }); context.put("strings", new String[] { "one", "two" }); context.put("doubles", new double[] { 1.5, 2.5 }); - context.put("float", new Float(1f)); + context.put("float", 1f); context.put("ints", new int[] { 1, 2 }); } @@ -137,9 +137,9 @@ public class VarargMethodsTestCase exten public String var(String[] ss) { StringBuilder out = new StringBuilder(); - for (int i=0; i < ss.length; i++) + for (String s : ss) { - out.append(ss[i]); + out.append(s); } return out.toString(); } @@ -147,9 +147,9 @@ public class VarargMethodsTestCase exten public double add(double[] dd) { double total = 0; - for (int i=0; i < dd.length; i++) + for (double aDd : dd) { - total += dd[i]; + total += aDd; } return total; } @@ -176,9 +176,9 @@ public class VarargMethodsTestCase exten public int add(int[] ii) { int total = 0; - for (int i=0; i < ii.length; i++) + for (int anIi : ii) { - total += ii[i]; + total += anIi; } return total; } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java Sat Jan 28 19:21:08 2017 @@ -56,7 +56,7 @@ public class VelocimacroTestCase extends */ Velocity.reset(); Velocity.setProperty( Velocity.VM_PERM_INLINE_LOCAL, Boolean.TRUE); - Velocity.setProperty( Velocity.VM_MAX_DEPTH, new Integer(5)); + Velocity.setProperty( Velocity.VM_MAX_DEPTH, 5); Velocity.setProperty( Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java?rev=1780734&r1=1780733&r2=1780734&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java Sat Jan 28 19:21:08 2017 @@ -87,7 +87,7 @@ public class VelTools66TestCase return; } - Method verifyMethod = TestInterface.class.getMethod("getTestValue", new Class[0]); + Method verifyMethod = TestInterface.class.getMethod("getTestValue"); RuntimeInstance ri = new RuntimeInstance(); log = new TestLogger(false, false); @@ -98,7 +98,7 @@ public class VelTools66TestCase assertEquals("Method object does not match!", verifyMethod, testMethod); } - public static interface TestInterface + public interface TestInterface { String getTestValue();