allow) {
super(Objects.requireNonNull(delegate));
allowedClasses = new HashSet<>(Objects.requireNonNull(allow));
}
- private boolean isClassAllowed(Class> clazz) {
+ private boolean isClassAllowed(final Class> clazz) {
return allowedClasses.contains(clazz.getCanonicalName());
}
@Override
- public boolean allow(Class> clazz) {
- return (validate(clazz) && isClassAllowed(clazz)) || super.allow(clazz);
+ public boolean allow(final Class> clazz) {
+ return validate(clazz) && isClassAllowed(clazz) || super.allow(clazz);
}
@Override
- public boolean allow(Method method) {
- return (validate(method) && isClassAllowed(method.getDeclaringClass())) || super.allow(method);
+ public boolean allow(final Method method) {
+ return validate(method) && isClassAllowed(method.getDeclaringClass()) || super.allow(method);
}
@Override
- public boolean allow(Constructor constructor) {
- return (validate(constructor) && isClassAllowed(constructor.getDeclaringClass())) || super.allow(constructor);
+ public boolean allow(final Constructor constructor) {
+ return validate(constructor) && isClassAllowed(constructor.getDeclaringClass()) || super.allow(constructor);
}
@Override
- public JexlPermissions compose(String... src) {
+ public JexlPermissions compose(final String... src) {
return new ClassPermissions(base.compose(src), allowedClasses);
}
}
diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTArrayAccess.java b/src/main/java/org/apache/commons/jexl3/parser/ASTArrayAccess.java
index 8cac2993e..cbcb84e1d 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/ASTArrayAccess.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/ASTArrayAccess.java
@@ -36,12 +36,12 @@ public ASTArrayAccess(final Parser p, final int id) {
super(p, id);
}
- void setSafe(long s) {
+ void setSafe(final long s) {
this.safe = s;
}
- public boolean isSafeChild(int c) {
- return (safe & (1L << c)) != 0;
+ public boolean isSafeChild(final int c) {
+ return (safe & 1L << c) != 0;
}
@Override
diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java b/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java
index acd85150f..46ca88bc8 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifier.java
@@ -76,7 +76,7 @@ public int getSymbol() {
* @return the new flags mask value
*/
private static int set(final int ordinal, final int mask, final boolean value) {
- return value? mask | (1 << ordinal) : mask & ~(1 << ordinal);
+ return value? mask | 1 << ordinal : mask & ~(1 << ordinal);
}
/**
diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java b/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java
index c9a41e4a5..334ad2884 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/ASTIdentifierAccess.java
@@ -88,7 +88,7 @@ else if (c < '0' || c > '9') {
return null;
}
val *= 10;
- val += (c - '0');
+ val += c - '0';
}
return val;
}
diff --git a/src/main/java/org/apache/commons/jexl3/parser/ASTJxltLiteral.java b/src/main/java/org/apache/commons/jexl3/parser/ASTJxltLiteral.java
index 3ba760179..f4a3c8dd6 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/ASTJxltLiteral.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/ASTJxltLiteral.java
@@ -38,7 +38,7 @@ void setLiteral(final String literal) {
this.literal = literal;
}
- public void setExpression(JxltEngine.Expression e) {
+ public void setExpression(final JxltEngine.Expression e) {
this.jxltExpression = e;
}
diff --git a/src/main/java/org/apache/commons/jexl3/parser/ExtensibleNode.java b/src/main/java/org/apache/commons/jexl3/parser/ExtensibleNode.java
index a9ce4b750..beb340393 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/ExtensibleNode.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/ExtensibleNode.java
@@ -29,15 +29,15 @@ public class ExtensibleNode extends JexlNode {
/** Whether this array/set/map is extended or not. */
private boolean extended = false;
- public ExtensibleNode(int id) {
+ public ExtensibleNode(final int id) {
super(id);
}
- public ExtensibleNode(Parser p, int id) {
+ public ExtensibleNode(final Parser p, final int id) {
super(p, id);
}
- public void setExtended(boolean e) {
+ public void setExtended(final boolean e) {
this.extended = e;
}
diff --git a/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java b/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java
index 2e0b14e23..73d1c3b12 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/FeatureController.java
@@ -74,8 +74,8 @@ protected Object visitNode(final JexlNode node, final Object data) {
*/
public void throwFeatureException(final int feature, final JexlNode node) {
final JexlInfo dbgInfo = node.jexlInfo();
- Debugger dbg = new Debugger().depth(1);
- String msg = dbg.data(node);
+ final Debugger dbg = new Debugger().depth(1);
+ final String msg = dbg.data(node);
throw new JexlException.Feature(dbgInfo, feature, msg);
}
diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java b/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
index 96be271b8..e52d223b4 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/JexlNode.java
@@ -54,7 +54,7 @@ public JexlNode(final Parser p, final int id) {
public void jjtSetFirstToken(final Token t) {
// 0xc = 12, 12 bits -> 4096
// 0xfff, 12 bits mask
- this.lc = (t.beginLine << 0xc) | (0xfff & t.beginColumn);
+ this.lc = t.beginLine << 0xc | 0xfff & t.beginColumn;
}
public void jjtSetLastToken(final Token t) {
@@ -145,7 +145,7 @@ protected boolean isConstant(final boolean literal) {
if (literal) {
for (int n = 0; n < jjtGetNumChildren(); ++n) {
final JexlNode child = jjtGetChild(n);
- if ((child instanceof ASTReference) || (child instanceof ASTMapEntry)) {
+ if (child instanceof ASTReference || child instanceof ASTMapEntry) {
final boolean is = child.isConstant(true);
if (!is) {
return false;
diff --git a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
index 8204d2cdf..ebd67ab5f 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
@@ -221,7 +221,7 @@ protected void controlPragmaAnywhere() {
* Gets the frame used by this parser.
*
* Since local variables create new symbols, it is important to
- * regain access after parsing to known which / how-many registers are needed.
+ * regain access after parsing to known which / how-many registers are needed.
*
* @return the named register map
*/
@@ -697,18 +697,18 @@ protected void jjtreeCloseNodeScope(final JexlNode node) {
* @param symbol the symbol
* @return true if constant, false otherwise
*/
- private boolean isConstant(int symbol) {
+ private boolean isConstant(final int symbol) {
if (symbol >= 0) {
if (block != null && block.hasSymbol(symbol)) {
return block.isConstant(symbol);
}
Scope blockScope = blockScopes.get(block);
int lexical = symbol;
- for (LexicalUnit unit : blocks) {
- Scope unitScope = blockScopes.get(unit);
+ for (final LexicalUnit unit : blocks) {
+ final Scope unitScope = blockScopes.get(unit);
// follow through potential capture
if (blockScope != unitScope) {
- int declared = blockScope.getCaptureDeclaration(lexical);
+ final int declared = blockScope.getCaptureDeclaration(lexical);
if (declared >= 0) {
lexical = declared;
}
diff --git a/src/main/java/org/apache/commons/jexl3/parser/NumberParser.java b/src/main/java/org/apache/commons/jexl3/parser/NumberParser.java
index 5a9151437..5bd2a285d 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/NumberParser.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/NumberParser.java
@@ -126,7 +126,7 @@ NumberParser assignNatural(final boolean negative, final String natural) {
// determine the base
final int base;
if (s.charAt(0) == '0') {
- if ((s.length() > 1 && (s.charAt(1) == 'x' || s.charAt(1) == 'X'))) {
+ if (s.length() > 1 && (s.charAt(1) == 'x' || s.charAt(1) == 'X')) {
base = 16;
s = s.substring(2); // Trim the 0x off the front
} else {
diff --git a/src/main/java/org/apache/commons/jexl3/parser/SimpleNode.java b/src/main/java/org/apache/commons/jexl3/parser/SimpleNode.java
index beed79a3f..e55201b56 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/SimpleNode.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/SimpleNode.java
@@ -125,7 +125,7 @@ public JexlNode jjtGetChild(final int i) {
*/
@Override
public int jjtGetNumChildren() {
- return (children == null) ? 0 : children.length;
+ return children == null ? 0 : children.length;
}
/** Sets this node value.
diff --git a/src/main/java/org/apache/commons/jexl3/parser/StringParser.java b/src/main/java/org/apache/commons/jexl3/parser/StringParser.java
index 89e2bf9a7..db8be5b8b 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/StringParser.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/StringParser.java
@@ -70,7 +70,7 @@ private static String buildString(final CharSequence str, final boolean eatsep,
final StringBuilder strb = new StringBuilder(str.length());
final char sep = eatsep ? str.charAt(0) : 0;
final int end = str.length() - (eatsep ? 1 : 0);
- final int begin = (eatsep ? 1 : 0);
+ final int begin = eatsep ? 1 : 0;
read(strb, str, begin, end, sep, esc);
return strb.toString();
}
@@ -116,7 +116,7 @@ private static int read(final StringBuilder strb, final CharSequence str, final
for (; index < end; ++index) {
final char c = str.charAt(index);
if (escape) {
- if (c == 'u' && (index + UCHAR_LEN) < end && readUnicodeChar(strb, str, index + 1) > 0) {
+ if (c == 'u' && index + UCHAR_LEN < end && readUnicodeChar(strb, str, index + 1) > 0) {
index += UCHAR_LEN;
} else {
// if c is not an escapable character, re-emmit the backslash before it
@@ -184,11 +184,11 @@ private static int readUnicodeChar(final StringBuilder strb, final CharSequence
for (int offset = 0; offset < UCHAR_LEN; ++offset) {
final char c = str.charAt(begin + offset);
if (c >= '0' && c <= '9') {
- value = (c - '0');
+ value = c - '0';
} else if (c >= 'a' && c <= 'h') {
- value = (c - 'a' + BASE10);
+ value = c - 'a' + BASE10;
} else if (c >= 'A' && c <= 'H') {
- value = (c - 'A' + BASE10);
+ value = c - 'A' + BASE10;
} else {
return 0;
}
diff --git a/src/main/java/org/apache/commons/jexl3/parser/TokenMgrException.java b/src/main/java/org/apache/commons/jexl3/parser/TokenMgrException.java
index 36c8514bc..f1cb981a6 100644
--- a/src/main/java/org/apache/commons/jexl3/parser/TokenMgrException.java
+++ b/src/main/java/org/apache/commons/jexl3/parser/TokenMgrException.java
@@ -84,12 +84,12 @@ public class TokenMgrException extends RuntimeException implements JavaccError {
*/
@Override
public String getMessage() {
- return ("Lexical error at line "
+ return "Lexical error at line "
+ line + ", column "
+ column + ". Encountered: "
+ (eof ? " "
- : (StringParser.escapeString(String.valueOf(current), '"')) + " (" + (int) current + "), ")
- + "after : " + StringParser.escapeString(after, '"'));
+ : StringParser.escapeString(String.valueOf(current), '"') + " (" + (int) current + "), ")
+ + "after : " + StringParser.escapeString(after, '"');
}
diff --git a/src/test/java/org/apache/commons/jexl3/AnnotationTest.java b/src/test/java/org/apache/commons/jexl3/AnnotationTest.java
index 9bde8c479..6ab3aaf70 100644
--- a/src/test/java/org/apache/commons/jexl3/AnnotationTest.java
+++ b/src/test/java/org/apache/commons/jexl3/AnnotationTest.java
@@ -110,7 +110,7 @@ public Object processAnnotation(final String name, final Object[] args, final Ca
}
// transient side effect for silent
if ("silent".equals(name)) {
- if ((args != null) && (args.length != 0)) {
+ if (args != null && args.length != 0) {
final boolean s = (Boolean) args[0];
final boolean b = options.isSilent();
options.setSilent(s);
diff --git a/src/test/java/org/apache/commons/jexl3/Arithmetic360.java b/src/test/java/org/apache/commons/jexl3/Arithmetic360.java
index a0028d229..6db71b53f 100644
--- a/src/test/java/org/apache/commons/jexl3/Arithmetic360.java
+++ b/src/test/java/org/apache/commons/jexl3/Arithmetic360.java
@@ -24,11 +24,11 @@
* An arithmetic that tries to keep argument types for bit-twiddling operators.
*/
public class Arithmetic360 extends JexlArithmetic {
- public Arithmetic360(boolean astrict) {
+ public Arithmetic360(final boolean astrict) {
super(astrict);
}
- public Arithmetic360(boolean astrict, MathContext bigdContext, int bigdScale) {
+ public Arithmetic360(final boolean astrict, final MathContext bigdContext, final int bigdScale) {
super(astrict, bigdContext, bigdScale);
}
@@ -44,7 +44,7 @@ public Arithmetic360(boolean astrict, MathContext bigdContext, int bigdScale) {
protected Number narrowLong(final Object lhs, final Object rhs, final long result) {
if (!(lhs instanceof Long || rhs instanceof Long)) {
final int ir = (int) result;
- if (result == (long) ir) {
+ if (result == ir) {
return ir;
}
}
@@ -61,7 +61,7 @@ protected Number narrowLong(final Object lhs, final Object rhs, final long resul
protected Number narrowLong(final Object operand, final long result) {
if (!(operand instanceof Long)) {
final int ir = (int) result;
- if (result == (long) ir) {
+ if (result == ir) {
return ir;
}
}
@@ -161,7 +161,7 @@ public Object complement(final Object val) {
* @return left << right.
*/
@Override
- public Object shiftLeft(Object left, Object right) {
+ public Object shiftLeft(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands(JexlOperator.SHIFTLEFT);
}
@@ -185,7 +185,7 @@ public Object shiftLeft(Object left, Object right) {
* @return left >> right.
*/
@Override
- public Object shiftRight(Object left, Object right) {
+ public Object shiftRight(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands(JexlOperator.SHIFTRIGHT);
}
@@ -209,7 +209,7 @@ public Object shiftRight(Object left, Object right) {
* @return left >>> right.
*/
@Override
- public Object shiftRightUnsigned(Object left, Object right) {
+ public Object shiftRightUnsigned(final Object left, final Object right) {
if (left == null && right == null) {
return controlNullNullOperands(JexlOperator.SHIFTRIGHTU);
}
@@ -222,7 +222,7 @@ public Object shiftRightUnsigned(Object left, Object right) {
if (l != null) {
return l.longValue() >>> r;
}
- BigInteger bl = toBigInteger(left);
+ final BigInteger bl = toBigInteger(left);
return bl.signum() < 0? bl.negate().shiftRight(r) : bl.shiftRight(r);
}
diff --git a/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java b/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java
index 07a291393..395b0b75d 100644
--- a/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java
@@ -96,7 +96,7 @@ public void testRegexp() throws Exception {
@Test
public void test391() throws Exception {
// with literals
- for(String src : Arrays.asList(
+ for(final String src : Arrays.asList(
"2 =~ [1, 2, 3, 4]",
"[2, 3] =~ [1, 2, 3, 4]",
"[2, 3,...] =~ [1, 2, 3, 4]",
@@ -106,15 +106,15 @@ public void test391() throws Exception {
asserter.assertExpression(src, Boolean.TRUE);
}
// with variables
- int[] ic = new int[]{1, 2, 3, 4};
- List iic = new ArrayList<>();
- for(int v : ic) { iic.add(v); }
- int[] iv = new int[]{2, 3};
- List iiv = new ArrayList<>();
- for(int v : iv) { iiv.add(v); }
- String src = "(x,y) -> x =~ y ";
- for(Object v : Arrays.asList(iv, iiv, 2)) {
- for(Object c : Arrays.asList(ic, iic)) {
+ final int[] ic = {1, 2, 3, 4};
+ final List iic = new ArrayList<>();
+ for(final int v : ic) { iic.add(v); }
+ final int[] iv = {2, 3};
+ final List iiv = new ArrayList<>();
+ for(final int v : iv) { iiv.add(v); }
+ final String src = "(x,y) -> x =~ y ";
+ for(final Object v : Arrays.asList(iv, iiv, 2)) {
+ for(final Object c : Arrays.asList(ic, iic)) {
asserter.assertExpression(src, Boolean.TRUE, v, c);
}
}
@@ -227,7 +227,11 @@ public boolean contains(final int i) {
}
public boolean contains(final int[] i) {
- for(int ii : i) if (!values.contains(ii)) return false;
+ for(final int ii : i) {
+ if (!values.contains(ii)) {
+ return false;
+ }
+ }
return true;
}
@@ -601,15 +605,15 @@ public void testFormatArithmeticJxlt() throws Exception {
testSelfAssignOperators("y.add(--x)", 42, 41, 41);
}
- void testSelfAssignOperators(String text, int x, int y0, int x0) {
+ void testSelfAssignOperators(final String text, final int x, final int y0, final int x0) {
//String text = "y.add(x++)";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(text);
- JexlContext context = new MapContext();
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(text);
+ final JexlContext context = new MapContext();
context.set("x", x);
- List y = new ArrayList<>();
+ final List y = new ArrayList<>();
context.set("y", y);
- Object result = script.execute(context);
+ final Object result = script.execute(context);
Assert.assertEquals("x0", x0, context.get("x"));
Assert.assertEquals("y0", y0, y.get(0));
}
diff --git a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
index d5da596c2..1ede95d30 100644
--- a/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
@@ -53,7 +53,7 @@ public ArithmeticTest() {
super("ArithmeticTest");
asserter = new Asserter(JEXL);
jexla = JEXL.getArithmetic();
- JexlOptions options = new JexlOptions();
+ final JexlOptions options = new JexlOptions();
options.setStrictArithmetic(false);
jexlb = jexla.options(options);
}
@@ -63,18 +63,18 @@ public ArithmeticTest() {
public void setUp() {
}
- static private void assertNullOperand(java.util.function.Supplier fun) {
+ static private void assertNullOperand(final java.util.function.Supplier fun) {
try {
Assert.assertNull(fun.get());
- } catch (JexlArithmetic.NullOperand xany) {
+ } catch (final JexlArithmetic.NullOperand xany) {
Assert.assertNotNull(xany);
}
}
- static private void assertArithmeticException(java.util.function.Supplier fun) {
+ static private void assertArithmeticException(final java.util.function.Supplier fun) {
try {
Assert.assertNull(fun.get());
- } catch (ArithmeticException xany) {
+ } catch (final ArithmeticException xany) {
Assert.assertNotNull(xany);
}
}
@@ -156,7 +156,7 @@ public void testIntegerCoercionEdges() {
assertArithmeticException(() -> jexla.toInteger(date));
Assert.assertEquals(0, jexla.toInteger(Double.NaN));
Assert.assertEquals(0, jexla.toInteger(""));
- Assert.assertEquals((int) 'b', jexla.toInteger('b'));
+ Assert.assertEquals('b', jexla.toInteger('b'));
Assert.assertEquals(1, jexla.toInteger(new AtomicBoolean(true)));
Assert.assertEquals(0, jexla.toInteger(new AtomicBoolean(false)));
@@ -333,25 +333,25 @@ public void testOverflows() throws Exception {
*/
@Test
public void testUnaryMinus() throws Exception {
- asserter.setVariable("aByte", new Byte((byte) 1));
- asserter.setVariable("aShort", new Short((short) 2));
- asserter.setVariable("anInteger", new Integer(3));
- asserter.setVariable("aLong", new Long(4));
- asserter.setVariable("aFloat", new Float(5.5));
- asserter.setVariable("aDouble", new Double(6.6));
+ asserter.setVariable("aByte", Byte.valueOf((byte) 1));
+ asserter.setVariable("aShort", Short.valueOf((short) 2));
+ asserter.setVariable("anInteger", Integer.valueOf(3));
+ asserter.setVariable("aLong", Long.valueOf(4));
+ asserter.setVariable("aFloat", Float.valueOf((float) 5.5));
+ asserter.setVariable("aDouble", Double.valueOf(6.6));
asserter.setVariable("aBigInteger", new BigInteger("7"));
asserter.setVariable("aBigDecimal", new BigDecimal("8.8"));
// loop to allow checking caching of constant numerals (debug)
for(int i = 0 ; i < 2; ++i) {
- asserter.assertExpression("-3", new Integer("-3"));
- asserter.assertExpression("-3.0", new Double("-3.0"));
- asserter.assertExpression("-aByte", new Byte((byte) -1));
- asserter.assertExpression("-aShort", new Short((short) -2));
- asserter.assertExpression("-anInteger", new Integer(-3));
- asserter.assertExpression("-aLong", new Long(-4));
- asserter.assertExpression("-aFloat", new Float(-5.5));
- asserter.assertExpression("-aDouble", new Double(-6.6));
+ asserter.assertExpression("-3", Integer.valueOf("-3"));
+ asserter.assertExpression("-3.0", Double.valueOf("-3.0"));
+ asserter.assertExpression("-aByte", Byte.valueOf((byte) -1));
+ asserter.assertExpression("-aShort", Short.valueOf((short) -2));
+ asserter.assertExpression("-anInteger", Integer.valueOf(-3));
+ asserter.assertExpression("-aLong", Long.valueOf(-4));
+ asserter.assertExpression("-aFloat", Float.valueOf((float) -5.5));
+ asserter.assertExpression("-aDouble", Double.valueOf(-6.6));
asserter.assertExpression("-aBigInteger", new BigInteger("-7"));
asserter.assertExpression("-aBigDecimal", new BigDecimal("-8.8"));
}
@@ -362,25 +362,25 @@ public void testUnaryMinus() throws Exception {
*/
@Test
public void testUnaryPlus() throws Exception {
- asserter.setVariable("aByte", new Byte((byte) 1));
- asserter.setVariable("aShort", new Short((short) 2));
- asserter.setVariable("anInteger", new Integer(3));
- asserter.setVariable("aLong", new Long(4));
- asserter.setVariable("aFloat", new Float(5.5));
- asserter.setVariable("aDouble", new Double(6.6));
+ asserter.setVariable("aByte", Byte.valueOf((byte) 1));
+ asserter.setVariable("aShort", Short.valueOf((short) 2));
+ asserter.setVariable("anInteger", Integer.valueOf(3));
+ asserter.setVariable("aLong", Long.valueOf(4));
+ asserter.setVariable("aFloat", Float.valueOf((float) 5.5));
+ asserter.setVariable("aDouble", Double.valueOf(6.6));
asserter.setVariable("aBigInteger", new BigInteger("7"));
asserter.setVariable("aBigDecimal", new BigDecimal("8.8"));
// loop to allow checking caching of constant numerals (debug)
for(int i = 0 ; i < 2; ++i) {
- asserter.assertExpression("+3", new Integer("3"));
- asserter.assertExpression("+3.0", new Double("3.0"));
- asserter.assertExpression("+aByte", new Integer(1));
- asserter.assertExpression("+aShort", new Integer(2));
- asserter.assertExpression("+anInteger", new Integer(3));
- asserter.assertExpression("+aLong", new Long(4));
- asserter.assertExpression("+aFloat", new Float(5.5));
- asserter.assertExpression("+aDouble", new Double(6.6));
+ asserter.assertExpression("+3", Integer.valueOf("3"));
+ asserter.assertExpression("+3.0", Double.valueOf("3.0"));
+ asserter.assertExpression("+aByte", Integer.valueOf(1));
+ asserter.assertExpression("+aShort", Integer.valueOf(2));
+ asserter.assertExpression("+anInteger", Integer.valueOf(3));
+ asserter.assertExpression("+aLong", Long.valueOf(4));
+ asserter.assertExpression("+aFloat", Float.valueOf((float) 5.5));
+ asserter.assertExpression("+aDouble", Double.valueOf(6.6));
asserter.assertExpression("+aBigInteger", new BigInteger("7"));
asserter.assertExpression("+aBigDecimal", new BigDecimal("8.8"));
}
@@ -388,22 +388,22 @@ public void testUnaryPlus() throws Exception {
@Test
public void testMinusMinusPrefix() throws Exception {
- asserter.setVariable("aByte", new Byte((byte) 2));
- asserter.setVariable("aShort", new Short((short) 3));
- asserter.setVariable("anInteger", new Integer(4));
- asserter.setVariable("aLong", new Long(5));
- asserter.setVariable("aFloat", new Float(6.6));
- asserter.setVariable("aDouble", new Double(7.7));
+ asserter.setVariable("aByte", Byte.valueOf((byte) 2));
+ asserter.setVariable("aShort", Short.valueOf((short) 3));
+ asserter.setVariable("anInteger", Integer.valueOf(4));
+ asserter.setVariable("aLong", Long.valueOf(5));
+ asserter.setVariable("aFloat", Float.valueOf((float) 6.6));
+ asserter.setVariable("aDouble", Double.valueOf(7.7));
asserter.setVariable("aBigInteger", new BigInteger("8"));
asserter.setVariable("aBigDecimal", new BigDecimal("9.9"));
asserter.setVariable("aString", "forty-two");
- asserter.assertExpression("--aByte", new Byte((byte) 1));
- asserter.assertExpression("--aShort", new Short((short) 2));
- asserter.assertExpression("--anInteger", new Integer(3));
- asserter.assertExpression("--aLong", new Long(4));
- asserter.assertExpression("--aFloat", new Float(5.6));
- asserter.assertExpression("--aDouble", new Double(6.7));
+ asserter.assertExpression("--aByte", Byte.valueOf((byte) 1));
+ asserter.assertExpression("--aShort", Short.valueOf((short) 2));
+ asserter.assertExpression("--anInteger", Integer.valueOf(3));
+ asserter.assertExpression("--aLong", Long.valueOf(4));
+ asserter.assertExpression("--aFloat", Float.valueOf((float) 5.6));
+ asserter.assertExpression("--aDouble", Double.valueOf(6.7));
asserter.assertExpression("--aBigInteger", new BigInteger("7"));
asserter.assertExpression("--aBigDecimal", new BigDecimal("8.9"));
@@ -412,31 +412,31 @@ public void testMinusMinusPrefix() throws Exception {
@Test
public void testMinusMinusPostfix() throws Exception {
- asserter.setVariable("aByte", new Byte((byte) 2));
- asserter.setVariable("aShort", new Short((short) 3));
- asserter.setVariable("anInteger", new Integer(4));
- asserter.setVariable("aLong", new Long(5));
- asserter.setVariable("aFloat", new Float(6.6));
- asserter.setVariable("aDouble", new Double(7.7));
+ asserter.setVariable("aByte", Byte.valueOf((byte) 2));
+ asserter.setVariable("aShort", Short.valueOf((short) 3));
+ asserter.setVariable("anInteger", Integer.valueOf(4));
+ asserter.setVariable("aLong", Long.valueOf(5));
+ asserter.setVariable("aFloat", Float.valueOf((float) 6.6));
+ asserter.setVariable("aDouble", Double.valueOf(7.7));
asserter.setVariable("aBigInteger", new BigInteger("8"));
asserter.setVariable("aBigDecimal", new BigDecimal("9.9"));
asserter.setVariable("aString", "forty-two");
- asserter.assertExpression("aByte--",new Byte((byte) 2));
- asserter.assertExpression("aShort--", new Short((short) 3));
- asserter.assertExpression("anInteger--", new Integer(4));
- asserter.assertExpression("aLong--", new Long(5));
- asserter.assertExpression("aFloat--", new Float(6.6));
- asserter.assertExpression("aDouble--", new Double(7.7));
+ asserter.assertExpression("aByte--",Byte.valueOf((byte) 2));
+ asserter.assertExpression("aShort--", Short.valueOf((short) 3));
+ asserter.assertExpression("anInteger--", Integer.valueOf(4));
+ asserter.assertExpression("aLong--", Long.valueOf(5));
+ asserter.assertExpression("aFloat--", Float.valueOf((float) 6.6));
+ asserter.assertExpression("aDouble--", Double.valueOf(7.7));
asserter.assertExpression("aBigInteger--", new BigInteger("8"));
asserter.assertExpression("aBigDecimal--", new BigDecimal("9.9"));
- asserter.assertExpression("aByte", new Byte((byte) 1));
- asserter.assertExpression("aShort", new Short((short) 2));
- asserter.assertExpression("anInteger", new Integer(3));
- asserter.assertExpression("aLong", new Long(4));
- asserter.assertExpression("aFloat", new Float(5.6));
- asserter.assertExpression("aDouble", new Double(6.7));
+ asserter.assertExpression("aByte", Byte.valueOf((byte) 1));
+ asserter.assertExpression("aShort", Short.valueOf((short) 2));
+ asserter.assertExpression("anInteger", Integer.valueOf(3));
+ asserter.assertExpression("aLong", Long.valueOf(4));
+ asserter.assertExpression("aFloat", Float.valueOf((float) 5.6));
+ asserter.assertExpression("aDouble", Double.valueOf(6.7));
asserter.assertExpression("aBigInteger", new BigInteger("7"));
asserter.assertExpression("aBigDecimal", new BigDecimal("8.9"));
@@ -445,22 +445,22 @@ public void testMinusMinusPostfix() throws Exception {
@Test
public void testPlusPlusPrefix() throws Exception {
- asserter.setVariable("aByte", new Byte((byte) 0));
- asserter.setVariable("aShort", new Short((short) 1));
- asserter.setVariable("anInteger", new Integer(2));
- asserter.setVariable("aLong", new Long(3));
- asserter.setVariable("aFloat", new Float(4.4));
- asserter.setVariable("aDouble", new Double(5.5));
+ asserter.setVariable("aByte", Byte.valueOf((byte) 0));
+ asserter.setVariable("aShort", Short.valueOf((short) 1));
+ asserter.setVariable("anInteger", Integer.valueOf(2));
+ asserter.setVariable("aLong", Long.valueOf(3));
+ asserter.setVariable("aFloat", Float.valueOf((float) 4.4));
+ asserter.setVariable("aDouble", Double.valueOf(5.5));
asserter.setVariable("aBigInteger", new BigInteger("6"));
asserter.setVariable("aBigDecimal", new BigDecimal("7.7"));
asserter.setVariable("aString", "forty-two");
- asserter.assertExpression("++aByte", new Byte((byte) 1));
- asserter.assertExpression("++aShort", new Short((short) 2));
- asserter.assertExpression("++anInteger", new Integer(3));
- asserter.assertExpression("++aLong", new Long(4));
- asserter.assertExpression("++aFloat", new Float(5.4));
- asserter.assertExpression("++aDouble", new Double(6.5));
+ asserter.assertExpression("++aByte", Byte.valueOf((byte) 1));
+ asserter.assertExpression("++aShort", Short.valueOf((short) 2));
+ asserter.assertExpression("++anInteger", Integer.valueOf(3));
+ asserter.assertExpression("++aLong", Long.valueOf(4));
+ asserter.assertExpression("++aFloat", Float.valueOf((float) 5.4));
+ asserter.assertExpression("++aDouble", Double.valueOf(6.5));
asserter.assertExpression("++aBigInteger", new BigInteger("7"));
asserter.assertExpression("++aBigDecimal", new BigDecimal("8.7"));
@@ -469,31 +469,31 @@ public void testPlusPlusPrefix() throws Exception {
@Test
public void testPlusPlusPostfix() throws Exception {
- asserter.setVariable("aByte", new Byte((byte) 0));
- asserter.setVariable("aShort", new Short((short) 1));
- asserter.setVariable("anInteger", new Integer(2));
- asserter.setVariable("aLong", new Long(3));
- asserter.setVariable("aFloat", new Float(4.4));
- asserter.setVariable("aDouble", new Double(5.5));
+ asserter.setVariable("aByte", Byte.valueOf((byte) 0));
+ asserter.setVariable("aShort", Short.valueOf((short) 1));
+ asserter.setVariable("anInteger", Integer.valueOf(2));
+ asserter.setVariable("aLong", Long.valueOf(3));
+ asserter.setVariable("aFloat", Float.valueOf((float) 4.4));
+ asserter.setVariable("aDouble", Double.valueOf(5.5));
asserter.setVariable("aBigInteger", new BigInteger("6"));
asserter.setVariable("aBigDecimal", new BigDecimal("7.7"));
asserter.setVariable("aString", "forty-two");
- asserter.assertExpression("aByte++", new Byte((byte) 0));
- asserter.assertExpression("aShort++", new Short((short) 1));
- asserter.assertExpression("anInteger++", new Integer(2));
- asserter.assertExpression("aLong++", new Long(3));
- asserter.assertExpression("aFloat++", new Float(4.4));
- asserter.assertExpression("aDouble++", new Double(5.5));
+ asserter.assertExpression("aByte++", Byte.valueOf((byte) 0));
+ asserter.assertExpression("aShort++", Short.valueOf((short) 1));
+ asserter.assertExpression("anInteger++", Integer.valueOf(2));
+ asserter.assertExpression("aLong++", Long.valueOf(3));
+ asserter.assertExpression("aFloat++", Float.valueOf((float) 4.4));
+ asserter.assertExpression("aDouble++", Double.valueOf(5.5));
asserter.assertExpression("aBigInteger++", new BigInteger("6"));
asserter.assertExpression("aBigDecimal++", new BigDecimal("7.7"));
- asserter.assertExpression("aByte", new Byte((byte) 1));
- asserter.assertExpression("aShort", new Short((short) 2));
- asserter.assertExpression("anInteger", new Integer(3));
- asserter.assertExpression("aLong", new Long(4));
- asserter.assertExpression("aFloat", new Float(5.4));
- asserter.assertExpression("aDouble", new Double(6.5));
+ asserter.assertExpression("aByte", Byte.valueOf((byte) 1));
+ asserter.assertExpression("aShort", Short.valueOf((short) 2));
+ asserter.assertExpression("anInteger", Integer.valueOf(3));
+ asserter.assertExpression("aLong", Long.valueOf(4));
+ asserter.assertExpression("aFloat", Float.valueOf((float) 5.4));
+ asserter.assertExpression("aDouble", Double.valueOf(6.5));
asserter.assertExpression("aBigInteger", new BigInteger("7"));
asserter.assertExpression("aBigDecimal", new BigDecimal("8.7"));
@@ -502,7 +502,7 @@ public void testPlusPlusPostfix() throws Exception {
@Test
public void testNarrowBig() throws Exception {
- List ls = Arrays.asList("zero", "one", "two");
+ final List ls = Arrays.asList("zero", "one", "two");
asserter.setVariable("list",ls);
asserter.setVariable("aBigDecimal", new BigDecimal("1"));
asserter.setVariable("aBigInteger", new BigDecimal("1"));
@@ -533,67 +533,67 @@ public void testCalculations() throws Exception {
* test new null coersion
*/
asserter.setVariable("imanull", null);
- asserter.assertExpression("imanull + 2", new Integer(2));
- asserter.assertExpression("imanull + imanull", new Integer(0));
- asserter.setVariable("foo", new Integer(2));
+ asserter.assertExpression("imanull + 2", Integer.valueOf(2));
+ asserter.assertExpression("imanull + imanull", Integer.valueOf(0));
+ asserter.setVariable("foo", Integer.valueOf(2));
- asserter.assertExpression("foo + 2", new Integer(4));
- asserter.assertExpression("3 + 3", new Integer(6));
- asserter.assertExpression("3 + 3 + foo", new Integer(8));
- asserter.assertExpression("3 * 3", new Integer(9));
- asserter.assertExpression("3 * 3 + foo", new Integer(11));
- asserter.assertExpression("3 * 3 - foo", new Integer(7));
+ asserter.assertExpression("foo + 2", Integer.valueOf(4));
+ asserter.assertExpression("3 + 3", Integer.valueOf(6));
+ asserter.assertExpression("3 + 3 + foo", Integer.valueOf(8));
+ asserter.assertExpression("3 * 3", Integer.valueOf(9));
+ asserter.assertExpression("3 * 3 + foo", Integer.valueOf(11));
+ asserter.assertExpression("3 * 3 - foo", Integer.valueOf(7));
/*
* test parenthesized exprs
*/
- asserter.assertExpression("(4 + 3) * 6", new Integer(42));
- asserter.assertExpression("(8 - 2) * 7", new Integer(42));
+ asserter.assertExpression("(4 + 3) * 6", Integer.valueOf(42));
+ asserter.assertExpression("(8 - 2) * 7", Integer.valueOf(42));
/*
* test some floaty stuff
*/
- asserter.assertExpression("3 * \"3.0\"", new Double(9));
- asserter.assertExpression("3 * 3.0", new Double(9));
+ asserter.assertExpression("3 * \"3.0\"", Double.valueOf(9));
+ asserter.assertExpression("3 * 3.0", Double.valueOf(9));
/*
* test / and %
*/
asserter.setStrict(false, false);
- asserter.assertExpression("6 / 3", new Integer(6 / 3));
- asserter.assertExpression("6.4 / 3", new Double(6.4 / 3));
- asserter.assertExpression("0 / 3", new Integer(0 / 3));
- asserter.assertExpression("3 / 0", new Double(0));
- asserter.assertExpression("4 % 3", new Integer(1));
- asserter.assertExpression("4.8 % 3", new Double(4.8 % 3));
+ asserter.assertExpression("6 / 3", Integer.valueOf(6 / 3));
+ asserter.assertExpression("6.4 / 3", Double.valueOf(6.4 / 3));
+ asserter.assertExpression("0 / 3", Integer.valueOf(0 / 3));
+ asserter.assertExpression("3 / 0", Double.valueOf(0));
+ asserter.assertExpression("4 % 3", Integer.valueOf(1));
+ asserter.assertExpression("4.8 % 3", Double.valueOf(4.8 % 3));
}
@Test
public void testCoercions() throws Exception {
- asserter.assertExpression("1", new Integer(1)); // numerics default to Integer
- asserter.assertExpression("5L", new Long(5));
+ asserter.assertExpression("1", Integer.valueOf(1)); // numerics default to Integer
+ asserter.assertExpression("5L", Long.valueOf(5));
- asserter.setVariable("I2", new Integer(2));
- asserter.setVariable("L2", new Long(2));
- asserter.setVariable("L3", new Long(3));
+ asserter.setVariable("I2", Integer.valueOf(2));
+ asserter.setVariable("L2", Long.valueOf(2));
+ asserter.setVariable("L3", Long.valueOf(3));
asserter.setVariable("B10", BigInteger.TEN);
// Integer & Integer => Integer
- asserter.assertExpression("I2 + 2", new Integer(4));
- asserter.assertExpression("I2 * 2", new Integer(4));
- asserter.assertExpression("I2 - 2", new Integer(0));
- asserter.assertExpression("I2 / 2", new Integer(1));
+ asserter.assertExpression("I2 + 2", Integer.valueOf(4));
+ asserter.assertExpression("I2 * 2", Integer.valueOf(4));
+ asserter.assertExpression("I2 - 2", Integer.valueOf(0));
+ asserter.assertExpression("I2 / 2", Integer.valueOf(1));
// Integer & Long => Long
- asserter.assertExpression("I2 * L2", new Long(4));
- asserter.assertExpression("I2 / L2", new Long(1));
+ asserter.assertExpression("I2 * L2", Long.valueOf(4));
+ asserter.assertExpression("I2 / L2", Long.valueOf(1));
// Long & Long => Long
- asserter.assertExpression("L2 + 3", new Long(5));
- asserter.assertExpression("L2 + L3", new Long(5));
- asserter.assertExpression("L2 / L2", new Long(1));
- asserter.assertExpression("L2 / 2", new Long(1));
+ asserter.assertExpression("L2 + 3", Long.valueOf(5));
+ asserter.assertExpression("L2 + L3", Long.valueOf(5));
+ asserter.assertExpression("L2 / L2", Long.valueOf(1));
+ asserter.assertExpression("L2 / 2", Long.valueOf(1));
// BigInteger
asserter.assertExpression("B10 / 10", BigInteger.ONE);
@@ -706,21 +706,21 @@ public void testDivideByZero() throws Exception {
final JexlEvalContext context = new JexlEvalContext(vars);
final JexlOptions options = context.getEngineOptions();
options.setStrictArithmetic(true);
- vars.put("aByte", new Byte((byte) 1));
- vars.put("aShort", new Short((short) 2));
- vars.put("aInteger", new Integer(3));
- vars.put("aLong", new Long(4));
- vars.put("aFloat", new Float(5.5));
- vars.put("aDouble", new Double(6.6));
+ vars.put("aByte", Byte.valueOf((byte) 1));
+ vars.put("aShort", Short.valueOf((short) 2));
+ vars.put("aInteger", Integer.valueOf(3));
+ vars.put("aLong", Long.valueOf(4));
+ vars.put("aFloat", Float.valueOf((float) 5.5));
+ vars.put("aDouble", Double.valueOf(6.6));
vars.put("aBigInteger", new BigInteger("7"));
vars.put("aBigDecimal", new BigDecimal("8.8"));
- vars.put("zByte", new Byte((byte) 0));
- vars.put("zShort", new Short((short) 0));
- vars.put("zInteger", new Integer(0));
- vars.put("zLong", new Long(0));
- vars.put("zFloat", new Float(0));
- vars.put("zDouble", new Double(0));
+ vars.put("zByte", Byte.valueOf((byte) 0));
+ vars.put("zShort", Short.valueOf((short) 0));
+ vars.put("zInteger", Integer.valueOf(0));
+ vars.put("zLong", Long.valueOf(0));
+ vars.put("zFloat", Float.valueOf(0));
+ vars.put("zDouble", Double.valueOf(0));
vars.put("zBigInteger", new BigInteger("0"));
vars.put("zBigDecimal", new BigDecimal("0"));
@@ -922,13 +922,13 @@ public void testAddWithStringsStrict() {
@Test
public void testNullArgs() {
- JexlEngine jexl = new JexlBuilder().arithmetic(new JexlArithmetic(true) {
- @Override public boolean isStrict(JexlOperator op) {
+ final JexlEngine jexl = new JexlBuilder().arithmetic(new JexlArithmetic(true) {
+ @Override public boolean isStrict(final JexlOperator op) {
return JexlOperator.ADD == op? false: super.isStrict(op);
}
}).create();
- JexlScript script = jexl.createScript("'1.2' + x ", "x");
- Object result = script.execute(null);
+ final JexlScript script = jexl.createScript("'1.2' + x ", "x");
+ final Object result = script.execute(null);
Assert.assertEquals("1.2", result);
}
@@ -1475,7 +1475,7 @@ public Object divide(final Object left, final Object right) {
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
final double l = toDouble(left);
final double r = toDouble(right);
- return new Double(l / r);
+ return Double.valueOf(l / r);
}
// otherwise treat as integers
final BigInteger l = toBigInteger(left);
@@ -1506,7 +1506,7 @@ public Object mod(final Object left, final Object right) {
if (isFloatingPointNumber(left) || isFloatingPointNumber(right)) {
final double l = toDouble(left);
final double r = toDouble(right);
- return new Double(l % r);
+ return Double.valueOf(l % r);
}
// otherwise treat as integers
final BigInteger l = toBigInteger(left);
@@ -1653,7 +1653,7 @@ public void testXmlArithmetic() throws Exception {
info = (Attr) nnm.getNamedItem("info");
Assert.assertEquals(y, r);
Assert.assertEquals(y, info.getValue());
- } catch (JexlException.Property xprop) {
+ } catch (final JexlException.Property xprop) {
// test fails in java > 11 because modules, etc; need investigation
Assert.assertTrue(xprop.getMessage().contains("info"));
Assert.assertTrue(getJavaVersion() > 11);
@@ -1846,10 +1846,10 @@ public void testAtomicBoolean() {
final AtomicBoolean ab = new AtomicBoolean(false);
Object o;
o = e.execute(jc, ab);
- Assert.assertEquals("Result is not 2", new Integer(2), o);
+ Assert.assertEquals("Result is not 2", Integer.valueOf(2), o);
ab.set(true);
o = e.execute(jc, ab);
- Assert.assertEquals("Result is not 1", new Integer(1), o);
+ Assert.assertEquals("Result is not 1", Integer.valueOf(1), o);
// in a binary logical op
e = JEXL.createScript("x && y", "x", "y");
ab.set(true);
diff --git a/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java b/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java
index a91af3e65..16d9970c1 100644
--- a/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java
@@ -40,11 +40,11 @@ public class ArrayAccessTest extends JexlTestCase {
// Needs to be accessible by Foo.class
static final String[] GET_METHOD_ARRAY =
- new String[] { "One", "Two", "Three" };
+ { "One", "Two", "Three" };
// Needs to be accessible by Foo.class
static final String[][] GET_METHOD_ARRAY2 =
- new String[][] { {"One", "Two", "Three"},{"Four", "Five", "Six"} };
+ { {"One", "Two", "Three"},{"Four", "Five", "Six"} };
public ArrayAccessTest() {
super("ArrayAccessTest");
@@ -67,16 +67,16 @@ public void testArrayAccess() throws Exception {
*/
final List l = new ArrayList<>();
- l.add(new Integer(1));
- l.add(new Integer(2));
- l.add(new Integer(3));
+ l.add(Integer.valueOf(1));
+ l.add(Integer.valueOf(2));
+ l.add(Integer.valueOf(3));
asserter.setVariable("list", l);
- asserter.assertExpression("list[1]", new Integer(2));
- asserter.assertExpression("list[1+1]", new Integer(3));
- asserter.setVariable("loc", new Integer(1));
- asserter.assertExpression("list[loc+1]", new Integer(3));
+ asserter.assertExpression("list[1]", Integer.valueOf(2));
+ asserter.assertExpression("list[1+1]", Integer.valueOf(3));
+ asserter.setVariable("loc", Integer.valueOf(1));
+ asserter.assertExpression("list[loc+1]", Integer.valueOf(3));
/*
* test array access
@@ -206,7 +206,7 @@ public void testArrayProperty() throws Exception {
// This is JEXL-26
@Test
public void testArrayAndDottedConflict() throws Exception {
- final Object[] objects = new Object[] {"an", "array", new Long(0)};
+ final Object[] objects = {"an", "array", Long.valueOf(0)};
asserter.setStrict(false);
asserter.setSilent(true);
asserter.setVariable("objects", objects);
@@ -234,11 +234,11 @@ public void testArrayIdentifierParsing() throws Exception {
@Test
public void testArrayMethods() throws Exception {
- final Object[] objects = new Object[] {"an", "array", new Long(0)};
+ final Object[] objects = {"an", "array", Long.valueOf(0)};
asserter.setVariable("objects", objects);
asserter.assertExpression("objects.get(1)", "array");
- asserter.assertExpression("objects.size()", new Integer(3));
+ asserter.assertExpression("objects.size()", Integer.valueOf(3));
// setting an index returns the old value
asserter.assertExpression("objects.set(1, 'dion')", "array");
asserter.assertExpression("objects[1]", "dion");
diff --git a/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java b/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java
index 43a001f6a..217d9f7b0 100644
--- a/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ArrayLiteralTest.java
@@ -43,15 +43,15 @@ public void testEmptyArrayLiteral() throws Exception {
Assert.assertTrue(o instanceof List>);
Assert.assertEquals(0, ((List>) o).size());
try {
- Object ff = JEXL.createExpression("[ , ]");
+ final Object ff = JEXL.createExpression("[ , ]");
Assert.fail(ff.toString());
- } catch(JexlException.Parsing parsing) {
+ } catch(final JexlException.Parsing parsing) {
Assert.assertNotNull(parsing);
}
try {
- Object ff = JEXL.createExpression("[ ... , ]");
+ final Object ff = JEXL.createExpression("[ ... , ]");
Assert.fail(ff.toString());
- } catch(JexlException.Parsing parsing) {
+ } catch(final JexlException.Parsing parsing) {
Assert.assertNotNull(parsing);
}
}
@@ -59,8 +59,8 @@ public void testEmptyArrayLiteral() throws Exception {
@Test
public void testLiteralWithStrings() throws Exception {
final Object[] check = {"foo", "bar"};
- List sources = Arrays.asList("[ 'foo' , 'bar' ]", "[ 'foo' , 'bar', ]");
- for(String src : sources) {
+ final List sources = Arrays.asList("[ 'foo' , 'bar' ]", "[ 'foo' , 'bar', ]");
+ for(final String src : sources) {
final JexlExpression e = JEXL.createExpression(src);
final Object o = e.evaluate(null);
Assert.assertArrayEquals(check, (Object[]) o);
@@ -79,7 +79,7 @@ public void testLiteralWithElipsis() throws Exception {
try {
JEXL.createExpression("[ 'foo' , 'bar', ... , ]");
Assert.fail("syntax");
- } catch(JexlException.Parsing parsing) {
+ } catch(final JexlException.Parsing parsing) {
Assert.assertNotNull(parsing);
}
}
@@ -87,8 +87,8 @@ public void testLiteralWithElipsis() throws Exception {
@Test
public void testLiteralWithOneEntry() throws Exception {
final Object[] check = {"foo"};
- List sources = Arrays.asList("[ 'foo']", "[ 'foo' , ]");
- for(String src : sources) {
+ final List sources = Arrays.asList("[ 'foo']", "[ 'foo' , ]");
+ for(final String src : sources) {
final JexlExpression e = JEXL.createExpression(src);
final Object o = e.evaluate(null);
Assert.assertArrayEquals(check, (Object[]) o);
@@ -101,7 +101,7 @@ public void testLiteralWithNumbers() throws Exception {
final JexlContext jc = new MapContext();
final Object o = e.evaluate(jc);
- final Object[] check = {new Double(5), new Integer(10)};
+ final Object[] check = {Double.valueOf(5), Integer.valueOf(10)};
Assert.assertArrayEquals(check, (Object[]) o);
Assert.assertTrue(o.getClass().isArray() && o.getClass().getComponentType().equals(Number.class));
}
@@ -116,9 +116,9 @@ public void testLiteralWithNulls() throws Exception {
"[ null, '10' , null ]"
};
final Object[][] checks = {
- {null, new Integer(10)},
- {new Integer(10), null},
- {new Integer(10), null, new Integer(10)},
+ {null, Integer.valueOf(10)},
+ {Integer.valueOf(10), null},
+ {Integer.valueOf(10), null, Integer.valueOf(10)},
{"10", null},
{null, "10", null}
};
@@ -147,7 +147,7 @@ public void testSizeOfSimpleArrayLiteral() throws Exception {
final JexlContext jc = new MapContext();
final Object o = e.evaluate(jc);
- Assert.assertEquals(new Integer(2), o);
+ Assert.assertEquals(Integer.valueOf(2), o);
}
@Test
@@ -156,7 +156,7 @@ public void notestCallingMethodsOnNewMapLiteral() throws Exception {
final JexlContext jc = new MapContext();
final Object o = e.evaluate(jc);
- Assert.assertEquals(new Integer(1), o);
+ Assert.assertEquals(Integer.valueOf(1), o);
}
@Test
diff --git a/src/test/java/org/apache/commons/jexl3/AssignTest.java b/src/test/java/org/apache/commons/jexl3/AssignTest.java
index ed510174e..bbbe3e798 100644
--- a/src/test/java/org/apache/commons/jexl3/AssignTest.java
+++ b/src/test/java/org/apache/commons/jexl3/AssignTest.java
@@ -81,9 +81,9 @@ public void testAntish() {
final JexlExpression check = JEXL.createExpression("froboz.value");
final JexlContext jc = new MapContext();
Object o = assign.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
o = check.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
}
@Test
@@ -92,9 +92,9 @@ public void testAntishInteger() {
final JexlExpression check = JEXL.createExpression("froboz.0");
final JexlContext jc = new MapContext();
Object o = assign.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
o = check.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
}
@Test
@@ -105,9 +105,9 @@ public void testBeanish() {
final Froboz froboz = new Froboz(-169);
jc.set("froboz", froboz);
Object o = assign.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
o = check.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
}
@Test
@@ -137,9 +137,9 @@ public void testArray() {
final Froboz froboz = new Froboz(0);
jc.set("froboz", froboz);
Object o = assign.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
o = check.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
}
@Test
@@ -147,7 +147,7 @@ public void testMini() {
final JexlContext jc = new MapContext();
final JexlExpression assign = JEXL.createExpression("quux = 10");
final Object o = assign.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
}
@@ -162,9 +162,9 @@ public void testMore() {
final Quux quux = (Quux) create.evaluate(jc);
Assert.assertNotNull("quux is null", quux);
Object o = assign.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
o = check.evaluate(jc);
- Assert.assertEquals("Result is not 10", new Integer(10), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(10), o);
}
@Test
@@ -173,10 +173,10 @@ public void testUtil() {
Assert.assertNotNull(quux);
JEXL.setProperty(quux, "froboz.value", Integer.valueOf(100));
Object o = JEXL.getProperty(quux, "froboz.value");
- Assert.assertEquals("Result is not 100", new Integer(100), o);
+ Assert.assertEquals("Result is not 100", Integer.valueOf(100), o);
JEXL.setProperty(quux, "['froboz'].value", Integer.valueOf(1000));
o = JEXL.getProperty(quux, "['froboz']['value']");
- Assert.assertEquals("Result is not 1000", new Integer(1000), o);
+ Assert.assertEquals("Result is not 1000", Integer.valueOf(1000), o);
}
@Test
@@ -199,7 +199,7 @@ public void testRejectLocal() {
@Test
public void testPropertyInError0() {
JexlScript script;
- for(String op : Arrays.asList(
+ for(final String op : Arrays.asList(
" = ", "+= ", " -= "," *= "," /= "," %= ",
" &= ", " |= ", " ^= ",
" <<= ", " >>= ", " >>>= ")) {
diff --git a/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java b/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java
index ead912557..f9d7fb548 100644
--- a/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java
+++ b/src/test/java/org/apache/commons/jexl3/BitwiseOperatorTest.java
@@ -44,133 +44,133 @@ public BitwiseOperatorTest() {
@Test
public void testAndWithTwoNulls() throws Exception {
- asserter.assertExpression("null & null", new Long(0));
+ asserter.assertExpression("null & null", Long.valueOf(0));
}
@Test
public void testAndWithLeftNull() throws Exception {
- asserter.assertExpression("null & 1", new Long(0));
+ asserter.assertExpression("null & 1", Long.valueOf(0));
}
@Test
public void testAndWithRightNull() throws Exception {
- asserter.assertExpression("1 & null", new Long(0));
+ asserter.assertExpression("1 & null", Long.valueOf(0));
}
@Test
public void testAndSimple() throws Exception {
- asserter.assertExpression("15 & 3", new Long(15 & 3));
+ asserter.assertExpression("15 & 3", Long.valueOf(15 & 3));
}
@Test
public void testAndVariableNumberCoercion() throws Exception {
- asserter.setVariable("x", new Integer(15));
- asserter.setVariable("y", new Short((short) 7));
- asserter.assertExpression("x & y", new Long(15 & 7));
+ asserter.setVariable("x", Integer.valueOf(15));
+ asserter.setVariable("y", Short.valueOf((short) 7));
+ asserter.assertExpression("x & y", Long.valueOf(15 & 7));
}
@Test
public void testAndVariableStringCoercion() throws Exception {
- asserter.setVariable("x", new Integer(15));
+ asserter.setVariable("x", Integer.valueOf(15));
asserter.setVariable("y", "7");
- asserter.assertExpression("x & y", new Long(15 & 7));
+ asserter.assertExpression("x & y", Long.valueOf(15 & 7));
}
@Test
public void testComplementWithNull() throws Exception {
- asserter.assertExpression("~null", new Long(-1));
+ asserter.assertExpression("~null", Long.valueOf(-1));
}
@Test
public void testComplementSimple() throws Exception {
- asserter.assertExpression("~128", new Long(-129));
+ asserter.assertExpression("~128", Long.valueOf(-129));
}
@Test
public void testComplementVariableNumberCoercion() throws Exception {
- asserter.setVariable("x", new Integer(15));
- asserter.assertExpression("~x", new Long(~15));
+ asserter.setVariable("x", Integer.valueOf(15));
+ asserter.assertExpression("~x", Long.valueOf(~15));
}
@Test
public void testComplementVariableStringCoercion() throws Exception {
asserter.setVariable("x", "15");
- asserter.assertExpression("~x", new Long(~15));
+ asserter.assertExpression("~x", Long.valueOf(~15));
}
@Test
public void testOrWithTwoNulls() throws Exception {
- asserter.assertExpression("null | null", new Long(0));
+ asserter.assertExpression("null | null", Long.valueOf(0));
}
@Test
public void testOrWithLeftNull() throws Exception {
- asserter.assertExpression("null | 1", new Long(1));
+ asserter.assertExpression("null | 1", Long.valueOf(1));
}
@Test
public void testOrWithRightNull() throws Exception {
- asserter.assertExpression("1 | null", new Long(1));
+ asserter.assertExpression("1 | null", Long.valueOf(1));
}
@Test
public void testOrSimple() throws Exception {
- asserter.assertExpression("12 | 3", new Long(15));
+ asserter.assertExpression("12 | 3", Long.valueOf(15));
}
@Test
public void testOrVariableNumberCoercion() throws Exception {
- asserter.setVariable("x", new Integer(12));
- asserter.setVariable("y", new Short((short) 3));
- asserter.assertExpression("x | y", new Long(15));
+ asserter.setVariable("x", Integer.valueOf(12));
+ asserter.setVariable("y", Short.valueOf((short) 3));
+ asserter.assertExpression("x | y", Long.valueOf(15));
}
@Test
public void testOrVariableStringCoercion() throws Exception {
- asserter.setVariable("x", new Integer(12));
+ asserter.setVariable("x", Integer.valueOf(12));
asserter.setVariable("y", "3");
- asserter.assertExpression("x | y", new Long(15));
+ asserter.assertExpression("x | y", Long.valueOf(15));
}
@Test
public void testXorWithTwoNulls() throws Exception {
- asserter.assertExpression("null ^ null", new Long(0));
+ asserter.assertExpression("null ^ null", Long.valueOf(0));
}
@Test
public void testXorWithLeftNull() throws Exception {
- asserter.assertExpression("null ^ 1", new Long(1));
+ asserter.assertExpression("null ^ 1", Long.valueOf(1));
}
@Test
public void testXorWithRightNull() throws Exception {
- asserter.assertExpression("1 ^ null", new Long(1));
+ asserter.assertExpression("1 ^ null", Long.valueOf(1));
}
@Test
public void testXorSimple() throws Exception {
- asserter.assertExpression("1 ^ 3", new Long(1 ^ 3));
+ asserter.assertExpression("1 ^ 3", Long.valueOf(1 ^ 3));
}
@Test
public void testXorVariableNumberCoercion() throws Exception {
- asserter.setVariable("x", new Integer(1));
- asserter.setVariable("y", new Short((short) 3));
- asserter.assertExpression("x ^ y", new Long(1 ^ 3));
+ asserter.setVariable("x", Integer.valueOf(1));
+ asserter.setVariable("y", Short.valueOf((short) 3));
+ asserter.assertExpression("x ^ y", Long.valueOf(1 ^ 3));
}
@Test
public void testXorVariableStringCoercion() throws Exception {
- asserter.setVariable("x", new Integer(1));
+ asserter.setVariable("x", Integer.valueOf(1));
asserter.setVariable("y", "3");
- asserter.assertExpression("x ^ y", new Long(1 ^ 3));
+ asserter.assertExpression("x ^ y", Long.valueOf(1 ^ 3));
}
@Test
public void testParenthesized() throws Exception {
asserter.assertExpression("(2 | 1) & 3", Long.valueOf(3L));
asserter.assertExpression("(2 & 1) | 3", Long.valueOf(3L));
- asserter.assertExpression("~(120 | 42)", new Long(~(120 | 42)));
+ asserter.assertExpression("~(120 | 42)", Long.valueOf(~(120 | 42)));
}
}
diff --git a/src/test/java/org/apache/commons/jexl3/BlockTest.java b/src/test/java/org/apache/commons/jexl3/BlockTest.java
index fb646caa8..678590b4c 100644
--- a/src/test/java/org/apache/commons/jexl3/BlockTest.java
+++ b/src/test/java/org/apache/commons/jexl3/BlockTest.java
@@ -64,7 +64,7 @@ public void testBlockLastExecuted01() throws Exception {
final JexlScript e = JEXL.createScript("if (true) { x = 1; } else { x = 2; }");
final JexlContext jc = new MapContext();
final Object o = e.execute(jc);
- Assert.assertEquals("Block result is wrong", new Integer(1), o);
+ Assert.assertEquals("Block result is wrong", Integer.valueOf(1), o);
}
@Test
@@ -72,7 +72,7 @@ public void testBlockLastExecuted02() throws Exception {
final JexlScript e = JEXL.createScript("if (false) { x = 1; } else { x = 2; }");
final JexlContext jc = new MapContext();
final Object o = e.execute(jc);
- Assert.assertEquals("Block result is wrong", new Integer(2), o);
+ Assert.assertEquals("Block result is wrong", Integer.valueOf(2), o);
}
@Test
diff --git a/src/test/java/org/apache/commons/jexl3/BuilderTest.java b/src/test/java/org/apache/commons/jexl3/BuilderTest.java
index 81fecc273..6b5e963a1 100644
--- a/src/test/java/org/apache/commons/jexl3/BuilderTest.java
+++ b/src/test/java/org/apache/commons/jexl3/BuilderTest.java
@@ -62,14 +62,14 @@ public void testValues() {
@Test
public void testOther() {
- ClassLoader cls = getClass().getClassLoader().getParent();
+ final ClassLoader cls = getClass().getClassLoader().getParent();
Assert.assertEquals(cls, builder().loader(cls).loader());
- Charset cs = Charset.forName("UTF16");
+ final Charset cs = Charset.forName("UTF16");
Assert.assertEquals(cs, builder().charset(cs).charset());
Assert.assertEquals(cs, builder().loader(cs).charset());
- JexlUberspect u0 = builder().create().getUberspect();
- JexlSandbox sandbox = new JexlSandbox();
- JexlUberspect uberspect = new SandboxUberspect(u0, sandbox);
+ final JexlUberspect u0 = builder().create().getUberspect();
+ final JexlSandbox sandbox = new JexlSandbox();
+ final JexlUberspect uberspect = new SandboxUberspect(u0, sandbox);
Assert.assertEquals(sandbox, builder().sandbox(sandbox).sandbox());
Assert.assertEquals(uberspect, builder().uberspect(uberspect).uberspect());
}
diff --git a/src/test/java/org/apache/commons/jexl3/CacheTest.java b/src/test/java/org/apache/commons/jexl3/CacheTest.java
index 4391f6dd1..751ea2a70 100644
--- a/src/test/java/org/apache/commons/jexl3/CacheTest.java
+++ b/src/test/java/org/apache/commons/jexl3/CacheTest.java
@@ -531,7 +531,7 @@ public ComputeTask(final int loops) {
@Override
public Integer call() throws Exception {
args.ca = new Object[]{args.c0, args.c1, args.c2};
- args.value = new Object[]{new Integer(2), "quux"};
+ args.value = new Object[]{Integer.valueOf(2), "quux"};
//jexl.setDebug(true);
final JexlExpression compute2 = jexl.createExpression("cache.compute(a0, a1)");
final JexlExpression compute1 = jexl.createExpression("cache.compute(a0)");
@@ -687,7 +687,7 @@ public void testCOMPUTENoCache() throws Exception {
args.ca = new Object[]{
Cached.class, Cached1.class, Cached2.class
};
- args.value = new Object[]{new Integer(2), "quux"};
+ args.value = new Object[]{Integer.valueOf(2), "quux"};
doCOMPUTE(args, LOOPS, false);
}
@@ -697,7 +697,7 @@ public void testCOMPUTECache() throws Exception {
args.ca = new Object[]{
Cached.class, Cached1.class, Cached2.class
};
- args.value = new Object[]{new Integer(2), "quux"};
+ args.value = new Object[]{Integer.valueOf(2), "quux"};
doCOMPUTE(args, LOOPS, true);
}
}
diff --git a/src/test/java/org/apache/commons/jexl3/ClassCreator.java b/src/test/java/org/apache/commons/jexl3/ClassCreator.java
index e3685ec38..4c8255d39 100644
--- a/src/test/java/org/apache/commons/jexl3/ClassCreator.java
+++ b/src/test/java/org/apache/commons/jexl3/ClassCreator.java
@@ -105,7 +105,7 @@ public Class> getClassInstance() throws Exception {
public ClassLoader getClassLoader() throws Exception {
if (loader == null) {
- final URL classpath = (new File(base, Integer.toString(seed))).toURI().toURL();
+ final URL classpath = new File(base, Integer.toString(seed)).toURI().toURL();
loader = new URLClassLoader(new URL[]{classpath}, getClass().getClassLoader());
}
return loader;
@@ -202,8 +202,8 @@ Class> compile() throws Exception {
// the classpath is {hbaseSrc}/target/classes.
final String currentDir = new File(".").getAbsolutePath();
final String classpath = currentDir + File.separator + "target" + File.separator + "classes"
- //+ System.getProperty("path.separator") + System.getProperty("java.class.path")
- + System.getProperty("path.separator") + System.getProperty("surefire.test.class.path");
+ //+ File.pathSeparator + System.getProperty("java.class.path")
+ + File.pathSeparator + System.getProperty("surefire.test.class.path");
options.add(classpath);
//LOG.debug("Setting classpath to: " + classpath);
diff --git a/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java b/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java
index 5ff6dcec9..df75fae86 100644
--- a/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java
@@ -309,12 +309,12 @@ public void testMany() throws Exception {
context.set("clazz", clazz);
z = newx.evaluate(context);
Assert.assertNotNull(clazz + ": class " + i + " could not be instantiated on pass " + pass, z);
- Assert.assertEquals(new Integer(i), expr.evaluate(context));
+ Assert.assertEquals(Integer.valueOf(i), expr.evaluate(context));
// with the proper class loader, attempt to create an instance from the class name
jexl.setClassLoader(cctor.getClassLoader());
z = newx.evaluate(context);
Assert.assertEquals(z.getClass(), clazz);
- Assert.assertEquals(new Integer(i), expr.evaluate(context));
+ Assert.assertEquals(Integer.valueOf(i), expr.evaluate(context));
cctor.clear();
jexl.setClassLoader(null);
diff --git a/src/test/java/org/apache/commons/jexl3/CollectionLiteralTest.java b/src/test/java/org/apache/commons/jexl3/CollectionLiteralTest.java
index 1898d2786..0adfd47a2 100644
--- a/src/test/java/org/apache/commons/jexl3/CollectionLiteralTest.java
+++ b/src/test/java/org/apache/commons/jexl3/CollectionLiteralTest.java
@@ -46,29 +46,29 @@ public static class Arithmetic363 extends JexlArithmetic {
final AtomicInteger sets = new AtomicInteger(0);
final AtomicInteger arrays = new AtomicInteger(0);
- public Arithmetic363(boolean strict) {
+ public Arithmetic363(final boolean strict) {
super(strict);
}
- @Override public MapBuilder mapBuilder(int size, boolean extended) {
+ @Override public MapBuilder mapBuilder(final int size, final boolean extended) {
return new CountingMapBuilder(maps, size, extended);
}
- @Override public SetBuilder setBuilder(int size, boolean extended) {
+ @Override public SetBuilder setBuilder(final int size, final boolean extended) {
return new CountingSetBuilder(sets, size, extended);
}
- @Override public ArrayBuilder arrayBuilder(int size, boolean extended) {
+ @Override public ArrayBuilder arrayBuilder(final int size, final boolean extended) {
return new CountingArrayBuilder(arrays, size, extended);
}
}
static class CountingSetBuilder extends SetBuilder {
final AtomicInteger count;
- public CountingSetBuilder(AtomicInteger ai, int size, boolean extended) {
+ public CountingSetBuilder(final AtomicInteger ai, final int size, final boolean extended) {
super(size, extended);
count = ai;
}
@Override public Set> create() {
- Set> set = super.create();
+ final Set> set = super.create();
count.incrementAndGet();
return set;
}
@@ -76,12 +76,12 @@ public CountingSetBuilder(AtomicInteger ai, int size, boolean extended) {
static class CountingMapBuilder extends MapBuilder {
final AtomicInteger count;
- public CountingMapBuilder(AtomicInteger ai, int size, boolean extended) {
+ public CountingMapBuilder(final AtomicInteger ai, final int size, final boolean extended) {
super(size, extended);
count = ai;
}
@Override public Map create() {
- Map map = super.create();
+ final Map map = super.create();
count.incrementAndGet();
return map;
}
@@ -90,13 +90,13 @@ public CountingMapBuilder(AtomicInteger ai, int size, boolean extended) {
static class CountingArrayBuilder extends ArrayBuilder {
final AtomicInteger count;
- public CountingArrayBuilder(AtomicInteger ai, int size, boolean extended) {
+ public CountingArrayBuilder(final AtomicInteger ai, final int size, final boolean extended) {
super(size, extended);
count = ai;
}
- @Override public Object create(boolean extended) {
- Object array = super.create(extended);
+ @Override public Object create(final boolean extended) {
+ final Object array = super.create(extended);
count.incrementAndGet();
return array;
}
@@ -104,7 +104,7 @@ public CountingArrayBuilder(AtomicInteger ai, int size, boolean extended) {
@Test
public void testMapLBuilder() {
- Arithmetic363 jc = new Arithmetic363(true);
+ final Arithmetic363 jc = new Arithmetic363(true);
final JexlEngine jexl = new JexlBuilder().cache(4).arithmetic(jc).create();
JexlScript script;
Object result;
@@ -122,7 +122,7 @@ public void testMapLBuilder() {
@Test
public void testSetBuilder() {
- Arithmetic363 jc = new Arithmetic363(true);
+ final Arithmetic363 jc = new Arithmetic363(true);
final JexlEngine jexl = new JexlBuilder().cache(4).arithmetic(jc).create();
JexlScript script;
Object result;
@@ -140,7 +140,7 @@ public void testSetBuilder() {
@Test
public void testArrayBuilder() {
- Arithmetic363 jc = new Arithmetic363(true);
+ final Arithmetic363 jc = new Arithmetic363(true);
final JexlEngine jexl = new JexlBuilder().cache(4).arithmetic(jc).create();
JexlScript script;
Object result;
diff --git a/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java b/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
index be4f20e98..13765d85c 100644
--- a/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
@@ -56,26 +56,26 @@ public void testComposePermissions2() throws Exception {
runComposePermissions(new JexlPermissions.ClassPermissions(JexlPermissions.UNRESTRICTED, Collections.emptySet()));
}
- void runComposePermissions(JexlPermissions p) throws Exception {
+ void runComposePermissions(final JexlPermissions p) throws Exception {
final String check = "http://example.com/content.jpg";
final File jsonFile = new File(SAMPLE_JSON);
- Gson gson = new Gson();
- Object json = gson.fromJson(new FileReader(jsonFile), Object.class);
+ final Gson gson = new Gson();
+ final Object json = gson.fromJson(new FileReader(jsonFile), Object.class);
Assert.assertNotNull(json);
// will succeed because java.util.Map is allowed and gson LinkedTreeMap is one
- JexlEngine j0 = createEngine(false, p);
- JexlScript s0 = j0.createScript("json.pageInfo.pagePic", "json");
- Object r0 = s0.execute(null, json);
+ final JexlEngine j0 = createEngine(false, p);
+ final JexlScript s0 = j0.createScript("json.pageInfo.pagePic", "json");
+ final Object r0 = s0.execute(null, json);
Assert.assertEquals(check, r0);
// will fail if gson package is denied
JexlEngine j1 = createEngine(false, p.compose("com.google.gson.internal {}"));
JexlScript s1 = j1.createScript("json.pageInfo.pagePic", "json");
try {
- Object r1 = s1.execute(null, json);
+ final Object r1 = s1.execute(null, json);
Assert.fail("gson restricted");
- } catch (JexlException.Property xproperty) {
+ } catch (final JexlException.Property xproperty) {
Assert.assertEquals("pageInfo", xproperty.getProperty());
}
@@ -83,16 +83,16 @@ void runComposePermissions(JexlPermissions p) throws Exception {
j1 = createEngine(false, p.compose("com.google.gson.internal { LinkedTreeMap {} }"));
s1 = j1.createScript("json.pageInfo.pagePic", "json");
try {
- Object r1 = s1.execute(null, json);
+ final Object r1 = s1.execute(null, json);
Assert.fail("gson LinkTreeMap restricted");
- } catch (JexlException.Property xproperty) {
+ } catch (final JexlException.Property xproperty) {
Assert.assertEquals("pageInfo", xproperty.getProperty());
}
// will not fail since gson objects
j1 = createEngine(false, JexlPermissions.RESTRICTED);
s1 = j1.createScript("json.pageInfo.pagePic", "json");
- Object r1 = s1.execute(null, json);
+ final Object r1 = s1.execute(null, json);
Assert.assertEquals(check, r0);
}
}
diff --git a/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java b/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java
index a6c868661..feb5db8fa 100644
--- a/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ContextNamespaceTest.java
@@ -49,7 +49,7 @@ public Taxes(final double d) {
}
public double vat(final double n) {
- return (n * vat) / 100.;
+ return n * vat / 100.;
}
}
@@ -104,14 +104,14 @@ public void testNamespacePragma() {
}
public static class Context346 extends MapContext {
- public int func(int y) { return 42 * y;}
+ public int func(final int y) { return 42 * y;}
}
@Test
public void testNamespace346a() {
- JexlContext ctxt = new Context346();
+ final JexlContext ctxt = new Context346();
final JexlEngine jexl = new JexlBuilder().safe(false).create();
- String src = "x != null ? x : func(y)";
+ final String src = "x != null ? x : func(y)";
final JexlScript script = jexl.createScript(src,"x","y");
Object result = script.execute(ctxt, null, 1);
Assert.assertEquals(42, result);
@@ -121,12 +121,12 @@ public void testNamespace346a() {
@Test
public void testNamespace346b() {
- JexlContext ctxt = new MapContext();
- Map ns = new HashMap<>();
+ final JexlContext ctxt = new MapContext();
+ final Map ns = new HashMap<>();
ns.put("x", Math.class);
ns.put(null, Math.class);
final JexlEngine jexl = new JexlBuilder().safe(false).namespaces(ns).create();
- String src = "x != null ? x : abs(y)";
+ final String src = "x != null ? x : abs(y)";
final JexlScript script = jexl.createScript(src,"x","y");
Object result = script.execute(ctxt, null, 42);
Assert.assertEquals(42, result);
@@ -135,22 +135,22 @@ public void testNamespace346b() {
}
public static class Ns348 {
- public static int func(int y) { return 42 * y;}
+ public static int func(final int y) { return 42 * y;}
}
public static class ContextNs348 extends MapContext implements JexlContext.NamespaceResolver {
- ContextNs348() { super(); }
+ ContextNs348() { }
@Override
- public Object resolveNamespace(String name) {
+ public Object resolveNamespace(final String name) {
return "ns".equals(name)? new Ns348() : null;
}
}
@Test
public void testNamespace348a() {
- JexlContext ctxt = new MapContext();
- Map ns = new HashMap<>();
+ final JexlContext ctxt = new MapContext();
+ final Map ns = new HashMap<>();
ns.put("ns", Ns348.class);
final JexlEngine jexl = new JexlBuilder().safe(false).namespaces(ns).create();
run348a(jexl, ctxt);
@@ -161,7 +161,7 @@ public void testNamespace348a() {
@Test
public void testNamespace348b() {
- JexlContext ctxt = new ContextNs348();
+ final JexlContext ctxt = new ContextNs348();
final JexlEngine jexl = new JexlBuilder().safe(false).create();
// no space for ns name as syntactic hint
run348a(jexl, ctxt, "ns:");
@@ -172,11 +172,11 @@ public void testNamespace348b() {
@Test
public void testNamespace348c() {
- JexlContext ctxt = new ContextNs348();
- Map ns = new HashMap<>();
+ final JexlContext ctxt = new ContextNs348();
+ final Map ns = new HashMap<>();
ns.put("ns", Ns348.class);
- JexlFeatures f = new JexlFeatures();
- f.namespaceTest((n)->true);
+ final JexlFeatures f = new JexlFeatures();
+ f.namespaceTest(n -> true);
final JexlEngine jexl = new JexlBuilder().namespaces(ns).features(f).safe(false).create();
run348a(jexl, ctxt);
run348b(jexl, ctxt);
@@ -186,9 +186,9 @@ public void testNamespace348c() {
@Test
public void testNamespace348d() {
- JexlContext ctxt = new ContextNs348();
- JexlFeatures f = new JexlFeatures();
- f.namespaceTest((n)->true);
+ final JexlContext ctxt = new ContextNs348();
+ final JexlFeatures f = new JexlFeatures();
+ f.namespaceTest(n -> true);
final JexlEngine jexl = new JexlBuilder().features(f).safe(false).create();
run348a(jexl, ctxt);
run348b(jexl, ctxt);
@@ -196,26 +196,26 @@ public void testNamespace348d() {
run348d(jexl, ctxt);
}
- private void run348a(JexlEngine jexl, JexlContext ctxt) {
+ private void run348a(final JexlEngine jexl, final JexlContext ctxt) {
run348a(jexl, ctxt, "ns : ");
}
- private void run348a(JexlEngine jexl, JexlContext ctxt, String ns) {
- String src = "empty(x) ? "+ns+"func(y) : z";
+ private void run348a(final JexlEngine jexl, final JexlContext ctxt, final String ns) {
+ final String src = "empty(x) ? "+ns+"func(y) : z";
// local vars
- JexlScript script = jexl.createScript(src, "x", "y", "z");
+ final JexlScript script = jexl.createScript(src, "x", "y", "z");
Object result = script.execute(ctxt, null, 1, 169);
Assert.assertEquals(42, result);
result = script.execute(ctxt, "42", 1, 169);
Assert.assertEquals(169, result);
}
- private void run348b(JexlEngine jexl, JexlContext ctxt) {
+ private void run348b(final JexlEngine jexl, final JexlContext ctxt) {
run348b(jexl, ctxt, "ns : ");
}
- private void run348b(JexlEngine jexl, JexlContext ctxt, String ns) {
- String src = "empty(x) ? "+ns+"func(y) : z";
+ private void run348b(final JexlEngine jexl, final JexlContext ctxt, final String ns) {
+ final String src = "empty(x) ? "+ns+"func(y) : z";
// global vars
- JexlScript script = jexl.createScript(src);
+ final JexlScript script = jexl.createScript(src);
ctxt.set("x", null);
ctxt.set("y", 1);
ctxt.set("z", 169);
@@ -229,29 +229,29 @@ private void run348b(JexlEngine jexl, JexlContext ctxt, String ns) {
Assert.assertEquals(169, result);
}
- private void run348c(JexlEngine jexl, JexlContext ctxt) {
+ private void run348c(final JexlEngine jexl, final JexlContext ctxt) {
run348c(jexl, ctxt, "ns : ");
}
- private void run348c(JexlEngine jexl, JexlContext ctxt, String ns) {
- String src = "empty(x) ? z : "+ns+"func(y)";
+ private void run348c(final JexlEngine jexl, final JexlContext ctxt, final String ns) {
+ final String src = "empty(x) ? z : "+ns+"func(y)";
// local vars
- JexlScript script = jexl.createScript(src, "x", "z", "y");
+ final JexlScript script = jexl.createScript(src, "x", "z", "y");
Object result = script.execute(ctxt, null, 169, 1);
Assert.assertEquals(src, 169, result);
result = script.execute(ctxt, "42", 169, 1);
Assert.assertEquals(src, 42, result);
}
- private void run348d(JexlEngine jexl, JexlContext ctxt) {
+ private void run348d(final JexlEngine jexl, final JexlContext ctxt) {
run348d(jexl, ctxt, "ns : ");
}
- private void run348d(JexlEngine jexl, JexlContext ctxt, String ns) {
- String src = "empty(x) ? z : "+ns+"func(y)";
+ private void run348d(final JexlEngine jexl, final JexlContext ctxt, final String ns) {
+ final String src = "empty(x) ? z : "+ns+"func(y)";
// global vars
JexlScript script = null;
try {
script = jexl.createScript(src);
- } catch (JexlException.Parsing xparse) {
+ } catch (final JexlException.Parsing xparse) {
Assert.fail(src);
}
ctxt.set("x", null);
@@ -329,13 +329,13 @@ public void testObjectContext() {
public static class NsNs {
private final int constVar;
- public NsNs(JexlContext ctxt) {
+ public NsNs(final JexlContext ctxt) {
nsnsCtor.incrementAndGet();
- Object n = ctxt.get("NUMBER");
- constVar = (n instanceof Number) ? ((Number) n).intValue() : -1;
+ final Object n = ctxt.get("NUMBER");
+ constVar = n instanceof Number ? ((Number) n).intValue() : -1;
}
- public int callIt(int n) {
+ public int callIt(final int n) {
return n + constVar;
}
}
@@ -343,7 +343,7 @@ public int callIt(int n) {
@Test
public void testNsNsContext0() {
nsnsCtor.set(0);
- String clsName = NsNs.class.getName();
+ final String clsName = NsNs.class.getName();
runNsNsContext(Collections.singletonMap("nsns", clsName));
}
@@ -353,8 +353,8 @@ public void testNsNsContext1() {
runNsNsContext(Collections.singletonMap("nsns", NsNs.class));
}
- private void runNsNsContext(Map nsMap) {
- JexlContext ctxt = new MapContext();
+ private void runNsNsContext(final Map nsMap) {
+ final JexlContext ctxt = new MapContext();
ctxt.set("NUMBER", 19);
final JexlEngine jexl = new JexlBuilder().strict(true).silent(false).cache(32)
.namespaces(nsMap).create();
@@ -369,7 +369,7 @@ private void runNsNsContext(Map nsMap) {
public static class StaticNs {
private StaticNs() { }
- public static int callIt(int n) {
+ public static int callIt(final int n) {
return n + 19;
}
}
@@ -384,8 +384,8 @@ public void testStaticNs1() {
runStaticNsContext(Collections.singletonMap("sns", StaticNs.class.getName()));
}
- private void runStaticNsContext(Map nsMap) {
- JexlContext ctxt = new MapContext();
+ private void runStaticNsContext(final Map nsMap) {
+ final JexlContext ctxt = new MapContext();
final JexlEngine jexl = new JexlBuilder().strict(true).silent(false).cache(32)
.namespaces(nsMap).create();
final JexlScript script = jexl.createScript("x ->{ sns:callIt(x); sns:callIt(x); }");
diff --git a/src/test/java/org/apache/commons/jexl3/DoWhileTest.java b/src/test/java/org/apache/commons/jexl3/DoWhileTest.java
index 3f2e43f95..d92e03bba 100644
--- a/src/test/java/org/apache/commons/jexl3/DoWhileTest.java
+++ b/src/test/java/org/apache/commons/jexl3/DoWhileTest.java
@@ -73,13 +73,13 @@ public void testWhileExecutesExpressionWhenLooping() throws Exception {
public void testWhileWithBlock() throws Exception {
final JexlScript e = JEXL.createScript("do { x = x + 1; y = y * 2; } while (x < 10)");
final JexlContext jc = new MapContext();
- jc.set("x", new Integer(1));
- jc.set("y", new Integer(1));
+ jc.set("x", Integer.valueOf(1));
+ jc.set("y", Integer.valueOf(1));
final Object o = e.execute(jc);
- Assert.assertEquals("Result is wrong", new Integer(512), o);
- Assert.assertEquals("x is wrong", new Integer(10), jc.get("x"));
- Assert.assertEquals("y is wrong", new Integer(512), jc.get("y"));
+ Assert.assertEquals("Result is wrong", Integer.valueOf(512), o);
+ Assert.assertEquals("x is wrong", Integer.valueOf(10), jc.get("x"));
+ Assert.assertEquals("y is wrong", Integer.valueOf(512), jc.get("y"));
}
@Test
@@ -143,32 +143,32 @@ public void testWhileEmptyStmtBody() throws Exception {
}
@Test public void testForLoop0() {
- String src = "(l)->{ for(let x = 0; x < 4; ++x) { l.add(x); } }";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(src);
- List l = new ArrayList<>();
- Object result = script.execute(null, l);
+ final String src = "(l)->{ for(let x = 0; x < 4; ++x) { l.add(x); } }";
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(src);
+ final List l = new ArrayList<>();
+ final Object result = script.execute(null, l);
Assert.assertNotNull(result);
Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l);
}
@Test public void testForLoop1() {
- String src = "(l)->{ for(var x = 0; x < 4; ++x) { l.add(x); } }";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(src);
- List l = new ArrayList<>();
- Object result = script.execute(null, l);
+ final String src = "(l)->{ for(var x = 0; x < 4; ++x) { l.add(x); } }";
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(src);
+ final List l = new ArrayList<>();
+ final Object result = script.execute(null, l);
Assert.assertNotNull(result);
Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l);
}
@Test public void testForLoop2() {
- String src = "(l)->{ for(x = 0; x < 4; ++x) { l.add(x); } }";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(src);
- List l = new ArrayList<>();
- JexlContext ctxt = new MapContext();
- Object result = script.execute(ctxt, l);
+ final String src = "(l)->{ for(x = 0; x < 4; ++x) { l.add(x); } }";
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(src);
+ final List l = new ArrayList<>();
+ final JexlContext ctxt = new MapContext();
+ final Object result = script.execute(ctxt, l);
Assert.assertNotNull(result);
Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l);
}
diff --git a/src/test/java/org/apache/commons/jexl3/FeaturesTest.java b/src/test/java/org/apache/commons/jexl3/FeaturesTest.java
index a197238a2..f61ee09bd 100644
--- a/src/test/java/org/apache/commons/jexl3/FeaturesTest.java
+++ b/src/test/java/org/apache/commons/jexl3/FeaturesTest.java
@@ -69,7 +69,7 @@ private void assertOk(final JexlFeatures features, final String[] scripts) {
public void testNoScript() throws Exception {
final JexlFeatures f = new JexlFeatures().script(false);
Assert.assertTrue(f.supportsExpression());
- final String[] scripts = new String[]{
+ final String[] scripts = {
"if (false) { block(); }",
"{ noway(); }",
"while(true);",
@@ -81,7 +81,7 @@ public void testNoScript() throws Exception {
@Test
public void testNoLoop() throws Exception {
final JexlFeatures f = new JexlFeatures().loops(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"while(true);",
"for(var i : {0 .. 10}) { bar(i); }"
};
@@ -91,7 +91,7 @@ public void testNoLoop() throws Exception {
@Test
public void testNoLambda() throws Exception {
final JexlFeatures f = new JexlFeatures().lambda(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"var x = ()->{ return 0 };",
"()->{ return 0 };",
"(x, y)->{ return 0 };",
@@ -105,7 +105,7 @@ public void testNoLambda() throws Exception {
@Test
public void testNoNew() throws Exception {
final JexlFeatures f = new JexlFeatures().newInstance(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"return new(clazz);",
"new('java.math.BigDecimal', 12) + 1"
};
@@ -115,7 +115,7 @@ public void testNoNew() throws Exception {
@Test
public void testNoSideEffects() throws Exception {
final JexlFeatures f = new JexlFeatures().sideEffect(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"x = 1",
"x.y = 1",
"x().y = 1",
@@ -139,7 +139,7 @@ public void testNoSideEffects() throws Exception {
@Test
public void testNoSideEffectsGlobal() throws Exception {
final JexlFeatures f = new JexlFeatures().sideEffectGlobal(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"x = 1",
"x.y = 1",
"x().y = 1",
@@ -170,7 +170,7 @@ public void testNoSideEffectsGlobal() throws Exception {
@Test
public void testNoLocals() throws Exception {
final JexlFeatures f = new JexlFeatures().localVar(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"var x = 0;",
"(x)->{ x }"
};
@@ -180,13 +180,13 @@ public void testNoLocals() throws Exception {
@Test
public void testReservedVars() throws Exception {
final JexlFeatures f = new JexlFeatures().reservedNames(Arrays.asList("foo", "bar"));
- final String[] scripts = new String[]{
+ final String[] scripts = {
"var foo = 0;",
"(bar)->{ bar }",
"var f = function(bar) { bar; }"
};
checkFeature(f, scripts);
- final String[] scriptsOk = new String[]{
+ final String[] scriptsOk = {
"var foo0 = 0;",
"(bar1)->{ bar }",
"var f = function(bar2) { bar2; }"
@@ -198,7 +198,7 @@ public void testReservedVars() throws Exception {
public void testArrayRefs() throws Exception {
final JexlFeatures f = new JexlFeatures().arrayReferenceExpr(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"x[y]",
"x['a'][b]",
"x()['a'][b]",
@@ -207,7 +207,7 @@ public void testArrayRefs() throws Exception {
checkFeature(f, scripts);
assertOk(f, scripts);
// same ones with constant array refs should work
- final String[] scriptsOk = new String[]{
+ final String[] scriptsOk = {
"x['y']",
"x['a'][1]",
"x()['a']['b']",
@@ -218,7 +218,7 @@ public void testArrayRefs() throws Exception {
@Test
public void testMethodCalls() throws Exception {
final JexlFeatures f = new JexlFeatures().methodCall(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"x.y(z)",
"x['a'].m(b)",
"x()['a'](b)",
@@ -226,7 +226,7 @@ public void testMethodCalls() throws Exception {
};
checkFeature(f, scripts);
// same ones with constant array refs should work
- final String[] scriptsOk = new String[]{
+ final String[] scriptsOk = {
"x('y')",
"x('a')[1]",
"x()['a']['b']",
@@ -237,7 +237,7 @@ public void testMethodCalls() throws Exception {
@Test
public void testStructuredLiterals() throws Exception {
final JexlFeatures f = new JexlFeatures().structuredLiteral(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"{1, 2, 3}",
"[1, 2, 3]",
"{ 1 :'one', 2 : 'two', 3 : 'three' }",
@@ -250,7 +250,7 @@ public void testStructuredLiterals() throws Exception {
@Test
public void testAnnotations() throws Exception {
final JexlFeatures f = new JexlFeatures().annotation(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"@synchronized(2) { return 42; }",
"@two var x = 3;"
};
@@ -261,7 +261,7 @@ public void testAnnotations() throws Exception {
@Test
public void testPragma() throws Exception {
final JexlFeatures f = new JexlFeatures().pragma(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"#pragma foo 42",
"#pragma foo 'bar'\n@two var x = 3;"
};
@@ -270,7 +270,7 @@ public void testPragma() throws Exception {
@Test
public void testPragmaAnywhere() throws Exception {
final JexlFeatures f = new JexlFeatures().pragmaAnywhere(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"var x = 3;\n#pragma foo 42",
};
checkFeature(f, scripts);
@@ -285,7 +285,7 @@ public void testMixedFeatures() throws Exception {
.lambda(false)
.loops(false)
.sideEffectGlobal(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"return new(clazz);",
"()->{ return 0 };",
"var x = 0;",
@@ -300,7 +300,7 @@ public void testMixedFeatures() throws Exception {
@Test
public void testNoComparatorNames() throws Exception {
final JexlFeatures f = new JexlFeatures().comparatorNames(false);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"1 eq 1",
"2 ne 3",
"1 lt 2",
@@ -314,7 +314,7 @@ public void testNoComparatorNames() throws Exception {
@Test
public void testConstCapture() throws Exception {
final JexlFeatures f = new JexlFeatures().constCapture(true);
- final String[] scripts = new String[]{
+ final String[] scripts = {
"let x = 0; const f = y -> x += y; f(42)",
"let x = 0; function f(y) { z -> x *= y }; f(42)"
};
diff --git a/src/test/java/org/apache/commons/jexl3/ForEachTest.java b/src/test/java/org/apache/commons/jexl3/ForEachTest.java
index f744d2014..ae4ee2ddd 100644
--- a/src/test/java/org/apache/commons/jexl3/ForEachTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ForEachTest.java
@@ -39,26 +39,26 @@ public ForEachTest() {
}
@Test public void testForLoop0b0() {
- String src = "(l)->{ for(let x = 0, y = 0; x < 4; ++x) l.add(x) }";
- JexlEngine jexl = new JexlBuilder().safe(false).create();
- JexlScript script = jexl.createScript(src);
- List l = new ArrayList<>();
- Object result = script.execute(null, l);
+ final String src = "(l)->{ for(let x = 0, y = 0; x < 4; ++x) l.add(x) }";
+ final JexlEngine jexl = new JexlBuilder().safe(false).create();
+ final JexlScript script = jexl.createScript(src);
+ final List l = new ArrayList<>();
+ final Object result = script.execute(null, l);
Assert.assertNotNull(result);
Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l);
- String resrc = toString(script);
+ final String resrc = toString(script);
Assert.assertEquals(src, resrc);
}
@Test public void testForLoop0a() {
- String src = "(l)->{ for(let x = 0; x < 4; ++x) { l.add(x); } }";
- JexlEngine jexl = new JexlBuilder().safe(false).create();
- JexlScript script = jexl.createScript(src);
- List l = new ArrayList<>();
- Object result = script.execute(null, l);
+ final String src = "(l)->{ for(let x = 0; x < 4; ++x) { l.add(x); } }";
+ final JexlEngine jexl = new JexlBuilder().safe(false).create();
+ final JexlScript script = jexl.createScript(src);
+ final List l = new ArrayList<>();
+ final Object result = script.execute(null, l);
Assert.assertNotNull(result);
Assert.assertEquals(Arrays.asList(0, 1, 2, 3), l);
- String resrc = toString(script);
+ final String resrc = toString(script);
Assert.assertEquals(src, resrc);
}
@@ -134,10 +134,10 @@ public void testForEachWithBlock() throws Exception {
final JexlScript exs0 = JEXL.createScript("for(var in : list) { x = x + in; }");
final JexlContext jc = new MapContext();
jc.set("list", new Object[]{2, 3});
- jc.set("x", new Integer(1));
+ jc.set("x", Integer.valueOf(1));
final Object o = exs0.execute(jc);
- Assert.assertEquals("Result is wrong", new Integer(6), o);
- Assert.assertEquals("x is wrong", new Integer(6), jc.get("x"));
+ Assert.assertEquals("Result is wrong", Integer.valueOf(6), o);
+ Assert.assertEquals("x is wrong", Integer.valueOf(6), jc.get("x"));
}
@Test
diff --git a/src/test/java/org/apache/commons/jexl3/IfTest.java b/src/test/java/org/apache/commons/jexl3/IfTest.java
index d160907a6..c0b76aefe 100644
--- a/src/test/java/org/apache/commons/jexl3/IfTest.java
+++ b/src/test/java/org/apache/commons/jexl3/IfTest.java
@@ -41,7 +41,7 @@ public void testSimpleIfTrue() throws Exception {
final JexlContext jc = new MapContext();
final Object o = e.execute(jc);
- Assert.assertEquals("Result is not 1", new Integer(1), o);
+ Assert.assertEquals("Result is not 1", Integer.valueOf(1), o);
}
/**
@@ -69,7 +69,7 @@ public void testSimpleElse() throws Exception {
final JexlContext jc = new MapContext();
final Object o = e.execute(jc);
- Assert.assertEquals("Result is not 2", new Integer(2), o);
+ Assert.assertEquals("Result is not 2", Integer.valueOf(2), o);
}
/**
@@ -97,7 +97,7 @@ public void testBlockElse() throws Exception {
final JexlContext jc = new MapContext();
final Object o = e.execute(jc);
- Assert.assertEquals("Result is wrong", new Integer(3), o);
+ Assert.assertEquals("Result is wrong", Integer.valueOf(3), o);
}
/**
@@ -109,7 +109,7 @@ public void testBlockElse() throws Exception {
public void testIfWithSimpleExpression() throws Exception {
final JexlScript e = JEXL.createScript("if (x == 1) true;");
final JexlContext jc = new MapContext();
- jc.set("x", new Integer(1));
+ jc.set("x", Integer.valueOf(1));
final Object o = e.execute(jc);
Assert.assertEquals("Result is not true", Boolean.TRUE, o);
@@ -165,7 +165,7 @@ public void testIfElseIfReturnExpression() throws Exception {
public void testIfWithArithmeticExpression() throws Exception {
final JexlScript e = JEXL.createScript("if ((x * 2) + 1 == 5) true;");
final JexlContext jc = new MapContext();
- jc.set("x", new Integer(2));
+ jc.set("x", Integer.valueOf(2));
final Object o = e.execute(jc);
Assert.assertEquals("Result is not true", Boolean.TRUE, o);
@@ -180,7 +180,7 @@ public void testIfWithArithmeticExpression() throws Exception {
public void testIfWithDecimalArithmeticExpression() throws Exception {
final JexlScript e = JEXL.createScript("if ((x * 2) == 5) true");
final JexlContext jc = new MapContext();
- jc.set("x", new Float(2.5f));
+ jc.set("x", Float.valueOf(2.5f));
final Object o = e.execute(jc);
Assert.assertEquals("Result is not true", Boolean.TRUE, o);
@@ -195,11 +195,11 @@ public void testIfWithDecimalArithmeticExpression() throws Exception {
public void testIfWithAssignment() throws Exception {
final JexlScript e = JEXL.createScript("if ((x * 2) == 5) {y = 1} else {y = 2;}");
final JexlContext jc = new MapContext();
- jc.set("x", new Float(2.5f));
+ jc.set("x", Float.valueOf(2.5f));
e.execute(jc);
final Object result = jc.get("y");
- Assert.assertEquals("y has the wrong value", new Integer(1), result);
+ Assert.assertEquals("y has the wrong value", Integer.valueOf(1), result);
}
/**
diff --git a/src/test/java/org/apache/commons/jexl3/Issues100Test.java b/src/test/java/org/apache/commons/jexl3/Issues100Test.java
index 9fbff9f10..bea1ebb5d 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues100Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues100Test.java
@@ -323,7 +323,7 @@ public void test117() throws Exception {
final JexlEngine jexl = new Engine();
final JexlExpression e = jexl.createExpression("TIMESTAMP > 20100102000000");
final JexlContext ctx = new MapContext();
- ctx.set("TIMESTAMP", new Long("20100103000000"));
+ ctx.set("TIMESTAMP", Long.valueOf("20100103000000"));
final Object result = e.evaluate(ctx);
Assert.assertTrue((Boolean) result);
}
diff --git a/src/test/java/org/apache/commons/jexl3/Issues200Test.java b/src/test/java/org/apache/commons/jexl3/Issues200Test.java
index fe5379097..3ac79973c 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues200Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues200Test.java
@@ -659,13 +659,13 @@ public void test275d() throws Exception {
@Test
public void test278() throws Exception {
- final String[] srcs = new String[]{
+ final String[] srcs = {
"return union x143('arg',5,6) ",
"return union y143('arg',5,6) ;",
"return union\n z143('arg',5,6) ;",
"var f =()->{ return union 143 } foo[0]"
};
- final Object[] ctls = new Object[]{
+ final Object[] ctls = {
"42","42","42", 42
};
final JexlEngine jexl = new JexlBuilder().cache(4).create();
@@ -716,7 +716,7 @@ public void test279() throws Exception {
Object result;
JexlScript script;
final JexlContext ctxt = new Context279();
- final String[] srcs = new String[]{
+ final String[] srcs = {
"var z = null; identity(z[0]);",
"var z = null; z.0;",
"var z = null; z.foo();",
@@ -932,7 +932,7 @@ public void test289() {
public void test290a() throws Exception {
Object result;
JexlScript script;
- final String[] srcs = new String[]{
+ final String[] srcs = {
"(x)->{ x.nothing().toString() }",
"(x)->{ x.toString().nothing() }",
"(x)->{ x.nothing().nothing() }",
@@ -963,7 +963,7 @@ public void test290a() throws Exception {
public void test290b() throws Exception {
Object result;
JexlScript script;
- final String[] srcs = new String[]{
+ final String[] srcs = {
"(x)->{ x?.nothing()?.toString() }",
"(x)->{ x.toString()?.nothing() }",
"(x)->{ x?.nothing().nothing() }",};
diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
index 2d1aea3cf..411002f6d 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
@@ -48,7 +48,7 @@ public class Issues300Test {
@Test
public void test301a() {
final JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(new JexlArithmetic(false)).create();
- final String[] srcs = new String[]{
+ final String[] srcs = {
"var x = null; x.0", "var x = null; x[0]", "var x = [null,1]; x[0][0]"
};
for (int i = 0; i < srcs.length; ++i) {
@@ -68,8 +68,8 @@ public void test301a() {
@Test
public void tests301b() {
final JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(new JexlArithmetic(false)).create();
- final Object[] xs = new Object[]{null, null, new Object[]{null, 1}};
- final String[] srcs = new String[]{
+ final Object[] xs = {null, null, new Object[]{null, 1}};
+ final String[] srcs = {
"x.0", "x[0]", "x[0][0]"
};
final JexlContext ctxt = new MapContext();
@@ -89,7 +89,7 @@ public void tests301b() {
@Test
public void test302() {
final JexlContext jc = new MapContext();
- final String[] strs = new String[]{
+ final String[] strs = {
"{if (0) 1 else 2; var x = 4;}",
"if (0) 1; else 2; ",
"{ if (0) 1; else 2; }",
@@ -125,7 +125,7 @@ public void test304() {
value = e304.evaluate(context);
assertEquals(42, value);
- final String[] keywords = new String[]{
+ final String[] keywords = {
"if", "else", "do", "while", "for", "break", "continue", "function", "return", "new", "size", "empty",
"var", "let", "const",
"null", "true", "false",
@@ -133,15 +133,15 @@ public void test304() {
"eq", "ne", "lt", "gt", "ge", "le",
};
- for(int i = 0; i < keywords.length; ++i) {
- String pkw = "e304." + keywords[i];
+ for (final String keyword : keywords) {
+ final String pkw = "e304." + keyword;
map.put(pkw, 42);
e304 = jexlEngine.createExpression(pkw);
value = e304.evaluate(context);
assertEquals(42, value);
}
for(int i = 0; i < keywords.length; ++i) {
- String pkw = "e304." + keywords[i] + "." + keywords[keywords.length - 1 - i];
+ final String pkw = "e304." + keywords[i] + "." + keywords[keywords.length - 1 - i];
map.put(pkw, 42);
e304 = jexlEngine.createExpression(pkw);
value = e304.evaluate(context);
@@ -390,10 +390,10 @@ public void test322a() {
final JxltEngine jxlt = jexl.createJxltEngine();
final JexlContext context = new MapContext();
- final String[] ins = new String[]{
+ final String[] ins = {
"${'{'}", "${\"{\"}", "${\"{}\"}", "${'{42}'}", "${\"{\\\"\\\"}\"}"
};
- final String[] ctls = new String[]{
+ final String[] ctls = {
"{", "{", "{}", "{42}", "{\"\"}"
};
StringWriter strw;
@@ -609,13 +609,13 @@ public void test347() {
Assert.assertFalse((Boolean) result);
jexl = new JexlBuilder().strict(true).safe(false).create();
- JexlContext ctxt = new MapContext();
+ final JexlContext ctxt = new MapContext();
script = jexl.createScript(src);
// A and A.B undefined
try {
result = script.execute(ctxt);
Assert.fail("should only succeed with safe navigation");
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
Assert.assertNotNull(xany);
}
// A is null, A.B is undefined
@@ -623,7 +623,7 @@ public void test347() {
try {
result = script.execute(ctxt);
Assert.fail("should only succeed with safe navigation");
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
Assert.assertNotNull(xany);
}
// A.B is null
@@ -634,10 +634,10 @@ public void test347() {
@Test public void test349() {
- String text = "(A ? C.D : E)";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlExpression expr = jexl.createExpression(text);
- JexlScript script = jexl.createScript(text);
+ final String text = "(A ? C.D : E)";
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlExpression expr = jexl.createExpression(text);
+ final JexlScript script = jexl.createScript(text);
}
static JexlContext pragmaticContext() {
@@ -653,170 +653,170 @@ static JexlContext pragmaticContext() {
+ " ${$options.lexicalShade?'+':'-'}lexicalShade"
+ " ${$options.sharedInstance?'+':'-'}sharedInstance"
+ " ${$options.safe?'+':'-'}safe`";
- String text = "#pragma script.mode pro50\n" +
+ final String text = "#pragma script.mode pro50\n" +
"()->{ ()->{ "+src0+"; } }";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(text);
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(text);
JexlContext context = pragmaticContext();
- JexlScript closure = (JexlScript) script.execute(context);
- JexlContext opts = new OptionsContext();
- Object result = closure.execute(opts);
+ final JexlScript closure = (JexlScript) script.execute(context);
+ final JexlContext opts = new OptionsContext();
+ final Object result = closure.execute(opts);
Assert.assertEquals("+strict +cancellable +lexical +lexicalShade -sharedInstance -safe", result);
- String text0 = "#pragma script.mode pro50\n" +
+ final String text0 = "#pragma script.mode pro50\n" +
"()->{ "+src0+"; }";
- JexlScript script0 = jexl.createScript(text0);
+ final JexlScript script0 = jexl.createScript(text0);
context = pragmaticContext();
- Object result0 = script0.execute(context);
+ final Object result0 = script0.execute(context);
Assert.assertEquals("+strict +cancellable +lexical +lexicalShade -sharedInstance -safe", result0);
- String text1 = "#pragma script.mode pro50\n"+src0;
- JexlScript script1 = jexl.createScript(text1);
+ final String text1 = "#pragma script.mode pro50\n"+src0;
+ final JexlScript script1 = jexl.createScript(text1);
context = pragmaticContext();
- Object result1 = script1.execute(context);
+ final Object result1 = script1.execute(context);
Assert.assertEquals("+strict +cancellable +lexical +lexicalShade -sharedInstance -safe", result1);
- String text2 = src0;
- JexlScript script2 = jexl.createScript(text2);
+ final String text2 = src0;
+ final JexlScript script2 = jexl.createScript(text2);
context = pragmaticContext();
- Object result2 = script2.execute(context);
+ final Object result2 = script2.execute(context);
Assert.assertEquals("-strict -cancellable -lexical -lexicalShade +sharedInstance +safe", result2);
}
@Test
public void test361a_32() {
- JexlEngine jexl = new Engine32(new JexlBuilder().safe(false));
- Object result = run361a(jexl);
+ final JexlEngine jexl = new Engine32(new JexlBuilder().safe(false));
+ final Object result = run361a(jexl);
Assert.assertNotNull(result);
}
@Test
public void test361a_33() {
- JexlEngine jexl = new JexlBuilder().safe(false).strict(true).create();
+ final JexlEngine jexl = new JexlBuilder().safe(false).strict(true).create();
try {
- Object result = run361a(jexl);
+ final Object result = run361a(jexl);
Assert.fail("null arg should fail");
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
Assert.assertNotNull(xany);
}
}
- private Object run361a(JexlEngine jexl) {
- String src = "()-> { ()-> { if (versionFile != null) { return 'foo'; } else { return 'bar'; }} }";
- JexlScript script = jexl.createScript(src);
- Object result = script.execute(null);
- JexlScript rs = (JexlScript) result;
+ private Object run361a(final JexlEngine jexl) {
+ final String src = "()-> { ()-> { if (versionFile != null) { return 'foo'; } else { return 'bar'; }} }";
+ final JexlScript script = jexl.createScript(src);
+ final Object result = script.execute(null);
+ final JexlScript rs = (JexlScript) result;
return rs.execute(null);
}
@Test
public void test361b_33() {
- JexlEngine jexl = new JexlBuilder().safe(false).strict(true).create();
+ final JexlEngine jexl = new JexlBuilder().safe(false).strict(true).create();
try {
- Object result = run361b(jexl);
+ final Object result = run361b(jexl);
Assert.fail("null arg should fail");
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
Assert.assertNotNull(xany);
}
}
@Test
public void test361b_32() {
- JexlEngine jexl = new Engine32(new JexlBuilder().safe(false).strict(false));
- Object result = run361b(jexl);
+ final JexlEngine jexl = new Engine32(new JexlBuilder().safe(false).strict(false));
+ final Object result = run361b(jexl);
Assert.assertNotNull(result);
}
- private Object run361b(JexlEngine jexl) {
- String src = "()-> { ()-> {" +
+ private Object run361b(final JexlEngine jexl) {
+ final String src = "()-> { ()-> {" +
"var voa = vaf.value;\n" +
"if (voa != NaN && voa <= 0)" +
"{ return 'foo'; } else { return 'bar'; }" +
"} }";
- JexlContext context = new MapContext();
- Map vaf = Collections.singletonMap("value", null);
+ final JexlContext context = new MapContext();
+ final Map vaf = Collections.singletonMap("value", null);
context.set("vaf", vaf);
- JexlScript script = jexl.createScript(src);
- Object result = script.execute(null);
- JexlScript rs = (JexlScript) result;
+ final JexlScript script = jexl.createScript(src);
+ final Object result = script.execute(null);
+ final JexlScript rs = (JexlScript) result;
return rs.execute(context);
}
@Test
public void test361_33() {
- JexlEngine jexl = new JexlBuilder().safe(false).strict(true).create();
+ final JexlEngine jexl = new JexlBuilder().safe(false).strict(true).create();
try {
run361c(jexl);
Assert.fail("null arg should fail");
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
Assert.assertNotNull(xany);
}
}
@Test
public void test361c_32() {
- JexlEngine jexl = new Engine32(new JexlBuilder().safe(false).strict(false));
- String result = run361c(jexl);
+ final JexlEngine jexl = new Engine32(new JexlBuilder().safe(false).strict(false));
+ final String result = run361c(jexl);
Assert.assertNotNull(result);
}
- private String run361c(JexlEngine jexl) {
- String src = "$$var t = null;\n" +
+ private String run361c(final JexlEngine jexl) {
+ final String src = "$$var t = null;\n" +
"$$if (t < 0) {\n" +
"'foo'\n" +
"$$} else {\n" +
"'bar'\n" +
"$$}";
- JxltEngine jxlt = jexl.createJxltEngine();
- JexlContext context = new MapContext();
- Map vaf = Collections.singletonMap("value", null);
+ final JxltEngine jxlt = jexl.createJxltEngine();
+ final JexlContext context = new MapContext();
+ final Map vaf = Collections.singletonMap("value", null);
context.set("vaf", vaf);
- JxltEngine.Template template = jxlt.createTemplate(src);
- StringWriter strw = new StringWriter();
+ final JxltEngine.Template template = jxlt.createTemplate(src);
+ final StringWriter strw = new StringWriter();
template.evaluate(context, strw);
return strw.toString();
}
@Test
public void test361d_32() {
- JexlEngine jexl = new Engine32(new JexlBuilder().lexical(false).lexicalShade(false).safe(false));
- Object result = run361d(jexl);
+ final JexlEngine jexl = new Engine32(new JexlBuilder().lexical(false).lexicalShade(false).safe(false));
+ final Object result = run361d(jexl);
Assert.assertNotNull(result);
}
@Test
public void test361d_33() {
- JexlEngine jexl = new JexlBuilder().lexical(true).lexicalShade(true).safe(false).strict(true).create();
+ final JexlEngine jexl = new JexlBuilder().lexical(true).lexicalShade(true).safe(false).strict(true).create();
try {
- Object result = run361d(jexl);
+ final Object result = run361d(jexl);
Assert.fail("null arg should fail");
- } catch (JexlException xany) {
+ } catch (final JexlException xany) {
Assert.assertNotNull(xany);
}
}
- private Object run361d(JexlEngine jexl) {
- String src = "var foo = 42; var foo = 43;";
- JexlScript script = jexl.createScript(src);
- Object result = script.execute(null);
+ private Object run361d(final JexlEngine jexl) {
+ final String src = "var foo = 42; var foo = 43;";
+ final JexlScript script = jexl.createScript(src);
+ final Object result = script.execute(null);
return result;
}
@Test public void test367() {
- String text = "var toto; function foo(x) { x }; var tata = 3; foo(3)";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(text);
- Object result = script.execute(null);
+ final String text = "var toto; function foo(x) { x }; var tata = 3; foo(3)";
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(text);
+ final Object result = script.execute(null);
Assert.assertEquals(3, result);
- String s0 = script.getParsedText();
- String s1 = script.getSourceText();
+ final String s0 = script.getParsedText();
+ final String s1 = script.getSourceText();
Assert.assertNotEquals(s0, s1);
}
public static class Var370 {
private String name = null;
- public void setName(String s) {
+ public void setName(final String s) {
name = s;
}
public String getName() {
@@ -825,9 +825,9 @@ public String getName() {
}
@Test public void test370() {
- Var370 var370 = new Var370();
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- ObjectContext ctxt = new ObjectContext<>(jexl, var370);
+ final Var370 var370 = new Var370();
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final ObjectContext ctxt = new ObjectContext<>(jexl, var370);
JexlExpression get = jexl.createExpression("name");
// not null
var370.setName("John");
@@ -843,7 +843,7 @@ public String getName() {
try {
get.evaluate(ctxt);
Assert.fail("phone should be undefined!");
- } catch (JexlException.Variable xvar) {
+ } catch (final JexlException.Variable xvar) {
Assert.assertEquals("phone", xvar.getVariable());
}
}
@@ -854,31 +854,31 @@ public static class TestObject374 {
public String getName() {
return name;
}
- public void setName(String pName) {
+ public void setName(final String pName) {
this.name = pName;
}
public TestObject374 getNested() {
return nested;
}
- public void setNested(TestObject374 pNested) {
+ public void setNested(final TestObject374 pNested) {
nested = pNested;
}
}
@Test
public void test374() {
- JexlEngine engine = new JexlBuilder().cache(512).strict(true).silent(false).antish(false).safe(false).create();
+ final JexlEngine engine = new JexlBuilder().cache(512).strict(true).silent(false).antish(false).safe(false).create();
// Create expression to evaluate 'name'
- JexlExpression expr = engine.createExpression("nested.name");
+ final JexlExpression expr = engine.createExpression("nested.name");
// Create an object with getter for name
- TestObject374 myObject = new TestObject374();
+ final TestObject374 myObject = new TestObject374();
myObject.setName("John");
- JexlContext context = new ObjectContext<>(engine, myObject);
+ final JexlContext context = new ObjectContext<>(engine, myObject);
// Expect an exception because nested is null, so we are doing null.name
try {
- Object result = expr.evaluate(context);
+ final Object result = expr.evaluate(context);
Assert.fail("An exception expected, but got: " + result);
- } catch (JexlException ex) {
+ } catch (final JexlException ex) {
// Expected
//ex.printStackTrace();
}
@@ -886,11 +886,11 @@ public void test374() {
@Test
public void test375() {
- JexlSandbox jexlSandbox = new JexlSandbox(false);
+ final JexlSandbox jexlSandbox = new JexlSandbox(false);
jexlSandbox.allow(Type375.class.getName());
- JexlEngine engine = new JexlBuilder().sandbox(jexlSandbox).create();
+ final JexlEngine engine = new JexlBuilder().sandbox(jexlSandbox).create();
- JexlContext context = new MapContext();
+ final JexlContext context = new MapContext();
context.set("Type", Type375.class);
Object result = engine.createScript("Type.valueOf('DOMICILE')").execute(context);
@@ -908,10 +908,10 @@ public enum Type375 {
@Test
public void test377() {
- String text = "function add(x, y) { x + y } add(a, b)";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(text, "a", "b");
- Object result = script.execute(null, 20, 22);
+ final String text = "function add(x, y) { x + y } add(a, b)";
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(text, "a", "b");
+ final Object result = script.execute(null, 20, 22);
Assert.assertEquals(42, result);
}
@@ -920,10 +920,10 @@ public void test379a() {
final String src =
"#pragma jexl.import java.util\n"+
"const map = new LinkedHashMap({0 : 'zero'});";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlScript script = jexl.createScript(src);
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlScript script = jexl.createScript(src);
Assert.assertNotNull(script);
- Object result = script.execute(null);
+ final Object result = script.execute(null);
Assert.assertNotNull(result);
Assert.assertTrue(result instanceof LinkedHashMap);
Assert.assertEquals(1, ((Map) result).size());
@@ -932,24 +932,24 @@ public void test379a() {
@Test
public void test373b() {
final String src = "var i = ++1";
- JexlEngine jexl = new JexlBuilder().safe(true).create();
- JexlInfo info = new JexlInfo("badscript", 0, 0);
+ final JexlEngine jexl = new JexlBuilder().safe(true).create();
+ final JexlInfo info = new JexlInfo("badscript", 0, 0);
try {
- JexlScript script = jexl.createScript(info, src);
+ final JexlScript script = jexl.createScript(info, src);
Assert.fail("should not parse");
- } catch (JexlException.Parsing xparse) {
- String msg = xparse.getMessage();
+ } catch (final JexlException.Parsing xparse) {
+ final String msg = xparse.getMessage();
Assert.assertTrue(msg.contains("badscript"));
}
}
@Test
public void testBackslashes() throws Exception {
- JexlEngine jexl = new JexlBuilder().safe(false).create();
- String src = "\"\b\t\f\"";
+ final JexlEngine jexl = new JexlBuilder().safe(false).create();
+ final String src = "\"\b\t\f\"";
JexlScript s = jexl.createScript(src);
Assert.assertNotNull(s);
- String ctl = "\b\t\f";
+ final String ctl = "\b\t\f";
Assert.assertEquals(ctl, s.execute(null));
String parsed = s.getParsedText();
Assert.assertEquals("'\\b\\t\\f'", parsed);
@@ -964,8 +964,8 @@ public void testBackslashes() throws Exception {
* Mock driver.
*/
public static class Driver0930 {
- private String name;
- Driver0930(String n) {
+ private final String name;
+ Driver0930(final String n) {
name = n;
}
public String getAttributeName() {
@@ -980,7 +980,7 @@ public static class Context0930 extends MapContext {
* @param filter the lambda to use as filter
* @return the filtered stream
*/
- public Stream> filter(Stream> stream, JexlScript filter) {
+ public Stream> filter(final Stream> stream, final JexlScript filter) {
return stream.filter(x -> Boolean.TRUE.equals(filter.execute(this, x)));
}
}
@@ -988,7 +988,7 @@ public Stream> filter(Stream> stream, JexlScript filter) {
@Test
public void testSO20220930() {
// fill some drivers in a list
- List values = new ArrayList<>();
+ final List values = new ArrayList<>();
for(int i = 0; i < 8; ++i) {
values.add(new Driver0930("drvr" + Integer.toOctalString(i)));
}
@@ -996,34 +996,34 @@ public void testSO20220930() {
values.add(new Driver0930("favorite" + Integer.toOctalString(i)));
}
// Use a context that can filter and that exposes Collectors
- JexlEngine jexl = new JexlBuilder().safe(false).create();
- JexlContext context = new Context0930();
+ final JexlEngine jexl = new JexlBuilder().safe(false).create();
+ final JexlContext context = new Context0930();
context.set("values", values);
context.set("Collectors", Collectors.class);
// The script with a JEXL 3.2 (lambda function) and 3.3 syntax (lambda expression)
- String src32 = "values.stream().filter((driver) ->{ driver.attributeName =^ 'favorite' }).collect(Collectors.toList())";
- String src33 = "values.stream().filter(driver -> driver.attributeName =^ 'favorite').collect(Collectors.toList())";
- for(String src : Arrays.asList(src32, src33)) {
- JexlExpression s = jexl.createExpression(src);
+ final String src32 = "values.stream().filter((driver) ->{ driver.attributeName =^ 'favorite' }).collect(Collectors.toList())";
+ final String src33 = "values.stream().filter(driver -> driver.attributeName =^ 'favorite').collect(Collectors.toList())";
+ for(final String src : Arrays.asList(src32, src33)) {
+ final JexlExpression s = jexl.createExpression(src);
Assert.assertNotNull(s);
- Object r = s.evaluate(context);
+ final Object r = s.evaluate(context);
Assert.assertNotNull(r);
// got a filtered list of 4 drivers whose attribute name starts with 'favorite'
- List l = (List) r;
+ final List l = (List) r;
Assert.assertEquals(4, l.size());
- for (Driver0930 d : l) {
+ for (final Driver0930 d : l) {
Assert.assertTrue(d.getAttributeName().startsWith("favorite"));
}
}
}
public static class Arithmetic383 extends JexlArithmetic {
- public Arithmetic383(boolean astrict) {
+ public Arithmetic383(final boolean astrict) {
super(astrict);
}
@Override
- public boolean isStrict(JexlOperator op) {
+ public boolean isStrict(final JexlOperator op) {
switch(op) {
case NOT:
case CONDITION:
@@ -1034,9 +1034,9 @@ public boolean isStrict(JexlOperator op) {
}
@Test public void test383() {
- JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(new Arithmetic383(true)).create();
- String src0 = "if (a) 1; else 2;";
- String src1 = "if (!a) 1; else 2;";
+ final JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(new Arithmetic383(true)).create();
+ final String src0 = "if (a) 1; else 2;";
+ final String src1 = "if (!a) 1; else 2;";
// local var
JexlScript s0 = jexl.createScript(src0, "a");
JexlScript s1 = jexl.createScript(src1, "a");
@@ -1047,28 +1047,28 @@ public boolean isStrict(JexlOperator op) {
s1 = jexl.createScript(src1);
try {
Assert.assertEquals(2, s0.execute(null, (Object) null));
- } catch (JexlException.Variable xvar) {
+ } catch (final JexlException.Variable xvar) {
Assert.assertEquals("a", xvar.getVariable());
}
try {
Assert.assertEquals(1, s1.execute(null, (Object) null));
- } catch (JexlException.Variable xvar) {
+ } catch (final JexlException.Variable xvar) {
Assert.assertEquals("a", xvar.getVariable());
}
// global var null
- MapContext ctxt = new MapContext();
+ final MapContext ctxt = new MapContext();
ctxt.set("a", null);
Assert.assertEquals(2, s0.execute(ctxt, (Object) null));
Assert.assertEquals(1, s1.execute(ctxt, (Object) null));
}
public static class Arithmetic384 extends JexlArithmetic {
- public Arithmetic384(boolean astrict) {
+ public Arithmetic384(final boolean astrict) {
super(astrict);
}
@Override
- public boolean isStrict(JexlOperator op) {
+ public boolean isStrict(final JexlOperator op) {
if (JexlOperator.ADD == op) {
return false;
}
@@ -1077,29 +1077,29 @@ public boolean isStrict(JexlOperator op) {
}
@Test
public void test384a() {
- JexlEngine jexl = new JexlBuilder()
+ final JexlEngine jexl = new JexlBuilder()
.safe(false)
.strict(true)
.create();
// constant
- for(String src0 : Arrays.asList("'ABC' + null", "null + 'ABC'")) {
- JexlContext ctxt = new MapContext();
- JexlScript s0 = jexl.createScript(src0);
+ for(final String src0 : Arrays.asList("'ABC' + null", "null + 'ABC'")) {
+ final JexlContext ctxt = new MapContext();
+ final JexlScript s0 = jexl.createScript(src0);
try {
s0.execute(ctxt, (Object) null);
Assert.fail("null argument should throw");
- } catch (JexlException xvar) {
+ } catch (final JexlException xvar) {
Assert.assertTrue(xvar.toString().contains("+"));
}
}
// null local a
- for(String src1 : Arrays.asList("'ABC' + a", "a + 'ABC'")) {
- JexlContext ctxt = new MapContext();
+ for(final String src1 : Arrays.asList("'ABC' + a", "a + 'ABC'")) {
+ final JexlContext ctxt = new MapContext();
JexlScript s1 = jexl.createScript(src1, "a");
try {
s1.execute(ctxt, (Object) null);
Assert.fail("null argument should throw");
- } catch (JexlException.Variable xvar) {
+ } catch (final JexlException.Variable xvar) {
Assert.assertEquals("a", xvar.getVariable());
}
// undefined a
@@ -1107,7 +1107,7 @@ public void test384a() {
try {
s1.execute(ctxt, (Object) null);
Assert.fail("null argument should throw");
- } catch (JexlException.Variable xvar) {
+ } catch (final JexlException.Variable xvar) {
Assert.assertEquals("a", xvar.getVariable());
Assert.assertTrue(xvar.isUndefined());
}
@@ -1116,7 +1116,7 @@ public void test384a() {
try {
s1.execute(ctxt, (Object) null);
Assert.fail("null argument should throw");
- } catch (JexlException.Variable xvar) {
+ } catch (final JexlException.Variable xvar) {
Assert.assertEquals("a", xvar.getVariable());
Assert.assertFalse(xvar.isUndefined());
}
@@ -1125,20 +1125,20 @@ public void test384a() {
@Test
public void test384b() {
// be explicit about + handling null
- JexlEngine jexl = new JexlBuilder()
+ final JexlEngine jexl = new JexlBuilder()
.arithmetic(new Arithmetic384(true))
.safe(false)
.strict(true)
.create();
// constant
- for(String src0 : Arrays.asList("'ABC' + null", "null + 'ABC'")) {
- JexlContext ctxt = new MapContext();
- JexlScript s0 = jexl.createScript(src0);
+ for(final String src0 : Arrays.asList("'ABC' + null", "null + 'ABC'")) {
+ final JexlContext ctxt = new MapContext();
+ final JexlScript s0 = jexl.createScript(src0);
Assert.assertEquals("ABC", s0.execute(ctxt));
}
// null local a
- for(String src1 : Arrays.asList("'ABC' + a", "a + 'ABC'")) {
- JexlContext ctxt = new MapContext();
+ for(final String src1 : Arrays.asList("'ABC' + a", "a + 'ABC'")) {
+ final JexlContext ctxt = new MapContext();
JexlScript s1 = jexl.createScript(src1, "a");
Assert.assertEquals("ABC", s1.execute(ctxt, (Object) null));
// undefined a
@@ -1146,7 +1146,7 @@ public void test384b() {
try {
s1.execute(ctxt, (Object) null);
Assert.fail("null argument should throw");
- } catch (JexlException.Variable xvar) {
+ } catch (final JexlException.Variable xvar) {
Assert.assertEquals("a", xvar.getVariable());
Assert.assertTrue(xvar.isUndefined());
}
@@ -1168,12 +1168,12 @@ public void test390() throws Exception {
try {
script = jexl.createScript(src);
Assert.fail("should have failed parsing");
- } catch (JexlException.Parsing xparse) {
+ } catch (final JexlException.Parsing xparse) {
Assert.assertTrue(xparse.getDetail().contains("pragma"));
}
src = "if (true) { #pragma one 42 }";
script = jexl.createScript(src);
- Object result = script.execute(null);
+ final Object result = script.execute(null);
debuggerCheck(jexl);
}
@@ -1182,32 +1182,32 @@ public static class Arithmetic384c extends JexlArithmetic {
int getCmpCalls() {
return cmp.get();
}
- public Arithmetic384c(boolean astrict) {
+ public Arithmetic384c(final boolean astrict) {
super(astrict);
}
- public Arithmetic384c(boolean astrict, MathContext bigdContext, int bigdScale) {
+ public Arithmetic384c(final boolean astrict, final MathContext bigdContext, final int bigdScale) {
super(astrict, bigdContext, bigdScale);
}
@Override
- protected int compare(Object l, Object r, String op) {
+ protected int compare(final Object l, final Object r, final String op) {
cmp.incrementAndGet();
return super.compare(l, r, op);
}
}
public static class Arithmetic384d extends Arithmetic384c {
- public Arithmetic384d(boolean astrict) {
+ public Arithmetic384d(final boolean astrict) {
super(astrict);
}
- public Arithmetic384d(boolean astrict, MathContext bigdContext, int bigdScale) {
+ public Arithmetic384d(final boolean astrict, final MathContext bigdContext, final int bigdScale) {
super(astrict, bigdContext, bigdScale);
}
}
@Test
public void test384c() {
- Arithmetic384c ja = new Arithmetic384c(true);
- JexlEngine jexl = new JexlBuilder()
+ final Arithmetic384c ja = new Arithmetic384c(true);
+ final JexlEngine jexl = new JexlBuilder()
.safe(false)
.strict(true)
.arithmetic(ja)
@@ -1223,8 +1223,8 @@ public void test384c() {
@Test
public void test384d() {
- Arithmetic384c ja = new Arithmetic384d(true);
- JexlEngine jexl = new JexlBuilder()
+ final Arithmetic384c ja = new Arithmetic384d(true);
+ final JexlEngine jexl = new JexlBuilder()
.safe(false)
.strict(true)
.arithmetic(ja)
@@ -1240,32 +1240,32 @@ public void test384d() {
@Test
public void test393() {
- String src = "const total = 0;\n" +
+ final String src = "const total = 0;\n" +
"if (true) {\n" +
" total = 1;\n" +
"}\n" +
"total; ";
- JexlEngine jexl = new JexlBuilder()
+ final JexlEngine jexl = new JexlBuilder()
.safe(false)
.strict(true)
.create();
try {
- JexlScript script = jexl.createScript(src);
+ final JexlScript script = jexl.createScript(src);
Assert.fail("should fail on const total assignment");
- } catch (JexlException.Parsing xparse) {
+ } catch (final JexlException.Parsing xparse) {
Assert.assertTrue(xparse.getMessage().contains("total"));
}
}
@Test public void testDow() {
- String src = "(y, m, d)->{\n" +
+ final String src = "(y, m, d)->{\n" +
"// will return 0 for Sunday, 6 for Saturday\n" +
"const t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];\n"+
"if (m < 3) { --y }\n" +
"(y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;\n" +
"}";
- JexlEngine jexl = new JexlBuilder().create();
- JexlScript script = jexl.createScript(src);
+ final JexlEngine jexl = new JexlBuilder().create();
+ final JexlScript script = jexl.createScript(src);
Object r = script.execute(null, 2023, 3, 1);
Assert.assertTrue(r instanceof Number);
Number dow = (Number) r;
@@ -1277,12 +1277,12 @@ public void test393() {
}
@Test public void testIssue394() {
- StringBuilder x = new StringBuilder("foobar");
+ final StringBuilder x = new StringBuilder("foobar");
Assert.assertEquals("foobar", x.toString());
- String src = "x -> x.setLength(3)";
- JexlEngine jexl = new JexlBuilder().create();
- JexlScript script = jexl.createScript(src);
- Object result = script.execute(null, x);
+ final String src = "x -> x.setLength(3)";
+ final JexlEngine jexl = new JexlBuilder().create();
+ final JexlScript script = jexl.createScript(src);
+ final Object result = script.execute(null, x);
Assert.assertEquals("foo", x.toString());
}
@@ -1306,15 +1306,15 @@ T createProxy(final JexlEngine jexl, final Object o, final Class[] clazzz) {
final String control = Class397.class.getName();
final JexlEngine jexl = new JexlBuilder().permissions(RESTRICTED).create();
- Interface397i instance = new Class397();
+ final Interface397i instance = new Class397();
result = (String) jexl.invokeMethod(instance, "summary");
Assert.assertEquals(control, result);
- Interface397i proxy = createProxy(jexl, instance, new Class[] { Interface397i.class }) ;
+ final Interface397i proxy = createProxy(jexl, instance, new Class[] { Interface397i.class }) ;
result = (String) jexl.invokeMethod(proxy, "summary");
Assert.assertEquals(control, result);
- JexlScript script = jexl.createScript("dan.summary()", "dan");
+ final JexlScript script = jexl.createScript("dan.summary()", "dan");
result = (String) script.execute(null, instance);
Assert.assertEquals(control, result);
result = (String) script.execute(null, proxy);
@@ -1324,7 +1324,7 @@ T createProxy(final JexlEngine jexl, final Object o, final Class[] clazzz) {
@Test
public void testUnsolvableMethod() throws Exception {
final JexlEngine jexl = new JexlBuilder().create();
- JexlScript script = jexl.createScript(
+ final JexlScript script = jexl.createScript(
"var myFunction1 = function(object) {"
+ " myNonExistentFunction();"
+ "}"
@@ -1342,15 +1342,15 @@ public void testUnsolvableMethod() throws Exception {
@Test
public void testIssue398() {
- String src = "let m = {\n" +
+ final String src = "let m = {\n" +
" \"foo\": 1,\n" +
" \"bar\": 2,\n" +
"}";
final JexlEngine jexl = new JexlBuilder().create();
- JexlScript script = jexl.createScript(src);
- Object result = script.execute(null);
+ final JexlScript script = jexl.createScript(src);
+ final Object result = script.execute(null);
Assert.assertTrue(result instanceof Map);
- Map,?> map = (Map, ?>) result;
+ final Map,?> map = (Map, ?>) result;
Assert.assertEquals(2, map.size());
}
}
diff --git a/src/test/java/org/apache/commons/jexl3/Issues400Test.java b/src/test/java/org/apache/commons/jexl3/Issues400Test.java
index 70be9f193..863d3b0e1 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues400Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues400Test.java
@@ -16,30 +16,11 @@
*/
package org.apache.commons.jexl3;
-import org.apache.commons.jexl3.internal.Engine32;
-import org.apache.commons.jexl3.internal.OptionsContext;
-import static org.apache.commons.jexl3.introspection.JexlPermissions.RESTRICTED;
-import org.apache.commons.jexl3.introspection.JexlSandbox;
import org.junit.Assert;
import org.junit.Test;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.Proxy;
-import java.math.MathContext;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.apache.commons.jexl3.internal.Util.debuggerCheck;
-import static org.junit.Assert.assertEquals;
/**
* Test cases for reported issue between JEXL-300 and JEXL-399.
@@ -49,7 +30,7 @@ public class Issues400Test {
@Test
public void test402() {
final JexlContext jc = new MapContext();
- final String[] sources = new String[]{
+ final String[] sources = {
"if (true) { return }",
"if (true) { 3; return }",
"(x->{ 3; return })()"
@@ -64,12 +45,12 @@ public void test402() {
@Test
public void test403() {
- for(String setmap : new String[]{
+ for(final String setmap : new String[]{
" map1.`${item.a}` = 1;\n",
" map1[`${item.a}`] = 1;\n",
" map1[item.a] = 1;\n"
}) {
- String src = "var a = {'a': 1};\n" +
+ final String src = "var a = {'a': 1};\n" +
"var list = [a, a];\n" +
"let map1 = {:};\n" +
"for (var item : list) {\n" +
@@ -77,11 +58,11 @@ public void test403() {
"}\n " +
"map1";
final JexlEngine jexl = new JexlBuilder().cache(64).create();
- JexlScript script = jexl.createScript(src);
+ final JexlScript script = jexl.createScript(src);
for (int i = 0; i < 2; ++i) {
- Object result = script.execute(null);
+ final Object result = script.execute(null);
Assert.assertTrue(result instanceof Map);
- Map, ?> map = (Map, ?>) result;
+ final Map, ?> map = (Map, ?>) result;
Assert.assertEquals(1, map.size());
Assert.assertTrue(map.containsKey(1));
Assert.assertTrue(map.containsValue(1));
@@ -98,32 +79,32 @@ public void test404a() {
.create();
Map a = Collections.singletonMap("b", 42);
// access is constant
- for(String src : new String[]{ "a.b", "a?.b", "a['b']", "a?['b']", "a?.`b`"}) {
+ for(final String src : new String[]{ "a.b", "a?.b", "a['b']", "a?['b']", "a?.`b`"}) {
run404(jexl, src, a);
run404(jexl, src + ";", a);
}
// access is variable
- for(String src : new String[]{ "a[b]", "a?[b]", "a?.`${b}`"}) {
+ for(final String src : new String[]{ "a[b]", "a?[b]", "a?.`${b}`"}) {
run404(jexl, src, a, "b");
run404(jexl, src + ";", a, "b");
}
// add a 3rd access
- Map b = Collections.singletonMap("c", 42);
+ final Map b = Collections.singletonMap("c", 42);
a = Collections.singletonMap("b", b);
- for(String src : new String[]{ "a[b].c", "a?[b]?['c']", "a?.`${b}`.c"}) {
+ for(final String src : new String[]{ "a[b].c", "a?[b]?['c']", "a?.`${b}`.c"}) {
run404(jexl, src, a, "b");
}
}
- private static void run404(JexlEngine jexl, String src, Object...a) {
+ private static void run404(final JexlEngine jexl, final String src, final Object...a) {
try {
- JexlScript script = jexl.createScript(src, "a", "b");
+ final JexlScript script = jexl.createScript(src, "a", "b");
if (!src.endsWith(";")) {
Assert.assertEquals(script.getSourceText(), script.getParsedText());
}
- Object result = script.execute(null, a);
+ final Object result = script.execute(null, a);
Assert.assertEquals(42, result);
- } catch(JexlException.Parsing xparse) {
+ } catch(final JexlException.Parsing xparse) {
Assert.fail(src);
}
}
@@ -135,8 +116,8 @@ public void test404b() {
.strict(true)
.safe(false)
.create();
- Map b = Collections.singletonMap("c", 42);
- Map a = Collections.singletonMap("b", b);
+ final Map b = Collections.singletonMap("c", 42);
+ final Map a = Collections.singletonMap("b", b);
JexlScript script;
Object result = -42;
script = jexl.createScript("a?['B']?['C']", "a");
diff --git a/src/test/java/org/apache/commons/jexl3/JXLTTest.java b/src/test/java/org/apache/commons/jexl3/JXLTTest.java
index 42b573c48..d61a07d5a 100644
--- a/src/test/java/org/apache/commons/jexl3/JXLTTest.java
+++ b/src/test/java/org/apache/commons/jexl3/JXLTTest.java
@@ -146,7 +146,7 @@ public void testStatement() throws Exception {
context.set("froboz", froboz);
final JxltEngine.Expression check = JXLT.createExpression("${ froboz.plus10() }");
final Object o = check.evaluate(context);
- Assert.assertEquals("Result is not 32", new Integer(32), o);
+ Assert.assertEquals("Result is not 32", Integer.valueOf(32), o);
Assert.assertEquals("Result is not 42", 42, froboz.getValue());
final Set> evars = check.getVariables();
Assert.assertEquals(1, evars.size());
@@ -159,9 +159,9 @@ public void testAssign() throws Exception {
final JxltEngine.Expression assign = JXLT.createExpression("${froboz.value = 42}");
final JxltEngine.Expression check = JXLT.createExpression("${froboz.value}");
Object o = assign.evaluate(context);
- Assert.assertEquals("Result is not 10", new Integer(42), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(42), o);
o = check.evaluate(context);
- Assert.assertEquals("Result is not 10", new Integer(42), o);
+ Assert.assertEquals("Result is not 10", Integer.valueOf(42), o);
}
@Test
@@ -778,7 +778,7 @@ public void testInterpolationLvsG2() throws Exception {
@Test
public void testInterpolationParameter() throws Exception {
final String expr = "(user)->{`Hello \n${user}`}";
- JexlScript script = ENGINE.createScript(expr);
+ final JexlScript script = ENGINE.createScript(expr);
Object value = script.execute(context, "Henrib");
Assert.assertEquals(expr, "Hello \nHenrib", value);
value = ENGINE.createScript(expr).execute(context, "Dimitri");
@@ -787,18 +787,18 @@ public void testInterpolationParameter() throws Exception {
@Test
public void testDbgEscapes() throws Exception {
- String[] srcs = new String[]{
+ final String[] srcs = {
"jexl:print('hello\\'\\nworld')",
"'hello\\tworld'",
"'hello\\nworld'",
"'hello\\fworld'",
"'hello\\rworld'"
};
- for(String src : srcs) {
- JexlScript script = ENGINE.createScript(src);
- Debugger dbg = new Debugger();
+ for(final String src : srcs) {
+ final JexlScript script = ENGINE.createScript(src);
+ final Debugger dbg = new Debugger();
dbg.debug(script);
- String msrc = dbg.toString();
+ final String msrc = dbg.toString();
Assert.assertEquals(src, msrc);
}
}
@@ -1035,7 +1035,7 @@ public void testLexicalTemplate() throws Exception {
final Writer strw0 = new StringWriter();
tmplt0.evaluate(ctxt, strw0);
final String output0 = strw0.toString();
- JexlFeatures features = BUILDER.features();
+ final JexlFeatures features = BUILDER.features();
if (features != null && features.isLexical() && features.isLexicalShade()) {
Assert.assertEquals("-strict -cancellable +lexical +lexicalShade +safe", output0);
} else {
@@ -1155,7 +1155,7 @@ public void testCommentedTemplate1() throws Exception {
@Test
public void testConstantTemplate() {
- String src = "