use of util.StubArray in project jdk8u_jdk by JetBrains.
the class CommonCachedRowSetTests method createDataTypesRows.
/*
* Add rows to DATAYPES table
*/
protected void createDataTypesRows(RowSet crs) throws SQLException {
Integer aInteger = 100;
String aChar = "Oswald Cobblepot";
Long aLong = Long.MAX_VALUE;
Short aShort = Short.MAX_VALUE;
Double aDouble = Double.MAX_VALUE;
BigDecimal aBigDecimal = BigDecimal.ONE;
Boolean aBoolean = false;
Float aFloat = Float.MAX_VALUE;
Byte aByte = Byte.MAX_VALUE;
Date aDate = Date.valueOf(LocalDate.now());
Time aTime = Time.valueOf(LocalTime.now());
Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
Array aArray = new StubArray("INTEGER", new Object[1]);
Ref aRef = new SerialRef(new StubRef("INTEGER", query));
byte[] bytes = new byte[10];
crs.moveToInsertRow();
crs.updateInt(1, aInteger);
crs.updateString(2, aChar);
crs.updateString(3, aChar);
crs.updateLong(4, aLong);
crs.updateBoolean(5, aBoolean);
crs.updateShort(6, aShort);
crs.updateDouble(7, aDouble);
crs.updateBigDecimal(8, aBigDecimal);
crs.updateFloat(9, aFloat);
crs.updateByte(10, aByte);
crs.updateDate(11, aDate);
crs.updateTime(12, aTime);
crs.updateTimestamp(13, aTimeStamp);
crs.updateBytes(14, bytes);
crs.updateArray(15, aArray);
crs.updateRef(16, aRef);
crs.updateDouble(17, aDouble);
crs.insertRow();
crs.moveToCurrentRow();
}
use of util.StubArray in project jdk8u_jdk by JetBrains.
the class CommonCachedRowSetTests method commonCachedRowSetTest0040.
/*
* Validate that columnUpdated works with the various datatypes specifying
* the column index
*/
@Test(dataProvider = "rowsetUsingDataTypes")
public void commonCachedRowSetTest0040(CachedRowSet rs, JDBCType type) throws Exception {
rs.beforeFirst();
assertTrue(rs.next());
switch(type) {
case INTEGER:
assertFalse(rs.columnUpdated(1));
rs.updateInt(1, Integer.MIN_VALUE);
assertTrue(rs.columnUpdated(1));
break;
case CHAR:
assertFalse(rs.columnUpdated(2));
rs.updateString(2, "foo");
assertTrue(rs.columnUpdated(2));
break;
case VARCHAR:
assertFalse(rs.columnUpdated(3));
rs.updateString(3, "foo");
assertTrue(rs.columnUpdated(3));
break;
case BIGINT:
assertFalse(rs.columnUpdated(4));
rs.updateLong(4, Long.MIN_VALUE);
assertTrue(rs.columnUpdated(4));
break;
case BOOLEAN:
assertFalse(rs.columnUpdated(5));
rs.updateBoolean(5, false);
assertTrue(rs.columnUpdated(5));
break;
case SMALLINT:
assertFalse(rs.columnUpdated(6));
rs.updateShort(6, Short.MIN_VALUE);
assertTrue(rs.columnUpdated(6));
break;
case DOUBLE:
assertFalse(rs.columnUpdated(7));
rs.updateDouble(7, Double.MIN_VALUE);
assertTrue(rs.columnUpdated(7));
break;
case DECIMAL:
assertFalse(rs.columnUpdated(8));
rs.updateBigDecimal(8, BigDecimal.TEN);
assertTrue(rs.columnUpdated(8));
break;
case REAL:
assertFalse(rs.columnUpdated(9));
rs.updateFloat(9, Float.MIN_VALUE);
assertTrue(rs.columnUpdated(9));
break;
case TINYINT:
assertFalse(rs.columnUpdated(10));
rs.updateByte(10, Byte.MIN_VALUE);
assertTrue(rs.columnUpdated(10));
break;
case DATE:
assertFalse(rs.columnUpdated(11));
rs.updateDate(11, Date.valueOf(LocalDate.now()));
assertTrue(rs.columnUpdated(11));
break;
case TIME:
assertFalse(rs.columnUpdated(12));
rs.updateTime(12, Time.valueOf(LocalTime.now()));
assertTrue(rs.columnUpdated(12));
break;
case TIMESTAMP:
assertFalse(rs.columnUpdated(13));
rs.updateTimestamp(13, Timestamp.valueOf(LocalDateTime.now()));
assertTrue(rs.columnUpdated(13));
break;
case VARBINARY:
assertFalse(rs.columnUpdated(14));
rs.updateBytes(14, new byte[1]);
assertTrue(rs.columnUpdated(14));
break;
case ARRAY:
assertFalse(rs.columnUpdated(15));
rs.updateArray(15, new StubArray("VARCHAR", new Object[10]));
assertTrue(rs.columnUpdated(15));
break;
case REF:
assertFalse(rs.columnUpdated(16));
rs.updateRef(16, new StubRef("INTEGER", query));
assertTrue(rs.columnUpdated(16));
break;
case FLOAT:
assertFalse(rs.columnUpdated(17));
rs.updateDouble(17, Double.MIN_NORMAL);
assertTrue(rs.columnUpdated(17));
}
}
use of util.StubArray in project jdk8u_jdk by JetBrains.
the class CommonCachedRowSetTests method commonCachedRowSetTest0041.
/*
* Validate that columnUpdated works with the various datatypes specifying
* the column name
*/
@Test(dataProvider = "rowsetUsingDataTypes")
public void commonCachedRowSetTest0041(CachedRowSet rs, JDBCType type) throws Exception {
rs.beforeFirst();
assertTrue(rs.next());
switch(type) {
case INTEGER:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[0]));
rs.updateInt(DATATYPES_COLUMN_NAMES[0], Integer.MIN_VALUE);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[0]));
break;
case CHAR:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[1]));
rs.updateString(DATATYPES_COLUMN_NAMES[1], "foo");
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[1]));
break;
case VARCHAR:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[2]));
rs.updateString(DATATYPES_COLUMN_NAMES[2], "foo");
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[2]));
break;
case BIGINT:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[3]));
rs.updateLong(DATATYPES_COLUMN_NAMES[3], Long.MIN_VALUE);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[3]));
break;
case BOOLEAN:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[4]));
rs.updateBoolean(DATATYPES_COLUMN_NAMES[4], false);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[4]));
break;
case SMALLINT:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[5]));
rs.updateShort(DATATYPES_COLUMN_NAMES[5], Short.MIN_VALUE);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[5]));
break;
case DOUBLE:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[6]));
rs.updateDouble(DATATYPES_COLUMN_NAMES[6], Double.MIN_VALUE);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[6]));
break;
case DECIMAL:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[7]));
rs.updateBigDecimal(DATATYPES_COLUMN_NAMES[7], BigDecimal.TEN);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[7]));
break;
case REAL:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[8]));
rs.updateFloat(DATATYPES_COLUMN_NAMES[8], Float.MIN_VALUE);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[8]));
break;
case TINYINT:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[9]));
rs.updateByte(DATATYPES_COLUMN_NAMES[9], Byte.MIN_VALUE);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[9]));
break;
case DATE:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[10]));
rs.updateDate(DATATYPES_COLUMN_NAMES[10], Date.valueOf(LocalDate.now()));
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[10]));
break;
case TIME:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[11]));
rs.updateTime(DATATYPES_COLUMN_NAMES[11], Time.valueOf(LocalTime.now()));
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[11]));
break;
case TIMESTAMP:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[12]));
rs.updateTimestamp(DATATYPES_COLUMN_NAMES[12], Timestamp.valueOf(LocalDateTime.now()));
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[12]));
break;
case VARBINARY:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[13]));
rs.updateBytes(DATATYPES_COLUMN_NAMES[13], new byte[1]);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[13]));
break;
case ARRAY:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[14]));
rs.updateArray(DATATYPES_COLUMN_NAMES[14], new StubArray("VARCHAR", new Object[10]));
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[14]));
break;
case REF:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[15]));
rs.updateRef(DATATYPES_COLUMN_NAMES[15], new StubRef("INTEGER", query));
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[15]));
break;
case FLOAT:
assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[16]));
rs.updateDouble(DATATYPES_COLUMN_NAMES[16], Double.MIN_NORMAL);
assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[16]));
break;
}
}
use of util.StubArray in project jdk8u_jdk by JetBrains.
the class BaseRowSetTests method testAdvancedParameters.
/*
* DataProvider used to set advanced parameters for types that are supported
*/
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {
byte[] bytes = new byte[10];
Ref aRef = new SerialRef(new StubRef("INTEGER", query));
Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
Blob aBlob = new SerialBlob(new StubBlob());
Clob aClob = new SerialClob(new StubClob());
Reader rdr = new StringReader(query);
InputStream is = new StringBufferInputStream(query);
;
brs = new StubBaseRowSet();
brs.setBytes(1, bytes);
brs.setAsciiStream(2, is, query.length());
brs.setRef(3, aRef);
brs.setArray(4, aArray);
brs.setBlob(5, aBlob);
brs.setClob(6, aClob);
brs.setBinaryStream(7, is, query.length());
brs.setUnicodeStream(8, is, query.length());
brs.setCharacterStream(9, rdr, query.length());
return new Object[][] { { 1, bytes }, { 2, is }, { 3, aRef }, { 4, aArray }, { 5, aBlob }, { 6, aClob }, { 7, is }, { 8, is }, { 9, rdr } };
}
use of util.StubArray in project jdk8u_jdk by JetBrains.
the class SerialArrayTests method setUpMethod.
@BeforeMethod
public void setUpMethod() throws Exception {
coffees = new Object[] { "Espresso", "Colombian", "French Roast", "Cappuccino" };
a = new StubArray(sqlType, coffees);
map = new HashMap<>();
}
Aggregations