提交 0ee505b7 编写于 作者: I igor-suhorukov 提交者: Juergen Hoeller

Polish: assertion arguments should be passed in the correct order,

use assertNull instead of assertEquals(null, value),
declare delta as double value in assertEquals
上级 39201adc
...@@ -193,7 +193,7 @@ public class BeanUtilsTests { ...@@ -193,7 +193,7 @@ public class BeanUtilsTests {
source.setFlag2(true); source.setFlag2(true);
InvalidProperty target = new InvalidProperty(); InvalidProperty target = new InvalidProperty();
BeanUtils.copyProperties(source, target); BeanUtils.copyProperties(source, target);
assertEquals(target.getName(), "name"); assertEquals("name", target.getName());
assertTrue(target.getFlag1()); assertTrue(target.getFlag1());
assertTrue(target.getFlag2()); assertTrue(target.getFlag2());
} }
......
...@@ -518,7 +518,7 @@ public class BeanWrapperGenericsTests { ...@@ -518,7 +518,7 @@ public class BeanWrapperGenericsTests {
assertEquals("y", bw.getPropertyValue("data['x']")); assertEquals("y", bw.getPropertyValue("data['x']"));
bw.setPropertyValue("data['message']", "it works!"); bw.setPropertyValue("data['message']", "it works!");
assertEquals(data.get("message"), "it works!"); assertEquals("it works!", data.get("message"));
} }
......
...@@ -126,8 +126,8 @@ public class ConcurrentBeanFactoryTests { ...@@ -126,8 +126,8 @@ public class ConcurrentBeanFactoryTests {
ConcurrentBean b1 = (ConcurrentBean) factory.getBean("bean1"); ConcurrentBean b1 = (ConcurrentBean) factory.getBean("bean1");
ConcurrentBean b2 = (ConcurrentBean) factory.getBean("bean2"); ConcurrentBean b2 = (ConcurrentBean) factory.getBean("bean2");
assertEquals(b1.getDate(), DATE_1); assertEquals(DATE_1, b1.getDate());
assertEquals(b2.getDate(), DATE_2); assertEquals(DATE_2, b2.getDate());
} }
......
...@@ -55,9 +55,9 @@ public class CollectionMergingTests { ...@@ -55,9 +55,9 @@ public class CollectionMergingTests {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithList"); TestBean bean = (TestBean) this.beanFactory.getBean("childWithList");
List list = bean.getSomeList(); List list = bean.getSomeList();
assertEquals("Incorrect size", 3, list.size()); assertEquals("Incorrect size", 3, list.size());
assertEquals(list.get(0), "Rob Harrop"); assertEquals("Rob Harrop", list.get(0));
assertEquals(list.get(1), "Rod Johnson"); assertEquals("Rod Johnson", list.get(1));
assertEquals(list.get(2), "Juergen Hoeller"); assertEquals("Juergen Hoeller", list.get(2));
} }
@Test @Test
...@@ -98,9 +98,9 @@ public class CollectionMergingTests { ...@@ -98,9 +98,9 @@ public class CollectionMergingTests {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap"); TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap");
Map map = bean.getSomeMap(); Map map = bean.getSomeMap();
assertEquals("Incorrect size", 3, map.size()); assertEquals("Incorrect size", 3, map.size());
assertEquals(map.get("Rob"), "Sally"); assertEquals("Sally", map.get("Rob"));
assertEquals(map.get("Rod"), "Kerry"); assertEquals("Kerry", map.get("Rod"));
assertEquals(map.get("Juergen"), "Eva"); assertEquals("Eva", map.get("Juergen"));
} }
@Test @Test
...@@ -119,9 +119,9 @@ public class CollectionMergingTests { ...@@ -119,9 +119,9 @@ public class CollectionMergingTests {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithProps"); TestBean bean = (TestBean) this.beanFactory.getBean("childWithProps");
Properties props = bean.getSomeProperties(); Properties props = bean.getSomeProperties();
assertEquals("Incorrect size", 3, props.size()); assertEquals("Incorrect size", 3, props.size());
assertEquals(props.getProperty("Rob"), "Sally"); assertEquals("Sally", props.getProperty("Rob"));
assertEquals(props.getProperty("Rod"), "Kerry"); assertEquals("Kerry",props.getProperty("Rod"));
assertEquals(props.getProperty("Juergen"), "Eva"); assertEquals("Eva", props.getProperty("Juergen"));
} }
@Test @Test
...@@ -129,9 +129,9 @@ public class CollectionMergingTests { ...@@ -129,9 +129,9 @@ public class CollectionMergingTests {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor"); TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor");
List list = bean.getSomeList(); List list = bean.getSomeList();
assertEquals("Incorrect size", 3, list.size()); assertEquals("Incorrect size", 3, list.size());
assertEquals(list.get(0), "Rob Harrop"); assertEquals("Rob Harrop", list.get(0));
assertEquals(list.get(1), "Rod Johnson"); assertEquals("Rod Johnson", list.get(1));
assertEquals(list.get(2), "Juergen Hoeller"); assertEquals("Juergen Hoeller", list.get(2));
} }
@Test @Test
...@@ -172,9 +172,9 @@ public class CollectionMergingTests { ...@@ -172,9 +172,9 @@ public class CollectionMergingTests {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor"); TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor");
Map map = bean.getSomeMap(); Map map = bean.getSomeMap();
assertEquals("Incorrect size", 3, map.size()); assertEquals("Incorrect size", 3, map.size());
assertEquals(map.get("Rob"), "Sally"); assertEquals("Sally", map.get("Rob"));
assertEquals(map.get("Rod"), "Kerry"); assertEquals("Kerry", map.get("Rod"));
assertEquals(map.get("Juergen"), "Eva"); assertEquals("Eva", map.get("Juergen"));
} }
@Test @Test
...@@ -193,9 +193,9 @@ public class CollectionMergingTests { ...@@ -193,9 +193,9 @@ public class CollectionMergingTests {
TestBean bean = (TestBean) this.beanFactory.getBean("childWithPropsInConstructor"); TestBean bean = (TestBean) this.beanFactory.getBean("childWithPropsInConstructor");
Properties props = bean.getSomeProperties(); Properties props = bean.getSomeProperties();
assertEquals("Incorrect size", 3, props.size()); assertEquals("Incorrect size", 3, props.size());
assertEquals(props.getProperty("Rob"), "Sally"); assertEquals("Sally", props.getProperty("Rob"));
assertEquals(props.getProperty("Rod"), "Kerry"); assertEquals("Kerry", props.getProperty("Rod"));
assertEquals(props.getProperty("Juergen"), "Eva"); assertEquals("Eva", props.getProperty("Juergen"));
} }
} }
...@@ -1064,12 +1064,12 @@ public abstract class AbstractAopProxyTests { ...@@ -1064,12 +1064,12 @@ public abstract class AbstractAopProxyTests {
pc.addAdvisor(dp); pc.addAdvisor(dp);
pc.setTarget(tb); pc.setTarget(tb);
ITestBean it = (ITestBean) createProxy(pc); ITestBean it = (ITestBean) createProxy(pc);
assertEquals(dp.count, 0); assertEquals(0, dp.count);
it.getAge(); it.getAge();
assertEquals(dp.count, 1); assertEquals(1, dp.count);
it.setAge(11); it.setAge(11);
assertEquals(it.getAge(), 11); assertEquals(11, it.getAge());
assertEquals(dp.count, 2); assertEquals(2, dp.count);
} }
@Test @Test
...@@ -1083,16 +1083,16 @@ public abstract class AbstractAopProxyTests { ...@@ -1083,16 +1083,16 @@ public abstract class AbstractAopProxyTests {
this.mockTargetSource.setTarget(tb); this.mockTargetSource.setTarget(tb);
pc.setTargetSource(mockTargetSource); pc.setTargetSource(mockTargetSource);
ITestBean it = (ITestBean) createProxy(pc); ITestBean it = (ITestBean) createProxy(pc);
assertEquals(dp.count, 0); assertEquals(0, dp.count);
it.getAge(); it.getAge();
// Statically vetoed // Statically vetoed
assertEquals(0, dp.count); assertEquals(0, dp.count);
it.setAge(11); it.setAge(11);
assertEquals(it.getAge(), 11); assertEquals(11, it.getAge());
assertEquals(dp.count, 1); assertEquals(1, dp.count);
// Applies statically but not dynamically // Applies statically but not dynamically
it.setName("joe"); it.setName("joe");
assertEquals(dp.count, 1); assertEquals(1, dp.count);
} }
@Test @Test
......
...@@ -154,7 +154,7 @@ public class ConfigurationClassProcessingTests { ...@@ -154,7 +154,7 @@ public class ConfigurationClassProcessingTests {
public void simplestPossibleConfig() { public void simplestPossibleConfig() {
BeanFactory factory = initBeanFactory(SimplestPossibleConfig.class); BeanFactory factory = initBeanFactory(SimplestPossibleConfig.class);
String stringBean = factory.getBean("stringBean", String.class); String stringBean = factory.getBean("stringBean", String.class);
assertEquals(stringBean, "foo"); assertEquals("foo", stringBean);
} }
@Test @Test
...@@ -163,7 +163,7 @@ public class ConfigurationClassProcessingTests { ...@@ -163,7 +163,7 @@ public class ConfigurationClassProcessingTests {
assertEquals(Object.class, factory.getType("stringBean")); assertEquals(Object.class, factory.getType("stringBean"));
assertFalse(factory.isTypeMatch("stringBean", String.class)); assertFalse(factory.isTypeMatch("stringBean", String.class));
String stringBean = factory.getBean("stringBean", String.class); String stringBean = factory.getBean("stringBean", String.class);
assertEquals(stringBean, "foo"); assertEquals("foo", stringBean);
} }
@Test @Test
......
...@@ -55,7 +55,7 @@ public class RmiSupportTests { ...@@ -55,7 +55,7 @@ public class RmiSupportTests {
assertTrue(factory.getObject() instanceof IRemoteBean); assertTrue(factory.getObject() instanceof IRemoteBean);
IRemoteBean proxy = (IRemoteBean) factory.getObject(); IRemoteBean proxy = (IRemoteBean) factory.getObject();
proxy.setName("myName"); proxy.setName("myName");
assertEquals(RemoteBean.name, "myName"); assertEquals("myName", RemoteBean.name);
assertEquals(1, factory.counter); assertEquals(1, factory.counter);
} }
...@@ -179,7 +179,7 @@ public class RmiSupportTests { ...@@ -179,7 +179,7 @@ public class RmiSupportTests {
IBusinessBean proxy = (IBusinessBean) factory.getObject(); IBusinessBean proxy = (IBusinessBean) factory.getObject();
assertFalse(proxy instanceof IRemoteBean); assertFalse(proxy instanceof IRemoteBean);
proxy.setName("myName"); proxy.setName("myName");
assertEquals(RemoteBean.name, "myName"); assertEquals("myName", RemoteBean.name);
assertEquals(1, factory.counter); assertEquals(1, factory.counter);
} }
......
...@@ -37,9 +37,9 @@ public class ConstantsTests { ...@@ -37,9 +37,9 @@ public class ConstantsTests {
assertEquals(A.class.getName(), c.getClassName()); assertEquals(A.class.getName(), c.getClassName());
assertEquals(9, c.getSize()); assertEquals(9, c.getSize());
assertEquals(c.asNumber("DOG").intValue(), A.DOG); assertEquals(A.DOG, c.asNumber("DOG").intValue());
assertEquals(c.asNumber("dog").intValue(), A.DOG); assertEquals(A.DOG, c.asNumber("dog").intValue());
assertEquals(c.asNumber("cat").intValue(), A.CAT); assertEquals(A.CAT, c.asNumber("cat").intValue());
try { try {
c.asNumber("bogus"); c.asNumber("bogus");
...@@ -152,20 +152,20 @@ public class ConstantsTests { ...@@ -152,20 +152,20 @@ public class ConstantsTests {
public void toCode() { public void toCode() {
Constants c = new Constants(A.class); Constants c = new Constants(A.class);
assertEquals(c.toCode(new Integer(0), ""), "DOG"); assertEquals("DOG", c.toCode(new Integer(0), ""));
assertEquals(c.toCode(new Integer(0), "D"), "DOG"); assertEquals("DOG", c.toCode(new Integer(0), "D"));
assertEquals(c.toCode(new Integer(0), "DO"), "DOG"); assertEquals("DOG", c.toCode(new Integer(0), "DO"));
assertEquals(c.toCode(new Integer(0), "DoG"), "DOG"); assertEquals("DOG", c.toCode(new Integer(0), "DoG"));
assertEquals(c.toCode(new Integer(0), null), "DOG"); assertEquals("DOG", c.toCode(new Integer(0), null));
assertEquals(c.toCode(new Integer(66), ""), "CAT"); assertEquals("CAT", c.toCode(new Integer(66), ""));
assertEquals(c.toCode(new Integer(66), "C"), "CAT"); assertEquals("CAT", c.toCode(new Integer(66), "C"));
assertEquals(c.toCode(new Integer(66), "ca"), "CAT"); assertEquals("CAT", c.toCode(new Integer(66), "ca"));
assertEquals(c.toCode(new Integer(66), "cAt"), "CAT"); assertEquals("CAT", c.toCode(new Integer(66), "cAt"));
assertEquals(c.toCode(new Integer(66), null), "CAT"); assertEquals("CAT", c.toCode(new Integer(66), null));
assertEquals(c.toCode("", ""), "S1"); assertEquals("S1", c.toCode("", ""));
assertEquals(c.toCode("", "s"), "S1"); assertEquals("S1", c.toCode("", "s"));
assertEquals(c.toCode("", "s1"), "S1"); assertEquals("S1", c.toCode("", "s1"));
assertEquals(c.toCode("", null), "S1"); assertEquals("S1", c.toCode("", null));
try { try {
c.toCode("bogus", "bogus"); c.toCode("bogus", "bogus");
fail("Should have thrown ConstantException"); fail("Should have thrown ConstantException");
...@@ -179,8 +179,8 @@ public class ConstantsTests { ...@@ -179,8 +179,8 @@ public class ConstantsTests {
catch (Constants.ConstantException expected) { catch (Constants.ConstantException expected) {
} }
assertEquals(c.toCodeForProperty(new Integer(1), "myProperty"), "MY_PROPERTY_NO"); assertEquals("MY_PROPERTY_NO", c.toCodeForProperty(new Integer(1), "myProperty"));
assertEquals(c.toCodeForProperty(new Integer(2), "myProperty"), "MY_PROPERTY_YES"); assertEquals("MY_PROPERTY_YES", c.toCodeForProperty(new Integer(2), "myProperty"));
try { try {
c.toCodeForProperty("bogus", "bogus"); c.toCodeForProperty("bogus", "bogus");
fail("Should have thrown ConstantException"); fail("Should have thrown ConstantException");
...@@ -188,20 +188,20 @@ public class ConstantsTests { ...@@ -188,20 +188,20 @@ public class ConstantsTests {
catch (Constants.ConstantException expected) { catch (Constants.ConstantException expected) {
} }
assertEquals(c.toCodeForSuffix(new Integer(0), ""), "DOG"); assertEquals("DOG", c.toCodeForSuffix(new Integer(0), ""));
assertEquals(c.toCodeForSuffix(new Integer(0), "G"), "DOG"); assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "G"));
assertEquals(c.toCodeForSuffix(new Integer(0), "OG"), "DOG"); assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "OG"));
assertEquals(c.toCodeForSuffix(new Integer(0), "DoG"), "DOG"); assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "DoG"));
assertEquals(c.toCodeForSuffix(new Integer(0), null), "DOG"); assertEquals("DOG", c.toCodeForSuffix(new Integer(0), null));
assertEquals(c.toCodeForSuffix(new Integer(66), ""), "CAT"); assertEquals("CAT", c.toCodeForSuffix(new Integer(66), ""));
assertEquals(c.toCodeForSuffix(new Integer(66), "T"), "CAT"); assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "T"));
assertEquals(c.toCodeForSuffix(new Integer(66), "at"), "CAT"); assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "at"));
assertEquals(c.toCodeForSuffix(new Integer(66), "cAt"), "CAT"); assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "cAt"));
assertEquals(c.toCodeForSuffix(new Integer(66), null), "CAT"); assertEquals("CAT", c.toCodeForSuffix(new Integer(66), null));
assertEquals(c.toCodeForSuffix("", ""), "S1"); assertEquals("S1", c.toCodeForSuffix("", ""));
assertEquals(c.toCodeForSuffix("", "1"), "S1"); assertEquals("S1", c.toCodeForSuffix("", "1"));
assertEquals(c.toCodeForSuffix("", "s1"), "S1"); assertEquals("S1", c.toCodeForSuffix("", "s1"));
assertEquals(c.toCodeForSuffix("", null), "S1"); assertEquals("S1", c.toCodeForSuffix("", null));
try { try {
c.toCodeForSuffix("bogus", "bogus"); c.toCodeForSuffix("bogus", "bogus");
fail("Should have thrown ConstantException"); fail("Should have thrown ConstantException");
......
...@@ -96,7 +96,7 @@ public class MutablePropertySourcesTests { ...@@ -96,7 +96,7 @@ public class MutablePropertySourcesTests {
assertThat(sources.size(), equalTo(6)); assertThat(sources.size(), equalTo(6));
assertThat(sources.contains("a"), is(false)); assertThat(sources.contains("a"), is(false));
assertEquals(sources.remove("a"), null); assertNull(sources.remove("a"));
assertThat(sources.size(), equalTo(6)); assertThat(sources.size(), equalTo(6));
String bogusPS = "bogus"; String bogusPS = "bogus";
......
...@@ -365,7 +365,7 @@ public class AnnotationMetadataTests { ...@@ -365,7 +365,7 @@ public class AnnotationMetadataTests {
assertArrayEquals(new String[] { Void.class.getName() }, (String[]) optionalArray[0].get("classArray")); assertArrayEquals(new String[] { Void.class.getName() }, (String[]) optionalArray[0].get("classArray"));
assertArrayEquals(new String[] { Void.class.getName() }, optionalArray[0].getStringArray("classArray")); assertArrayEquals(new String[] { Void.class.getName() }, optionalArray[0].getStringArray("classArray"));
assertEquals(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value"), "direct"); assertEquals("direct", metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value"));
allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value"); allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta"))))); assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet<Object>(Arrays.asList("direct", "meta")))));
} }
......
...@@ -167,7 +167,7 @@ public class FastByteArrayOutputStreamTests { ...@@ -167,7 +167,7 @@ public class FastByteArrayOutputStreamTests {
this.os.write(this.helloBytes); this.os.write(this.helloBytes);
InputStream inputStream = this.os.getInputStream(); InputStream inputStream = this.os.getInputStream();
assertEquals(inputStream.read(), this.helloBytes[0]); assertEquals(inputStream.read(), this.helloBytes[0]);
assertEquals(inputStream.skip(1), 1); assertEquals(1, inputStream.skip(1));
assertEquals(inputStream.read(), this.helloBytes[2]); assertEquals(inputStream.read(), this.helloBytes[2]);
assertEquals(this.helloBytes.length - 3, inputStream.available()); assertEquals(this.helloBytes.length - 3, inputStream.available());
} }
......
...@@ -70,7 +70,7 @@ public abstract class AbstractExpressionTests { ...@@ -70,7 +70,7 @@ public abstract class AbstractExpressionTests {
if (expectedValue == null) { if (expectedValue == null) {
return; // no point doing other checks 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(); Class<?> resultType = value.getClass();
...@@ -100,7 +100,7 @@ public abstract class AbstractExpressionTests { ...@@ -100,7 +100,7 @@ public abstract class AbstractExpressionTests {
if (expectedValue == null) { if (expectedValue == null) {
return; // no point doing other checks 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(); Class<?> resultType = value.getClass();
...@@ -132,7 +132,7 @@ public abstract class AbstractExpressionTests { ...@@ -132,7 +132,7 @@ public abstract class AbstractExpressionTests {
if (expectedValue == null) { if (expectedValue == null) {
return; // no point doing other checks 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(); Class<? extends Object> resultType = value.getClass();
if (expectedValue instanceof String) { if (expectedValue instanceof String) {
...@@ -142,8 +142,8 @@ public abstract class AbstractExpressionTests { ...@@ -142,8 +142,8 @@ public abstract class AbstractExpressionTests {
else { else {
assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value); assertEquals("Did not get expected value for expression '" + expression + "'.", expectedValue, value);
} }
assertEquals("Type of the result was not as expected. Expected '" + expectedClassOfResult + assertNull("Type of the result was not as expected. Expected '" + expectedClassOfResult +
"' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType), true); "' but result was of type '" + resultType + "'", expectedClassOfResult.equals(resultType));
boolean isWritable = expr.isWritable(eContext); boolean isWritable = expr.isWritable(eContext);
if (isWritable != shouldBeWritable) { if (isWritable != shouldBeWritable) {
......
...@@ -103,7 +103,7 @@ public class ConstructorInvocationTests extends AbstractExpressionTests { ...@@ -103,7 +103,7 @@ public class ConstructorInvocationTests extends AbstractExpressionTests {
eContext.setRootObject(new Tester()); eContext.setRootObject(new Tester());
eContext.setVariable("bar", 3); eContext.setVariable("bar", 3);
Object o = expr.getValue(eContext); Object o = expr.getValue(eContext);
assertEquals(o, 3); assertEquals(3, o);
assertEquals(1, parser.parseExpression("counter").getValue(eContext)); assertEquals(1, parser.parseExpression("counter").getValue(eContext));
// Now the expression has cached that throwException(int) is the right thing to // Now the expression has cached that throwException(int) is the right thing to
......
...@@ -535,7 +535,7 @@ public class EvaluationTests extends AbstractExpressionTests { ...@@ -535,7 +535,7 @@ public class EvaluationTests extends AbstractExpressionTests {
int twentyFour = parser.parseExpression("2.0 * 3e0 * 4").getValue(Integer.class); int twentyFour = parser.parseExpression("2.0 * 3e0 * 4").getValue(Integer.class);
assertEquals(24, twentyFour); assertEquals(24, twentyFour);
double one = parser.parseExpression("8.0 / 5e0 % 2").getValue(Double.class); 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); int o = parser.parseExpression("8.0 / 5e0 % 2").getValue(Integer.class);
assertEquals(1, o); assertEquals(1, o);
int sixteen = parser.parseExpression("-2 ^ 4").getValue(Integer.class); int sixteen = parser.parseExpression("-2 ^ 4").getValue(Integer.class);
......
...@@ -219,7 +219,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests { ...@@ -219,7 +219,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
fail("Should not be allowed to set oranges to be blue !"); fail("Should not be allowed to set oranges to be blue !");
} }
catch (SpelEvaluationException ee) { 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 { ...@@ -240,7 +240,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
fail("Should not be allowed to set peas to be blue !"); fail("Should not be allowed to set peas to be blue !");
} }
catch (SpelEvaluationException ee) { 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 { ...@@ -59,7 +59,7 @@ public class LiteralExpressionTests {
} }
catch (EvaluationException ee) { catch (EvaluationException ee) {
// success, not allowed - whilst here, check the expression value in the exception // success, not allowed - whilst here, check the expression value in the exception
assertEquals(ee.getExpressionString(), "somevalue"); assertEquals("somevalue", ee.getExpressionString());
} }
try { try {
LiteralExpression lEx = new LiteralExpression("somevalue"); LiteralExpression lEx = new LiteralExpression("somevalue");
...@@ -68,7 +68,7 @@ public class LiteralExpressionTests { ...@@ -68,7 +68,7 @@ public class LiteralExpressionTests {
} }
catch (EvaluationException ee) { catch (EvaluationException ee) {
// success, not allowed - whilst here, check the expression value in the exception // success, not allowed - whilst here, check the expression value in the exception
assertEquals(ee.getExpressionString(), "somevalue"); assertEquals("somevalue", ee.getExpressionString());
} }
try { try {
LiteralExpression lEx = new LiteralExpression("somevalue"); LiteralExpression lEx = new LiteralExpression("somevalue");
...@@ -77,7 +77,7 @@ public class LiteralExpressionTests { ...@@ -77,7 +77,7 @@ public class LiteralExpressionTests {
} }
catch (EvaluationException ee) { catch (EvaluationException ee) {
// success, not allowed - whilst here, check the expression value in the exception // 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 { ...@@ -98,7 +98,7 @@ public class MethodInvocationTests extends AbstractExpressionTests {
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext(); StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();
eContext.setVariable("bar", 3); eContext.setVariable("bar", 3);
Object o = expr.getValue(eContext); Object o = expr.getValue(eContext);
assertEquals(o, 3); assertEquals(3, o);
assertEquals(1, parser.parseExpression("counter").getValue(eContext)); assertEquals(1, parser.parseExpression("counter").getValue(eContext));
// Now the expression has cached that throwException(int) is the right thing to call // Now the expression has cached that throwException(int) is the right thing to call
...@@ -294,7 +294,7 @@ public class MethodInvocationTests extends AbstractExpressionTests { ...@@ -294,7 +294,7 @@ public class MethodInvocationTests extends AbstractExpressionTests {
public void testMethodOfClass() throws Exception { public void testMethodOfClass() throws Exception {
Expression expression = parser.parseExpression("getName()"); Expression expression = parser.parseExpression("getName()");
Object value = expression.getValue(new StandardEvaluationContext(String.class)); Object value = expression.getValue(new StandardEvaluationContext(String.class));
assertEquals(value, "java.lang.String"); assertEquals("java.lang.String", value);
} }
@Test @Test
......
...@@ -115,7 +115,7 @@ public class PropertyAccessTests extends AbstractExpressionTests { ...@@ -115,7 +115,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
ctx.addPropertyAccessor(new StringyPropertyAccessor()); ctx.addPropertyAccessor(new StringyPropertyAccessor());
Expression expr = parser.parseRaw("new String('hello').flibbles"); Expression expr = parser.parseRaw("new String('hello').flibbles");
Integer i = expr.getValue(ctx, Integer.class); Integer i = expr.getValue(ctx, Integer.class);
assertEquals((int) i, 7); assertEquals(7, (int) i);
// The reflection one will be used for other properties... // The reflection one will be used for other properties...
expr = parser.parseRaw("new String('hello').CASE_INSENSITIVE_ORDER"); expr = parser.parseRaw("new String('hello').CASE_INSENSITIVE_ORDER");
...@@ -125,7 +125,7 @@ public class PropertyAccessTests extends AbstractExpressionTests { ...@@ -125,7 +125,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
expr = parser.parseRaw("new String('hello').flibbles"); expr = parser.parseRaw("new String('hello').flibbles");
expr.setValue(ctx, 99); expr.setValue(ctx, 99);
i = expr.getValue(ctx, Integer.class); i = expr.getValue(ctx, Integer.class);
assertEquals((int) i, 99); assertEquals(99, (int) i);
// Cannot set it to a string value // Cannot set it to a string value
try { try {
...@@ -165,7 +165,7 @@ public class PropertyAccessTests extends AbstractExpressionTests { ...@@ -165,7 +165,7 @@ public class PropertyAccessTests extends AbstractExpressionTests {
public void testAccessingPropertyOfClass() throws Exception { public void testAccessingPropertyOfClass() throws Exception {
Expression expression = parser.parseExpression("name"); Expression expression = parser.parseExpression("name");
Object value = expression.getValue(new StandardEvaluationContext(String.class)); Object value = expression.getValue(new StandardEvaluationContext(String.class));
assertEquals(value, "java.lang.String"); assertEquals("java.lang.String", value);
} }
@Test @Test
......
...@@ -47,7 +47,7 @@ public class JdbcDaoSupportTests { ...@@ -47,7 +47,7 @@ public class JdbcDaoSupportTests {
dao.afterPropertiesSet(); dao.afterPropertiesSet();
assertEquals("Correct DataSource", ds, dao.getDataSource()); assertEquals("Correct DataSource", ds, dao.getDataSource());
assertEquals("Correct JdbcTemplate", ds, dao.getJdbcTemplate().getDataSource()); assertEquals("Correct JdbcTemplate", ds, dao.getJdbcTemplate().getDataSource());
assertEquals("initDao called", test.size(), 1); assertEquals("initDao called", 1, test.size());
} }
@Test @Test
...@@ -63,7 +63,7 @@ public class JdbcDaoSupportTests { ...@@ -63,7 +63,7 @@ public class JdbcDaoSupportTests {
dao.setJdbcTemplate(template); dao.setJdbcTemplate(template);
dao.afterPropertiesSet(); dao.afterPropertiesSet();
assertEquals("Correct JdbcTemplate", dao.getJdbcTemplate(), template); assertEquals("Correct JdbcTemplate", dao.getJdbcTemplate(), template);
assertEquals("initDao called", test.size(), 1); assertEquals("initDao called", 1, test.size());
} }
} }
...@@ -615,7 +615,7 @@ public class SqlQueryTests { ...@@ -615,7 +615,7 @@ public class SqlQueryTests {
ids.add(2); ids.add(2);
List<Customer> cust = query.findCustomers(ids); List<Customer> cust = query.findCustomers(ids);
assertEquals("We got two customers back", cust.size(), 2); assertEquals("We got two customers back", 2, cust.size());
assertEquals("First customer id was assigned correctly", cust.get(0).getId(), 1); assertEquals("First customer id was assigned correctly", cust.get(0).getId(), 1);
assertEquals("First customer forename was assigned correctly", cust.get(0).getForename(), "rod"); assertEquals("First customer forename was assigned correctly", cust.get(0).getForename(), "rod");
assertEquals("Second customer id was assigned correctly", cust.get(1).getId(), 2); assertEquals("Second customer id was assigned correctly", cust.get(1).getId(), 2);
...@@ -664,7 +664,7 @@ public class SqlQueryTests { ...@@ -664,7 +664,7 @@ public class SqlQueryTests {
CustomerQuery query = new CustomerQuery(dataSource); CustomerQuery query = new CustomerQuery(dataSource);
List<Customer> cust = query.findCustomers(1); List<Customer> cust = query.findCustomers(1);
assertEquals("We got two customers back", cust.size(), 2); assertEquals("We got two customers back", 2, cust.size());
assertEquals("First customer id was assigned correctly", cust.get(0).getId(), 1); assertEquals("First customer id was assigned correctly", cust.get(0).getId(), 1);
assertEquals("First customer forename was assigned correctly", cust.get(0).getForename(), "rod"); assertEquals("First customer forename was assigned correctly", cust.get(0).getForename(), "rod");
assertEquals("Second customer id was assigned correctly", cust.get(1).getId(), 2); assertEquals("Second customer id was assigned correctly", cust.get(1).getId(), 2);
......
...@@ -194,7 +194,7 @@ public class StoredProcedureTests { ...@@ -194,7 +194,7 @@ public class StoredProcedureTests {
t.setExceptionTranslator(new SQLStateSQLExceptionTranslator()); t.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t); StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t);
assertEquals(sp.execute(11), 5); assertEquals(5, sp.execute(11));
assertEquals(1, t.calls); assertEquals(1, t.calls);
verify(callableStatement).setObject(1, 11, Types.INTEGER); verify(callableStatement).setObject(1, 11, Types.INTEGER);
...@@ -216,7 +216,7 @@ public class StoredProcedureTests { ...@@ -216,7 +216,7 @@ public class StoredProcedureTests {
JdbcTemplate t = new JdbcTemplate(); JdbcTemplate t = new JdbcTemplate();
t.setDataSource(dataSource); t.setDataSource(dataSource);
StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t); StoredProcedureConfiguredViaJdbcTemplate sp = new StoredProcedureConfiguredViaJdbcTemplate(t);
assertEquals(sp.execute(1106), 4); assertEquals(4, sp.execute(1106));
verify(callableStatement).setObject(1, 1106, Types.INTEGER); verify(callableStatement).setObject(1, 1106, Types.INTEGER);
verify(callableStatement).registerOutParameter(2, Types.INTEGER); verify(callableStatement).registerOutParameter(2, Types.INTEGER);
} }
......
...@@ -46,7 +46,7 @@ public class JmsGatewaySupportTests { ...@@ -46,7 +46,7 @@ public class JmsGatewaySupportTests {
gateway.afterPropertiesSet(); gateway.afterPropertiesSet();
assertEquals("Correct ConnectionFactory", mockConnectionFactory, gateway.getConnectionFactory()); assertEquals("Correct ConnectionFactory", mockConnectionFactory, gateway.getConnectionFactory());
assertEquals("Correct JmsTemplate", mockConnectionFactory, gateway.getJmsTemplate().getConnectionFactory()); assertEquals("Correct JmsTemplate", mockConnectionFactory, gateway.getJmsTemplate().getConnectionFactory());
assertEquals("initGatway called", test.size(), 1); assertEquals("initGatway called", 1, test.size());
} }
@Test @Test
...@@ -62,7 +62,7 @@ public class JmsGatewaySupportTests { ...@@ -62,7 +62,7 @@ public class JmsGatewaySupportTests {
gateway.setJmsTemplate(template); gateway.setJmsTemplate(template);
gateway.afterPropertiesSet(); gateway.afterPropertiesSet();
assertEquals("Correct JmsTemplate", template, gateway.getJmsTemplate()); assertEquals("Correct JmsTemplate", template, gateway.getJmsTemplate());
assertEquals("initGateway called", test.size(), 1); assertEquals("initGateway called", 1, test.size());
} }
} }
...@@ -301,7 +301,7 @@ public class MockHttpServletResponseTests { ...@@ -301,7 +301,7 @@ public class MockHttpServletResponseTests {
public void modifyStatusAfterSendError() throws IOException { public void modifyStatusAfterSendError() throws IOException {
response.sendError(HttpServletResponse.SC_NOT_FOUND); response.sendError(HttpServletResponse.SC_NOT_FOUND);
response.setStatus(HttpServletResponse.SC_OK); response.setStatus(HttpServletResponse.SC_OK);
assertEquals(response.getStatus(),HttpServletResponse.SC_NOT_FOUND); assertEquals(HttpServletResponse.SC_NOT_FOUND, response.getStatus());
} }
@Test // SPR-10414 @Test // SPR-10414
...@@ -309,7 +309,7 @@ public class MockHttpServletResponseTests { ...@@ -309,7 +309,7 @@ public class MockHttpServletResponseTests {
public void modifyStatusMessageAfterSendError() throws IOException { public void modifyStatusMessageAfterSendError() throws IOException {
response.sendError(HttpServletResponse.SC_NOT_FOUND); response.sendError(HttpServletResponse.SC_NOT_FOUND);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Server Error"); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Server Error");
assertEquals(response.getStatus(),HttpServletResponse.SC_NOT_FOUND); assertEquals(HttpServletResponse.SC_NOT_FOUND, response.getStatus());
} }
} }
...@@ -92,9 +92,9 @@ public class TransactionAttributeEditorTests { ...@@ -92,9 +92,9 @@ public class TransactionAttributeEditorTests {
pe.setAsText("PROPAGATION_MANDATORY,ISOLATION_REPEATABLE_READ,timeout_10,-IOException,+MyRuntimeException"); pe.setAsText("PROPAGATION_MANDATORY,ISOLATION_REPEATABLE_READ,timeout_10,-IOException,+MyRuntimeException");
TransactionAttribute ta = (TransactionAttribute) pe.getValue(); TransactionAttribute ta = (TransactionAttribute) pe.getValue();
assertNotNull(ta); assertNotNull(ta);
assertEquals(ta.getPropagationBehavior(), TransactionDefinition.PROPAGATION_MANDATORY); assertEquals(TransactionDefinition.PROPAGATION_MANDATORY, ta.getPropagationBehavior());
assertEquals(ta.getIsolationLevel(), TransactionDefinition.ISOLATION_REPEATABLE_READ); assertEquals(TransactionDefinition.ISOLATION_REPEATABLE_READ, ta.getIsolationLevel());
assertEquals(ta.getTimeout(), 10); assertEquals(10, ta.getTimeout());
assertFalse(ta.isReadOnly()); assertFalse(ta.isReadOnly());
assertTrue(ta.rollbackOn(new RuntimeException())); assertTrue(ta.rollbackOn(new RuntimeException()));
assertFalse(ta.rollbackOn(new Exception())); assertFalse(ta.rollbackOn(new Exception()));
...@@ -109,9 +109,9 @@ public class TransactionAttributeEditorTests { ...@@ -109,9 +109,9 @@ public class TransactionAttributeEditorTests {
pe.setAsText("+IOException,readOnly,ISOLATION_READ_COMMITTED,-MyRuntimeException,PROPAGATION_SUPPORTS"); pe.setAsText("+IOException,readOnly,ISOLATION_READ_COMMITTED,-MyRuntimeException,PROPAGATION_SUPPORTS");
TransactionAttribute ta = (TransactionAttribute) pe.getValue(); TransactionAttribute ta = (TransactionAttribute) pe.getValue();
assertNotNull(ta); assertNotNull(ta);
assertEquals(ta.getPropagationBehavior(), TransactionDefinition.PROPAGATION_SUPPORTS); assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
assertEquals(ta.getIsolationLevel(), TransactionDefinition.ISOLATION_READ_COMMITTED); assertEquals(TransactionDefinition.ISOLATION_READ_COMMITTED, ta.getIsolationLevel());
assertEquals(ta.getTimeout(), TransactionDefinition.TIMEOUT_DEFAULT); assertEquals(TransactionDefinition.TIMEOUT_DEFAULT, ta.getTimeout());
assertTrue(ta.isReadOnly()); assertTrue(ta.isReadOnly());
assertTrue(ta.rollbackOn(new RuntimeException())); assertTrue(ta.rollbackOn(new RuntimeException()));
assertFalse(ta.rollbackOn(new Exception())); assertFalse(ta.rollbackOn(new Exception()));
...@@ -132,9 +132,9 @@ public class TransactionAttributeEditorTests { ...@@ -132,9 +132,9 @@ public class TransactionAttributeEditorTests {
pe.setAsText(source.toString()); pe.setAsText(source.toString());
TransactionAttribute ta = (TransactionAttribute) pe.getValue(); TransactionAttribute ta = (TransactionAttribute) pe.getValue();
assertEquals(ta, source); assertEquals(ta, source);
assertEquals(ta.getPropagationBehavior(), TransactionDefinition.PROPAGATION_SUPPORTS); assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
assertEquals(ta.getIsolationLevel(), TransactionDefinition.ISOLATION_REPEATABLE_READ); assertEquals(TransactionDefinition.ISOLATION_REPEATABLE_READ, ta.getIsolationLevel());
assertEquals(ta.getTimeout(), 10); assertEquals(10, ta.getTimeout());
assertTrue(ta.isReadOnly()); assertTrue(ta.isReadOnly());
assertTrue(ta.rollbackOn(new RuntimeException())); assertTrue(ta.rollbackOn(new RuntimeException()));
assertFalse(ta.rollbackOn(new Exception())); assertFalse(ta.rollbackOn(new Exception()));
...@@ -159,9 +159,9 @@ public class TransactionAttributeEditorTests { ...@@ -159,9 +159,9 @@ public class TransactionAttributeEditorTests {
pe.setAsText(source.toString()); pe.setAsText(source.toString());
TransactionAttribute ta = (TransactionAttribute) pe.getValue(); TransactionAttribute ta = (TransactionAttribute) pe.getValue();
assertEquals(ta, source); assertEquals(ta, source);
assertEquals(ta.getPropagationBehavior(), TransactionDefinition.PROPAGATION_SUPPORTS); assertEquals(TransactionDefinition.PROPAGATION_SUPPORTS, ta.getPropagationBehavior());
assertEquals(ta.getIsolationLevel(), TransactionDefinition.ISOLATION_REPEATABLE_READ); assertEquals(TransactionDefinition.ISOLATION_REPEATABLE_READ, ta.getIsolationLevel());
assertEquals(ta.getTimeout(), 10); assertEquals(10, ta.getTimeout());
assertTrue(ta.isReadOnly()); assertTrue(ta.isReadOnly());
assertTrue(ta.rollbackOn(new IllegalArgumentException())); assertTrue(ta.rollbackOn(new IllegalArgumentException()));
assertFalse(ta.rollbackOn(new IllegalStateException())); assertFalse(ta.rollbackOn(new IllegalStateException()));
......
...@@ -92,7 +92,7 @@ public class SpringHandlerInstantiatorTests { ...@@ -92,7 +92,7 @@ public class SpringHandlerInstantiatorTests {
public void autowiredDeserializer() throws IOException { public void autowiredDeserializer() throws IOException {
String json = "{\"username\":\"bob\"}"; String json = "{\"username\":\"bob\"}";
User user = this.objectMapper.readValue(json, User.class); User user = this.objectMapper.readValue(json, User.class);
assertEquals(user.getUsername(), "BOB"); assertEquals("BOB", user.getUsername());
} }
@Test @Test
......
...@@ -99,8 +99,8 @@ public class CauchoRemotingTests { ...@@ -99,8 +99,8 @@ public class CauchoRemotingTests {
assertTrue(factory.getObject() instanceof ITestBean); assertTrue(factory.getObject() instanceof ITestBean);
ITestBean bean = (ITestBean) factory.getObject(); ITestBean bean = (ITestBean) factory.getObject();
assertEquals(proxyFactory.user, "test"); assertEquals("test", proxyFactory.user);
assertEquals(proxyFactory.password, "bean"); assertEquals("bean", proxyFactory.password);
assertTrue(proxyFactory.overloadEnabled); assertTrue(proxyFactory.overloadEnabled);
exception.expect(RemoteAccessException.class); exception.expect(RemoteAccessException.class);
......
...@@ -62,7 +62,7 @@ public class MappingMediaTypeFileExtensionResolverTests { ...@@ -62,7 +62,7 @@ public class MappingMediaTypeFileExtensionResolverTests {
MappingMediaTypeFileExtensionResolver resolver = new MappingMediaTypeFileExtensionResolver(mapping); MappingMediaTypeFileExtensionResolver resolver = new MappingMediaTypeFileExtensionResolver(mapping);
MediaType mediaType = resolver.lookupMediaType("JSON"); MediaType mediaType = resolver.lookupMediaType("JSON");
assertEquals(mediaType, MediaType.APPLICATION_JSON); assertEquals(MediaType.APPLICATION_JSON, mediaType);
} }
} }
...@@ -66,7 +66,7 @@ public class WebAsyncManagerTests { ...@@ -66,7 +66,7 @@ public class WebAsyncManagerTests {
fail("Expected exception"); fail("Expected exception");
} }
catch (IllegalStateException ex) { catch (IllegalStateException ex) {
assertEquals(ex.getMessage(), "AsyncWebRequest must not be null"); assertEquals("AsyncWebRequest must not be null", ex.getMessage());
} }
try { try {
...@@ -74,7 +74,7 @@ public class WebAsyncManagerTests { ...@@ -74,7 +74,7 @@ public class WebAsyncManagerTests {
fail("Expected exception"); fail("Expected exception");
} }
catch (IllegalStateException ex) { catch (IllegalStateException ex) {
assertEquals(ex.getMessage(), "AsyncWebRequest must not be null"); assertEquals("AsyncWebRequest must not be null", ex.getMessage());
} }
} }
...@@ -256,7 +256,7 @@ public class WebAsyncManagerTests { ...@@ -256,7 +256,7 @@ public class WebAsyncManagerTests {
fail("Expected exception"); fail("Expected exception");
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Callable must not be null"); assertEquals("Callable must not be null", ex.getMessage());
} }
} }
...@@ -357,7 +357,7 @@ public class WebAsyncManagerTests { ...@@ -357,7 +357,7 @@ public class WebAsyncManagerTests {
fail("Expected exception"); fail("Expected exception");
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "DeferredResult must not be null"); assertEquals("DeferredResult must not be null", ex.getMessage());
} }
} }
......
...@@ -51,7 +51,7 @@ public class DelegatingPhaseListenerTests { ...@@ -51,7 +51,7 @@ public class DelegatingPhaseListenerTests {
TestListener target = new TestListener(); TestListener target = new TestListener();
beanFactory.addBean("testListener", target); beanFactory.addBean("testListener", target);
assertEquals(delPhaseListener.getPhaseId(), PhaseId.ANY_PHASE); assertEquals(PhaseId.ANY_PHASE, delPhaseListener.getPhaseId());
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle()); PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle());
delPhaseListener.beforePhase(event); delPhaseListener.beforePhase(event);
...@@ -68,7 +68,7 @@ public class DelegatingPhaseListenerTests { ...@@ -68,7 +68,7 @@ public class DelegatingPhaseListenerTests {
beanFactory.addBean("testListener1", target1); beanFactory.addBean("testListener1", target1);
beanFactory.addBean("testListener2", target2); beanFactory.addBean("testListener2", target2);
assertEquals(delPhaseListener.getPhaseId(), PhaseId.ANY_PHASE); assertEquals(PhaseId.ANY_PHASE, delPhaseListener.getPhaseId());
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle()); PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle());
delPhaseListener.beforePhase(event); delPhaseListener.beforePhase(event);
......
...@@ -42,7 +42,7 @@ public class HtmlUtilsTests { ...@@ -42,7 +42,7 @@ public class HtmlUtilsTests {
public void testHtmlUnescape() { public void testHtmlUnescape() {
String escaped = "&quot;This is a quote&#39;"; String escaped = "&quot;This is a quote&#39;";
String unescaped = HtmlUtils.htmlUnescape(escaped); String unescaped = HtmlUtils.htmlUnescape(escaped);
assertEquals(unescaped, "\"This is a quote'"); assertEquals("\"This is a quote'", unescaped);
} }
@Test @Test
......
...@@ -31,7 +31,7 @@ public class ServletContextPropertyUtilsTests { ...@@ -31,7 +31,7 @@ public class ServletContextPropertyUtilsTests {
MockServletContext servletContext = new MockServletContext(); MockServletContext servletContext = new MockServletContext();
servletContext.setInitParameter("test.prop", "bar"); servletContext.setInitParameter("test.prop", "bar");
String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext); String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext);
assertEquals(resolved, "bar"); assertEquals("bar", resolved);
} }
@Test @Test
...@@ -40,7 +40,7 @@ public class ServletContextPropertyUtilsTests { ...@@ -40,7 +40,7 @@ public class ServletContextPropertyUtilsTests {
System.setProperty("test.prop", "bar"); System.setProperty("test.prop", "bar");
try { try {
String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext); String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext);
assertEquals(resolved, "bar"); assertEquals("bar", resolved);
} }
finally { finally {
System.clearProperty("test.prop"); System.clearProperty("test.prop");
......
...@@ -34,10 +34,10 @@ public class TagUtilsTests { ...@@ -34,10 +34,10 @@ public class TagUtilsTests {
@Test @Test
public void getScopeSunnyDay() { public void getScopeSunnyDay() {
assertEquals(TagUtils.SCOPE_PAGE, "page"); assertEquals("page", TagUtils.SCOPE_PAGE);
assertEquals(TagUtils.SCOPE_APPLICATION, "application"); assertEquals("application", TagUtils.SCOPE_APPLICATION);
assertEquals(TagUtils.SCOPE_SESSION, "session"); assertEquals("session", TagUtils.SCOPE_SESSION);
assertEquals(TagUtils.SCOPE_REQUEST, "request"); assertEquals("request", TagUtils.SCOPE_REQUEST);
assertEquals(PageContext.PAGE_SCOPE, TagUtils.getScope("page")); assertEquals(PageContext.PAGE_SCOPE, TagUtils.getScope("page"));
assertEquals(PageContext.REQUEST_SCOPE, TagUtils.getScope("request")); assertEquals(PageContext.REQUEST_SCOPE, TagUtils.getScope("request"));
......
...@@ -72,8 +72,8 @@ public class UrlBasedViewResolverTests { ...@@ -72,8 +72,8 @@ public class UrlBasedViewResolverTests {
.consumeNextWith(view -> { .consumeNextWith(view -> {
assertEquals(RedirectView.class, view.getClass()); assertEquals(RedirectView.class, view.getClass());
RedirectView redirectView = (RedirectView) view; RedirectView redirectView = (RedirectView) view;
assertEquals(redirectView.getUrl(), "foo"); assertEquals("foo", redirectView.getUrl());
assertEquals(redirectView.getStatusCode(), HttpStatus.SEE_OTHER); assertEquals(HttpStatus.SEE_OTHER, redirectView.getStatusCode());
}) })
.expectComplete() .expectComplete()
.verify(Duration.ZERO); .verify(Duration.ZERO);
...@@ -88,8 +88,8 @@ public class UrlBasedViewResolverTests { ...@@ -88,8 +88,8 @@ public class UrlBasedViewResolverTests {
.consumeNextWith(view -> { .consumeNextWith(view -> {
assertEquals(RedirectView.class, view.getClass()); assertEquals(RedirectView.class, view.getClass());
RedirectView redirectView = (RedirectView) view; RedirectView redirectView = (RedirectView) view;
assertEquals(redirectView.getUrl(), "foo"); assertEquals("foo", redirectView.getUrl());
assertEquals(redirectView.getStatusCode(), HttpStatus.FOUND); assertEquals(HttpStatus.FOUND, redirectView.getStatusCode());
}) })
.expectComplete() .expectComplete()
.verify(Duration.ZERO); .verify(Duration.ZERO);
......
...@@ -49,7 +49,7 @@ public class CookieLocaleResolverTests { ...@@ -49,7 +49,7 @@ public class CookieLocaleResolverTests {
CookieLocaleResolver resolver = new CookieLocaleResolver(); CookieLocaleResolver resolver = new CookieLocaleResolver();
resolver.setCookieName("LanguageKoekje"); resolver.setCookieName("LanguageKoekje");
Locale loc = resolver.resolveLocale(request); Locale loc = resolver.resolveLocale(request);
assertEquals(loc.getLanguage(), "nl"); assertEquals("nl", loc.getLanguage());
} }
@Test @Test
......
...@@ -68,7 +68,7 @@ public class LocaleResolverTests { ...@@ -68,7 +68,7 @@ public class LocaleResolverTests {
// check original locale // check original locale
Locale locale = localeResolver.resolveLocale(request); Locale locale = localeResolver.resolveLocale(request);
assertEquals(locale, Locale.UK); assertEquals(Locale.UK, locale);
// set new locale // set new locale
try { try {
localeResolver.setLocale(request, response, Locale.GERMANY); localeResolver.setLocale(request, response, Locale.GERMANY);
...@@ -76,7 +76,7 @@ public class LocaleResolverTests { ...@@ -76,7 +76,7 @@ public class LocaleResolverTests {
fail("should not be able to set Locale"); fail("should not be able to set Locale");
// check new locale // check new locale
locale = localeResolver.resolveLocale(request); locale = localeResolver.resolveLocale(request);
assertEquals(locale, Locale.GERMANY); assertEquals(Locale.GERMANY, locale);
} }
catch (UnsupportedOperationException ex) { catch (UnsupportedOperationException ex) {
if (shouldSet) { if (shouldSet) {
...@@ -89,10 +89,10 @@ public class LocaleResolverTests { ...@@ -89,10 +89,10 @@ public class LocaleResolverTests {
LocaleContextResolver localeContextResolver = (LocaleContextResolver) localeResolver; LocaleContextResolver localeContextResolver = (LocaleContextResolver) localeResolver;
LocaleContext localeContext = localeContextResolver.resolveLocaleContext(request); LocaleContext localeContext = localeContextResolver.resolveLocaleContext(request);
if (shouldSet) { if (shouldSet) {
assertEquals(localeContext.getLocale(), Locale.GERMANY); assertEquals(Locale.GERMANY, localeContext.getLocale());
} }
else { else {
assertEquals(localeContext.getLocale(), Locale.UK); assertEquals(Locale.UK, localeContext.getLocale());
} }
assertTrue(localeContext instanceof TimeZoneAwareLocaleContext); assertTrue(localeContext instanceof TimeZoneAwareLocaleContext);
assertNull(((TimeZoneAwareLocaleContext) localeContext).getTimeZone()); assertNull(((TimeZoneAwareLocaleContext) localeContext).getTimeZone());
...@@ -108,7 +108,7 @@ public class LocaleResolverTests { ...@@ -108,7 +108,7 @@ public class LocaleResolverTests {
fail("should not be able to set Locale"); fail("should not be able to set Locale");
} }
localeContext = localeContextResolver.resolveLocaleContext(request); localeContext = localeContextResolver.resolveLocaleContext(request);
assertEquals(localeContext.getLocale(), Locale.US); assertEquals(Locale.US, localeContext.getLocale());
if (localeContextResolver instanceof AbstractLocaleContextResolver) { if (localeContextResolver instanceof AbstractLocaleContextResolver) {
assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+1")); assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+1"));
} }
...@@ -119,20 +119,20 @@ public class LocaleResolverTests { ...@@ -119,20 +119,20 @@ public class LocaleResolverTests {
localeContextResolver.setLocaleContext(request, response, localeContextResolver.setLocaleContext(request, response,
new SimpleTimeZoneAwareLocaleContext(Locale.GERMANY, TimeZone.getTimeZone("GMT+2"))); new SimpleTimeZoneAwareLocaleContext(Locale.GERMANY, TimeZone.getTimeZone("GMT+2")));
localeContext = localeContextResolver.resolveLocaleContext(request); localeContext = localeContextResolver.resolveLocaleContext(request);
assertEquals(localeContext.getLocale(), Locale.GERMANY); assertEquals(Locale.GERMANY, localeContext.getLocale());
assertTrue(localeContext instanceof TimeZoneAwareLocaleContext); assertTrue(localeContext instanceof TimeZoneAwareLocaleContext);
assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+2")); assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+2"));
localeContextResolver.setLocaleContext(request, response, localeContextResolver.setLocaleContext(request, response,
new SimpleTimeZoneAwareLocaleContext(null, TimeZone.getTimeZone("GMT+3"))); new SimpleTimeZoneAwareLocaleContext(null, TimeZone.getTimeZone("GMT+3")));
localeContext = localeContextResolver.resolveLocaleContext(request); localeContext = localeContextResolver.resolveLocaleContext(request);
assertEquals(localeContext.getLocale(), Locale.UK); assertEquals(Locale.UK, localeContext.getLocale());
assertTrue(localeContext instanceof TimeZoneAwareLocaleContext); assertTrue(localeContext instanceof TimeZoneAwareLocaleContext);
assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+3")); assertEquals(((TimeZoneAwareLocaleContext) localeContext).getTimeZone(), TimeZone.getTimeZone("GMT+3"));
if (localeContextResolver instanceof AbstractLocaleContextResolver) { if (localeContextResolver instanceof AbstractLocaleContextResolver) {
((AbstractLocaleContextResolver) localeContextResolver).setDefaultLocale(Locale.GERMANY); ((AbstractLocaleContextResolver) localeContextResolver).setDefaultLocale(Locale.GERMANY);
assertEquals(localeContext.getLocale(), Locale.GERMANY); assertEquals(Locale.GERMANY, localeContext.getLocale());
} }
} }
catch (UnsupportedOperationException ex) { catch (UnsupportedOperationException ex) {
......
...@@ -195,7 +195,7 @@ public class BindTagTests extends AbstractTagTests { ...@@ -195,7 +195,7 @@ public class BindTagTests extends AbstractTagTests {
tag.doStartTag(); tag.doStartTag();
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE); BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
assertEquals("Error messages String should be 'message1'", assertEquals("Error messages String should be 'message1'",
status.getErrorMessagesAsString(","), "message1"); "message1", status.getErrorMessagesAsString(","));
// two errors // two errors
pc = createPageContext(); pc = createPageContext();
...@@ -209,7 +209,7 @@ public class BindTagTests extends AbstractTagTests { ...@@ -209,7 +209,7 @@ public class BindTagTests extends AbstractTagTests {
tag.doStartTag(); tag.doStartTag();
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE); status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
assertEquals("Error messages String should be 'message1,message2'", assertEquals("Error messages String should be 'message1,message2'",
status.getErrorMessagesAsString(","), "message1,message2"); "message1,message2", status.getErrorMessagesAsString(","));
// no errors // no errors
pc = createPageContext(); pc = createPageContext();
...@@ -220,7 +220,7 @@ public class BindTagTests extends AbstractTagTests { ...@@ -220,7 +220,7 @@ public class BindTagTests extends AbstractTagTests {
tag.setPath("tb"); tag.setPath("tb");
tag.doStartTag(); tag.doStartTag();
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE); status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
assertEquals("Error messages String should be ''", status.getErrorMessagesAsString(","), ""); assertEquals("Error messages String should be ''", "", status.getErrorMessagesAsString(","));
} }
@Test @Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册