Polishing

This commit is contained in:
Juergen Hoeller 2013-12-17 18:21:04 +01:00
parent 479d073f1b
commit 74c679eb2f
2 changed files with 14 additions and 13 deletions

View File

@ -173,11 +173,11 @@ public class NamedParameterQueryTests {
parms.addValue("id", 3);
Object o = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID = :id",
parms, new RowMapper<Object>() {
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getInt(1);
}
});
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getInt(1);
}
});
assertTrue("Correct result type", o instanceof Integer);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID = ?");
@ -225,7 +225,7 @@ public class NamedParameterQueryTests {
given(resultSet.getInt(1)).willReturn(22);
MapSqlParameterSource parms = new MapSqlParameterSource();
parms.addValue("ids", Arrays.asList(new Object[] { 3, 4 }));
parms.addValue("ids", Arrays.asList(3, 4));
Object o = template.queryForObject(sql, parms, Integer.class);
assertTrue("Correct result type", o instanceof Integer);
@ -241,8 +241,8 @@ public class NamedParameterQueryTests {
MapSqlParameterSource parms = new MapSqlParameterSource();
List<Object[]> l1 = new ArrayList<Object[]>();
l1.add(new Object[] { 3, "Rod" });
l1.add(new Object[] { 4, "Juergen" });
l1.add(new Object[] {3, "Rod"});
l1.add(new Object[] {4, "Juergen"});
parms.addValue("multiExpressionList", l1);
Object o = template.queryForObject(
"SELECT AGE FROM CUSTMR WHERE (ID, NAME) IN (:multiExpressionList)",

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,11 +20,12 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import static org.junit.Assert.*;
/**
* @author Thomas Risberg
* @author Juergen Hoeller
@ -117,7 +118,7 @@ public class NamedParameterUtilsTests {
@Test(expected = InvalidDataAccessApiUsageException.class)
public void buildValueArrayWithMissingParameterValue() throws Exception {
String sql = "select count(0) from foo where id = :id";
NamedParameterUtils.buildValueArray(sql, new HashMap());
NamedParameterUtils.buildValueArray(sql, Collections.<String, Object>emptyMap());
}
@Test
@ -168,7 +169,7 @@ public class NamedParameterUtilsTests {
String sql4 = "/*+ HINT */ xxx /* comment :a ? */ :a yyyy :b :c :a zzzzz /* :xx XX*";
ParsedSql psql4 = NamedParameterUtils.parseSqlStatement(sql4);
Map parameters = Collections.singletonMap("a", "0");
Map<String, String> parameters = Collections.singletonMap("a", "0");
assertEquals("/*+ HINT */ xxx /* comment :a ? */ ? yyyy ? ? ? zzzzz /* :xx XX*",
NamedParameterUtils.substituteNamedParameters(psql4, new MapSqlParameterSource(parameters)));
}
@ -235,7 +236,6 @@ public class NamedParameterUtilsTests {
assertEquals(0, parsedSql2.getParameterNames().size());
String finalSql2 = NamedParameterUtils.substituteNamedParameters(parsedSql2, null);
assertEquals(expectedSql2, finalSql2);
}
/*
@ -294,4 +294,5 @@ public class NamedParameterUtilsTests {
assertEquals(1, psql2.getTotalParameterCount());
assertEquals("xxx", psql2.getParameterNames().get(0));
}
}