summaryrefslogtreecommitdiff
path: root/qadevOOo/runner
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r--qadevOOo/runner/base/java_fat.java4
-rw-r--r--qadevOOo/runner/lib/TestParameters.java2
-rw-r--r--qadevOOo/runner/util/DBTools.java51
-rw-r--r--qadevOOo/runner/util/db/DataSource.java162
-rw-r--r--qadevOOo/runner/util/db/DataSourceDescriptor.java73
-rw-r--r--qadevOOo/runner/util/db/DatabaseDocument.java89
-rw-r--r--qadevOOo/runner/util/utils.java10
7 files changed, 353 insertions, 38 deletions
diff --git a/qadevOOo/runner/base/java_fat.java b/qadevOOo/runner/base/java_fat.java
index c058cb72d5a2..6b555fc1f1e5 100644
--- a/qadevOOo/runner/base/java_fat.java
+++ b/qadevOOo/runner/base/java_fat.java
@@ -338,11 +338,11 @@ public class java_fat implements TestBase
}
catch (Exception e)
{
- System.out.println("couldn't cleanup");
+ System.err.println( "couldn't cleanup:" + e.toString() );
}
catch (java.lang.NoClassDefFoundError e)
{
- System.out.println("couldn't cleanup");
+ System.err.println( "couldn't cleanup:" + e.toString() );
}
sumIt.summarizeUp(entry);
diff --git a/qadevOOo/runner/lib/TestParameters.java b/qadevOOo/runner/lib/TestParameters.java
index 42f64331e661..24b9503184ae 100644
--- a/qadevOOo/runner/lib/TestParameters.java
+++ b/qadevOOo/runner/lib/TestParameters.java
@@ -117,7 +117,7 @@ public class TestParameters extends Hashtable {
* The Path to the test documents that are loaded during the test <br>
*/
- public String TestDocumentPath="unkown";
+ public String TestDocumentPath="unknown";
/**
* 'true' is a log should be written, 'false' elsewhere <br>
diff --git a/qadevOOo/runner/util/DBTools.java b/qadevOOo/runner/util/DBTools.java
index 4ff1448ac30c..407afde30a2b 100644
--- a/qadevOOo/runner/util/DBTools.java
+++ b/qadevOOo/runner/util/DBTools.java
@@ -30,6 +30,7 @@
package util;
+import com.sun.star.uno.Exception;
import java.io.PrintWriter ;
// access the implementations via names
@@ -69,6 +70,7 @@ public class DBTools {
private XMultiServiceFactory xMSF = null ;
private XNamingService dbContext = null ;
+ private PrintWriter m_log = null;
//JDBC driver
public final static String TST_JDBC_DRIVER = "org.gjt.mm.mysql.Driver";
@@ -166,7 +168,9 @@ public class DBTools {
/**
* Creates an empty instance.
*/
- public DataSourceInfo() {}
+ public DataSourceInfo()
+ {
+ }
/**
* Creates an instance laying upon specified DataSource.
@@ -248,38 +252,23 @@ public class DBTools {
* appropriate service properties.
* @return <code>com.sun.star.sdb.DataSource</code> service.
*/
- public Object getDataSourceService() {
- Object src = null ;
- try {
- src = xMSF.createInstance("com.sun.star.sdb.DataSource") ;
- } catch (com.sun.star.uno.Exception e) {}
-
- if (src == null) return null ;
+ public Object getDataSourceService() throws Exception
+ {
+ Object src = src = xMSF.createInstance("com.sun.star.sdb.DataSource") ;
XPropertySet props = (XPropertySet) UnoRuntime.queryInterface
(XPropertySet.class, src) ;
- try {
- if (Name != null) props.setPropertyValue("Name", Name) ;
- if (URL != null) props.setPropertyValue("URL", URL) ;
- if (Info != null) props.setPropertyValue("Info", Info) ;
- if (User != null) props.setPropertyValue("User", User) ;
- if (Password != null) props.setPropertyValue("Password", Password) ;
- if (IsPasswordRequired != null) props.setPropertyValue("IsPasswordRequired", IsPasswordRequired) ;
- if (SuppressVersionColumns != null) props.setPropertyValue("SuppressVersionColumns", SuppressVersionColumns) ;
- if (IsReadOnly != null) props.setPropertyValue("IsReadOnly", IsReadOnly) ;
- if (TableFilter != null) props.setPropertyValue("TableFilter", TableFilter) ;
- if (TableTypeFilter != null) props.setPropertyValue("TableTypeFilter", TableTypeFilter) ;
-
- } catch (com.sun.star.beans.UnknownPropertyException e) {
- return null ;
- } catch (com.sun.star.beans.PropertyVetoException e) {
- return null ;
- } catch (com.sun.star.lang.WrappedTargetException e) {
- return null ;
- } catch (com.sun.star.lang.IllegalArgumentException e) {
- return null ;
- }
+ if (Name != null) props.setPropertyValue("Name", Name) ;
+ if (URL != null) props.setPropertyValue("URL", URL) ;
+ if (Info != null) props.setPropertyValue("Info", Info) ;
+ if (User != null) props.setPropertyValue("User", User) ;
+ if (Password != null) props.setPropertyValue("Password", Password) ;
+ if (IsPasswordRequired != null) props.setPropertyValue("IsPasswordRequired", IsPasswordRequired) ;
+ if (SuppressVersionColumns != null) props.setPropertyValue("SuppressVersionColumns", SuppressVersionColumns) ;
+ if (IsReadOnly != null) props.setPropertyValue("IsReadOnly", IsReadOnly) ;
+ if (TableFilter != null) props.setPropertyValue("TableFilter", TableFilter) ;
+ if (TableTypeFilter != null) props.setPropertyValue("TableTypeFilter", TableTypeFilter) ;
return src ;
}
@@ -289,8 +278,10 @@ public class DBTools {
* Creates class instance.
* @param xMSF <code>XMultiServiceFactory</code>.
*/
- public DBTools(XMultiServiceFactory xMSF) {
+ public DBTools(XMultiServiceFactory xMSF, PrintWriter _logger )
+ {
this.xMSF = xMSF ;
+ this.m_log = _logger;
try {
Object cont = xMSF.createInstance("com.sun.star.sdb.DatabaseContext") ;
diff --git a/qadevOOo/runner/util/db/DataSource.java b/qadevOOo/runner/util/db/DataSource.java
new file mode 100644
index 000000000000..dc21c1f247ba
--- /dev/null
+++ b/qadevOOo/runner/util/db/DataSource.java
@@ -0,0 +1,162 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XNamingService;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import lib.StatusException;
+
+/** wraps a com.sun.star.sdb.DataSource
+ *
+ * @author fs93730
+ */
+public class DataSource
+{
+ protected DataSource( XMultiServiceFactory _orb, DataSourceDescriptor _descriptor )
+ {
+ m_orb = _orb;
+ try
+ {
+ m_dataSource = (XDataSource)UnoRuntime.queryInterface( XDataSource.class,
+ m_orb.createInstance( "com.sun.star.sdb.DataSource" ) );
+ m_properties = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
+ m_dataSource );
+
+ Object[] descriptorProperties = new Object[] {
+ _descriptor.Name, _descriptor.URL, _descriptor.Info, _descriptor.User, _descriptor.Password,
+ _descriptor.IsPasswordRequired };
+ String[] propertyNames = new String[] {
+ "Name", "URL", "Info", "User", "Password", "IsPasswordRequired" };
+ for ( int i=0; i < descriptorProperties.length; ++i )
+ if ( descriptorProperties[i] != null )
+ m_properties.setPropertyValue( propertyNames[i], descriptorProperties[i] );
+ }
+ catch ( Exception e )
+ {
+ throw new StatusException( "could not create/fill a css.sdb.DataSource object", e );
+ }
+ }
+
+ public XDataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ /**
+ * retrieves the css.sdb.OfficeDatabaseDocument associated with the data source
+ * @return
+ */
+ public DatabaseDocument getDatabaseDocument()
+ {
+ synchronized ( this )
+ {
+ if ( m_document == null )
+ m_document = new DatabaseDocument( m_orb, this );
+ }
+ return m_document;
+ }
+
+ public void revokeRegistration()
+ {
+ String dataSourceName = "";
+ try
+ {
+ dataSourceName = (String)m_properties.getPropertyValue( "Name" );
+ XNamingService dbContext = (XNamingService)UnoRuntime.queryInterface( XNamingService.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+ dbContext.revokeObject( dataSourceName );
+ }
+ catch ( Exception e )
+ {
+ throw new StatusException( "DataSource.revokeRegistration: could not revoke the object (" + dataSourceName + ")", e );
+ }
+ }
+
+ public void registerAs( final String _registrationName, final boolean _revokeIfRegistered )
+ {
+ String doing = null;
+ try
+ {
+ doing = "creating database context";
+ XNamingService dbContext = UnoRuntime.queryInterface( XNamingService.class,
+ m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) );
+
+ if ( _revokeIfRegistered )
+ {
+ doing = "revoking previously registered data source";
+ try
+ {
+ dbContext.revokeObject( _registrationName );
+ }
+ catch( NoSuchElementException e )
+ { /* allowed here */ }
+ }
+
+ // if the document associated with the database document has not yet been saved, then we need to do so
+ DatabaseDocument doc = getDatabaseDocument();
+ String docURL = doc.getURL();
+ if ( docURL.length() == 0 )
+ {
+ final java.io.File tempFile = java.io.File.createTempFile( _registrationName + "_", ".odb" );
+ if ( tempFile.exists() )
+ // we did not really want to create that file, we just wanted its local name, but
+ // createTempFile actually creates it => throw it away
+ // (This is necessary since some JVM/platform combinations seem to actually lock the file)
+ tempFile.delete();
+ String localPart = tempFile.toURI().toURL().toString();
+ localPart = localPart.substring( localPart.lastIndexOf( '/' ) + 1 );
+ docURL = util.utils.getOfficeTemp( m_orb ) + localPart;
+ doing = "storing database document to temporary location (" + docURL + ")";
+ doc.storeAsURL( docURL );
+ }
+
+ // register the data soource
+ doing = "registering the data source at the database context";
+ dbContext.registerObject( _registrationName, m_dataSource );
+ }
+ catch( final java.lang.Exception e )
+ {
+ throw new StatusException( "DataSource.registerAs: error during " + doing, e );
+ }
+ }
+
+ private XMultiServiceFactory m_orb = null;
+ private XDataSource m_dataSource = null;
+ private XPropertySet m_properties = null;
+ private DatabaseDocument m_document = null;
+}
diff --git a/qadevOOo/runner/util/db/DataSourceDescriptor.java b/qadevOOo/runner/util/db/DataSourceDescriptor.java
new file mode 100644
index 000000000000..734c9e123b3c
--- /dev/null
+++ b/qadevOOo/runner/util/db/DataSourceDescriptor.java
@@ -0,0 +1,73 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XMultiServiceFactory;
+
+/** a descriptor for creating a com.sun.star.sdb.DataSource
+ *
+ * @author fs93730
+ */
+public class DataSourceDescriptor
+{
+ /**
+ * Representation of <code>'Name'</code> property.
+ */
+ public String Name = null ;
+ /**
+ * Representation of <code>'URL'</code> property.
+ */
+ public String URL = null ;
+ /**
+ * Representation of <code>'Info'</code> property.
+ */
+ public PropertyValue[] Info = null ;
+ /**
+ * Representation of <code>'User'</code> property.
+ */
+ public String User = null ;
+ /**
+ * Representation of <code>'Password'</code> property.
+ */
+ public String Password = null ;
+ /**
+ * Representation of <code>'IsPasswordRequired'</code> property.
+ */
+ public Boolean IsPasswordRequired = null ;
+
+ public DataSourceDescriptor( XMultiServiceFactory _orb )
+ {
+ m_orb = _orb;
+ }
+
+ public DataSource createDataSource()
+ {
+ return new DataSource( m_orb, this );
+ }
+
+ private XMultiServiceFactory m_orb = null;
+}
diff --git a/qadevOOo/runner/util/db/DatabaseDocument.java b/qadevOOo/runner/util/db/DatabaseDocument.java
new file mode 100644
index 000000000000..3dfe11088293
--- /dev/null
+++ b/qadevOOo/runner/util/db/DatabaseDocument.java
@@ -0,0 +1,89 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2009 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 util.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * encapsulates a css.sdb.DatabaseDocument
+ */
+public class DatabaseDocument
+{
+ protected DatabaseDocument( final XMultiServiceFactory _orb, final DataSource _dataSource )
+ {
+ m_orb = _orb;
+ m_dataSource = _dataSource;
+
+ XDocumentDataSource docDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(
+ XDocumentDataSource.class, m_dataSource.getDataSource() );
+ m_databaseDocument = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class,
+ docDataSource.getDatabaseDocument() );
+
+ m_model = (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
+ m_storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
+ }
+
+ public DataSource getDataSource()
+ {
+ return m_dataSource;
+ }
+
+ public XOfficeDatabaseDocument getDatabaseDocument()
+ {
+ return m_databaseDocument;
+ }
+
+ /**
+ * passes through to XModel.getURL.
+ */
+ public String getURL()
+ {
+ return m_model.getURL();
+ }
+
+ /**
+ * simplified version (taking no arguments except the target URL) of XStorage.storeAsURL
+ * @param _url
+ * specifies the location to where to store the document
+ */
+ public void storeAsURL( final String _url ) throws IOException
+ {
+ m_storeDoc.storeAsURL( _url, new PropertyValue[] { } );
+ }
+
+ private XMultiServiceFactory m_orb;
+ private DataSource m_dataSource;
+ private XOfficeDatabaseDocument m_databaseDocument;
+ private XModel m_model;
+ private XStorable m_storeDoc;
+}
diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java
index 3ec523e32fec..d555452ff4ee 100644
--- a/qadevOOo/runner/util/utils.java
+++ b/qadevOOo/runner/util/utils.java
@@ -81,7 +81,7 @@ public class utils {
String pthSep = System.getProperty("file.separator");
- if (docpth.equals("unkown")) {
+ if (docpth.equals("unknown")) {
System.out.println("try to get tDoc from $SRC_ROOT/qadevOOo");
String srcRoot = System.getProperty(PropertyName.SRC_ROOT);
if (srcRoot != null) {
@@ -108,7 +108,7 @@ public class utils {
}
String testdocPth = "";
- if (docpth.equals("unkown")) {
+ if (docpth.equals("unknown")) {
System.out.println("try to get tDoc from OBJDSCS");
String objdscPth = System.getProperty("OBJDSCS");
if (objdscPth != null) {
@@ -549,7 +549,7 @@ public class utils {
}
/**
- * Copies file to a new location using SOffice features. If the target
+ * Copies file to a new location using OpenOffice.org features. If the target
* file already exists, the file is deleted.
*
* @returns <code>true</code> if the file was successfully copied,
@@ -571,7 +571,7 @@ public class utils {
} catch (com.sun.star.ucb.InteractiveAugmentedIOException e) {
return false;
} catch (com.sun.star.uno.Exception e) {
- System.out.println("Couldn't create a service.");
+ System.out.println("Couldn't copy " + oldF + " to " + newF + ".");
e.printStackTrace();
}
@@ -909,7 +909,7 @@ public class utils {
* @return unxsols, unxsoli, unxlngi, wntmsci
*/
public static String getOfficeOS(XMultiServiceFactory xMSF) {
- String platform = "unkown";
+ String platform = "unknown";
try {
String theOS = expandMacro(xMSF, "$_OS");