use of com.microsoft.sqlserver.testframework.DBResultSet in project mssql-jdbc by Microsoft.
the class BulkCopyColumnMappingTest method validateValuesRepetativeCM.
/**
* validate if same values are in both source and destination table taking into account 1 extra column in destination which should be a copy of
* first column of source.
*
* @param con
* @param sourceTable
* @param destinationTable
* @throws SQLException
*/
private void validateValuesRepetativeCM(DBConnection con, DBTable sourceTable, DBTable destinationTable) throws SQLException {
try (DBStatement srcStmt = con.createStatement();
DBStatement dstStmt = con.createStatement();
DBResultSet srcResultSet = srcStmt.executeQuery("SELECT * FROM " + sourceTable.getEscapedTableName() + ";");
DBResultSet dstResultSet = dstStmt.executeQuery("SELECT * FROM " + destinationTable.getEscapedTableName() + ";")) {
ResultSetMetaData sourceMeta = ((ResultSet) srcResultSet.product()).getMetaData();
int totalColumns = sourceMeta.getColumnCount();
// verify data from sourceType and resultSet
while (srcResultSet.next() && dstResultSet.next()) {
for (int i = 1; i <= totalColumns; i++) {
// TODO: check row and column count in both the tables
Object srcValue, dstValue;
srcValue = srcResultSet.getObject(i);
dstValue = dstResultSet.getObject(i);
ComparisonUtil.compareExpectedAndActual(sourceMeta.getColumnType(i), srcValue, dstValue);
// compare value of first column of source with extra column in destination
if (1 == i) {
Object srcValueFirstCol = srcResultSet.getObject(i);
Object dstValLastCol = dstResultSet.getObject(totalColumns + 1);
ComparisonUtil.compareExpectedAndActual(sourceMeta.getColumnType(i), srcValueFirstCol, dstValLastCol);
}
}
}
}
}
use of com.microsoft.sqlserver.testframework.DBResultSet in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtSserverCursorForwardOnly.
/**
* Create a statement TYPE_SS_SEVER_CURSOR_FORWARD_ONLY, CONCUR_READ_ONLY, executeQuery verify cursor by using next and verify data
*
* @throws SQLException
*/
@Test
public void testStmtSserverCursorForwardOnly() throws SQLException {
DBResultSetTypes rsType = DBResultSetTypes.TYPE_FORWARD_ONLY_CONCUR_READ_ONLY;
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(rsType.resultsetCursor, rsType.resultSetConcurrency);
DBResultSet rs = stmt.executeQuery(query)) {
// Verify resultset behavior
rs.next();
rs.verify(table1);
}
}
use of com.microsoft.sqlserver.testframework.DBResultSet in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtScrollInsensitiveReadOnly.
/**
* Create a statement, ResultSet.SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, executeQuery verify cursor by using next, afterlast and previous
* and verify data
*
* @throws SQLException
* @throws ClassNotFoundException
*/
@Test
public void testStmtScrollInsensitiveReadOnly() throws SQLException, ClassNotFoundException {
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_SCROLL_INSENSITIVE_CONCUR_READ_ONLY);
DBResultSet rs = stmt.selectAll(table1)) {
rs.next();
rs.verifyCurrentRow(table1);
rs.afterLast();
rs.previous();
rs.verifyCurrentRow(table1);
rs.verify(table1);
}
}
use of com.microsoft.sqlserver.testframework.DBResultSet in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtScrollSensitiveUpdatable.
/**
* Create a statement ResultSet.SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE, executeQuery verify cursor by using next and previous and verify
* data
*
* @throws SQLException
*/
@Test
public void testStmtScrollSensitiveUpdatable() throws SQLException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_SCROLL_SENSITIVE_CONCUR_UPDATABLE);
DBResultSet rs = stmt.executeQuery(query)) {
// Verify resultset behavior
rs.next();
rs.next();
rs.verifyCurrentRow(table1);
rs.absolute(3);
rs.verifyCurrentRow(table1);
rs.absolute(1);
rs.verify(table1);
}
}
use of com.microsoft.sqlserver.testframework.DBResultSet in project mssql-jdbc by Microsoft.
the class bvtTest method testStmtForwardOnlyUpdateable.
/**
* Create a statement ResultSet.Type_forward_only, ResultSet.CONCUR_UPDATABLE, executeQuery verify cursor by using next and previous and verify
* data
*
* @throws SQLException
*/
@Test
public void testStmtForwardOnlyUpdateable() throws SQLException {
String query = "SELECT * FROM " + table1.getEscapedTableName();
try (DBConnection conn = new DBConnection(connectionString);
DBStatement stmt = conn.createStatement(DBResultSetTypes.TYPE_FORWARD_ONLY_CONCUR_UPDATABLE);
DBResultSet rs = stmt.executeQuery(query)) {
rs.next();
// Verify resultset behavior
rs.next();
rs.verifyCurrentRow(table1);
rs.next();
rs.verifyCurrentRow(table1);
try {
rs.previous();
assertTrue(false, "Previous should have thrown an exception");
} catch (SQLException ex) {
// expected exception
}
rs.verify(table1);
}
}
Aggregations