提交 c27872f3 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not use deprecated constructors of wrapper types except for ClassUtils

上级 16b47879
...@@ -127,7 +127,7 @@ public class FunctionMultiReturn { ...@@ -127,7 +127,7 @@ public class FunctionMultiReturn {
public static Object[] polar2CartesianArray(Double r, Double alpha) { public static Object[] polar2CartesianArray(Double r, Double alpha) {
double x = r.doubleValue() * Math.cos(alpha.doubleValue()); double x = r.doubleValue() * Math.cos(alpha.doubleValue());
double y = r.doubleValue() * Math.sin(alpha.doubleValue()); double y = r.doubleValue() * Math.sin(alpha.doubleValue());
return new Object[]{new Double(x), new Double(y)}; return new Object[]{x, y};
} }
/** /**
......
...@@ -876,7 +876,7 @@ public class TestOptimizations extends TestBase { ...@@ -876,7 +876,7 @@ public class TestOptimizations extends TestBase {
case 5: case 5:
if (random.nextInt(1000) == 1) { if (random.nextInt(1000) == 1) {
stat.execute("insert into test values(" + i + ", null)"); stat.execute("insert into test values(" + i + ", null)");
map.put(new Integer(i), null); map.put(i, null);
} else { } else {
int value = random.nextInt(); int value = random.nextInt();
stat.execute("insert into test values(" + i + ", " + value + ")"); stat.execute("insert into test values(" + i + ", " + value + ")");
......
...@@ -74,13 +74,13 @@ public class SupportedTypes { ...@@ -74,13 +74,13 @@ public class SupportedTypes {
static SupportedTypes randomValue() { static SupportedTypes randomValue() {
Random rand = new Random(); Random rand = new Random();
SupportedTypes s = new SupportedTypes(); SupportedTypes s = new SupportedTypes();
s.myBool = Boolean.valueOf(rand.nextBoolean()); s.myBool = rand.nextBoolean();
s.myByte = new Byte((byte) rand.nextInt(Byte.MAX_VALUE)); s.myByte = (byte) rand.nextInt(Byte.MAX_VALUE);
s.myShort = new Short((short) rand.nextInt(Short.MAX_VALUE)); s.myShort = (short) rand.nextInt(Short.MAX_VALUE);
s.myInteger = new Integer(rand.nextInt()); s.myInteger = rand.nextInt();
s.myLong = new Long(rand.nextLong()); s.myLong = rand.nextLong();
s.myFloat = new Float(rand.nextFloat()); s.myFloat = rand.nextFloat();
s.myDouble = new Double(rand.nextDouble()); s.myDouble = rand.nextDouble();
s.myBigDecimal = new BigDecimal(rand.nextDouble()); s.myBigDecimal = new BigDecimal(rand.nextDouble());
s.myString = Long.toHexString(rand.nextLong()); s.myString = Long.toHexString(rand.nextLong());
s.myUtilDate = new java.util.Date(rand.nextLong()); s.myUtilDate = new java.util.Date(rand.nextLong());
......
...@@ -986,7 +986,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -986,7 +986,7 @@ public class TestPreparedStatement extends TestBase {
prep.setString(2, "-1"); prep.setString(2, "-1");
prep.executeUpdate(); prep.executeUpdate();
prep.setInt(1, 7); prep.setInt(1, 7);
prep.setObject(2, new Integer(3)); prep.setObject(2, 3);
prep.executeUpdate(); prep.executeUpdate();
prep.setObject(1, "8"); prep.setObject(1, "8");
// should throw an exception // should throw an exception
...@@ -1132,12 +1132,12 @@ public class TestPreparedStatement extends TestBase { ...@@ -1132,12 +1132,12 @@ public class TestPreparedStatement extends TestBase {
prep.setObject(1, Boolean.TRUE); prep.setObject(1, Boolean.TRUE);
prep.setObject(2, "Abc"); prep.setObject(2, "Abc");
prep.setObject(3, new BigDecimal("10.2")); prep.setObject(3, new BigDecimal("10.2"));
prep.setObject(4, new Byte((byte) 0xff)); prep.setObject(4, (byte) 0xff);
prep.setObject(5, new Short(Short.MAX_VALUE)); prep.setObject(5, Short.MAX_VALUE);
prep.setObject(6, new Integer(Integer.MIN_VALUE)); prep.setObject(6, Integer.MIN_VALUE);
prep.setObject(7, new Long(Long.MAX_VALUE)); prep.setObject(7, Long.MAX_VALUE);
prep.setObject(8, new Float(Float.MAX_VALUE)); prep.setObject(8, Float.MAX_VALUE);
prep.setObject(9, new Double(Double.MAX_VALUE)); prep.setObject(9, Double.MAX_VALUE);
prep.setObject(10, java.sql.Date.valueOf("2001-02-03")); prep.setObject(10, java.sql.Date.valueOf("2001-02-03"));
prep.setObject(11, java.sql.Time.valueOf("04:05:06")); prep.setObject(11, java.sql.Time.valueOf("04:05:06"));
prep.setObject(12, java.sql.Timestamp.valueOf( prep.setObject(12, java.sql.Timestamp.valueOf(
...@@ -1145,7 +1145,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -1145,7 +1145,7 @@ public class TestPreparedStatement extends TestBase {
prep.setObject(13, new java.util.Date(java.sql.Date.valueOf( prep.setObject(13, new java.util.Date(java.sql.Date.valueOf(
"2001-02-03").getTime())); "2001-02-03").getTime()));
prep.setObject(14, new byte[] { 10, 20, 30 }); prep.setObject(14, new byte[] { 10, 20, 30 });
prep.setObject(15, new Character('a'), Types.OTHER); prep.setObject(15, 'a', Types.OTHER);
prep.setObject(16, "2001-01-02", Types.DATE); prep.setObject(16, "2001-01-02", Types.DATE);
// converting to null seems strange... // converting to null seems strange...
prep.setObject(17, "2001-01-02", Types.NULL); prep.setObject(17, "2001-01-02", Types.NULL);
...@@ -1163,14 +1163,10 @@ public class TestPreparedStatement extends TestBase { ...@@ -1163,14 +1163,10 @@ public class TestPreparedStatement extends TestBase {
(Object) Byte.valueOf((byte) 0xff) : (Object) Integer.valueOf(-1))); (Object) Byte.valueOf((byte) 0xff) : (Object) Integer.valueOf(-1)));
assertTrue(rs.getObject(5).equals(SysProperties.OLD_RESULT_SET_GET_OBJECT ? assertTrue(rs.getObject(5).equals(SysProperties.OLD_RESULT_SET_GET_OBJECT ?
(Object) Short.valueOf(Short.MAX_VALUE) : (Object) Integer.valueOf(Short.MAX_VALUE))); (Object) Short.valueOf(Short.MAX_VALUE) : (Object) Integer.valueOf(Short.MAX_VALUE)));
assertTrue(rs.getObject(6).equals( assertTrue(rs.getObject(6).equals(Integer.MIN_VALUE));
new Integer(Integer.MIN_VALUE))); assertTrue(rs.getObject(7).equals(Long.MAX_VALUE));
assertTrue(rs.getObject(7).equals( assertTrue(rs.getObject(8).equals(Float.MAX_VALUE));
new Long(Long.MAX_VALUE))); assertTrue(rs.getObject(9).equals(Double.MAX_VALUE));
assertTrue(rs.getObject(8).equals(
new Float(Float.MAX_VALUE)));
assertTrue(rs.getObject(9).equals(
new Double(Double.MAX_VALUE)));
assertTrue(rs.getObject(10).equals( assertTrue(rs.getObject(10).equals(
java.sql.Date.valueOf("2001-02-03"))); java.sql.Date.valueOf("2001-02-03")));
assertEquals("04:05:06", rs.getObject(11).toString()); assertEquals("04:05:06", rs.getObject(11).toString());
...@@ -1185,8 +1181,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -1185,8 +1181,7 @@ public class TestPreparedStatement extends TestBase {
assertTrue(rs.getObject(16).equals( assertTrue(rs.getObject(16).equals(
java.sql.Date.valueOf("2001-01-02"))); java.sql.Date.valueOf("2001-01-02")));
assertTrue(rs.getObject(17) == null && rs.wasNull()); assertTrue(rs.getObject(17) == null && rs.wasNull());
assertTrue(rs.getObject(18).equals( assertTrue(rs.getObject(18).equals(3.725d));
new Double(3.725)));
assertTrue(rs.getObject(19).equals( assertTrue(rs.getObject(19).equals(
java.sql.Time.valueOf("23:22:21"))); java.sql.Time.valueOf("23:22:21")));
assertTrue(rs.getObject(20).equals( assertTrue(rs.getObject(20).equals(
......
...@@ -1205,19 +1205,19 @@ public class TestResultSet extends TestBase { ...@@ -1205,19 +1205,19 @@ public class TestResultSet extends TestBase {
o = rs.getObject(2); o = rs.getObject(2);
trace(o.getClass().getName()); trace(o.getClass().getName());
assertTrue(o instanceof Double); assertTrue(o instanceof Double);
assertTrue(((Double) o).compareTo(new Double("-1.00")) == 0); assertTrue(((Double) o).compareTo(-1d) == 0);
o = rs.getObject(2, Double.class); o = rs.getObject(2, Double.class);
trace(o.getClass().getName()); trace(o.getClass().getName());
assertTrue(o instanceof Double); assertTrue(o instanceof Double);
assertTrue(((Double) o).compareTo(new Double("-1.00")) == 0); assertTrue(((Double) o).compareTo(-1d) == 0);
o = rs.getObject(3); o = rs.getObject(3);
trace(o.getClass().getName()); trace(o.getClass().getName());
assertTrue(o instanceof Float); assertTrue(o instanceof Float);
assertTrue(((Float) o).compareTo(new Float("-1.00")) == 0); assertTrue(((Float) o).compareTo(-1f) == 0);
o = rs.getObject(3, Float.class); o = rs.getObject(3, Float.class);
trace(o.getClass().getName()); trace(o.getClass().getName());
assertTrue(o instanceof Float); assertTrue(o instanceof Float);
assertTrue(((Float) o).compareTo(new Float("-1.00")) == 0); assertTrue(((Float) o).compareTo(-1f) == 0);
rs.next(); rs.next();
assertTrue(rs.getInt(1) == 2); assertTrue(rs.getInt(1) == 2);
assertTrue(!rs.wasNull()); assertTrue(!rs.wasNull());
...@@ -1745,7 +1745,7 @@ public class TestResultSet extends TestBase { ...@@ -1745,7 +1745,7 @@ public class TestResultSet extends TestBase {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, VALUE ARRAY)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, VALUE ARRAY)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?)"); PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?)");
prep.setInt(1, 1); prep.setInt(1, 1);
prep.setObject(2, new Object[] { new Integer(1), new Integer(2) }); prep.setObject(2, new Object[] { 1, 2 });
prep.execute(); prep.execute();
prep.setInt(1, 2); prep.setInt(1, 2);
prep.setObject(2, new Object[] { 11, 12 }); prep.setObject(2, new Object[] { 11, 12 });
......
...@@ -440,7 +440,7 @@ public class TestCrashAPI extends TestBase implements Runnable { ...@@ -440,7 +440,7 @@ public class TestCrashAPI extends TestBase implements Runnable {
} else if (type == boolean.class) { } else if (type == boolean.class) {
return random.nextBoolean(); return random.nextBoolean();
} else if (type == double.class) { } else if (type == double.class) {
return new Double(random.getRandomDouble()); return random.getRandomDouble();
} else if (type == String.class) { } else if (type == String.class) {
if (random.getInt(10) == 0) { if (random.getInt(10) == 0) {
return null; return null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论