summaryrefslogtreecommitdiff
path: root/dbaccess/qa/complex/dbaccess
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/qa/complex/dbaccess')
-rw-r--r--dbaccess/qa/complex/dbaccess/ApplicationController.java19
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java10
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMDatabase.java239
-rw-r--r--dbaccess/qa/complex/dbaccess/DataSource.java3
-rw-r--r--dbaccess/qa/complex/dbaccess/Query.java15
-rw-r--r--dbaccess/qa/complex/dbaccess/RowSet.java82
-rw-r--r--dbaccess/qa/complex/dbaccess/TestCase.java19
-rw-r--r--dbaccess/qa/complex/dbaccess/UISettings.java111
8 files changed, 142 insertions, 356 deletions
diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java
index df4aaa2f5cf9..5b2dd1e0e613 100644
--- a/dbaccess/qa/complex/dbaccess/ApplicationController.java
+++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java
@@ -107,16 +107,16 @@ public class ApplicationController extends TestCase
// load it into a frame
final Object object = getORB().createInstance("com.sun.star.frame.Desktop");
- final XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, object);
+ final XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, object);
final XComponent loadedComponent = xComponentLoader.loadComponentFromURL(m_database.getDocumentURL(), "_blank", FrameSearchFlag.ALL, new PropertyValue[0]);
assure("too many document instances!",
UnoRuntime.areSame(loadedComponent, m_databaseDocument));
// get the controller, which provides access to various UI operations
- final XModel docModel = (XModel) UnoRuntime.queryInterface(XModel.class,
+ final XModel docModel = UnoRuntime.queryInterface(XModel.class,
loadedComponent);
- m_documentUI = (XDatabaseDocumentUI) UnoRuntime.queryInterface(XDatabaseDocumentUI.class,
+ m_documentUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class,
docModel.getCurrentController());
}
@@ -144,11 +144,8 @@ public class ApplicationController extends TestCase
final String newDocumentURL = createTempFileURL();
// store the doc in a new location
- final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
- m_databaseDocument);
- storeDoc.storeAsURL(newDocumentURL, new PropertyValue[]
- {
- });
+ final XStorable storeDoc = UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
+ storeDoc.storeAsURL( newDocumentURL, new PropertyValue[] { } );
// connect
m_documentUI.connect();
@@ -166,8 +163,7 @@ public class ApplicationController extends TestCase
impl_switchToDocument(oldDocumentURL);
m_documentUI.connect();
assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
- XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class,
- m_documentUI.getActiveConnection());
+ XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_documentUI.getActiveConnection() );
XNameAccess tables = suppTables.getTables();
assure("the table was created in the wrong database", !tables.hasByName("abc"));
@@ -176,8 +172,7 @@ public class ApplicationController extends TestCase
m_documentUI.connect();
assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
- suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class,
- m_documentUI.getActiveConnection());
+ suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_documentUI.getActiveConnection() );
tables = suppTables.getTables();
assure("the newly created table has not been written", tables.hasByName("abc"));
}
diff --git a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
index eccb48647bae..b7c1ea987968 100644
--- a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
+++ b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
@@ -32,6 +32,7 @@ package complex.dbaccess;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XSingleSelectQueryComposer;
import com.sun.star.uno.UnoRuntime;
+import connectivity.tools.CRMDatabase;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -44,7 +45,7 @@ public abstract class CRMBasedTestCase extends TestCase
{
try
{
- m_database = new CRMDatabase( getORB() );
+ m_database = new CRMDatabase( getORB(), false );
}
catch ( Exception e )
{
@@ -67,7 +68,7 @@ public abstract class CRMBasedTestCase extends TestCase
try
{
if ( m_database != null )
- m_database.close();
+ m_database.saveAndClose();
}
catch ( Exception ex )
{
@@ -80,9 +81,6 @@ public abstract class CRMBasedTestCase extends TestCase
*/
protected final XSingleSelectQueryComposer createQueryComposer() throws com.sun.star.uno.Exception
{
- final XMultiServiceFactory connectionFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
- XMultiServiceFactory.class, m_database.getConnection() );
- return (XSingleSelectQueryComposer)UnoRuntime.queryInterface(
- XSingleSelectQueryComposer.class, connectionFactory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
+ return m_database.getConnection().createSingleSelectQueryComposer();
}
}
diff --git a/dbaccess/qa/complex/dbaccess/CRMDatabase.java b/dbaccess/qa/complex/dbaccess/CRMDatabase.java
deleted file mode 100644
index 77e2dcf6b2e2..000000000000
--- a/dbaccess/qa/complex/dbaccess/CRMDatabase.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: CRMDatabase.java,v $
- * $Revision: 1.6.2.1 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-package complex.dbaccess;
-
-import com.sun.star.container.ElementExistException;
-import com.sun.star.io.IOException;
-import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.sdb.XSingleSelectQueryComposer;
-import com.sun.star.sdbc.SQLException;
-import com.sun.star.sdbc.XConnection;
-import com.sun.star.sdbcx.XTablesSupplier;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XRefreshable;
-import connectivity.tools.DataSource;
-import connectivity.tools.HsqlColumnDescriptor;
-import connectivity.tools.HsqlDatabase;
-import connectivity.tools.HsqlTableDescriptor;
-import connectivity.tools.QueryDefinition;
-
-/** implements a small Customer Relationship Management database
- *
- * Not finished, by far. Feel free to add features as you need them.
- */
-public class CRMDatabase
-{
- private static final String INTEGER = "INTEGER";
- private static final String VARCHAR50 = "VARCHAR(50)";
- private final XMultiServiceFactory m_orb;
- private final HsqlDatabase m_database;
- private final DataSource m_dataSource;
- private final XConnection m_connection;
-
- /** constructs the CRM database
- */
- public CRMDatabase( XMultiServiceFactory _orb ) throws Exception
- {
- m_orb = _orb;
-
- m_database = new HsqlDatabase( m_orb );
- m_dataSource = m_database.getDataSource();
- m_connection = m_database.defaultConnection();
- createTables();
- createQueries();
- }
-
- // --------------------------------------------------------------------------------------------------------
- /** returns the database document underlying the CRM database
- */
- public final HsqlDatabase getDatabase()
- {
- return m_database;
- }
-
- // --------------------------------------------------------------------------------------------------------
- /** returns the default connection to the database
- */
- public final XConnection getConnection()
- {
- return m_connection;
- }
-
- // --------------------------------------------------------------------------------------------------------
- public void close() throws SQLException, IOException
- {
- m_database.store();
- m_database.close();
- }
-
- // --------------------------------------------------------------------------------------------------------
- private void createTables() throws SQLException
- {
- HsqlTableDescriptor table = new HsqlTableDescriptor( "categories",
- new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
- new HsqlColumnDescriptor( "Name",VARCHAR50),
- new HsqlColumnDescriptor( "Description", "VARCHAR(1024)" ),
- new HsqlColumnDescriptor( "Image", "LONGVARBINARY" ) } );
- m_database.createTable( table, true );
-
- m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 1, 'Food' )" );
- m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 2, 'Furniture' )" );
-
- table = new HsqlTableDescriptor( "products",
- new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
- new HsqlColumnDescriptor( "Name",VARCHAR50),
- new HsqlColumnDescriptor( "CategoryID",INTEGER, HsqlColumnDescriptor.REQUIRED, "categories", "ID" ) } );
- m_database.createTable( table, true );
-
- m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 1, 'Oranges', 1 )" );
- m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 2, 'Apples', 1 )" );
- m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 3, 'Pears', 1 )" );
- m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 4, 'Strawberries', 1 )" );
-
- table = new HsqlTableDescriptor( "customers",
- new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
- new HsqlColumnDescriptor( "Name",VARCHAR50),
- new HsqlColumnDescriptor( "Address",VARCHAR50),
- new HsqlColumnDescriptor( "City",VARCHAR50),
- new HsqlColumnDescriptor( "Postal",VARCHAR50),
- new HsqlColumnDescriptor( "Comment","LONGVARCHAR")} );
- m_database.createTable( table, true );
-
- m_database.executeSQL( "INSERT INTO \"customers\" VALUES(1,'Food, Inc.','Down Under','Melbourne','509','Prefered') " );
- m_database.executeSQL( "INSERT INTO \"customers\" VALUES(2,'Simply Delicious','Down Under','Melbourne','518',null) " );
- m_database.executeSQL( "INSERT INTO \"customers\" VALUES(3,'Pure Health','10 Fish St.','San Francisco','94107',null) " );
- m_database.executeSQL( "INSERT INTO \"customers\" VALUES(4,'Milk And More','Arlington Road 21','Dublin','31021','Good one.') " );
-
- table = new HsqlTableDescriptor( "orders",
- new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ),
- new HsqlColumnDescriptor( "CustomerID",INTEGER, HsqlColumnDescriptor.REQUIRED, "customers", "ID" ),
- new HsqlColumnDescriptor( "OrderDate", "DATE" ),
- new HsqlColumnDescriptor( "ShipDate", "DATE" ) } );
- m_database.createTable( table, true );
-
- m_database.executeSQL( "INSERT INTO \"orders\" (\"ID\", \"CustomerID\", \"OrderDate\") VALUES(1, 1, {D '2009-01-01'})" );
- m_database.executeSQL( "INSERT INTO \"orders\" VALUES(2, 2, {D '2009-01-01'}, {D '2009-01-23'})" );
-
- table = new HsqlTableDescriptor( "orders_details",
- new HsqlColumnDescriptor[] {
- new HsqlColumnDescriptor( "OrderID",INTEGER, HsqlColumnDescriptor.PRIMARY, "orders", "ID" ),
- new HsqlColumnDescriptor( "ProductID",INTEGER, HsqlColumnDescriptor.PRIMARY, "products", "ID" ),
- new HsqlColumnDescriptor( "Quantity",INTEGER) } );
- m_database.createTable( table, true );
-
- m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 1, 100)" );
- m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 2, 100)" );
- m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 2, 2000)" );
- m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 3, 2000)" );
- m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 4, 2000)" );
-
- // since we created the tables by directly executing the SQL statements, we need to refresh
- // the tables container
- final XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface(
- XTablesSupplier.class, m_connection );
- final XRefreshable refreshTables = (XRefreshable)UnoRuntime.queryInterface(
- XRefreshable.class, suppTables.getTables() );
- refreshTables.refresh();
- }
-
- // --------------------------------------------------------------------------------------------------------
- private void validateUnparseable()
- {
- // The "unparseable" query should be indeed be unparseable by OOo (though a valid HSQL query)
- XSingleSelectQueryComposer composer;
- QueryDefinition unparseableQuery;
- try
- {
- final XMultiServiceFactory factory = (XMultiServiceFactory)UnoRuntime.queryInterface(
- XMultiServiceFactory.class, m_database.defaultConnection() );
- composer = (XSingleSelectQueryComposer)UnoRuntime.queryInterface(
- XSingleSelectQueryComposer.class, factory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) );
- unparseableQuery = m_dataSource.getQueryDefinition( "unparseable" );
- }
- catch( Exception e )
- {
- throw new RuntimeException( "caught an unexpected exception: " + e.getMessage() );
- }
-
- boolean caughtExpected = false;
- try
- {
- composer.setQuery( unparseableQuery.getCommand() );
- }
- catch (WrappedTargetException e) { }
- catch( SQLException e )
- {
- caughtExpected = true;
- }
-
- if ( !caughtExpected )
- throw new RuntimeException( "Somebody improved the parser! This is bad :), since we need an unparsable query here!" );
- }
-
- // --------------------------------------------------------------------------------------------------------
- private void createQueries() throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException
- {
- m_database.getDataSource().createQuery(
- "all orders",
- "SELECT \"orders\".\"ID\" AS \"Order No.\", " +
- "\"customers\".\"Name\" AS \"Customer Name\", " +
- "\"orders\".\"OrderDate\" AS \"Order Date\", " +
- "\"orders\".\"ShipDate\" AS \"Ship Date\", " +
- "\"orders_details\".\"Quantity\", " +
- "\"products\".\"Name\" AS \"Product Name\" " +
- "FROM \"orders_details\" AS \"orders_details\", " +
- "\"orders\" AS \"orders\", " +
- "\"products\" AS \"products\", " +
- "\"customers\" AS \"customers\" " +
- "WHERE ( \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " +
- "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " +
- "AND \"orders\".\"CustomerID\" = \"customers\".\"ID\" )"
- );
-
- m_database.getDataSource().createQuery(
- "unshipped orders",
- "SELECT * " +
- "FROM \"all orders\"" +
- "WHERE ( \"ShipDate\" IS NULL )"
- );
-
- m_database.getDataSource().createQuery( "parseable", "SELECT * FROM \"customers\"" );
- m_database.getDataSource().createQuery( "parseable native", "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_VIEWS", false );
- m_database.getDataSource().createQuery( "unparseable",
- "SELECT CAST( \"ID\" AS VARCHAR(3) ) AS \"ID_VARCHAR\" FROM \"products\"", false );
-
- validateUnparseable();
- }
-}
diff --git a/dbaccess/qa/complex/dbaccess/DataSource.java b/dbaccess/qa/complex/dbaccess/DataSource.java
index 29c9d2f2cdd7..6cb0b7ee4b17 100644
--- a/dbaccess/qa/complex/dbaccess/DataSource.java
+++ b/dbaccess/qa/complex/dbaccess/DataSource.java
@@ -34,6 +34,7 @@ import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XNamingService;
import complexlib.ComplexTestCase;
+import connectivity.tools.CRMDatabase;
import connectivity.tools.HsqlDatabase;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -66,7 +67,7 @@ public class DataSource extends ComplexTestCase
{
if (m_database == null)
{
- final CRMDatabase database = new CRMDatabase(getFactory());
+ final CRMDatabase database = new CRMDatabase( getFactory(), false );
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
diff --git a/dbaccess/qa/complex/dbaccess/Query.java b/dbaccess/qa/complex/dbaccess/Query.java
index 684df2b65a25..f39c37a8fbdb 100644
--- a/dbaccess/qa/complex/dbaccess/Query.java
+++ b/dbaccess/qa/complex/dbaccess/Query.java
@@ -37,6 +37,7 @@ import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XQueriesSupplier;
import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.uno.UnoRuntime;
+import connectivity.tools.CRMDatabase;
public class Query extends complexlib.ComplexTestCase {
@@ -62,7 +63,7 @@ public class Query extends complexlib.ComplexTestCase {
{
if ( m_database == null )
{
- final CRMDatabase database = new CRMDatabase( getFactory() );
+ final CRMDatabase database = new CRMDatabase( getFactory(), false );
m_database = database.getDatabase();
}
}
@@ -87,8 +88,8 @@ public class Query extends complexlib.ComplexTestCase {
try
{
- final XQueriesSupplier suppQueries = (XQueriesSupplier)UnoRuntime.queryInterface(
- XQueriesSupplier.class, m_database.defaultConnection());
+ final XQueriesSupplier suppQueries = UnoRuntime.queryInterface(
+ XQueriesSupplier.class, m_database.defaultConnection().getXConnection() );
final XNameAccess queries = suppQueries.getQueries();
final String[] queryNames = new String[] { "parseable", "parseable native", "unparseable" };
@@ -100,12 +101,12 @@ public class Query extends complexlib.ComplexTestCase {
for ( int i = 0; i < queryNames.length; ++i )
{
- final XPropertySet query = (XPropertySet)UnoRuntime.queryInterface(
+ final XPropertySet query = UnoRuntime.queryInterface(
XPropertySet.class, queries.getByName( queryNames[i] ) );
- final XColumnsSupplier suppCols = (XColumnsSupplier)UnoRuntime.queryInterface(
+ final XColumnsSupplier suppCols = UnoRuntime.queryInterface(
XColumnsSupplier.class, query);
- final XIndexAccess columns = (XIndexAccess)UnoRuntime.queryInterface(
+ final XIndexAccess columns = UnoRuntime.queryInterface(
XIndexAccess.class, suppCols.getColumns());
// check whether the columns supplied by the query match what we expected
@@ -113,7 +114,7 @@ public class Query extends complexlib.ComplexTestCase {
columns.getCount() == expectedColumnNames[i].length );
for ( int col = 0; col < columns.getCount(); ++col )
{
- final XNamed columnName = (XNamed)UnoRuntime.queryInterface(
+ final XNamed columnName = UnoRuntime.queryInterface(
XNamed.class, columns.getByIndex(col) );
assure( "column no. " + col + " of query \"" + queryNames[i] + "\" not matching",
columnName.getName().equals( expectedColumnNames[i][col] ) );
diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java
index d9145d7aaee8..6a2b4e49c25a 100644
--- a/dbaccess/qa/complex/dbaccess/RowSet.java
+++ b/dbaccess/qa/complex/dbaccess/RowSet.java
@@ -41,7 +41,6 @@ import com.sun.star.sdb.XParametersSupplier;
import com.sun.star.sdb.XResultSetAccess;
import com.sun.star.sdb.XRowSetApproveBroadcaster;
import com.sun.star.sdbc.SQLException;
-import com.sun.star.sdbc.XConnection;
import com.sun.star.sdbc.XParameters;
import com.sun.star.sdbc.XPreparedStatement;
import com.sun.star.sdbc.XResultSet;
@@ -52,12 +51,12 @@ import com.sun.star.sdbc.XRowUpdate;
import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.sdbcx.XDeleteRows;
import com.sun.star.sdbcx.XRowLocate;
-import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.util.XRefreshable;
import complexlib.ComplexTestCase;
+import connectivity.tools.CRMDatabase;
import connectivity.tools.DataSource;
import connectivity.tools.HsqlDatabase;
+import connectivity.tools.sdb.Connection;
import java.lang.reflect.Method;
import java.util.Random;
@@ -89,7 +88,7 @@ public class RowSet extends ComplexTestCase
public ResultSetMovementStress(XResultSet _resultSet, int _id) throws java.lang.Exception
{
m_resultSet = _resultSet;
- m_row = (XRow) UnoRuntime.queryInterface(XRow.class, m_resultSet);
+ m_row = UnoRuntime.queryInterface( XRow.class, m_resultSet );
m_id = _id;
}
@@ -144,7 +143,7 @@ public class RowSet extends ComplexTestCase
{
try
{
- final CRMDatabase database = new CRMDatabase(getFactory());
+ final CRMDatabase database = new CRMDatabase( getFactory(), false );
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
@@ -204,23 +203,22 @@ public class RowSet extends ComplexTestCase
{
try
{
- m_rowSet = (XRowSet) UnoRuntime.queryInterface(XRowSet.class,
- getFactory().createInstance("com.sun.star.sdb.RowSet"));
- final XPropertySet rowSetProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_rowSet);
+ m_rowSet = UnoRuntime.queryInterface( XRowSet.class, getFactory().createInstance( "com.sun.star.sdb.RowSet" ) );
+ final XPropertySet rowSetProperties = UnoRuntime.queryInterface( XPropertySet.class, m_rowSet );
rowSetProperties.setPropertyValue("Command", command);
rowSetProperties.setPropertyValue("CommandType", Integer.valueOf(commandType));
- rowSetProperties.setPropertyValue("ActiveConnection", m_database.defaultConnection());
+ rowSetProperties.setPropertyValue("ActiveConnection", m_database.defaultConnection().getXConnection());
if (limitFetchSize)
{
rowSetProperties.setPropertyValue("FetchSize", Integer.valueOf(MAX_FETCH_ROWS));
}
- m_resultSet = (XResultSet) UnoRuntime.queryInterface(XResultSet.class, m_rowSet);
- m_resultSetUpdate = (XResultSetUpdate) UnoRuntime.queryInterface(XResultSetUpdate.class, m_rowSet);
- m_row = (XRow) UnoRuntime.queryInterface(XRow.class, m_rowSet);
- m_rowLocate = (XRowLocate) UnoRuntime.queryInterface(XRowLocate.class, m_resultSet);
- m_rowSetProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, m_rowSet);
- m_paramsSupplier = (XParametersSupplier) UnoRuntime.queryInterface(XParametersSupplier.class, m_rowSet);
+ m_resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
+ m_resultSetUpdate = UnoRuntime.queryInterface( XResultSetUpdate.class, m_rowSet );
+ m_row = UnoRuntime.queryInterface( XRow.class, m_rowSet );
+ m_rowLocate = UnoRuntime.queryInterface( XRowLocate.class, m_resultSet );
+ m_rowSetProperties = UnoRuntime.queryInterface( XPropertySet.class, m_rowSet );
+ m_paramsSupplier = UnoRuntime.queryInterface( XParametersSupplier.class, m_rowSet );
if (execute)
{
@@ -259,7 +257,7 @@ public class RowSet extends ComplexTestCase
// --------------------------------------------------------------------------------------------------------
XResultSet createClone() throws SQLException
{
- final XResultSetAccess rowAcc = (XResultSetAccess) UnoRuntime.queryInterface(XResultSetAccess.class, m_rowSet);
+ final XResultSetAccess rowAcc = UnoRuntime.queryInterface( XResultSetAccess.class, m_rowSet );
return rowAcc.createResultSet();
}
@@ -269,9 +267,9 @@ public class RowSet extends ComplexTestCase
m_database.executeSQL("DROP TABLE \"TEST1\" IF EXISTS");
m_database.executeSQL("CREATE TABLE \"TEST1\" (\"ID\" integer not null primary key, \"col2\" varchar(50) )");
- final XConnection connection = m_database.defaultConnection();
+ final Connection connection = m_database.defaultConnection();
final XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
- final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, prep);
+ final XParameters para = UnoRuntime.queryInterface( XParameters.class, prep );
for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
{
para.setInt(1, i);
@@ -279,9 +277,7 @@ public class RowSet extends ComplexTestCase
prep.executeUpdate();
}
- final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection);
- final XRefreshable refresh = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, suppTables.getTables());
- refresh.refresh();
+ connection.refreshTables();
}
// --------------------------------------------------------------------------------------------------------
@@ -335,8 +331,8 @@ public class RowSet extends ComplexTestCase
{
try
{
- final XRow _row = (XRow) UnoRuntime.queryInterface(XRow.class, _resultSet);
- final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ final XRow _row = UnoRuntime.queryInterface( XRow.class, _resultSet );
+ final XRow cloneRow = UnoRuntime.queryInterface( XRow.class, clone );
for (int i = 1; i <= MAX_FETCH_ROWS; ++i)
{
final int calcPos = (MAX_TABLE_ROWS % i) + 1;
@@ -359,14 +355,14 @@ public class RowSet extends ComplexTestCase
{
try
{
- final XRow _row = (XRow) UnoRuntime.queryInterface(XRow.class, _resultSet);
+ final XRow _row = UnoRuntime.queryInterface( XRow.class, _resultSet );
_resultSet.beforeFirst();
for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
{
_resultSet.next();
final XResultSet clone = createClone();
- final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ final XRow cloneRow = UnoRuntime.queryInterface( XRow.class, clone );
final int calcPos = MAX_TABLE_ROWS - 1;
if (calcPos != 0 && clone.absolute(calcPos))
{
@@ -420,15 +416,15 @@ public class RowSet extends ComplexTestCase
// first we create our RowSet object
final RowSetEventListener pRow = new RowSetEventListener();
- final XColumnsSupplier colSup = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, m_rowSet);
- final XPropertySet col = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, colSup.getColumns().getByName("ID"));
+ final XColumnsSupplier colSup = UnoRuntime.queryInterface( XColumnsSupplier.class, m_rowSet );
+ final XPropertySet col = UnoRuntime.queryInterface( XPropertySet.class, colSup.getColumns().getByName( "ID" ) );
col.addPropertyChangeListener("Value", pRow);
m_rowSetProperties.addPropertyChangeListener("IsModified", pRow);
m_rowSetProperties.addPropertyChangeListener("IsNew", pRow);
m_rowSetProperties.addPropertyChangeListener("IsRowCountFinal", pRow);
m_rowSetProperties.addPropertyChangeListener("RowCount", pRow);
- final XRowSetApproveBroadcaster xApBroad = (XRowSetApproveBroadcaster) UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class, m_resultSet);
+ final XRowSetApproveBroadcaster xApBroad = UnoRuntime.queryInterface( XRowSetApproveBroadcaster.class, m_resultSet );
xApBroad.addRowSetApproveListener(pRow);
m_rowSet.addRowSetListener(pRow);
@@ -458,13 +454,13 @@ public class RowSet extends ComplexTestCase
testCursorMove(m_resultSet, cResSet.getMethod("previous", (Class[]) null), pRow, moves, null);
testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_MODIFIED] = true;
- final XRowUpdate updRow = (XRowUpdate) UnoRuntime.queryInterface(XRowUpdate.class, m_resultSet);
+ final XRowUpdate updRow = UnoRuntime.queryInterface( XRowUpdate.class, m_resultSet );
updRow.updateString(2, TEST21);
testCursorMove(m_resultSet, cResSet.getMethod(NEXT, (Class[]) null), pRow, moves, null);
moves[RowSetEventListener.IS_MODIFIED] = false;
final Class cupd = Class.forName("com.sun.star.sdbc.XResultSetUpdate");
- final XResultSetUpdate upd = (XResultSetUpdate) UnoRuntime.queryInterface(XResultSetUpdate.class, m_resultSet);
+ final XResultSetUpdate upd = UnoRuntime.queryInterface( XResultSetUpdate.class, m_resultSet );
testCursorMove(upd, cupd.getMethod("moveToInsertRow", (Class[]) null), pRow, moves, null);
updRow.updateInt(1, MAX_TABLE_ROWS + 2);
@@ -536,7 +532,7 @@ public class RowSet extends ComplexTestCase
moves[RowSetEventListener.ROW_COUNT] = true;
final Class cdelRows = Class.forName("com.sun.star.sdbcx.XDeleteRows");
ctemp[0] = Object[].class;
- final XDeleteRows delRows = (XDeleteRows) UnoRuntime.queryInterface(XDeleteRows.class, m_resultSet);
+ final XDeleteRows delRows = UnoRuntime.queryInterface( XDeleteRows.class, m_resultSet );
final Object bookmarks[] = new Object[5];
m_resultSet.first();
for (int i = 0; i < bookmarks.length; ++i)
@@ -549,7 +545,7 @@ public class RowSet extends ComplexTestCase
testCursorMove(delRows, cdelRows.getMethod("deleteRows", ctemp), pRow, moves, temp);
// now destroy the RowSet
- final XComponent xComp = (XComponent) UnoRuntime.queryInterface(XComponent.class, m_resultSet);
+ final XComponent xComp = UnoRuntime.queryInterface( XComponent.class, m_resultSet );
xComp.dispose();
}
@@ -715,7 +711,7 @@ public class RowSet extends ComplexTestCase
positionRandom();
final Object deleteBookmark = m_rowLocate.getBookmark();
m_resultSetUpdate.deleteRow();
- final XDeleteRows multiDelete = (XDeleteRows) UnoRuntime.queryInterface(XDeleteRows.class, m_resultSet);
+ final XDeleteRows multiDelete = UnoRuntime.queryInterface( XDeleteRows.class, m_resultSet );
final int[] deleteSuccess = multiDelete.deleteRows(new Object[]
{
firstBookmark, deleteBookmark
@@ -745,7 +741,7 @@ public class RowSet extends ComplexTestCase
// .....................................................................................................
// updating values in a deleted row should fail
deleteRandom();
- final XRowUpdate rowUpdated = (XRowUpdate) UnoRuntime.queryInterface(XRowUpdate.class, m_resultSet);
+ final XRowUpdate rowUpdated = UnoRuntime.queryInterface( XRowUpdate.class, m_resultSet );
caughtException = false;
try
{
@@ -762,6 +758,7 @@ public class RowSet extends ComplexTestCase
/** checks whether deletions on the main RowSet properly interfere (or don't interfere) with the movement
* on a clone of the RowSet
*/
+ @SuppressWarnings("empty-statement")
public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException
{
createTestCase(true);
@@ -769,7 +766,7 @@ public class RowSet extends ComplexTestCase
m_resultSet.last();
final XResultSet clone = createClone();
- final XRowLocate cloneRowLocate = (XRowLocate) UnoRuntime.queryInterface(XRowLocate.class, clone);
+ final XRowLocate cloneRowLocate = UnoRuntime.queryInterface( XRowLocate.class, clone );
positionRandom();
@@ -837,7 +834,7 @@ public class RowSet extends ComplexTestCase
m_rowSetProperties.setPropertyValue("FetchSize", Integer.valueOf(10));
final XResultSet clone = createClone();
- final XRow cloneRow = (XRow) UnoRuntime.queryInterface(XRow.class, clone);
+ final XRow cloneRow = UnoRuntime.queryInterface( XRow.class, clone );
// .....................................................................................................
// first check the basic scenario without the |moveToInsertRow| |moveToCurrentRow|, to ensure that
@@ -893,8 +890,7 @@ public class RowSet extends ComplexTestCase
{
createRowSet("SELECT * FROM \"customers\"", CommandType.COMMAND, true);
m_rowSetProperties.setPropertyValue("Command", "SELECT * FROM \"customers\" WHERE \"City\" = :city");
- final XParameters rowsetParams = (XParameters) UnoRuntime.queryInterface(XParameters.class,
- m_rowSet);
+ final XParameters rowsetParams = UnoRuntime.queryInterface( XParameters.class, m_rowSet );
rowsetParams.setString(1, "London");
m_rowSet.execute();
}
@@ -921,8 +917,7 @@ public class RowSet extends ComplexTestCase
for (int i = 0; i < expected; ++i)
{
- final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
- params.getByIndex(i));
+ final XPropertySet parameter = UnoRuntime.queryInterface( XPropertySet.class, params.getByIndex( i ) );
final String expectedName = _paramNames[i];
final String foundName = (String) parameter.getPropertyValue("Name");
@@ -959,12 +954,11 @@ public class RowSet extends ComplexTestCase
createRowSet("products like", CommandType.QUERY, false);
// let's fill in a parameter value via XParameters, and see whether it is respected by the parameters container
- final XParameters rowsetParams = (XParameters) UnoRuntime.queryInterface(XParameters.class,
- m_rowSet);
+ final XParameters rowsetParams = UnoRuntime.queryInterface(XParameters.class, m_rowSet);
rowsetParams.setString(1, "Apples");
XIndexAccess params = m_paramsSupplier.getParameters();
- XPropertySet firstParam = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(0));
+ XPropertySet firstParam = UnoRuntime.queryInterface( XPropertySet.class, params.getByIndex( 0 ) );
Object firstParamValue = firstParam.getPropertyValue("Value");
assure("XParameters and the parameters container do not properly interact",
@@ -978,7 +972,7 @@ public class RowSet extends ComplexTestCase
// the execution of the row set. It currently doesn't (though the values it represents do).
// It would be nice, but not strictly necessary, if it would.
params = m_paramsSupplier.getParameters();
- firstParam = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(0));
+ firstParam = UnoRuntime.queryInterface( XPropertySet.class, params.getByIndex( 0 ) );
}
firstParamValue = firstParam.getPropertyValue("Value");
assure("XParameters and the parameters container do not properly interact, after the row set has been executed",
diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java
index 40370d9aeebd..e331ccc33e7c 100644
--- a/dbaccess/qa/complex/dbaccess/TestCase.java
+++ b/dbaccess/qa/complex/dbaccess/TestCase.java
@@ -29,8 +29,12 @@
************************************************************************/
package complex.dbaccess;
+import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XModel;
import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import helper.FileTools;
@@ -38,8 +42,6 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URI;
-import java.net.URISyntaxException;
public abstract class TestCase extends complexlib.ComplexTestCase
{
@@ -55,8 +57,8 @@ public abstract class TestCase extends complexlib.ComplexTestCase
XComponentContext context = null;
try
{
- final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, getORB() );
- context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class,
+ final XPropertySet orbProps = UnoRuntime.queryInterface( XPropertySet.class, getORB() );
+ context = UnoRuntime.queryInterface( XComponentContext.class,
orbProps.getPropertyValue( "DefaultContext" ) );
}
catch ( Exception ex )
@@ -109,6 +111,15 @@ public abstract class TestCase extends complexlib.ComplexTestCase
}
// --------------------------------------------------------------------------------------------------------
+ protected final XModel loadDocument( final String _docURL ) throws Exception
+ {
+ final XComponentLoader loader = UnoRuntime.queryInterface( XComponentLoader.class,
+ getORB().createInstance( "com.sun.star.frame.Desktop" ) );
+ return UnoRuntime.queryInterface( XModel.class,
+ loader.loadComponentFromURL( _docURL, "_blank", 0, new PropertyValue[] {} ) );
+ }
+
+ // --------------------------------------------------------------------------------------------------------
protected void assureException( Object _object, Class _unoInterfaceClass, String _methodName, Object[] _methodArgs,
Class _expectedExceptionClass )
{
diff --git a/dbaccess/qa/complex/dbaccess/UISettings.java b/dbaccess/qa/complex/dbaccess/UISettings.java
index 23fe10618810..92be58f28dd6 100644
--- a/dbaccess/qa/complex/dbaccess/UISettings.java
+++ b/dbaccess/qa/complex/dbaccess/UISettings.java
@@ -30,15 +30,17 @@
package complex.dbaccess;
import com.sun.star.awt.FontSlant;
-import com.sun.star.beans.PropertyValue;
+import com.sun.star.awt.TextAlign;
import com.sun.star.beans.XPropertySet;
-import com.sun.star.form.XFormController;
-import com.sun.star.frame.XComponentLoader;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.form.runtime.XFormController;
+import com.sun.star.frame.XController;
import com.sun.star.frame.XModel;
-import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.application.DatabaseObject;
import com.sun.star.sdb.application.XDatabaseDocumentUI;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.util.XCloseable;
+import connectivity.tools.CRMDatabase;
public class UISettings extends TestCase
{
@@ -46,7 +48,8 @@ public class UISettings extends TestCase
public String[] getTestMethodNames()
{
return new String[] {
- "checkTableFormattingPersistence"
+ "checkTableFormattingPersistence",
+ "checkTransparentQueryColumnSettings"
};
}
@@ -61,25 +64,13 @@ public class UISettings extends TestCase
*/
public void checkTableFormattingPersistence() throws java.lang.Exception
{
- final CRMDatabase database = new CRMDatabase( getORB() );
-
- // load the document
- String docURL = database.getDatabase().getDocumentURL();
- final XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class,
- getORB().createInstance( "com.sun.star.frame.Desktop" ) );
- XModel doc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( docURL, "_blank", 0, new PropertyValue[] {} ) );
-
- // establish the connection
- XDatabaseDocumentUI docUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
- doc.getCurrentController() );
- docUI.connect();
-
- // display the table
- XComponent tableViewComp = docUI.loadComponent( com.sun.star.sdb.application.DatabaseObject.TABLE, "customers", false );
- XFormController tableViewController = (XFormController)UnoRuntime.queryInterface( XFormController.class,
- tableViewComp );
- XPropertySet tableControlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ // create, load, and connect a DB doc
+ CRMDatabase database = new CRMDatabase( getORB(), true );
+
+ // display a table
+ XFormController tableViewController = UnoRuntime.queryInterface( XFormController.class,
+ database.loadSubComponent( DatabaseObject.TABLE, "customers" ) );
+ XPropertySet tableControlModel = UnoRuntime.queryInterface( XPropertySet.class,
tableViewController.getCurrentControl().getModel() );
// change the table's formatting
@@ -87,12 +78,10 @@ public class UISettings extends TestCase
tableControlModel.setPropertyValue( "FontHeight", Float.valueOf( 20 ) );
tableControlModel.setPropertyValue( "FontSlant", FontSlant.ITALIC );
- // close the table
- docUI.closeSubComponents();
+ String docURL = database.getDatabase().getModel().getURL();
- // save and close the database document
- database.getDatabase().store();
- database.close();
+ // save close the database document
+ database.saveAndClose();
// load a copy of the document
// normally, it should be sufficient to load the same doc. However, there might be objects in the Java VM
@@ -102,18 +91,13 @@ public class UISettings extends TestCase
// not cleaned up, the "database model impl" - the structure holding all document data - will
// stay alive, and subsequent requests to load the doc will just reuse it, without really loading it.
docURL = copyToTempFile( docURL );
- doc = (XModel)UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( docURL, "_blank", 0, new PropertyValue[] {} ) );
-
- docUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
- doc.getCurrentController() );
- docUI.connect();
+ loadDocument( docURL );
+ database = new CRMDatabase( getORB(), docURL );
// display the table, again
- tableViewComp = docUI.loadComponent( com.sun.star.sdb.application.DatabaseObject.TABLE, "customers", false );
- tableViewController = (XFormController)UnoRuntime.queryInterface( XFormController.class,
- tableViewComp );
- tableControlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ tableViewController = UnoRuntime.queryInterface( XFormController.class,
+ database.loadSubComponent( DatabaseObject.TABLE, "customers" ) );
+ tableControlModel = UnoRuntime.queryInterface( XPropertySet.class,
tableViewController.getCurrentControl().getModel() );
// verify the properties
@@ -122,9 +106,50 @@ public class UISettings extends TestCase
assureEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) );
// close the doc
- docUI.closeSubComponents();
- final XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class,
- doc );
- closeDoc.close( true );
+ database.saveAndClose();
+ }
+
+ /**
+ * checks whether query columns use the settings of the underlying table column, if they do not (yet) have own
+ * settings
+ * @throws java.lang.Exception
+ */
+ public void checkTransparentQueryColumnSettings() throws java.lang.Exception
+ {
+ // create, load, and connect a DB doc
+ CRMDatabase database = new CRMDatabase( getORB(), true );
+
+ // display a table
+ XController tableView = database.loadSubComponent( DatabaseObject.TABLE, "customers" );
+ XFormController tableViewController = UnoRuntime.queryInterface( XFormController.class,
+ tableView );
+ XNameAccess tableControlModel = UnoRuntime.queryInterface( XNameAccess.class,
+ tableViewController.getCurrentControl().getModel() );
+
+ // change the formatting of a table column
+ XPropertySet idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) );
+ assure( "precondition not met: column already centered",
+ ((Short)idColumn.getPropertyValue( "Align" )).shortValue() != TextAlign.CENTER );
+ idColumn.setPropertyValue( "Align", TextAlign.CENTER );
+
+ // close the table data view
+ XCloseable closeSubComponent = UnoRuntime.queryInterface( XCloseable.class, tableView.getFrame() );
+ closeSubComponent.close( true );
+
+ // create a query based on that column
+ database.getDatabase().getDataSource().createQuery( "q_customers", "SELECT * FROM \"customers\"" );
+
+ // load this query, and verify the table column settings was propagated to the query column
+ XFormController queryViewController = UnoRuntime.queryInterface( XFormController.class,
+ database.loadSubComponent( DatabaseObject.QUERY, "q_customers" ) );
+ tableControlModel = UnoRuntime.queryInterface( XNameAccess.class,
+ queryViewController.getCurrentControl().getModel() );
+ idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) );
+
+ assure( "table column alignment was not propagated to the query column",
+ ((Short)idColumn.getPropertyValue( "Align" )).shortValue() == TextAlign.CENTER );
+
+ // save close the database document
+ database.saveAndClose();
}
}