final XRowSet rowSet = UnoRuntime.queryInterface( XRowSet.class, m_rowSet);
rowSet.execute();
m_connection = UnoRuntime.queryInterface( XConnection.class, rowSetProps.getPropertyValue("ActiveConnection") );
XResultSet xRes = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
xRes.first();
log.println( "creating a new environment for object" );
TestEnvironment tEnv = new TestEnvironment( (XInterface)m_rowSet );
// Adding obj relation for XRowSetApproveBroadcaster test
{
final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
final XResultSetUpdate resultSetUpdate = UnoRuntime.queryInterface( XResultSetUpdate.class, m_rowSet );
final XRowUpdate rowUpdate = UnoRuntime.queryInterface(XRowUpdate.class, m_rowSet );
final PrintWriter logF = log ;
tEnv.addObjRelation( "XRowSetApproveBroadcaster.ApproveChecker",
new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker()
{
public void moveCursor()
{
try
{
resultSet.beforeFirst();
resultSet.afterLast();
resultSet.first();
}
catch (com.sun.star.sdbc.SQLException e)
{
logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.moveCursor() :");
e.printStackTrace(logF);
throw new StatusException( "RowSetApproveChecker.moveCursor failed", e );
}
}
public RowChangeEvent changeRow()
{
try
{
resultSet.first();
rowUpdate.updateString(1, "ORowSetTest2");
resultSetUpdate.updateRow();
}
catch (com.sun.star.sdbc.SQLException e)
{
logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRow() :");
e.printStackTrace(logF);
throw new StatusException( "RowSetApproveChecker.changeRow failed", e );
}
RowChangeEvent ev = new RowChangeEvent();
ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE ;
ev.Rows = 1 ;
return ev ;
}
public void changeRowSet()
{
try
{
// since we gave the row set a parametrized statement, we need to ensure the
// parameter is actually filled, otherwise we would get an empty result set,
// which would imply some further tests failing
XParameters rowSetParams = UnoRuntime.queryInterface( XParameters.class, resultSet );
rowSetParams.setString( 1, "String2" );
rowSet.execute();
resultSet.first();
}
catch (com.sun.star.sdbc.SQLException e)
{
logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRowSet() :");
e.printStackTrace(logF);
throw new StatusException( "RowSetApproveChecker.changeRowSet failed", e );
}
}
}
);
}
// Adding relations for XRow as a Vector with all data
// of current row of RowSet.
Vector rowData = new Vector();
for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) {
rowData.add(DBTools.TST_TABLE_VALUES[0][i]);
}
// here XRef must be added
// here XBlob must be added
// here XClob must be added
// here XArray must be added
tEnv.addObjRelation("CurrentRowData", rowData);
// Adding relation for XColumnLocate ifc test
tEnv.addObjRelation( "XColumnLocate.ColumnName", DBTools.TST_STRING_F );
// Adding relation for XCompletedExecution
tEnv.addObjRelation( "InteractionHandlerChecker", new InteractionHandlerImpl() );
try
{
String sqlCommand = isMySQLDB
? "SELECT Column0 FROM soffice_test_table WHERE ( ( Column0 = :param1 ) )"
: "SELECT \"_TEXT\" FROM \"" + tableName + "\" WHERE ( ( \"_TEXT\" = :param1 ) )";
rowSetProps.setPropertyValue( "DataSourceName", dbSourceName );
rowSetProps.setPropertyValue( "Command", sqlCommand );
rowSetProps.setPropertyValue( "CommandType", new Integer(CommandType.COMMAND) );
}
catch(Exception e)
{
throw new StatusException( "setting up the RowSet with a parametrized command failed", e );
}
// Adding relation for XParameters ifc test
tEnv.addObjRelation( "XParameters.ParamValues", new Vector() );
// Adding relation for XRowUpdate
final XRow row = UnoRuntime.queryInterface( XRow.class, m_rowSet );
tEnv.addObjRelation("XRowUpdate.XRow", row);
// Adding relation for XResultSetUpdate
{
final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
final XRowUpdate rowUpdate = UnoRuntime.queryInterface( XRowUpdate.class, m_rowSet );
tEnv.addObjRelation("XResultSetUpdate.UpdateTester",
new ifc.sdbc._XResultSetUpdate.UpdateTester()
{
String lastUpdate = null ;
public int rowCount() throws SQLException
{
int prevPos = resultSet.getRow();
resultSet.last();
int count = resultSet.getRow();
resultSet.absolute(prevPos);
return count ;
}
public void update() throws SQLException
{
lastUpdate = row.getString(1);
lastUpdate += "_" ;
rowUpdate.updateString(1, lastUpdate);
}
public boolean wasUpdated() throws SQLException
{
String getStr = row.getString(1);
return lastUpdate.equals(getStr);
}
public int currentRow() throws SQLException
{
return resultSet.getRow();
}
}
);
}