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