diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-09-14 09:35:03 +0200 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-09-14 09:35:03 +0200 |
commit | b7cce6910fcdbb7285ac9079017db86478209ba0 (patch) | |
tree | 8f6bf714dbcebeb64cd4330a472df6893858d142 /qadevOOo/tests/java | |
parent | fd448baea5479552a906a42bc07b8ff4f2e3002f (diff) |
dba34a: properly close the connection, and survive (without error log) if there actually isn't a connection
Diffstat (limited to 'qadevOOo/tests/java')
-rw-r--r-- | qadevOOo/tests/java/mod/_forms/GenericModelTest.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/qadevOOo/tests/java/mod/_forms/GenericModelTest.java b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java index dce88234885f..5ac071c38eb5 100644 --- a/qadevOOo/tests/java/mod/_forms/GenericModelTest.java +++ b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java @@ -27,6 +27,7 @@ package mod._forms; import com.sun.star.beans.NamedValue; import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; import java.io.PrintWriter; import lib.StatusException; @@ -251,11 +252,10 @@ public class GenericModelTest extends TestCase { if (m_ConnectionColsed) return; try { + XIndexAccess forms = UnoRuntime.queryInterface( XIndexAccess.class, + FormTools.getForms( WriterTools.getDrawPage( m_xTextDoc ) ) ); XForm myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), - (FormTools.getForms( - WriterTools.getDrawPage( - m_xTextDoc))) - .getByName("Standard")); + forms.getByIndex(0)); if (debug){ if (myForm == null){ @@ -269,18 +269,20 @@ public class GenericModelTest extends TestCase { } - XPropertySet xSetProp = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, myForm); - XConnection connection = (XConnection) AnyConverter.toObject( - new Type(XConnection.class), - xSetProp.getPropertyValue("ActiveConnection")); - if (debug && connection == null){ - log.println("ERROR: could not get property 'ActiveConnection' from the XForm"); + XPropertySet xSetProp = UnoRuntime.queryInterface( XPropertySet.class, myForm ); + XConnection connection = UnoRuntime.queryInterface( XConnection.class, xSetProp.getPropertyValue( "ActiveConnection" ) ); + if ( connection == null ) + { + if ( debug ) + log.println("ERROR: could not get property 'ActiveConnection' from the XForm"); + } + else + { + connection.close(); } - - connection.close(); } catch (Exception e) { log.println("ERROR: Can't close the connection: " + e.toString()); + e.printStackTrace( log ); } log.println("closing data source..."); |