Polish test classes

- Consistent importing of org.junit.Assert.*;
- Proper declaration of expected exceptions via @Test(expected).
- Renamed SpEL ExpressionTestCase to AbstractExpressionTests.
- Formatting and test method naming conventions.
This commit is contained in:
Sam Brannen 2014-02-08 17:24:11 +01:00
parent f717b55035
commit 1f778530b5
34 changed files with 879 additions and 748 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -15,15 +15,6 @@
*/
package org.springframework.aop.aspectj.annotation;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -46,7 +37,9 @@ import org.aspectj.lang.annotation.DeclareParents;
import org.aspectj.lang.annotation.DeclarePrecedence;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.junit.Test;
import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.SyntheticInstantiationAdvisor;
import org.springframework.aop.framework.Advised;
@ -66,6 +59,9 @@ import test.aop.Lockable;
import test.aop.PerTargetAspect;
import test.aop.TwoAdviceAspect;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
/**
* Abstract tests for AspectJAdvisorFactory.
* See subclasses for tests of concrete factories.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,10 +16,6 @@
package org.springframework.aop.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.Before;
@ -27,6 +23,8 @@ import org.junit.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.SerializationTestUtils;
import static org.junit.Assert.*;
/**
* @author Rod Johnson
* @author Dmitriy Kopylenko

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,14 +16,6 @@
package org.springframework.aop.framework;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Method;
@ -41,9 +33,11 @@ import junit.framework.TestCase;
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.Advisor;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.DynamicIntroductionAdvice;
@ -85,6 +79,8 @@ import test.mixin.LockMixinAdvisor;
import test.mixin.Lockable;
import test.mixin.LockedException;
import static org.junit.Assert.*;
/**
* @author Rod Johnson
* @author Juergen Hoeller

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,6 @@
package org.springframework.expression.spel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.List;
@ -29,12 +26,14 @@ import org.springframework.expression.ParseException;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import static org.junit.Assert.*;
/**
* Common superclass for expression tests.
*
* @author Andy Clement
*/
public abstract class ExpressionTestCase {
public abstract class AbstractExpressionTests {
private final static boolean DEBUG = false;
@ -44,6 +43,7 @@ public abstract class ExpressionTestCase {
protected final ExpressionParser parser = new SpelExpressionParser();
protected final StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
/**
* Evaluate an expression and check that the actual result matches the expectedValue and the class of the result
* matches the expectedClassOfResult.
@ -51,7 +51,7 @@ public abstract class ExpressionTestCase {
* @param expectedValue the expected result for evaluating the expression
* @param expectedResultType the expected class of the evaluation result
*/
public void evaluate(String expression, Object expectedValue, Class<?> expectedResultType) {
protected void evaluate(String expression, Object expectedValue, Class<?> expectedResultType) {
try {
Expression expr = parser.parseExpression(expression);
if (expr == null) {
@ -61,9 +61,9 @@ public abstract class ExpressionTestCase {
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
}
// Class<?> expressionType = expr.getValueType();
// assertEquals("Type of the expression is not as expected. Should be '"+expectedResultType+"' but is
// '"+expressionType+"'",
// expectedResultType,expressionType);
// assertEquals("Type of the expression is not as expected. Should be '" +
// expectedResultType + "' but is '"
// + expressionType + "'", expectedResultType, expressionType);
Object value = expr.getValue(eContext);
@ -73,7 +73,7 @@ public abstract class ExpressionTestCase {
return; // no point doing other checks
}
assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
null);
null);
}
Class<?> resultType = value.getClass();
@ -86,20 +86,23 @@ public abstract class ExpressionTestCase {
if (expectedValue instanceof String) {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
ExpressionTestCase.stringValueOf(value));
} else {
AbstractExpressionTests.stringValueOf(value));
}
else {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
}
} catch (EvaluationException ee) {
}
catch (EvaluationException ee) {
ee.printStackTrace();
fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
}
catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
}
}
public void evaluateAndAskForReturnType(String expression, Object expectedValue, Class<?> expectedResultType) {
protected void evaluateAndAskForReturnType(String expression, Object expectedValue, Class<?> expectedResultType) {
try {
Expression expr = parser.parseExpression(expression);
if (expr == null) {
@ -109,16 +112,16 @@ public abstract class ExpressionTestCase {
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
}
// Class<?> expressionType = expr.getValueType();
// assertEquals("Type of the expression is not as expected. Should be '"+expectedResultType+"' but is
// '"+expressionType+"'",
// expectedResultType,expressionType);
// assertEquals("Type of the expression is not as expected. Should be '" +
// expectedResultType + "' but is '"
// + expressionType + "'", expectedResultType, expressionType);
Object value = expr.getValue(eContext, expectedResultType);
if (value == null) {
if (expectedValue == null)
return; // no point doing other checks
assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
null);
null);
}
Class<?> resultType = value.getClass();
@ -128,11 +131,13 @@ public abstract class ExpressionTestCase {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
// isAssignableFrom would allow some room for compatibility
// in the above expression...
} catch (EvaluationException ee) {
}
catch (EvaluationException ee) {
SpelEvaluationException ex = (SpelEvaluationException) ee;
ex.printStackTrace();
fail("Unexpected EvaluationException: " + ex.getMessage());
} catch (ParseException pe) {
}
catch (ParseException pe) {
fail("Unexpected ParseException: " + pe.getMessage());
}
}
@ -147,7 +152,7 @@ public abstract class ExpressionTestCase {
* @param expectedClassOfResult the expected class of the evaluation result
* @param shouldBeWritable should the parsed expression be writable?
*/
public void evaluate(String expression, Object expectedValue, Class<?> expectedClassOfResult,
protected void evaluate(String expression, Object expectedValue, Class<?> expectedClassOfResult,
boolean shouldBeWritable) {
try {
Expression e = parser.parseExpression(expression);
@ -163,20 +168,21 @@ public abstract class ExpressionTestCase {
return; // no point doing other
// checks
assertEquals("Expression returned null value, but expected '" + expectedValue + "'", expectedValue,
null);
null);
}
Class<? extends Object> resultType = value.getClass();
if (expectedValue instanceof String) {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
ExpressionTestCase.stringValueOf(value));
} else {
AbstractExpressionTests.stringValueOf(value));
}
else {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
}
// assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue,
// ExpressionTestCase.stringValueOf(value));
// assertEquals("Did not get expected value for expression '" + expression +
// "'.", expectedValue, stringValueOf(value));
assertEquals("Type of the result was not as expected. Expected '" + expectedClassOfResult
+ "' but result was of type '" + resultType + "'", expectedClassOfResult
.equals/* isAssignableFrom */(resultType), true);
+ "' but result was of type '" + resultType + "'",
expectedClassOfResult.equals/* isAssignableFrom */(resultType), true);
// TODO isAssignableFrom would allow some room for compatibility
// in the above expression...
@ -187,10 +193,12 @@ public abstract class ExpressionTestCase {
else
fail("Expected the expression to be readonly but it is not");
}
} catch (EvaluationException ee) {
}
catch (EvaluationException ee) {
ee.printStackTrace();
fail("Unexpected Exception: " + ee.getMessage());
} catch (ParseException pe) {
}
catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
}
@ -228,15 +236,16 @@ public abstract class ExpressionTestCase {
if (expectedReturnType != null) {
@SuppressWarnings("unused")
Object value = expr.getValue(eContext, expectedReturnType);
} else {
}
else {
@SuppressWarnings("unused")
Object value = expr.getValue(eContext);
}
fail("Should have failed with message " + expectedMessage);
} catch (EvaluationException ee) {
}
catch (EvaluationException ee) {
SpelEvaluationException ex = (SpelEvaluationException) ee;
if (ex.getMessageCode() != expectedMessage) {
// System.out.println(ex.getMessage());
ex.printStackTrace();
assertEquals("Failed to get expected message", expectedMessage, ex.getMessageCode());
}
@ -262,13 +271,15 @@ public abstract class ExpressionTestCase {
fail("Insert does not match, expected 'null' but insert value was '" + inserts[i - 1]
+ "'");
}
} else if (inserts[i - 1] == null) {
}
else if (inserts[i - 1] == null) {
if (otherProperties[i] != null) {
ex.printStackTrace();
fail("Insert does not match, expected '" + otherProperties[i]
+ "' but insert value was 'null'");
}
} else if (!inserts[i - 1].equals(otherProperties[i])) {
}
else if (!inserts[i - 1].equals(otherProperties[i])) {
ex.printStackTrace();
fail("Insert does not match, expected '" + otherProperties[i] + "' but insert value was '"
+ inserts[i - 1] + "'");
@ -276,7 +287,8 @@ public abstract class ExpressionTestCase {
}
}
}
} catch (ParseException pe) {
}
catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
}
@ -295,21 +307,22 @@ public abstract class ExpressionTestCase {
Expression expr = parser.parseExpression(expression);
SpelUtilities.printAbstractSyntaxTree(System.out, expr);
fail("Parsing should have failed!");
} catch (ParseException pe) {
// pe.printStackTrace();
// Throwable t = pe.getCause();
// if (t == null) {
// fail("ParseException caught with no defined cause");
// }
// if (!(t instanceof SpelEvaluationException)) {
// t.printStackTrace();
// fail("Cause of parse exception is not a SpelException");
// }
// SpelEvaluationException ex = (SpelEvaluationException) t;
// pe.printStackTrace();
SpelParseException ex = (SpelParseException)pe;
}
catch (ParseException pe) {
// pe.printStackTrace();
// Throwable t = pe.getCause();
// if (t == null) {
// fail("ParseException caught with no defined cause");
// }
// if (!(t instanceof SpelEvaluationException)) {
// t.printStackTrace();
// fail("Cause of parse exception is not a SpelException");
// }
// SpelEvaluationException ex = (SpelEvaluationException) t;
// pe.printStackTrace();
SpelParseException ex = (SpelParseException) pe;
if (ex.getMessageCode() != expectedMessage) {
// System.out.println(ex.getMessage());
// System.out.println(ex.getMessage());
ex.printStackTrace();
assertEquals("Failed to get expected message", expectedMessage, ex.getMessageCode());
}
@ -340,16 +353,17 @@ public abstract class ExpressionTestCase {
}
}
public static String stringValueOf(Object value) {
protected static String stringValueOf(Object value) {
return stringValueOf(value, false);
}
/**
* Produce a nice string representation of the input object.
*
* @param value object to be formatted
* @return a nice string
*/
public static String stringValueOf(Object value, boolean isNested) {
protected static String stringValueOf(Object value, boolean isNested) {
// do something nice for arrays
if (value == null) {
return "null";
@ -368,7 +382,8 @@ public abstract class ExpressionTestCase {
sb.append(stringValueOf(l[j]));
}
sb.append("}");
} else if (primitiveType == Long.TYPE) {
}
else if (primitiveType == Long.TYPE) {
long[] l = (long[]) value;
sb.append("long[").append(l.length).append("]{");
for (int j = 0; j < l.length; j++) {
@ -378,11 +393,13 @@ public abstract class ExpressionTestCase {
sb.append(stringValueOf(l[j]));
}
sb.append("}");
} else {
}
else {
throw new RuntimeException("Please implement support for type " + primitiveType.getName()
+ " in ExpressionTestCase.stringValueOf()");
}
} else if (value.getClass().getComponentType().isArray()) {
}
else if (value.getClass().getComponentType().isArray()) {
List<Object> l = Arrays.asList((Object[]) value);
if (!isNested) {
sb.append(value.getClass().getComponentType().getName());
@ -397,7 +414,8 @@ public abstract class ExpressionTestCase {
sb.append(stringValueOf(object, true));
}
sb.append("}");
} else {
}
else {
List<Object> l = Arrays.asList((Object[]) value);
if (!isNested) {
sb.append(value.getClass().getComponentType().getName());
@ -414,7 +432,8 @@ public abstract class ExpressionTestCase {
sb.append("}");
}
return sb.toString();
} else {
}
else {
return value.toString();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,35 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.expression.spel;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.expression.Expression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import static org.junit.Assert.*;
/**
* Test construction of arrays.
*
* @author Andy Clement
*/
public class ArrayConstructorTests extends ExpressionTestCase {
public class ArrayConstructorTests extends AbstractExpressionTests {
@Test
public void testSimpleArrayWithInitializer() {
public void simpleArrayWithInitializer() {
evaluateArrayBuildingExpression("new int[]{1,2,3}", "[1,2,3]");
evaluateArrayBuildingExpression("new int[]{}", "[]");
evaluate("new int[]{}.length", "0", Integer.class);
}
@Test
public void testConversion() {
public void conversion() {
evaluate("new String[]{1,2,3}[0]", "1", String.class);
evaluate("new int[]{'123'}[0]", 123, Integer.class);
}
@Test
public void testMultidimensionalArrays() {
public void multidimensionalArrays() {
evaluateAndCheckError("new int[][]{{1,2},{3,4}}", SpelMessage.MULTIDIM_ARRAY_INITIALIZER_NOT_SUPPORTED);
evaluateAndCheckError("new int[3][]", SpelMessage.MISSING_ARRAY_DIMENSION);
evaluateAndCheckError("new int[]", SpelMessage.MISSING_ARRAY_DIMENSION);
@ -50,7 +52,7 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
@Test
public void testPrimitiveTypeArrayConstructors() {
public void primitiveTypeArrayConstructors() {
evaluateArrayBuildingExpression("new int[]{1,2,3,4}", "[1,2,3,4]");
evaluateArrayBuildingExpression("new boolean[]{true,false,true}", "[true,false,true]");
evaluateArrayBuildingExpression("new char[]{'a','b','c'}", "[a,b,c]");
@ -62,7 +64,7 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
@Test
public void testPrimitiveTypeArrayConstructorsElements() {
public void primitiveTypeArrayConstructorsElements() {
evaluate("new int[]{1,2,3,4}[0]", 1, Integer.class);
evaluate("new boolean[]{true,false,true}[0]", true, Boolean.class);
evaluate("new char[]{'a','b','c'}[0]", 'a', Character.class);
@ -75,7 +77,7 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
@Test
public void testErrorCases() {
public void errorCases() {
evaluateAndCheckError("new char[7]{'a','c','d','e'}", SpelMessage.INITIALIZER_LENGTH_INCORRECT);
evaluateAndCheckError("new char[3]{'a','c','d','e'}", SpelMessage.INITIALIZER_LENGTH_INCORRECT);
evaluateAndCheckError("new char[2]{'hello','world'}", SpelMessage.TYPE_CONVERSION_ERROR);
@ -83,32 +85,32 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
@Test
public void testTypeArrayConstructors() {
public void typeArrayConstructors() {
evaluate("new String[]{'a','b','c','d'}[1]", "b", String.class);
evaluateAndCheckError("new String[]{'a','b','c','d'}.size()", SpelMessage.METHOD_NOT_FOUND, 30, "size()",
"java.lang.String[]");
"java.lang.String[]");
evaluate("new String[]{'a','b','c','d'}.length", 4, Integer.class);
}
@Test
public void testBasicArray() {
public void basicArray() {
evaluate("new String[3]", "java.lang.String[3]{null,null,null}", String[].class);
}
@Test
public void testMultiDimensionalArray() {
public void multiDimensionalArray() {
evaluate("new String[2][2]", "[Ljava.lang.String;[2]{[2]{null,null},[2]{null,null}}", String[][].class);
evaluate("new String[3][2][1]",
"[[Ljava.lang.String;[3]{[2]{[1]{null},[1]{null}},[2]{[1]{null},[1]{null}},[2]{[1]{null},[1]{null}}}",
String[][][].class);
"[[Ljava.lang.String;[3]{[2]{[1]{null},[1]{null}},[2]{[1]{null},[1]{null}},[2]{[1]{null},[1]{null}}}",
String[][][].class);
}
@Test
public void testConstructorInvocation03() {
public void constructorInvocation03() {
evaluateAndCheckError("new String[]", SpelMessage.MISSING_ARRAY_DIMENSION);
}
public void testConstructorInvocation04() {
public void constructorInvocation04() {
evaluateAndCheckError("new Integer[3]{'3','ghi','5'}", SpelMessage.INCORRECT_ELEMENT_TYPE_FOR_ARRAY, 4);
}
@ -116,8 +118,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
SpelExpressionParser parser = new SpelExpressionParser();
Expression e = parser.parseExpression(expression);
Object o = e.getValue();
Assert.assertNotNull(o);
Assert.assertTrue(o.getClass().isArray());
assertNotNull(o);
assertTrue(o.getClass().isArray());
StringBuilder s = new StringBuilder();
s.append('[');
if (o instanceof int[]) {
@ -128,7 +130,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else if (o instanceof boolean[]) {
}
else if (o instanceof boolean[]) {
boolean[] array = (boolean[]) o;
for (int i = 0; i < array.length; i++) {
if (i > 0) {
@ -136,7 +139,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else if (o instanceof char[]) {
}
else if (o instanceof char[]) {
char[] array = (char[]) o;
for (int i = 0; i < array.length; i++) {
if (i > 0) {
@ -144,7 +148,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else if (o instanceof long[]) {
}
else if (o instanceof long[]) {
long[] array = (long[]) o;
for (int i = 0; i < array.length; i++) {
if (i > 0) {
@ -152,7 +157,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else if (o instanceof short[]) {
}
else if (o instanceof short[]) {
short[] array = (short[]) o;
for (int i = 0; i < array.length; i++) {
if (i > 0) {
@ -160,7 +166,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else if (o instanceof double[]) {
}
else if (o instanceof double[]) {
double[] array = (double[]) o;
for (int i = 0; i < array.length; i++) {
if (i > 0) {
@ -168,7 +175,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else if (o instanceof float[]) {
}
else if (o instanceof float[]) {
float[] array = (float[]) o;
for (int i = 0; i < array.length; i++) {
if (i > 0) {
@ -176,7 +184,8 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else if (o instanceof byte[]) {
}
else if (o instanceof byte[]) {
byte[] array = (byte[]) o;
for (int i = 0; i < array.length; i++) {
if (i > 0) {
@ -184,11 +193,12 @@ public class ArrayConstructorTests extends ExpressionTestCase {
}
s.append(array[i]);
}
} else {
Assert.fail("Not supported " + o.getClass());
}
else {
fail("Not supported " + o.getClass());
}
s.append(']');
Assert.assertEquals(expectedToString, s.toString());
assertEquals(expectedToString, s.toString());
return s.toString();
}

View File

@ -27,7 +27,7 @@ import org.springframework.expression.spel.support.StandardTypeConverter;
* @author Andy Clement
* @author Oliver Becker
*/
public class BooleanExpressionTests extends ExpressionTestCase {
public class BooleanExpressionTests extends AbstractExpressionTests {
@Test
public void testBooleanTrue() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,9 +19,9 @@ package org.springframework.expression.spel;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.ConstructorExecutor;
@ -32,12 +32,14 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.testresources.PlaceOfBirth;
import static org.junit.Assert.*;
/**
* Tests invocation of constructors.
*
* @author Andy Clement
*/
public class ConstructorInvocationTests extends ExpressionTestCase {
public class ConstructorInvocationTests extends AbstractExpressionTests {
@Test
public void testTypeConstructors() {
@ -46,29 +48,33 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
@Test
public void testNonExistentType() {
evaluateAndCheckError("new FooBar()",SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM);
evaluateAndCheckError("new FooBar()", SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM);
}
@SuppressWarnings("serial")
static class TestException extends Exception {
}
static class Tester {
public static int counter;
public int i;
public Tester() {}
public Tester() {
}
public Tester(int i) throws Exception {
counter++;
if (i==1) {
if (i == 1) {
throw new IllegalArgumentException("IllegalArgumentException for 1");
}
if (i==2) {
if (i == 2) {
throw new RuntimeException("RuntimeException for 2");
}
if (i==4) {
if (i == 4) {
throw new TestException();
}
this.i = i;
@ -79,6 +85,8 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
}
}
@Test
public void testConstructorThrowingException_SPR6760() {
// Test ctor on inventor:
@ -93,60 +101,65 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
// Normal exit
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
eContext.setRootObject(new Tester());
eContext.setVariable("bar",3);
eContext.setVariable("bar", 3);
Object o = expr.getValue(eContext);
Assert.assertEquals(o,3);
Assert.assertEquals(1,parser.parseExpression("counter").getValue(eContext));
assertEquals(o, 3);
assertEquals(1, parser.parseExpression("counter").getValue(eContext));
// Now the expression has cached that throwException(int) is the right thing to call
// Let's change 'bar' to be a PlaceOfBirth which indicates the cached reference is
// out of date.
eContext.setVariable("bar",new PlaceOfBirth("London"));
// Now the expression has cached that throwException(int) is the right thing to
// call. Let's change 'bar' to be a PlaceOfBirth which indicates the cached
// reference is out of date.
eContext.setVariable("bar", new PlaceOfBirth("London"));
o = expr.getValue(eContext);
Assert.assertEquals(0, o);
assertEquals(0, o);
// That confirms the logic to mark the cached reference stale and retry is working
// Now let's cause the method to exit via exception and ensure it doesn't cause
// a retry.
// First, switch back to throwException(int)
eContext.setVariable("bar",3);
eContext.setVariable("bar", 3);
o = expr.getValue(eContext);
Assert.assertEquals(3, o);
Assert.assertEquals(2,parser.parseExpression("counter").getValue(eContext));
assertEquals(3, o);
assertEquals(2, parser.parseExpression("counter").getValue(eContext));
// 4 will make it throw a checked exception - this will be wrapped by spel on the way out
eContext.setVariable("bar",4);
// 4 will make it throw a checked exception - this will be wrapped by spel on the
// way out
eContext.setVariable("bar", 4);
try {
o = expr.getValue(eContext);
Assert.fail("Should have failed");
} catch (Exception e) {
// A problem occurred whilst attempting to construct an object of type 'org.springframework.expression.spel.ConstructorInvocationTests$Tester' using arguments '(java.lang.Integer)'
fail("Should have failed");
}
catch (Exception e) {
// A problem occurred whilst attempting to construct an object of type
// 'org.springframework.expression.spel.ConstructorInvocationTests$Tester'
// using arguments '(java.lang.Integer)'
int idx = e.getMessage().indexOf("Tester");
if (idx==-1) {
Assert.fail("Expected reference to Tester in :"+e.getMessage());
if (idx == -1) {
fail("Expected reference to Tester in :" + e.getMessage());
}
// normal
}
// If counter is 4 then the method got called twice!
Assert.assertEquals(3,parser.parseExpression("counter").getValue(eContext));
assertEquals(3, parser.parseExpression("counter").getValue(eContext));
// 1 will make it throw a RuntimeException - SpEL will let this through
eContext.setVariable("bar",1);
eContext.setVariable("bar", 1);
try {
o = expr.getValue(eContext);
Assert.fail("Should have failed");
} catch (Exception e) {
// A problem occurred whilst attempting to construct an object of type 'org.springframework.expression.spel.ConstructorInvocationTests$Tester' using arguments '(java.lang.Integer)'
fail("Should have failed");
}
catch (Exception e) {
// A problem occurred whilst attempting to construct an object of type
// 'org.springframework.expression.spel.ConstructorInvocationTests$Tester'
// using arguments '(java.lang.Integer)'
if (e instanceof SpelEvaluationException) {
e.printStackTrace();
Assert.fail("Should not have been wrapped");
fail("Should not have been wrapped");
}
}
// If counter is 5 then the method got called twice!
Assert.assertEquals(4,parser.parseExpression("counter").getValue(eContext));
assertEquals(4, parser.parseExpression("counter").getValue(eContext));
}
@Test
@ -155,58 +168,69 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
// reflective constructor accessor is the only one by default
List<ConstructorResolver> constructorResolvers = ctx.getConstructorResolvers();
Assert.assertEquals(1,constructorResolvers.size());
assertEquals(1, constructorResolvers.size());
ConstructorResolver dummy = new DummyConstructorResolver();
ctx.addConstructorResolver(dummy);
Assert.assertEquals(2,ctx.getConstructorResolvers().size());
assertEquals(2, ctx.getConstructorResolvers().size());
List<ConstructorResolver> copy = new ArrayList<ConstructorResolver>();
copy.addAll(ctx.getConstructorResolvers());
Assert.assertTrue(ctx.removeConstructorResolver(dummy));
Assert.assertFalse(ctx.removeConstructorResolver(dummy));
Assert.assertEquals(1,ctx.getConstructorResolvers().size());
assertTrue(ctx.removeConstructorResolver(dummy));
assertFalse(ctx.removeConstructorResolver(dummy));
assertEquals(1, ctx.getConstructorResolvers().size());
ctx.setConstructorResolvers(copy);
Assert.assertEquals(2,ctx.getConstructorResolvers().size());
assertEquals(2, ctx.getConstructorResolvers().size());
}
static class DummyConstructorResolver implements ConstructorResolver {
@Override
public ConstructorExecutor resolve(EvaluationContext context, String typeName, List<TypeDescriptor> argumentTypes)
throws AccessException {
public ConstructorExecutor resolve(EvaluationContext context, String typeName,
List<TypeDescriptor> argumentTypes) throws AccessException {
throw new UnsupportedOperationException("Auto-generated method stub");
}
}
@Test
public void testVarargsInvocation01() {
// Calling 'Fruit(String... strings)'
evaluate("new org.springframework.expression.spel.testresources.Fruit('a','b','c').stringscount()", 3, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit('a','b','c').stringscount()", 3,
Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit('a').stringscount()", 1, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit().stringscount()", 0, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(1,2,3).stringscount()", 3, Integer.class); // all need converting to strings
evaluate("new org.springframework.expression.spel.testresources.Fruit(1).stringscount()", 1, Integer.class); // needs string conversion
evaluate("new org.springframework.expression.spel.testresources.Fruit(1,'a',3.0d).stringscount()", 3, Integer.class); // first and last need conversion
// all need converting to strings
evaluate("new org.springframework.expression.spel.testresources.Fruit(1,2,3).stringscount()", 3, Integer.class);
// needs string conversion
evaluate("new org.springframework.expression.spel.testresources.Fruit(1).stringscount()", 1, Integer.class);
// first and last need conversion
evaluate("new org.springframework.expression.spel.testresources.Fruit(1,'a',3.0d).stringscount()", 3,
Integer.class);
}
@Test
public void testVarargsInvocation02() {
// Calling 'Fruit(int i, String... strings)' - returns int+length_of_strings
evaluate("new org.springframework.expression.spel.testresources.Fruit(5,'a','b','c').stringscount()", 8, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(5,'a','b','c').stringscount()", 8,
Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(2,'a').stringscount()", 3, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(4).stringscount()", 4, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(8,2,3).stringscount()", 10, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(9).stringscount()", 9, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(2,'a',3.0d).stringscount()", 4, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(8,stringArrayOfThreeItems).stringscount()", 11, Integer.class);
evaluate("new org.springframework.expression.spel.testresources.Fruit(2,'a',3.0d).stringscount()", 4,
Integer.class);
evaluate(
"new org.springframework.expression.spel.testresources.Fruit(8,stringArrayOfThreeItems).stringscount()",
11, Integer.class);
}
/*
* These tests are attempting to call constructors where we need to widen or convert the argument in order to
* satisfy a suitable constructor.
* These tests are attempting to call constructors where we need to widen or convert
* the argument in order to satisfy a suitable constructor.
*/
@Test
public void testWidening01() {
@ -220,7 +244,8 @@ public class ConstructorInvocationTests extends ExpressionTestCase {
@Ignore
public void testArgumentConversion01() {
// Closest ctor will be new String(String) and converter supports Double>String
// TODO currently failing as with new ObjectToArray converter closest constructor matched becomes String(byte[]) which fails...
// TODO currently failing as with new ObjectToArray converter closest constructor
// matched becomes String(byte[]) which fails...
evaluate("new String(3.0d)", "3.0", String.class);
}

View File

@ -59,7 +59,7 @@ import org.springframework.expression.spel.testresources.TestPerson;
* @author Giovanni Dall'Oglio Risso
* @since 3.0
*/
public class EvaluationTests extends ExpressionTestCase {
public class EvaluationTests extends AbstractExpressionTests {
@Test
public void testCreateListsOnAttemptToIndexNull01() throws EvaluationException, ParseException {

View File

@ -60,7 +60,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*
* @author Andy Clement
*/
public class ExpressionLanguageScenarioTests extends ExpressionTestCase {
public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
/**
* Scenario: using the standard infrastructure and running simple expression evaluation.

View File

@ -39,7 +39,7 @@ import org.springframework.expression.spel.testresources.Inventor;
*
* @author Andy Clement
*/
public class ExpressionStateTests extends ExpressionTestCase {
public class ExpressionStateTests extends AbstractExpressionTests {
@Test
public void testConstruction() {

View File

@ -42,7 +42,7 @@ import static org.junit.Assert.*;
* @author Andy Clement
* @author Dave Syer
*/
public class ExpressionWithConversionTests extends ExpressionTestCase {
public class ExpressionWithConversionTests extends AbstractExpressionTests {
private static List<String> listOfString = new ArrayList<String>();
private static TypeDescriptor typeDescriptorForListOfString = null;

View File

@ -32,7 +32,7 @@ import org.springframework.expression.spel.standard.SpelExpression;
*
* @author Andy Clement
*/
public class InProgressTests extends ExpressionTestCase {
public class InProgressTests extends AbstractExpressionTests {
@Test
public void testRelOperatorsBetween01() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,17 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.expression.spel;
import java.util.ArrayList;
import java.util.Collections;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.expression.spel.ast.InlineList;
import org.springframework.expression.spel.standard.SpelExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import static org.junit.Assert.*;
/**
* Test usage of inline lists.
*
@ -31,11 +34,13 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
* @author Giovanni Dall'Oglio Risso
* @since 3.0.4
*/
public class ListTests extends ExpressionTestCase {
public class ListTests extends AbstractExpressionTests {
// if the list is full of literals then it will be of the type unmodifiableClass rather than ArrayList
// if the list is full of literals then it will be of the type unmodifiableClass
// rather than ArrayList
Class<?> unmodifiableClass = Collections.unmodifiableList(new ArrayList<Object>()).getClass();
@Test
public void testInlineListCreation01() {
evaluate("{1, 2, 3, 4, 5}", "[1, 2, 3, 4, 5]", unmodifiableClass);
@ -111,10 +116,14 @@ public class ListTests extends ExpressionTestCase {
@Test
public void testRelOperatorsBetween04() {
evaluate("new java.math.BigDecimal('1') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}", "true", Boolean.class);
evaluate("new java.math.BigDecimal('3') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}", "true", Boolean.class);
evaluate("new java.math.BigDecimal('5') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}", "true", Boolean.class);
evaluate("new java.math.BigDecimal('8') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}", "false", Boolean.class);
evaluate("new java.math.BigDecimal('1') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}",
"true", Boolean.class);
evaluate("new java.math.BigDecimal('3') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}",
"true", Boolean.class);
evaluate("new java.math.BigDecimal('5') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}",
"true", Boolean.class);
evaluate("new java.math.BigDecimal('8') between {new java.math.BigDecimal('1'),new java.math.BigDecimal('5')}",
"false", Boolean.class);
}
@Test
@ -136,23 +145,19 @@ public class ListTests extends ExpressionTestCase {
SpelExpressionParser parser = new SpelExpressionParser();
SpelExpression expression = (SpelExpression) parser.parseExpression(expressionText);
SpelNode node = expression.getAST();
Assert.assertTrue(node instanceof InlineList);
assertTrue(node instanceof InlineList);
InlineList inlineList = (InlineList) node;
if (expectedToBeConstant) {
Assert.assertTrue(inlineList.isConstant());
} else {
Assert.assertFalse(inlineList.isConstant());
assertTrue(inlineList.isConstant());
}
else {
assertFalse(inlineList.isConstant());
}
}
@Test
@Test(expected = UnsupportedOperationException.class)
public void testInlineListWriting() {
// list should be unmodifiable
try {
evaluate("{1, 2, 3, 4, 5}[0]=6", "[1, 2, 3, 4, 5]", unmodifiableClass);
Assert.fail();
} catch (UnsupportedOperationException uoe) {
// success
}
evaluate("{1, 2, 3, 4, 5}[0]=6", "[1, 2, 3, 4, 5]", unmodifiableClass);
}
}

View File

@ -27,7 +27,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*
* @author Andy Clement
*/
public class LiteralTests extends ExpressionTestCase {
public class LiteralTests extends AbstractExpressionTests {
@Test
public void testLiteralBoolean01() {

View File

@ -37,7 +37,7 @@ import static org.junit.Assert.*;
*
* @author Andy Clement
*/
public class MapAccessTests extends ExpressionTestCase {
public class MapAccessTests extends AbstractExpressionTests {
@Test
public void testSimpleMapAccess01() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,6 @@
package org.springframework.expression.spel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -26,8 +23,8 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.AccessException;
import org.springframework.expression.BeanResolver;
@ -42,13 +39,15 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.testresources.PlaceOfBirth;
import static org.junit.Assert.*;
/**
* Tests invocation of methods.
*
* @author Andy Clement
* @author Phillip Webb
*/
public class MethodInvocationTests extends ExpressionTestCase {
public class MethodInvocationTests extends AbstractExpressionTests {
@Test
public void testSimpleAccess01() {
@ -110,15 +109,15 @@ public class MethodInvocationTests extends ExpressionTestCase {
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
eContext.setVariable("bar",3);
Object o = expr.getValue(eContext);
Assert.assertEquals(o,3);
Assert.assertEquals(1,parser.parseExpression("counter").getValue(eContext));
assertEquals(o, 3);
assertEquals(1, parser.parseExpression("counter").getValue(eContext));
// Now the expression has cached that throwException(int) is the right thing to call
// Let's change 'bar' to be a PlaceOfBirth which indicates the cached reference is
// out of date.
eContext.setVariable("bar",new PlaceOfBirth("London"));
o = expr.getValue(eContext);
Assert.assertEquals("London", o);
assertEquals("London", o);
// That confirms the logic to mark the cached reference stale and retry is working
@ -128,39 +127,39 @@ public class MethodInvocationTests extends ExpressionTestCase {
// First, switch back to throwException(int)
eContext.setVariable("bar",3);
o = expr.getValue(eContext);
Assert.assertEquals(3, o);
Assert.assertEquals(2,parser.parseExpression("counter").getValue(eContext));
assertEquals(3, o);
assertEquals(2, parser.parseExpression("counter").getValue(eContext));
// Now cause it to throw an exception:
eContext.setVariable("bar",1);
try {
o = expr.getValue(eContext);
Assert.fail();
fail();
} catch (Exception e) {
if (e instanceof SpelEvaluationException) {
e.printStackTrace();
Assert.fail("Should not be a SpelEvaluationException");
fail("Should not be a SpelEvaluationException");
}
// normal
}
// If counter is 4 then the method got called twice!
Assert.assertEquals(3,parser.parseExpression("counter").getValue(eContext));
assertEquals(3, parser.parseExpression("counter").getValue(eContext));
eContext.setVariable("bar",4);
try {
o = expr.getValue(eContext);
Assert.fail();
fail();
} catch (Exception e) {
// 4 means it will throw a checked exception - this will be wrapped
if (!(e instanceof ExpressionInvocationTargetException)) {
e.printStackTrace();
Assert.fail("Should have been wrapped");
fail("Should have been wrapped");
}
// normal
}
// If counter is 5 then the method got called twice!
Assert.assertEquals(4,parser.parseExpression("counter").getValue(eContext));
assertEquals(4, parser.parseExpression("counter").getValue(eContext));
}
/**
@ -180,11 +179,11 @@ public class MethodInvocationTests extends ExpressionTestCase {
eContext.setVariable("bar",2);
try {
expr.getValue(eContext);
Assert.fail();
fail();
} catch (Exception e) {
if (e instanceof SpelEvaluationException) {
e.printStackTrace();
Assert.fail("Should not be a SpelEvaluationException");
fail("Should not be a SpelEvaluationException");
}
// normal
}
@ -204,13 +203,15 @@ public class MethodInvocationTests extends ExpressionTestCase {
eContext.setVariable("bar",4);
try {
expr.getValue(eContext);
Assert.fail();
fail();
} catch (ExpressionInvocationTargetException e) {
Throwable t = e.getCause();
Assert.assertEquals("org.springframework.expression.spel.testresources.Inventor$TestException", t.getClass().getName());
assertEquals(
"org.springframework.expression.spel.testresources.Inventor$TestException",
t.getClass().getName());
return;
}
Assert.fail("Should not be a SpelEvaluationException");
fail("Should not be a SpelEvaluationException");
}
@Test
@ -224,24 +225,24 @@ public class MethodInvocationTests extends ExpressionTestCase {
// Filter will be called but not do anything, so first doit() will be invoked
SpelExpression expr = (SpelExpression) parser.parseExpression("doit(1)");
String result = expr.getValue(context,String.class);
Assert.assertEquals("1",result);
Assert.assertTrue(filter.filterCalled);
assertEquals("1", result);
assertTrue(filter.filterCalled);
// Filter will now remove non @Anno annotated methods
filter.removeIfNotAnnotated = true;
filter.filterCalled = false;
expr = (SpelExpression) parser.parseExpression("doit(1)");
result = expr.getValue(context,String.class);
Assert.assertEquals("double 1.0",result);
Assert.assertTrue(filter.filterCalled);
assertEquals("double 1.0", result);
assertTrue(filter.filterCalled);
// check not called for other types
filter.filterCalled=false;
context.setRootObject(new String("abc"));
expr = (SpelExpression) parser.parseExpression("charAt(0)");
result = expr.getValue(context,String.class);
Assert.assertEquals("a",result);
Assert.assertFalse(filter.filterCalled);
assertEquals("a", result);
assertFalse(filter.filterCalled);
// check de-registration works
filter.filterCalled = false;
@ -249,8 +250,8 @@ public class MethodInvocationTests extends ExpressionTestCase {
context.setRootObject(new TestObject());
expr = (SpelExpression) parser.parseExpression("doit(1)");
result = expr.getValue(context,String.class);
Assert.assertEquals("1",result);
Assert.assertFalse(filter.filterCalled);
assertEquals("1", result);
assertFalse(filter.filterCalled);
}
// Simple filter
@ -312,20 +313,20 @@ public class MethodInvocationTests extends ExpressionTestCase {
// reflective method accessor is the only one by default
List<MethodResolver> methodResolvers = ctx.getMethodResolvers();
Assert.assertEquals(1,methodResolvers.size());
assertEquals(1, methodResolvers.size());
MethodResolver dummy = new DummyMethodResolver();
ctx.addMethodResolver(dummy);
Assert.assertEquals(2,ctx.getMethodResolvers().size());
assertEquals(2, ctx.getMethodResolvers().size());
List<MethodResolver> copy = new ArrayList<MethodResolver>();
copy.addAll(ctx.getMethodResolvers());
Assert.assertTrue(ctx.removeMethodResolver(dummy));
Assert.assertFalse(ctx.removeMethodResolver(dummy));
Assert.assertEquals(1,ctx.getMethodResolvers().size());
assertTrue(ctx.removeMethodResolver(dummy));
assertFalse(ctx.removeMethodResolver(dummy));
assertEquals(1, ctx.getMethodResolvers().size());
ctx.setMethodResolvers(copy);
Assert.assertEquals(2,ctx.getMethodResolvers().size());
assertEquals(2, ctx.getMethodResolvers().size());
}
static class DummyMethodResolver implements MethodResolver {

View File

@ -30,7 +30,7 @@ import org.springframework.expression.spel.standard.SpelExpression;
*
* @author Andy Clement
*/
public class OperatorOverloaderTests extends ExpressionTestCase {
public class OperatorOverloaderTests extends AbstractExpressionTests {
static class StringAndBooleanAddition implements OperatorOverloader {

View File

@ -29,7 +29,7 @@ import org.springframework.expression.spel.standard.SpelExpression;
* @author Andy Clement
* @author Giovanni Dall'Oglio Risso
*/
public class OperatorTests extends ExpressionTestCase {
public class OperatorTests extends AbstractExpressionTests {
@Test
public void testIntegerLiteral() {

View File

@ -23,7 +23,7 @@ import org.junit.Test;
*
* @author Andy Clement
*/
public class ParserErrorMessagesTests extends ExpressionTestCase {
public class ParserErrorMessagesTests extends AbstractExpressionTests {
@Test
public void testBrokenExpression01() {

View File

@ -44,7 +44,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*
* @author Andy Clement
*/
public class PropertyAccessTests extends ExpressionTestCase {
public class PropertyAccessTests extends AbstractExpressionTests {
@Test
public void testSimpleAccess01() {

View File

@ -45,7 +45,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*
* @author Andy Clement
*/
public class ScenariosForSpringSecurity extends ExpressionTestCase {
public class ScenariosForSpringSecurity extends AbstractExpressionTests {
@Test
public void testScenario01_Roles() throws Exception {

View File

@ -38,7 +38,7 @@ import org.springframework.expression.spel.testresources.PlaceOfBirth;
* @author Keith Donald
* @author Andy Clement
*/
public class SetValueTests extends ExpressionTestCase {
public class SetValueTests extends AbstractExpressionTests {
private final static boolean DEBUG = false;

View File

@ -48,7 +48,7 @@ import org.springframework.expression.spel.testresources.PlaceOfBirth;
*
* @author Andy Clement
*/
public class SpelDocumentationTests extends ExpressionTestCase {
public class SpelDocumentationTests extends AbstractExpressionTests {
static Inventor tesla ;
static Inventor pupin ;

View File

@ -34,7 +34,7 @@ import static org.junit.Assert.*;
* @author Andy Clement
* @author Juergen Hoeller
*/
public class TemplateExpressionParsingTests extends ExpressionTestCase {
public class TemplateExpressionParsingTests extends AbstractExpressionTests {
public static final ParserContext DEFAULT_TEMPLATE_PARSER_CONTEXT = new ParserContext() {
@Override

View File

@ -27,7 +27,7 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
*
* @author Andy Clement
*/
public class VariableAndFunctionTests extends ExpressionTestCase {
public class VariableAndFunctionTests extends AbstractExpressionTests {
@Test
public void testVariableAccess01() {

View File

@ -29,7 +29,7 @@ import org.springframework.expression.EvaluationContext;
import org.springframework.expression.ParseException;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.ExpressionTestCase;
import org.springframework.expression.spel.AbstractExpressionTests;
import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessage;
import org.springframework.expression.spel.SpelUtilities;
@ -44,7 +44,7 @@ import static org.junit.Assert.*;
*
* @author Andy Clement
*/
public class ReflectionHelperTests extends ExpressionTestCase {
public class ReflectionHelperTests extends AbstractExpressionTests {
@Test
public void testFormatHelperForClassName() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,8 +18,8 @@ package org.springframework.expression.spel.support;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Operation;
@ -28,45 +28,42 @@ import org.springframework.expression.TypeComparator;
import org.springframework.expression.TypeConverter;
import org.springframework.expression.TypeLocator;
import static org.junit.Assert.*;
public class StandardComponentsTests {
@Test
public void testStandardEvaluationContext() {
StandardEvaluationContext context = new StandardEvaluationContext();
Assert.assertNotNull(context.getTypeComparator());
assertNotNull(context.getTypeComparator());
TypeComparator tc = new StandardTypeComparator();
context.setTypeComparator(tc);
Assert.assertEquals(tc,context.getTypeComparator());
assertEquals(tc, context.getTypeComparator());
TypeLocator tl = new StandardTypeLocator();
context.setTypeLocator(tl);
Assert.assertEquals(tl,context.getTypeLocator());
assertEquals(tl, context.getTypeLocator());
}
@Test
@Test(expected = EvaluationException.class)
public void testStandardOperatorOverloader() throws EvaluationException {
OperatorOverloader oo = new StandardOperatorOverloader();
Assert.assertFalse(oo.overridesOperation(Operation.ADD, null, null));
try {
oo.operate(Operation.ADD, 2, 3);
Assert.fail("should have failed");
} catch (EvaluationException e) {
// success
}
assertFalse(oo.overridesOperation(Operation.ADD, null, null));
oo.operate(Operation.ADD, 2, 3);
}
@Test
public void testStandardTypeLocator() {
StandardTypeLocator tl = new StandardTypeLocator();
List<String> prefixes = tl.getImportPrefixes();
Assert.assertEquals(1,prefixes.size());
assertEquals(1, prefixes.size());
tl.registerImport("java.util");
prefixes = tl.getImportPrefixes();
Assert.assertEquals(2,prefixes.size());
assertEquals(2, prefixes.size());
tl.removeImport("java.util");
prefixes = tl.getImportPrefixes();
Assert.assertEquals(1,prefixes.size());
assertEquals(1, prefixes.size());
}
@Test
@ -76,4 +73,3 @@ public class StandardComponentsTests {
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,7 +28,6 @@ import org.custommonkey.xmlunit.NamespaceContext;
import org.custommonkey.xmlunit.SimpleNamespaceContext;
import org.custommonkey.xmlunit.XMLUnit;
import org.custommonkey.xmlunit.XpathEngine;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.InOrder;
import org.springframework.core.io.ClassPathResource;
@ -42,7 +41,7 @@ import org.xml.sax.ContentHandler;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.*;
import static org.mockito.Matchers.*;
import static org.mockito.BDDMockito.*;
import static org.mockito.Mockito.*;
/**
* Tests the {@link CastorMarshaller} class.
@ -55,53 +54,53 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
/**
* Represents the expected result that doesn't contain the xml declaration.
*/
private static final String DOCUMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<tns:flights xmlns:tns=\"http://samples.springframework.org/flight\">" +
"<tns:flight><tns:number>42</tns:number></tns:flight></tns:flights>";
private static final String DOCUMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<tns:flights xmlns:tns=\"http://samples.springframework.org/flight\">"
+ "<tns:flight><tns:number>42</tns:number></tns:flight></tns:flights>";
/**
* Represents the expected result that doesn't contain the xml namespaces.
*/
private static final String SUPPRESSED_NAMESPACE_EXPECTED_STRING =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><flights><flight><number>42</number></flight></flights>";
private static final String SUPPRESSED_NAMESPACE_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><flights><flight><number>42</number></flight></flights>";
/**
* Represents the expected result with modified root element name.
*/
private static final String ROOT_ELEMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<tns:canceledFlights xmlns:tns=\"http://samples.springframework.org/flight\">" +
"<tns:flight><tns:number>42</tns:number></tns:flight></tns:canceledFlights>";
private static final String ROOT_ELEMENT_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<tns:canceledFlights xmlns:tns=\"http://samples.springframework.org/flight\">"
+ "<tns:flight><tns:number>42</tns:number></tns:flight></tns:canceledFlights>";
/**
* Represents the expected result with 'xsi:type' attribute.
*/
private static final String XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>";
private static final String XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">"
+ "<name>test</name><value>8</value></castor-object></objects>";
/**
* Represents the expected result with suppressed 'xsi:type' attribute.
*/
private static final String SUPPRESSED_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object><name>test</name><value>8</value></castor-object></objects>";
private static final String SUPPRESSED_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects><castor-object><name>test</name><value>8</value></castor-object></objects>";
/**
* Represents the expected result with 'xsi:type' attribute for root element.
*/
private static final String ROOT_WITH_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xsi:type=\"java:java.util.Arrays$ArrayList\">" +
"<castor-object xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>";
private static final String ROOT_WITH_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xsi:type=\"java:java.util.Arrays$ArrayList\">"
+ "<castor-object xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">"
+ "<name>test</name><value>8</value></castor-object></objects>";
/**
* Represents the expected result without 'xsi:type' attribute for root element.
*/
private static final String ROOT_WITHOUT_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>";
private static final String ROOT_WITHOUT_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">"
+ "<name>test</name><value>8</value></castor-object></objects>";
@Override
protected Marshaller createMarshaller() throws Exception {
@ -129,10 +128,13 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
InOrder ordered = inOrder(contentHandler);
ordered.verify(contentHandler).startDocument();
ordered.verify(contentHandler).startPrefixMapping("tns", "http://samples.springframework.org/flight");
ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flights"), eq("tns:flights"), isA(Attributes.class));
ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flight"), eq("tns:flight"), isA(Attributes.class));
ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("number"), eq("tns:number"), isA(Attributes.class));
ordered.verify(contentHandler).characters(eq(new char[]{'4', '2'}), eq(0), eq(2));
ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flights"),
eq("tns:flights"), isA(Attributes.class));
ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flight"),
eq("tns:flight"), isA(Attributes.class));
ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("number"),
eq("tns:number"), isA(Attributes.class));
ordered.verify(contentHandler).characters(eq(new char[] { '4', '2' }), eq(0), eq(2));
ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "number", "tns:number");
ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "flight", "tns:flight");
ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "flights", "tns:flights");
@ -142,8 +144,8 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
@Test
public void supports() throws Exception {
Assert.assertTrue("CastorMarshaller does not support Flights", marshaller.supports(Flights.class));
Assert.assertTrue("CastorMarshaller does not support Flight", marshaller.supports(Flight.class));
assertTrue("CastorMarshaller does not support Flights", marshaller.supports(Flights.class));
assertTrue("CastorMarshaller does not support Flight", marshaller.supports(Flight.class));
}
@Test
@ -186,8 +188,8 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
getCastorMarshaller().setMarshalAsDocument(true);
String result = marshalFlights();
assertXMLEqual("Marshaller wrote invalid result", DOCUMENT_EXPECTED_STRING, result);
Assert.assertTrue("Result doesn't contain xml declaration.",
result.contains("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
assertTrue("Result doesn't contain xml declaration.",
result.contains("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
}
@Test
@ -196,7 +198,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
getCastorMarshaller().setMarshalAsDocument(true);
String result = marshalFlights();
assertXMLEqual("Marshaller wrote invalid result", EXPECTED_STRING, result);
Assert.assertFalse("Result contains xml declaration.", result.matches("<\\?\\s*xml"));
assertFalse("Result contains xml declaration.", result.matches("<\\?\\s*xml"));
}
@Test
@ -215,7 +217,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
String result = marshalFlights();
assertXpathEvaluatesTo("The xsi:noNamespaceSchemaLocation hasn't been written or has invalid value.",
noNamespaceSchemaLocation, "/tns:flights/@xsi:noNamespaceSchemaLocation", result);
noNamespaceSchemaLocation, "/tns:flights/@xsi:noNamespaceSchemaLocation", result);
assertXMLEqual("Marshaller wrote invalid result", EXPECTED_STRING, result);
}
@ -227,7 +229,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
String result = marshalFlights();
assertXpathEvaluatesTo("The xsi:noNamespaceSchemaLocation hasn't been written or has invalid value.",
schemaLocation, "/tns:flights/@xsi:schemaLocation", result);
schemaLocation, "/tns:flights/@xsi:schemaLocation", result);
assertXMLEqual("Marshaller wrote invalid result", EXPECTED_STRING, result);
}
@ -253,7 +255,6 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
assertXMLEqual("Marshaller wrote invalid result", ROOT_WITHOUT_XSI_EXPECTED_STRING, result);
}
private CastorMarshaller getCastorMarshaller() {
return (CastorMarshaller) marshaller;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,16 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.web.servlet;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -39,6 +36,11 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
/**
* Test for SPR-10025.
*
@ -57,6 +59,7 @@ public class Spr10025Tests {
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = webAppContextSetup(this.wac).build();
@ -86,8 +89,8 @@ public class Spr10025Tests {
@ResponseBody
public void handle() {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
Assert.assertNull(attributes.getAttribute("foo1", RequestAttributes.SCOPE_REQUEST));
Assert.assertNotNull(attributes.getAttribute("foo2", RequestAttributes.SCOPE_REQUEST));
assertNull(attributes.getAttribute("foo1", RequestAttributes.SCOPE_REQUEST));
assertNotNull(attributes.getAttribute("foo2", RequestAttributes.SCOPE_REQUEST));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,18 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.web.servlet;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.options;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
package org.springframework.test.web.servlet;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -39,8 +36,14 @@ import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
/**
* Tests for SPR-10093 (support for OPTIONS requests).
*
* @author Arnaud Cogoluègnes
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ -48,47 +51,48 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@ContextConfiguration
public class Spr10093Tests {
@Autowired
private WebApplicationContext wac;
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = webAppContextSetup(this.wac).dispatchOptions(true).build();
}
@Test
public void test() throws Exception {
MyController controller = this.wac.getBean(MyController.class);
int initialCount = controller.counter.get();
this.mockMvc.perform(options("/myUrl")).andExpect(status().isOk());
Assert.assertEquals(initialCount+1,controller.counter.get());
}
private MockMvc mockMvc;
@Configuration
@EnableWebMvc
static class WebConfig extends WebMvcConfigurerAdapter {
@Before
public void setup() {
this.mockMvc = webAppContextSetup(this.wac).dispatchOptions(true).build();
}
@Bean
public MyController myController() {
return new MyController();
}
}
@Test
public void test() throws Exception {
MyController controller = this.wac.getBean(MyController.class);
int initialCount = controller.counter.get();
this.mockMvc.perform(options("/myUrl")).andExpect(status().isOk());
@Controller
private static class MyController {
assertEquals(initialCount + 1, controller.counter.get());
}
private AtomicInteger counter = new AtomicInteger(0);
@RequestMapping(value="/myUrl",method=RequestMethod.OPTIONS)
@ResponseBody
public void handle() {
counter.incrementAndGet();
}
}
@Configuration
@EnableWebMvc
static class WebConfig extends WebMvcConfigurerAdapter {
@Bean
public MyController myController() {
return new MyController();
}
}
@Controller
private static class MyController {
private AtomicInteger counter = new AtomicInteger(0);
@RequestMapping(value = "/myUrl", method = RequestMethod.OPTIONS)
@ResponseBody
public void handle() {
counter.incrementAndGet();
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,8 +23,6 @@ import java.util.Arrays;
import java.util.Locale;
import java.util.concurrent.Future;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@ -37,6 +35,8 @@ import org.springframework.util.StreamUtils;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import static org.junit.Assert.*;
public abstract class AbstractAsyncHttpRequestFactoryTestCase extends
AbstractJettyServerTestCase {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package org.springframework.http.client;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
@ -30,13 +31,15 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.SocketUtils;
import static org.junit.Assert.*;
/** @author Arjen Poutsma */
public class AbstractJettyServerTestCase {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,12 +17,6 @@
package org.springframework.web.servlet.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -33,11 +27,14 @@ import javax.servlet.http.HttpServletResponse;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.mock.web.test.MockHttpServletResponse;
import org.springframework.web.servlet.FlashMap;
import org.springframework.web.util.WebUtils;
import static org.junit.Assert.*;
/**
* Test fixture for testing {@link AbstractFlashMapManager} methods.
*