diff options
4 files changed, 145 insertions, 37 deletions
diff --git a/dbaccess/source/core/api/CRowSetDataColumn.cxx b/dbaccess/source/core/api/CRowSetDataColumn.cxx index 48e922162039..189ae6844fb1 100644 --- a/dbaccess/source/core/api/CRowSetDataColumn.cxx +++ b/dbaccess/source/core/api/CRowSetDataColumn.cxx @@ -113,17 +113,9 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH } catch(const SQLException &e) { - SAL_INFO("dbaccess", "exception caught: " << e.Message); - // TODO: doing nothing matches the previous behaviour, - // (and keeps dbaccess unoapi test working...) - // but should be investigated... If the value could not be - // fetched, that's a different result than "value is null", - // which corresponds to an empty Any. - //throw WrappedTargetRuntimeException("Could not retrieve column value", *const_cast<ORowSetDataColumn*>(this), Any(e)); - // css::uno::Any a(cppu::getCaughtException()); - // throw css::lang::WrappedTargetException( - // "wrapped css::sdbc::SQLException: " + e.Message, - // css::uno::Reference<css::uno::XInterface>(), a); + throw WrappedTargetRuntimeException("Could not retrieve column value: " + e.Message, + *const_cast<ORowSetDataColumn*>(this), + Any(e)); } } else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() ) diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index 09c6b1ad8f2b..4fbbb0bf5034 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -1180,15 +1180,17 @@ void ORowSetBase::firePropertyChange(const ORowSetRow& _rOldRow) SAL_INFO("dbaccess", "ORowSetBase::firePropertyChange() Clone = " << m_bClone); OSL_ENSURE(m_pColumns,"Columns can not be NULL here!"); sal_Int32 i=0; - try + TDataColumns::iterator aEnd = m_aDataColumns.end(); + for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i) { - TDataColumns::iterator aEnd = m_aDataColumns.end(); - for(TDataColumns::iterator aIter = m_aDataColumns.begin();aIter != aEnd;++aIter,++i) + try + { (*aIter)->fireValueChange(_rOldRow.is() ? (_rOldRow->get())[i+1] : ::connectivity::ORowSetValue()); - } - catch (const Exception&) - { - SAL_WARN("dbaccess", "firePropertyChange: Exception"); + } + catch (const Exception&) + { + SAL_WARN("dbaccess", "firePropertyChange: Exception on column " << i); + } } SAL_INFO("dbaccess", "ORowSetBase::firePropertyChange() Clone = " << m_bClone); } diff --git a/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer.java b/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer.java index c4ee58c11443..b8022140c51b 100644 --- a/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer.java +++ b/qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer.java @@ -21,6 +21,7 @@ package ifc.sdb; import com.sun.star.sdb.XSingleSelectQueryComposer; import lib.MultiMethodTest; import com.sun.star.sdb.XSingleSelectQueryAnalyzer; +import com.sun.star.sdbc.XResultSet; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import lib.StatusException; @@ -28,6 +29,7 @@ import lib.Status; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.sdb.SQLFilterOperator; +import com.sun.star.sdbc.SQLException; /** * Testing <code>com.sun.star.sdb.XSingleSelectQueryComposer</code> @@ -58,6 +60,8 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { private String colName = null; + private XResultSet xReSet = null; + /** * Retcieves the object relations: * <ul> @@ -88,6 +92,15 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { } + xReSet = UnoRuntime.queryInterface(XResultSet.class, + tEnv.getObjRelation("xResultSet")); + + if (xReSet == null) { + throw new StatusException(Status.failed( + "Couldn't get object relation 'xResultSet'. Test must be modified")); + + } + try { colName = AnyConverter.toString(tEnv.getObjRelation("colName")); @@ -116,7 +129,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { oObj.setFilter(filter); tRes.tested("setFilter()", (xQueryAna.getFilter().equals(filter))); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("setFilter()", false); } @@ -140,7 +153,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { oObj.setStructuredFilter(aStructuredFilter); tRes.tested("setStructuredFilter()", (xQueryAna.getFilter().equals(complexFilter))); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("setStructuredFilter()", false); } catch (com.sun.star.lang.IllegalArgumentException e){ @@ -154,17 +167,53 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { * Relation <code>xQueryAna</code> was used to check if relation * <code>colName</code> was found. * Second an empty <code>XPropertySet</code> was used as parameter. A - * <code>com.sun.star.sdbc.SQLException</code> must be thrown. + * <code>SQLException</code> must be thrown. */ public void _appendFilterByColumn() { boolean ok = true; + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + try + { + oObj.appendFilterByColumn(xProp, true,SQLFilterOperator.EQUAL); + log.println("expected Exception was not thrown"); + tRes.tested("appendFilterByColumn()", false); + ok = false; + } + catch (com.sun.star.uno.RuntimeException e) + { + log.println("expected Exception: " + e.toString()); + ok = ok && true; + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } + + try + { + xReSet.first(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } try{ oObj.appendFilterByColumn(xProp, true,SQLFilterOperator.EQUAL); log.println("appendFilterByColumn: " + xQueryAna.getFilter()); ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("appendFilterByColumn()", false); } @@ -175,7 +224,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { log.println("appendFilterByColumn: " + xQueryAna.getFilter()); ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("appendFilterByColumn()", false); } @@ -186,10 +235,19 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { log.println("expected Exception was not thrown"); tRes.tested("appendFilterByColumn()", false); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("expected Exception"); ok = ok && true; } + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendFilterByColumn()", false); + } tRes.tested("appendFilterByColumn()", ok); } @@ -198,7 +256,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { * Relation <code>xQueryAna</code> was used to check if relation * <code>colName</code> was found. * Second an empty <code>XPropertySet</code> was used as parameter. An - * <code>com.sun.star.sdbc.SQLException</code> must be thrown. + * <code>SQLException</code> must be thrown. */ public void _appendGroupByColumn() { boolean ok = true; @@ -208,7 +266,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { log.println("appendGroupByColumn: " + xQueryAna.getFilter()); ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("appendGroupByColumn()", false); } @@ -218,7 +276,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { log.println("expected Exception was not thrown"); tRes.tested("appendGroupByColumn()", false); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("expected Exception"); ok = ok && true; } @@ -236,7 +294,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { oObj.setGroup(group); tRes.tested("setGroup()", (xQueryAna.getGroup().equals(group))); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("setGroup()", false); } @@ -255,7 +313,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { tRes.tested("setHavingClause()", ( xQueryAna.getHavingClause().equals(clause))); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("setHavingClause()", false); } @@ -291,7 +349,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { tRes.tested("setStructuredHavingClause()", (xQueryAna.getHavingClause().equals(complexFilter))); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("setStructuredHavingClause()", false); } @@ -302,30 +360,80 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { * <code>xQueryAna</code> was used to check if relation <code>colName</code> * was found. * Second an empty <code>XPropertySet</code> was given as parameter. An - * <code>com.sun.star.sdbc.SQLException</code> must be thrown. + * <code>SQLException</code> must be thrown. */ public void _appendHavingClauseByColumn() { boolean ok = true; + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + try{ + + oObj.appendHavingClauseByColumn(xProp, true,SQLFilterOperator.EQUAL); + log.println("expected Exception was not thrown"); + tRes.tested("appendHavingClauseByColumn()", false); + ok = false; + + } + catch (com.sun.star.uno.RuntimeException e) + { + log.println("expected Exception: " + e.toString()); + ok = ok && true; + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } + + try + { + xReSet.first(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } try{ oObj.appendHavingClauseByColumn(xProp, true,SQLFilterOperator.EQUAL); log.println("appendHavingClauseByColumn: " + xQueryAna.getFilter()); ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("appendHavingClauseByColumn()", false); } + + try{ XPropertySet dummy = null; oObj.appendHavingClauseByColumn(dummy, true,SQLFilterOperator.EQUAL); log.println("expected Exception was not thrown"); tRes.tested("appendHavingClauseByColumn()", false); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("expected Exception"); ok = ok && true; } + + // cleanup + try + { + xReSet.beforeFirst(); + } + catch (SQLException e) + { + log.println("unexpected Exception: " + e.toString()); + tRes.tested("appendHavingClauseByColumn()", false); + } tRes.tested("appendHavingClauseByColumn()", ok); } @@ -334,7 +442,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { * <code>xQueryAna</code> was used to check if relation <code>colName</code> * was found. * Second an empty <code>XPropertySet</code> was given as parameter. An - * <code>com.sun.star.sdbc.SQLException</code> must be thrown. + * <code>SQLException</code> must be thrown. */ public void _appendOrderByColumn() { boolean ok = true; @@ -344,7 +452,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { log.println("appendOrderByColumn: " + xQueryAna.getFilter()); ok = ok && (xQueryAna.getFilter().indexOf(colName) > 0); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("appendOrderByColumn()", false); } @@ -354,7 +462,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { log.println("expected Exception was not thrown"); tRes.tested("appendOrderByColumn()", false); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("expected Exception"); ok = ok && true; } @@ -372,7 +480,7 @@ public class _XSingleSelectQueryComposer extends MultiMethodTest { oObj.setOrder(order); tRes.tested("setOrder()", (xQueryAna.getOrder().equals(order))); - } catch (com.sun.star.sdbc.SQLException e){ + } catch (SQLException e){ log.println("unexpected Exception: " + e.toString()); tRes.tested("setOrder()", false); } diff --git a/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java b/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java index 501cf0bbfcb8..297b80e8c0f1 100644 --- a/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java +++ b/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java @@ -35,6 +35,7 @@ import com.sun.star.sdb.XSingleSelectQueryAnalyzer; import com.sun.star.sdb.XSingleSelectQueryComposer; import com.sun.star.sdbc.XConnection; import com.sun.star.sdbc.XDataSource; +import com.sun.star.sdbc.XResultSet; import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.Type; @@ -158,6 +159,8 @@ public class OSingleSelectQueryComposer extends TestCase { * {@link ifc.sdb._XSingleSelectQueryComposer} interface * <li> <code>'colName'</code> for * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * <li> <code>'xResultSet'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface * </ul> * */ @@ -242,6 +245,9 @@ public class OSingleSelectQueryComposer extends TestCase { tEnv.addObjRelation("xProp", xCol); tEnv.addObjRelation("colName", xCols.getElementNames()[0]); + XResultSet xResultSet = UnoRuntime.queryInterface(XResultSet.class, oRowSet); + tEnv.addObjRelation("xResultSet", xResultSet); + return tEnv; } catch(com.sun.star.uno.Exception e) { |