Polish: assertion arguments should be passed in the correct order,
use assertNull instead of assertEquals(null, value), declare delta as double value in assertEquals
This commit is contained in:
committed by
Juergen Hoeller
parent
39201adca4
commit
0ee505b73e
@@ -70,7 +70,7 @@ public abstract class AbstractExpressionTests {
|
||||
if (expectedValue == null) {
|
||||
return; // no point doing other checks
|
||||
}
|
||||
assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue, null);
|
||||
assertNull("Expression returned null value, but expected '" + expectedValue + "'", expectedValue);
|
||||
}
|
||||
|
||||
Class<?> resultType = value.getClass();
|
||||
@@ -100,7 +100,7 @@ public abstract class AbstractExpressionTests {
|
||||
if (expectedValue == null) {
|
||||
return; // no point doing other checks
|
||||
}
|
||||
assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue, null);
|
||||
assertNull("Expression returned null value, but expected '" + expectedValue + "'", expectedValue);
|
||||
}
|
||||
|
||||
Class<?> resultType = value.getClass();
|
||||
@@ -132,7 +132,7 @@ public abstract class AbstractExpressionTests {
|
||||
if (expectedValue == null) {
|
||||
return; // no point doing other checks
|
||||
}
|
||||
assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue, null);
|
||||
assertNull("Expression returned null value, but expected '" + expectedValue + "'", expectedValue);
|
||||
}
|
||||
Class<? extends Object> resultType = value.getClass();
|
||||
if (expectedValue instanceof String) {
|
||||
@@ -142,8 +142,8 @@ public abstract class AbstractExpressionTests {
|
||||
else {
|
||||
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
|
||||
}
|
||||
assertEquals("Type of the result was not as expected. Expected '" + expectedClassOfResult +
|
||||
"' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType), true);
|
||||
assertNull("Type of the result was not as expected. Expected '" + expectedClassOfResult +
|
||||
"' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType));
|
||||
|
||||
boolean isWritable = expr.isWritable(eContext);
|
||||
if (isWritable != shouldBeWritable) {
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ConstructorInvocationTests extends AbstractExpressionTests {
|
||||
eContext.setRootObject(new Tester());
|
||||
eContext.setVariable("bar", 3);
|
||||
Object o = expr.getValue(eContext);
|
||||
assertEquals(o, 3);
|
||||
assertEquals(3, o);
|
||||
assertEquals(1, parser.parseExpression("counter").getValue(eContext));
|
||||
|
||||
// Now the expression has cached that throwException(int) is the right thing to
|
||||
|
||||
@@ -535,7 +535,7 @@ public class EvaluationTests extends AbstractExpressionTests {
|
||||
int twentyFour = parser.parseExpression("2.0 * 3e0 * 4").getValue(Integer.class);
|
||||
assertEquals(24, twentyFour);
|
||||
double one = parser.parseExpression("8.0 / 5e0 % 2").getValue(Double.class);
|
||||
assertEquals(1.6d, one, 0);
|
||||
assertEquals(1.6d, one, 0d);
|
||||
int o = parser.parseExpression("8.0 / 5e0 % 2").getValue(Integer.class);
|
||||
assertEquals(1, o);
|
||||
int sixteen = parser.parseExpression("-2 ^ 4").getValue(Integer.class);
|
||||
|
||||
@@ -219,7 +219,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
|
||||
fail("Should not be allowed to set oranges to be blue !");
|
||||
}
|
||||
catch (SpelEvaluationException ee) {
|
||||
assertEquals(ee.getMessageCode(), SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
assertEquals(SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL, ee.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
|
||||
fail("Should not be allowed to set peas to be blue !");
|
||||
}
|
||||
catch (SpelEvaluationException ee) {
|
||||
assertEquals(ee.getMessageCode(), SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL);
|
||||
assertEquals(SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL, ee.getMessageCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class LiteralExpressionTests {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
// success, not allowed - whilst here, check the expression value in the exception
|
||||
assertEquals(ee.getExpressionString(), "somevalue");
|
||||
assertEquals("somevalue", ee.getExpressionString());
|
||||
}
|
||||
try {
|
||||
LiteralExpression lEx = new LiteralExpression("somevalue");
|
||||
@@ -68,7 +68,7 @@ public class LiteralExpressionTests {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
// success, not allowed - whilst here, check the expression value in the exception
|
||||
assertEquals(ee.getExpressionString(), "somevalue");
|
||||
assertEquals("somevalue", ee.getExpressionString());
|
||||
}
|
||||
try {
|
||||
LiteralExpression lEx = new LiteralExpression("somevalue");
|
||||
@@ -77,7 +77,7 @@ public class LiteralExpressionTests {
|
||||
}
|
||||
catch (EvaluationException ee) {
|
||||
// success, not allowed - whilst here, check the expression value in the exception
|
||||
assertEquals(ee.getExpressionString(), "somevalue");
|
||||
assertEquals("somevalue", ee.getExpressionString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class MethodInvocationTests extends AbstractExpressionTests {
|
||||
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
|
||||
eContext.setVariable("bar", 3);
|
||||
Object o = expr.getValue(eContext);
|
||||
assertEquals(o, 3);
|
||||
assertEquals(3, o);
|
||||
assertEquals(1, parser.parseExpression("counter").getValue(eContext));
|
||||
|
||||
// Now the expression has cached that throwException(int) is the right thing to call
|
||||
@@ -294,7 +294,7 @@ public class MethodInvocationTests extends AbstractExpressionTests {
|
||||
public void testMethodOfClass() throws Exception {
|
||||
Expression expression = parser.parseExpression("getName()");
|
||||
Object value = expression.getValue(new StandardEvaluationContext(String.class));
|
||||
assertEquals(value, "java.lang.String");
|
||||
assertEquals("java.lang.String", value);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -115,7 +115,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
ctx.addPropertyAccessor(new StringyPropertyAccessor());
|
||||
Expression expr = parser.parseRaw("new String('hello').flibbles");
|
||||
Integer i = expr.getValue(ctx, Integer.class);
|
||||
assertEquals((int) i, 7);
|
||||
assertEquals(7, (int) i);
|
||||
|
||||
// The reflection one will be used for other properties...
|
||||
expr = parser.parseRaw("new String('hello').CASE_INSENSITIVE_ORDER");
|
||||
@@ -125,7 +125,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
expr = parser.parseRaw("new String('hello').flibbles");
|
||||
expr.setValue(ctx, 99);
|
||||
i = expr.getValue(ctx, Integer.class);
|
||||
assertEquals((int) i, 99);
|
||||
assertEquals(99, (int) i);
|
||||
|
||||
// Cannot set it to a string value
|
||||
try {
|
||||
@@ -165,7 +165,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
|
||||
public void testAccessingPropertyOfClass() throws Exception {
|
||||
Expression expression = parser.parseExpression("name");
|
||||
Object value = expression.getValue(new StandardEvaluationContext(String.class));
|
||||
assertEquals(value, "java.lang.String");
|
||||
assertEquals("java.lang.String", value);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user