summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2010-10-21 15:10:42 +0200
committerMathias Bauer <mba@openoffice.org>2010-10-21 15:10:42 +0200
commit8bc77374a6d7f1f0fc69bca0250d485eb90be5ed (patch)
treeae8a95b4ef7fb9f51fd96259ef68dfef97b35c9b
parent91ff13dd6a625dcd75e3783474c2bee8b6675304 (diff)
parentc2c8869c40e7831f0d040dc4b7d54c31954413d8 (diff)
CWS changehid: resync to m90
Notes
split repo tag: base_ooo/DEV300_m91
-rw-r--r--dbaccess/prj/build.lst5
-rw-r--r--dbaccess/qa/complex/dbaccess/ApplicationController.java49
-rw-r--r--dbaccess/qa/complex/dbaccess/Beamer.java126
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java24
-rwxr-xr-xdbaccess/qa/complex/dbaccess/CopyTableWizard.java58
-rw-r--r--dbaccess/qa/complex/dbaccess/DataSource.java72
-rwxr-xr-xdbaccess/qa/complex/dbaccess/DatabaseApplication.java11
-rw-r--r--dbaccess/qa/complex/dbaccess/DatabaseDocument.java261
-rw-r--r--dbaccess/qa/complex/dbaccess/Parser.java59
-rw-r--r--dbaccess/qa/complex/dbaccess/PropertyBag.java130
-rw-r--r--dbaccess/qa/complex/dbaccess/Query.java52
-rw-r--r--dbaccess/qa/complex/dbaccess/QueryInQuery.java72
-rw-r--r--dbaccess/qa/complex/dbaccess/RowSet.java220
-rwxr-xr-xdbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java136
-rw-r--r--dbaccess/qa/complex/dbaccess/TestCase.java65
-rw-r--r--dbaccess/qa/complex/dbaccess/UISettings.java58
-rwxr-xr-xdbaccess/qa/complex/dbaccess/makefile.mk143
-rw-r--r--dbaccess/source/core/api/KeySet.cxx70
-rw-r--r--dbaccess/source/core/api/KeySet.hxx7
-rw-r--r--dbaccess/source/core/api/OptimisticSet.cxx2
-rw-r--r--dbaccess/source/core/api/RowSetCache.cxx103
-rw-r--r--dbaccess/source/core/inc/DatabaseDataProvider.hxx2
-rw-r--r--dbaccess/source/core/misc/DatabaseDataProvider.cxx301
-rw-r--r--dbaccess/source/ui/app/AppController.cxx19
-rw-r--r--dbaccess/source/ui/app/AppControllerGen.cxx3
-rw-r--r--reportdesign/prj/build.lst3
-rw-r--r--reportdesign/qa/complex/reportdesign/FileURL.java62
-rwxr-xr-xreportdesign/qa/complex/reportdesign/ReportDesignerTest.java (renamed from reportdesign/qa/complex/ReportDesignerTest.java)370
-rw-r--r--reportdesign/qa/complex/reportdesign/TestDocument.java41
-rwxr-xr-xreportdesign/qa/complex/reportdesign/makefile.mk (renamed from reportdesign/qa/complex/makefile.mk)44
-rw-r--r--reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl (renamed from reportdesign/qa/complex/mysql-connector-exists.pl)0
-rwxr-xr-xreportdesign/qa/complex/reportdesign/runner.props (renamed from reportdesign/qa/complex/runner.props)0
-rwxr-xr-xreportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb (renamed from reportdesign/qa/complex/RPTCalcTests.odb)bin6715 -> 6715 bytes
-rwxr-xr-xreportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb (renamed from reportdesign/qa/complex/RPTWriterTests.odb)bin5886 -> 5762 bytes
-rw-r--r--reportdesign/source/core/sdr/RptObject.cxx20
-rw-r--r--reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx4
-rw-r--r--reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx38
-rw-r--r--reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx1
-rw-r--r--reportdesign/source/ui/inspection/DataProviderHandler.cxx21
39 files changed, 1516 insertions, 1136 deletions
diff --git a/dbaccess/prj/build.lst b/dbaccess/prj/build.lst
index f8b0502574e0..a6bbb58d8c57 100644
--- a/dbaccess/prj/build.lst
+++ b/dbaccess/prj/build.lst
@@ -27,5 +27,8 @@ ba dbaccess\source\ui\uno nmake - all ba_uiuno ba_inc NULL
ba dbaccess\source\ui\imagelists nmake - all ba_uiimglst ba_inc NULL
ba dbaccess\util nmake - all ba_util ba_uiimglst ba_capi ba_cdaccess ba_cmisc ba_crecovery ba_shared ba_uibrowser ba_uiapp ba_uicontrol ba_uidlg ba_uimisc ba_uiquery ba_uitabledesign ba_uirelationdesign ba_uiuno ba_conntools ba_misctools ba_miscres ba_ext_adabasui NULL
ba dbaccess\win32\source\odbcconfig nmake - w ba_odbcconfig ba_inc NULL
-ba dbaccess\qa\complex\dbaccess nmake - all ba_complex_tests NULL
ba dbaccess\qa\unoapi nmake - all ba_q_unoapi NULL
+
+# complex tests doesn't work
+# ba dbaccess\qa\complex\dbaccess nmake - all ba_qa_complex NULL
+
diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java
index 4c964e82dc06..bffc1ce97c4c 100644
--- a/dbaccess/qa/complex/dbaccess/ApplicationController.java
+++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java
@@ -48,6 +48,17 @@ import helper.URLHelper;
import java.io.File;
import java.io.IOException;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
/** complex test case for Base's application UI
*/
public class ApplicationController extends TestCase
@@ -64,13 +75,13 @@ public class ApplicationController extends TestCase
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "checkSaveAs"
- };
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "checkSaveAs"
+// };
+// }
// --------------------------------------------------------------------------------------------------------
public String getTestObjectName()
@@ -98,16 +109,16 @@ public class ApplicationController extends TestCase
// create/load the new database document
m_database = (_documentURL == null)
- ? new HsqlDatabase(getORB())
- : new HsqlDatabase(getORB(), _documentURL);
+ ? new HsqlDatabase(getMSF())
+ : new HsqlDatabase(getMSF(), _documentURL);
m_databaseDocument = m_database.getDatabaseDocument();
// load it into a frame
- final Object object = getORB().createInstance("com.sun.star.frame.Desktop");
+ final Object object = getMSF().createInstance("com.sun.star.frame.Desktop");
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!",
+ assertTrue("too many document instances!",
UnoRuntime.areSame(loadedComponent, m_databaseDocument));
// get the controller, which provides access to various UI operations
@@ -118,21 +129,21 @@ public class ApplicationController extends TestCase
}
// --------------------------------------------------------------------------------------------------------
- public void before() throws java.lang.Exception
+ @Before public void before() throws java.lang.Exception
{
super.before();
impl_switchToDocument(null);
}
// --------------------------------------------------------------------------------------------------------
- public void after() throws java.lang.Exception
+ @After public void after() throws java.lang.Exception
{
impl_closeDocument();
super.after();
}
// --------------------------------------------------------------------------------------------------------
- public void checkSaveAs() throws Exception, IOException, java.lang.Exception
+ @Test public void checkSaveAs() throws Exception, IOException, java.lang.Exception
{
// issue 93737 describes the problem that when you save-as a database document, and do changes to it,
// then those changes are saved in the old document, actually
@@ -146,7 +157,7 @@ public class ApplicationController extends TestCase
// connect
m_documentUI.connect();
- assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
+ assertTrue("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
// create a table in the database
m_database.createTable(new HsqlTableDescriptor("abc", new HsqlColumnDescriptor[]
@@ -159,18 +170,18 @@ public class ApplicationController extends TestCase
// load the old document, and verify there is *no* table therein
impl_switchToDocument(oldDocumentURL);
m_documentUI.connect();
- assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
+ assertTrue("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
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"));
+ assertTrue("the table was created in the wrong database", !tables.hasByName("abc"));
// load the new document, and verify there *is* a table therein
impl_switchToDocument(newDocumentURL);
m_documentUI.connect();
- assure("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
+ assertTrue("could not connect to " + m_database.getDocumentURL(), m_documentUI.isConnected());
suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, m_documentUI.getActiveConnection() );
tables = suppTables.getTables();
- assure("the newly created table has not been written", tables.hasByName("abc"));
+ assertTrue("the newly created table has not been written", tables.hasByName("abc"));
}
}
diff --git a/dbaccess/qa/complex/dbaccess/Beamer.java b/dbaccess/qa/complex/dbaccess/Beamer.java
index 909bf39d1707..2b77e21b9d60 100644
--- a/dbaccess/qa/complex/dbaccess/Beamer.java
+++ b/dbaccess/qa/complex/dbaccess/Beamer.java
@@ -28,10 +28,8 @@ package complex.dbaccess;
import com.sun.star.beans.PropertyState;
import com.sun.star.beans.PropertyValue;
-import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XEnumeration;
import com.sun.star.container.XEnumerationAccess;
-import com.sun.star.container.XNameAccess;
import com.sun.star.frame.FrameSearchFlag;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XController;
@@ -39,34 +37,30 @@ import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XDispatchProvider;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XModel;
-import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.CommandType;
-import com.sun.star.sdb.XDocumentDataSource;
-import com.sun.star.sdb.XOfficeDatabaseDocument;
-import com.sun.star.sdb.application.XDatabaseDocumentUI;
-import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.XNamingService;
import com.sun.star.util.URL;
-import com.sun.star.util.XCloseable;
import com.sun.star.util.XURLTransformer;
import com.sun.star.view.XSelectionSupplier;
-import connectivity.tools.DataSource;
-import connectivity.tools.HsqlColumnDescriptor;
-import connectivity.tools.HsqlDatabase;
-import connectivity.tools.HsqlTableDescriptor;
-import helper.URLHelper;
-import java.io.File;
import java.io.IOException;
-import util.UITools;
+
+
+// ---------- junit imports -----------------
+import org.junit.After;
+// import org.junit.AfterClass;
+import org.junit.Before;
+// import org.junit.BeforeClass;
+import org.junit.Test;
+// import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
/** complex test case for Base's application UI
*/
-public class Beamer extends complexlib.ComplexTestCase
+public class Beamer extends TestCase
{
private XModel docModel;
@@ -76,43 +70,43 @@ public class Beamer extends complexlib.ComplexTestCase
super();
}
- // --------------------------------------------------------------------------------------------------------
- protected final XComponentContext getComponentContext()
- {
- XComponentContext context = null;
- try
- {
- final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getORB());
- context = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
- orbProps.getPropertyValue("DefaultContext"));
- }
- catch (Exception ex)
- {
- failed("could not retrieve the ComponentContext");
- }
- return context;
- }
+// // --------------------------------------------------------------------------------------------------------
+// protected final XComponentContext getComponentContext()
+// {
+// XComponentContext context = null;
+// try
+// {
+// final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getORB());
+// context = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
+// orbProps.getPropertyValue("DefaultContext"));
+// }
+// catch (Exception ex)
+// {
+// failed("could not retrieve the ComponentContext");
+// }
+// return context;
+// }
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "testBeamer"
- };
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "testBeamer"
+// };
+// }
- // --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return getClass().getName();
- }
+// // --------------------------------------------------------------------------------------------------------
+// public String getTestObjectName()
+// {
+// return getClass().getName();
+// }
// --------------------------------------------------------------------------------------------------------
- protected final XMultiServiceFactory getORB()
- {
- return (XMultiServiceFactory) param.getMSF();
- }
+// protected final XMultiServiceFactory getORB()
+// {
+// return (XMultiServiceFactory) param.getMSF();
+// }
// --------------------------------------------------------------------------------------------------------
private void impl_closeDocument()
@@ -120,40 +114,40 @@ public class Beamer extends complexlib.ComplexTestCase
}
// --------------------------------------------------------------------------------------------------------
- public void before() throws Exception, java.lang.Exception
+ @Before public void before() throws Exception, java.lang.Exception
{
// 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 Object object = getMSF().createInstance("com.sun.star.frame.Desktop");
+ final XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, object);
final XComponent loadedComponent = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new PropertyValue[0]);
// get the controller, which provides access to various UI operations
- docModel = (XModel) UnoRuntime.queryInterface(XModel.class, loadedComponent);
+ docModel = UnoRuntime.queryInterface(XModel.class, loadedComponent);
}
// --------------------------------------------------------------------------------------------------------
- public void after()
+ @After public void after()
{
}
// --------------------------------------------------------------------------------------------------------
- public void testBeamer() throws Exception, IOException, java.lang.Exception
+ @Test public void testBeamer() throws Exception, IOException, java.lang.Exception
{
final XController controller = docModel.getCurrentController();
final XFrame frame = controller.getFrame();
- final XDispatchProvider dispatchP = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, frame);
+ final XDispatchProvider dispatchP = UnoRuntime.queryInterface(XDispatchProvider.class, frame);
URL command = new URL();
// command.Complete = ".component:DB/DataSourceBrowser";
command.Complete = ".uno:ViewDataSourceBrowser";
- Object instance = getORB().createInstance("com.sun.star.util.URLTransformer");
- XURLTransformer atrans = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, instance);
+ Object instance = getMSF().createInstance("com.sun.star.util.URLTransformer");
+ XURLTransformer atrans = UnoRuntime.queryInterface(XURLTransformer.class, instance);
com.sun.star.util.URL[] aURLA = new com.sun.star.util.URL[1];
aURLA[0] = command;
atrans.parseStrict(aURLA);
command = aURLA[0];
final XDispatch dispatch = dispatchP.queryDispatch(command, "_self", FrameSearchFlag.AUTO);
- assure(dispatch != null);
+ assertNotNull(dispatch);
dispatch.dispatch(command, new PropertyValue[0]);
final PropertyValue[] props = new PropertyValue[]
@@ -164,8 +158,8 @@ public class Beamer extends complexlib.ComplexTestCase
};
final XFrame beamer = frame.findFrame("_beamer", 0);
- assure(beamer != null);
- final XEnumerationAccess evtBc = (XEnumerationAccess) UnoRuntime.queryInterface(XEnumerationAccess.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
+ assertNotNull(beamer);
+ final XEnumerationAccess evtBc = UnoRuntime.queryInterface(XEnumerationAccess.class, getMSF().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
XEnumeration enumeration = evtBc.createEnumeration();
int count = -1;
while (enumeration.hasMoreElements())
@@ -173,9 +167,9 @@ public class Beamer extends complexlib.ComplexTestCase
enumeration.nextElement();
++count;
}
- final XSelectionSupplier selSup = (XSelectionSupplier)UnoRuntime.queryInterface(XSelectionSupplier.class, beamer.getController());
+ final XSelectionSupplier selSup = UnoRuntime.queryInterface(XSelectionSupplier.class, beamer.getController());
selSup.select(props);
- final com.sun.star.util.XCloseable close = (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class, frame);
+ final com.sun.star.util.XCloseable close = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class, frame);
close.close(false);
enumeration = evtBc.createEnumeration();
@@ -186,6 +180,6 @@ public class Beamer extends complexlib.ComplexTestCase
++count2;
}
- assure("count1 = " + count + " count2 = " + count2, count == count2);
+ assertTrue("count1 = " + count + " count2 = " + count2, count == count2);
}
}
diff --git a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
index 3bba8fa45001..ff89c755a90f 100644
--- a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
+++ b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
@@ -26,13 +26,21 @@
************************************************************************/
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;
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
public abstract class CRMBasedTestCase extends TestCase
{
protected CRMDatabase m_database;
@@ -42,30 +50,30 @@ public abstract class CRMBasedTestCase extends TestCase
{
try
{
- m_database = new CRMDatabase( getORB(), false );
+ m_database = new CRMDatabase( getMSF(), false );
}
catch ( Exception e )
{
e.printStackTrace( System.err );
- assure( "caught an exception (" + e.getMessage() + ") while creating the test case", false );
+ fail( "caught an exception (" + e.getMessage() + ") while creating the test case");
}
}
// --------------------------------------------------------------------------------------------------------
- @Override
- public void before()
+ @Before public void before()
{
createTestCase();
}
// --------------------------------------------------------------------------------------------------------
- @Override
- public void after()
+ @After public void after()
{
try
{
if ( m_database != null )
+ {
m_database.saveAndClose();
+ }
}
catch ( Exception ex )
{
diff --git a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
index 7c3db7f6020d..89fc56253ed0 100755
--- a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
+++ b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
@@ -46,6 +46,16 @@ import connectivity.tools.DbaseDatabase;
import java.io.IOException;
import util.UITools;
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
/** complex test case for Base's application UI
*/
public class CopyTableWizard extends CRMBasedTestCase
@@ -60,42 +70,40 @@ public class CopyTableWizard extends CRMBasedTestCase
}
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "copyTable", "copyTableDbase"
- };
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "copyTable", "copyTableDbase"
+// };
+// }
// --------------------------------------------------------------------------------------------------------
- @Override
- public String getTestObjectName()
- {
- return getClass().getName();
- }
+// @Override
+// public String getTestObjectName()
+// {
+// return getClass().getName();
+// }
// --------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------
- @Override
- public void after()
+ @After public void after()
{
dest.store();
super.after();
}
- @Override
- public void before()
+ @Before public void before()
{
try
{
createTestCase();
source = new DatabaseApplication(this.m_database.getDatabase());
- dest = new DatabaseApplication(new DbaseDatabase(getORB()));
+ dest = new DatabaseApplication(new DbaseDatabase(getMSF()));
}
catch (java.lang.Exception ex)
{
- assure(false);
+ fail("");
}
}
// --------------------------------------------------------------------------------------------------------
@@ -123,7 +131,7 @@ public class CopyTableWizard extends CRMBasedTestCase
Object toolKit = null;
try
{
- toolKit = getORB().createInstance("com.sun.star.awt.Toolkit");
+ toolKit = getMSF().createInstance("com.sun.star.awt.Toolkit");
}
catch (com.sun.star.uno.Exception e)
{
@@ -135,21 +143,21 @@ public class CopyTableWizard extends CRMBasedTestCase
return (XWindow) UnoRuntime.queryInterface(XWindow.class, atw);
}
- public void copyTable() throws Exception, IOException, java.lang.Exception
+ @Test public void copyTable() throws Exception, IOException, java.lang.Exception
{
copyTable(source,source);
}
- public void copyTableDbase() throws Exception, IOException, java.lang.Exception
+ @Test public void copyTableDbase() throws Exception, IOException, java.lang.Exception
{
copyTable(source,dest);
}
- public void copyTable(final DatabaseApplication sourceDb,final DatabaseApplication destDb) throws Exception, IOException, java.lang.Exception
+ private void copyTable(final DatabaseApplication sourceDb,final DatabaseApplication destDb) throws Exception, IOException, java.lang.Exception
{
final XConnection destConnection = destDb.getDocumentUI().getActiveConnection();
final XConnection sourceConnection = sourceDb.getDocumentUI().getActiveConnection();
- final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, sourceConnection);
+ final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, sourceConnection);
final XNameAccess tables = suppTables.getTables();
final String[] names = tables.getElementNames();
@@ -161,7 +169,7 @@ public class CopyTableWizard extends CRMBasedTestCase
public void assure(final String message)
{
- assure(message, false);
+ fail(message);
}
private void copyTable(final String tableName, final XConnection sourceConnection, final XConnection destConnection) throws Exception, IOException, java.lang.Exception
@@ -194,7 +202,7 @@ public class CopyTableWizard extends CRMBasedTestCase
try
{
final XWindow dialog = getActiveWindow();
- final UITools uiTools = new UITools(getORB(), dialog);
+ final UITools uiTools = new UITools(getMSF(), dialog);
final XAccessible root = uiTools.getRoot();
final XAccessibleContext accContext = root.getAccessibleContext();
final int count = accContext.getAccessibleChildCount();
diff --git a/dbaccess/qa/complex/dbaccess/DataSource.java b/dbaccess/qa/complex/dbaccess/DataSource.java
index f74d5af8d8f0..ce1e6db28e99 100644
--- a/dbaccess/qa/complex/dbaccess/DataSource.java
+++ b/dbaccess/qa/complex/dbaccess/DataSource.java
@@ -30,32 +30,43 @@ import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XNamingService;
-import complexlib.ComplexTestCase;
+// import complexlib.ComplexTestCase;
import connectivity.tools.CRMDatabase;
import connectivity.tools.HsqlDatabase;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+//import java.util.logging.Level;
+//import java.util.logging.Logger;
-public class DataSource extends ComplexTestCase
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+
+public class DataSource extends TestCase
{
HsqlDatabase m_database;
connectivity.tools.DataSource m_dataSource;
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "testRegistrationName"
- };
- }
-
- // --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return "DataSource";
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "testRegistrationName"
+// };
+// }
+//
+// // --------------------------------------------------------------------------------------------------------
+// public String getTestObjectName()
+// {
+// return "DataSource";
+// }
// --------------------------------------------------------------------------------------------------------
private void createTestCase()
@@ -64,47 +75,48 @@ public class DataSource extends ComplexTestCase
{
if (m_database == null)
{
- final CRMDatabase database = new CRMDatabase( getFactory(), false );
+ final CRMDatabase database = new CRMDatabase( getMSF(), false );
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
}
catch (Exception e)
{
- failed("could not create the test case, error message:\n" + e.getMessage());
+ fail("could not create the test case, error message:\n" + e.getMessage());
}
catch (java.lang.Exception e)
{
- failed("could not create the test case, error message:\n" + e.getMessage());
+ fail("could not create the test case, error message:\n" + e.getMessage());
}
}
// --------------------------------------------------------------------------------------------------------
- private XMultiServiceFactory getFactory()
- {
- return (XMultiServiceFactory) param.getMSF();
- }
+// private XMultiServiceFactory getFactory()
+// {
+// return (XMultiServiceFactory) param.getMSF();
+// }
// --------------------------------------------------------------------------------------------------------
- public void testRegistrationName()
+ @Test public void testRegistrationName()
{
try
{
createTestCase();
// 1. check the existing "Bibliography" data source whether it has the proper name
String dataSourceName = "Bibliography";
- final connectivity.tools.DataSource bibliography = new connectivity.tools.DataSource(getFactory(), dataSourceName);
- assureEquals("pre-registered database has a wrong name!", dataSourceName, bibliography.getName());
+ final connectivity.tools.DataSource bibliography = new connectivity.tools.DataSource(getMSF(), dataSourceName);
+ assertEquals("pre-registered database has a wrong name!", dataSourceName, bibliography.getName());
// 2. register a newly created data source, and verify it has the proper name
dataSourceName = "someDataSource";
final XNamingService dataSourceRegistrations = (XNamingService) UnoRuntime.queryInterface(
- XNamingService.class, getFactory().createInstance("com.sun.star.sdb.DatabaseContext"));
+ XNamingService.class, getMSF().createInstance("com.sun.star.sdb.DatabaseContext"));
dataSourceRegistrations.registerObject("someDataSource", m_dataSource.getXDataSource());
- assureEquals("registration name of a newly registered data source is wrong", dataSourceName, m_dataSource.getName());
+ assertEquals("registration name of a newly registered data source is wrong", dataSourceName, m_dataSource.getName());
}
catch (Exception ex)
{
- Logger.getLogger(DataSource.class.getName()).log(Level.SEVERE, null, ex);
+ // Logger.getLogger(DataSource.class.getName()).log(Level.SEVERE, null, ex);
+ fail();
}
}
}
diff --git a/dbaccess/qa/complex/dbaccess/DatabaseApplication.java b/dbaccess/qa/complex/dbaccess/DatabaseApplication.java
index d6bfa804eafa..0941bd318d47 100755
--- a/dbaccess/qa/complex/dbaccess/DatabaseApplication.java
+++ b/dbaccess/qa/complex/dbaccess/DatabaseApplication.java
@@ -56,14 +56,12 @@ public class DatabaseApplication
// load it into a frame
final Object object = db.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(db.getDocumentURL(), "_blank", FrameSearchFlag.ALL, new PropertyValue[0]);
// get the controller, which provides access to various UI operations
- final XModel docModel = (XModel) UnoRuntime.queryInterface(XModel.class,
- loadedComponent);
- documentUI = (XDatabaseDocumentUI) UnoRuntime.queryInterface(XDatabaseDocumentUI.class,
- docModel.getCurrentController());
+ final XModel docModel = UnoRuntime.queryInterface(XModel.class, loadedComponent);
+ documentUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, docModel.getCurrentController());
documentUI.connect();
}
@@ -87,8 +85,7 @@ public class DatabaseApplication
// store the doc in a new location
try
{
- final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
- databaseDocument);
+ final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDocument);
if (storeDoc != null)
{
storeDoc.store();
diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
index 02fb820f3fd4..757ae2de22d5 100644
--- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
+++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
@@ -33,7 +33,7 @@ import com.sun.star.lang.XEventListener;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.script.XStorageBasedLibraryContainer;
import com.sun.star.task.XInteractionRequest;
-import com.sun.star.uno.Exception;
+
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.frame.XStorable;
@@ -45,7 +45,6 @@ import com.sun.star.document.XDocumentEventBroadcaster;
import com.sun.star.document.XDocumentEventListener;
import com.sun.star.document.XEmbeddedScripts;
import com.sun.star.document.XEventsSupplier;
-import com.sun.star.frame.DoubleInitializationException;
import com.sun.star.lang.XComponent;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XDispatch;
@@ -56,13 +55,12 @@ import com.sun.star.frame.XModel;
import com.sun.star.frame.XModel2;
import com.sun.star.frame.XTitle;
import com.sun.star.lang.EventObject;
-import com.sun.star.lang.NotInitializedException;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lang.XTypeProvider;
import com.sun.star.script.provider.XScriptProviderSupplier;
import com.sun.star.sdb.XDocumentDataSource;
-import com.sun.star.sdbc.XDataSource;
+
import com.sun.star.sdb.XFormDocumentsSupplier;
import com.sun.star.sdb.XOfficeDatabaseDocument;
import com.sun.star.sdb.XReportDocumentsSupplier;
@@ -83,6 +81,16 @@ import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
public class DatabaseDocument extends TestCase implements com.sun.star.document.XDocumentEventListener
{
@@ -145,12 +153,12 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
private final ArrayList m_eventListeners = new ArrayList();
- public Object createInstanceWithContext(XComponentContext _context) throws Exception
+ public Object createInstanceWithContext(XComponentContext _context) throws com.sun.star.uno.Exception
{
return new CallbackComponent();
}
- public Object createInstanceWithArgumentsAndContext(Object[] arg0, XComponentContext _context) throws Exception
+ public Object createInstanceWithArgumentsAndContext(Object[] arg0, XComponentContext _context) throws com.sun.star.uno.Exception
{
return createInstanceWithContext(_context);
}
@@ -209,8 +217,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
{
try
{
- m_defaultHandler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class,
- _factory.createInstance("com.sun.star.task.InteractionHandler"));
+ m_defaultHandler = UnoRuntime.queryInterface(XInteractionHandler.class, _factory.createInstance("com.sun.star.task.InteractionHandler"));
}
catch (Exception ex)
{
@@ -227,14 +234,13 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
return;
}
- assureEquals("interaction handleer called in wrong state", STATE_LOADING_DOC, m_loadDocState);
+ assertEquals("interaction handleer called in wrong state", STATE_LOADING_DOC, m_loadDocState);
// auto-approve
final XInteractionContinuation continuations[] = _request.getContinuations();
for (int i = 0; i < continuations.length; ++i)
{
- final XInteractionApprove approve = (XInteractionApprove) UnoRuntime.queryInterface(XInteractionApprove.class,
- continuations[i]);
+ final XInteractionApprove approve = UnoRuntime.queryInterface(XInteractionApprove.class, continuations[i]);
if (approve != null)
{
approve.select();
@@ -247,25 +253,25 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// ========================================================================================================
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "testLoadable",
- "testDocumentRevenants",
- "testDocumentEvents",
- "testGlobalEvents"
- };
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "testLoadable",
+// "testDocumentRevenants",
+// "testDocumentEvents",
+// "testGlobalEvents"
+// };
+// }
+//
+// // --------------------------------------------------------------------------------------------------------
+// public String getTestObjectName()
+// {
+// return "DatabaseDocument";
+// }
// --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return "DatabaseDocument";
- }
-
- // --------------------------------------------------------------------------------------------------------
- public void before() throws java.lang.Exception
+ @Before public void before() throws java.lang.Exception
{
super.before();
@@ -274,26 +280,24 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// at our service factory, insert a new factory for our CallbackComponent
// this will allow the Basic code in our test documents to call back into this test case
// here, by just instantiating this service
- final XSet globalFactory = (XSet) UnoRuntime.queryInterface(
- XSet.class, getORB());
+ final XSet globalFactory = UnoRuntime.queryInterface(XSet.class, getMSF());
m_callbackFactory = new CallbackComponentFactory();
globalFactory.insert(m_callbackFactory);
// register ourself as listener at the global event broadcaster
- final XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface(
- XDocumentEventBroadcaster.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
+ final XDocumentEventBroadcaster broadcaster = UnoRuntime.queryInterface(XDocumentEventBroadcaster.class, getMSF().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
broadcaster.addDocumentEventListener(this);
}
catch (Exception e)
{
- log.println("could not create the test case, error message:\n" + e.getMessage());
+ System.out.println("could not create the test case, error message:\n" + e.getMessage());
e.printStackTrace(System.err);
- failed("failed to create the test case");
+ fail("failed to create the test case");
}
}
// --------------------------------------------------------------------------------------------------------
- public void after() throws java.lang.Exception
+ @After public void after() throws java.lang.Exception
{
try
{
@@ -302,15 +306,14 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
m_callbackFactory.dispose();
// revoke ourself as listener at the global event broadcaster
- final XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface(
- XDocumentEventBroadcaster.class, getORB().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
+ final XDocumentEventBroadcaster broadcaster = UnoRuntime.queryInterface(XDocumentEventBroadcaster.class, getMSF().createInstance("com.sun.star.frame.GlobalEventBroadcaster"));
broadcaster.removeDocumentEventListener(this);
}
catch (Exception e)
{
- log.println("could not create the test case, error message:\n" + e.getMessage());
+ System.out.println("could not create the test case, error message:\n" + e.getMessage());
e.printStackTrace(System.err);
- failed("failed to close the test case");
+ fail("failed to close the test case");
}
super.after();
@@ -348,16 +351,15 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
for (int i = 0; i < unsupportedMethods.length; ++i)
{
- assureException( _document, unsupportedMethods[i].unoInterfaceClass,
- unsupportedMethods[i].methodName, new Object[]{}, _isInitialized ? null : NotInitializedException.class );
+// assureException( _document, unsupportedMethods[i].unoInterfaceClass,
+// unsupportedMethods[i].methodName, new Object[]{}, _isInitialized ? null : NotInitializedException.class );
}
}
// --------------------------------------------------------------------------------------------------------
private XModel impl_createDocument() throws Exception
{
- final XModel databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
- getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ final XModel databaseDoc = UnoRuntime.queryInterface(XModel.class, getMSF().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
// should not be initialized here - we did neither initNew nor load nor storeAsURL it
impl_checkDocumentInitState(databaseDoc, false);
@@ -368,17 +370,15 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// --------------------------------------------------------------------------------------------------------
private void impl_closeDocument(XModel _databaseDoc) throws CloseVetoException, IOException, Exception
{
- final XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,
- _databaseDoc);
+ final XCloseable closeDoc = UnoRuntime.queryInterface(XCloseable.class, _databaseDoc);
closeDoc.close(true);
}
// --------------------------------------------------------------------------------------------------------
private XModel impl_createEmptyEmbeddedHSQLDocument() throws Exception, IOException
{
- final XModel databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
- getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
- final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, databaseDoc);
+ final XModel databaseDoc = UnoRuntime.queryInterface(XModel.class, getMSF().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDoc);
// verify the document rejects API calls which require it to be initialized
impl_checkDocumentInitState(databaseDoc, false);
@@ -388,15 +388,13 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
final String url = databaseDoc.getURL();
final PropertyValue[] args = databaseDoc.getArgs();
// they should be all empty at this time
- assureEquals("location is expected to be empty here", "", location);
- assureEquals("URL is expected to be empty here", "", url);
- assureEquals("Args are expected to be empty here", 0, args.length);
+ assertEquals("location is expected to be empty here", "", location);
+ assertEquals("URL is expected to be empty here", "", url);
+ assertEquals("Args are expected to be empty here", 0, args.length);
// and, you should be able to set properties at the data source
- final XOfficeDatabaseDocument dataSourceAccess = (XOfficeDatabaseDocument) UnoRuntime.queryInterface(
- XOfficeDatabaseDocument.class, databaseDoc);
- final XPropertySet dsProperties = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, dataSourceAccess.getDataSource());
+ final XOfficeDatabaseDocument dataSourceAccess = UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, databaseDoc);
+ final XPropertySet dsProperties = UnoRuntime.queryInterface(XPropertySet.class, dataSourceAccess.getDataSource());
dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
final String documentURL = createTempFileURL();
@@ -404,7 +402,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// now that the document is stored, ...
// ... its URL should be correct
- assureEquals("wrong URL after storing the document", documentURL, databaseDoc.getURL());
+ assertEquals("wrong URL after storing the document", documentURL, databaseDoc.getURL());
// ... it should be initialized
impl_checkDocumentInitState(databaseDoc, true);
@@ -412,7 +410,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
}
// --------------------------------------------------------------------------------------------------------
- public void testLoadable() throws Exception, IOException
+ @Test public void testLoadable() throws Exception, IOException
{
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
String documentURL = databaseDoc.getURL();
@@ -426,40 +424,39 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// ....................................................................
// 2. XLoadable::load
- databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
- getORB().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
+ databaseDoc = UnoRuntime.queryInterface(XModel.class, getMSF().createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
documentURL = copyToTempFile(documentURL);
// load the doc, and verify it's initialized then, and has the proper URL
- XLoadable loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, databaseDoc);
+ XLoadable loadDoc = UnoRuntime.queryInterface(XLoadable.class, databaseDoc);
loadDoc.load(new PropertyValue[]
{
new PropertyValue("URL", 0, documentURL, PropertyState.DIRECT_VALUE)
});
databaseDoc.attachResource(documentURL, new PropertyValue[0]);
- assureEquals("wrong URL after loading the document", documentURL, databaseDoc.getURL());
+ assertEquals("wrong URL after loading the document", documentURL, databaseDoc.getURL());
impl_checkDocumentInitState(databaseDoc, true);
// and while we are here ... initilizing the same document again should not be possible
- assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
- DoubleInitializationException.class );
- assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] },
- DoubleInitializationException.class );
+// assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
+// DoubleInitializationException.class );
+// assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] },
+// DoubleInitializationException.class );
// ....................................................................
// 3. XLoadable::initNew
impl_closeDocument(databaseDoc);
databaseDoc = impl_createDocument();
- loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, databaseDoc);
+ loadDoc = UnoRuntime.queryInterface(XLoadable.class, databaseDoc);
loadDoc.initNew();
- assureEquals("wrong URL after initializing the document", "", databaseDoc.getURL());
+ assertEquals("wrong URL after initializing the document", "", databaseDoc.getURL());
impl_checkDocumentInitState(databaseDoc, true);
// same as above - initializing the document a second time must fail
- assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
- DoubleInitializationException.class );
- assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] },
- DoubleInitializationException.class );
+// assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
+// DoubleInitializationException.class );
+// assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] },
+// DoubleInitializationException.class );
}
// --------------------------------------------------------------------------------------------------------
@@ -478,7 +475,9 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
for ( int i=0; i<_args.length; ++i )
{
if ( _args[i].Name.equals( "TestCase_Marker" ) && _args[i].Value.equals( "Yes" ) )
+ {
return true;
+ }
}
return false;
}
@@ -499,28 +498,25 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
{
new PropertyValue("PickListEntry", 0, false, PropertyState.DIRECT_VALUE),
new PropertyValue("MacroExecutionMode", 0, com.sun.star.document.MacroExecMode.USE_CONFIG, PropertyState.DIRECT_VALUE),
- new PropertyValue("InteractionHandler", 0, new MacroExecutionApprove(getORB()), PropertyState.DIRECT_VALUE)
+ new PropertyValue("InteractionHandler", 0, new MacroExecutionApprove(getMSF()), PropertyState.DIRECT_VALUE)
};
}
// --------------------------------------------------------------------------------------------------------
private int impl_setMacroSecurityLevel(int _level) throws Exception
{
- final XMultiServiceFactory configProvider = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
- getORB().createInstance("com.sun.star.configuration.ConfigurationProvider"));
+ final XMultiServiceFactory configProvider = UnoRuntime.queryInterface(XMultiServiceFactory.class, getMSF().createInstance("com.sun.star.configuration.ConfigurationProvider"));
final PropertyValue[] args = new PropertyValue[]
{
new PropertyValue("nodepath", 0, "/org.openoffice.Office.Common/Security/Scripting", PropertyState.DIRECT_VALUE)
};
- final XPropertySet securitySettings = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
- configProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", args));
+ final XPropertySet securitySettings = UnoRuntime.queryInterface(XPropertySet.class, configProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", args));
final int oldValue = ((Integer) securitySettings.getPropertyValue("MacroSecurityLevel")).intValue();
securitySettings.setPropertyValue("MacroSecurityLevel", Integer.valueOf(_level));
- final XChangesBatch committer = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class,
- securitySettings);
+ final XChangesBatch committer = UnoRuntime.queryInterface(XChangesBatch.class, securitySettings);
committer.commitChanges();
return oldValue;
@@ -529,10 +525,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// --------------------------------------------------------------------------------------------------------
private XModel impl_loadDocument( final String _documentURL, final PropertyValue[] _loadArgs ) throws Exception
{
- final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class,
- getORB().createInstance("com.sun.star.frame.Desktop") );
- return (XModel) UnoRuntime.queryInterface( XModel.class,
- loader.loadComponentFromURL( _documentURL, _BLANK, 0, _loadArgs ) );
+ final XComponentLoader loader = UnoRuntime.queryInterface(XComponentLoader.class, getMSF().createInstance("com.sun.star.frame.Desktop"));
+ return UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(_documentURL, _BLANK, 0, _loadArgs));
}
// --------------------------------------------------------------------------------------------------------
@@ -540,8 +534,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
{
// store the document
final String documentURL = FileHelper.getOOoCompatibleFileURL( _document.getURL() );
- final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface( XStorable.class,
- _document );
+ final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, _document);
storeDoc.store();
}
@@ -553,8 +546,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
// create Basic library/module therein
- final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class,
- databaseDoc);
+ final XEmbeddedScripts embeddedScripts = UnoRuntime.queryInterface(XEmbeddedScripts.class, databaseDoc);
final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries();
final XNameContainer newLib = basicLibs.createLibrary( _libName );
newLib.insertByName( _moduleName, _code );
@@ -579,7 +571,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
* This method here tests some of those aspects of a document which should survive the death of one
* instance and re-creation as a revenant.
*/
- public void testDocumentRevenants() throws Exception, IOException
+ @Test public void testDocumentRevenants() throws Exception, IOException
{
// create an empty document
XModel databaseDoc = impl_createDocWithMacro( "Lib", "Module",
@@ -592,42 +584,38 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// at this stage, the marker should not yet be present in the doc's args, else some of the below
// tests become meaningless
- assure( "A newly created doc should not have the test case marker", !impl_hasMarker( databaseDoc.getArgs() ) );
+ assertTrue( "A newly created doc should not have the test case marker", !impl_hasMarker( databaseDoc.getArgs() ) );
// obtain the DataSource associated with the document. Keeping this alive
// ensures that the "impl data" of the document is kept alive, too, so when closing
// and re-opening it, this "impl data" must be re-used.
- XDocumentDataSource dataSource = (XDocumentDataSource)UnoRuntime.queryInterface( XDocumentDataSource.class,
- ((XOfficeDatabaseDocument)UnoRuntime.queryInterface(
- XOfficeDatabaseDocument.class, databaseDoc )).getDataSource() );
+ XDocumentDataSource dataSource = UnoRuntime.queryInterface(XDocumentDataSource.class, (UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, databaseDoc)).getDataSource());
// close and reload the doc
impl_closeDocument(databaseDoc);
databaseDoc = impl_loadDocument( documentURL, impl_getMarkerLoadArgs() );
// since we just put the marker into the load-call, it should be present at the doc
- assure( "The test case marker got lost.", impl_hasMarker( databaseDoc.getArgs() ) );
+ assertTrue( "The test case marker got lost.", impl_hasMarker( databaseDoc.getArgs() ) );
// The basic library should have survived
- final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class,
- databaseDoc);
+ final XEmbeddedScripts embeddedScripts = UnoRuntime.queryInterface(XEmbeddedScripts.class, databaseDoc);
final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries();
- assure( "Baisc lib did not survive reloading a closed document", basicLibs.hasByName( "Lib" ) );
- final XNameContainer lib = (XNameContainer)UnoRuntime.queryInterface(
- XNameContainer.class, basicLibs.getByName( "Lib" ) );
- assure( "Basic module did not survive reloading a closed document", lib.hasByName( "Module" ) );
+ assertTrue( "Baisc lib did not survive reloading a closed document", basicLibs.hasByName( "Lib" ) );
+ final XNameContainer lib = UnoRuntime.queryInterface(XNameContainer.class, basicLibs.getByName("Lib"));
+ assertTrue( "Basic module did not survive reloading a closed document", lib.hasByName( "Module" ) );
// now closing the doc, and obtaining it from the data source, should preserve the marker we put into the load
// args
impl_closeDocument( databaseDoc );
- databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class, dataSource.getDatabaseDocument() );
- assure( "The test case marker did not survive re-retrieval of the doc from the data source.",
+ databaseDoc = UnoRuntime.queryInterface(XModel.class, dataSource.getDatabaseDocument());
+ assertTrue( "The test case marker did not survive re-retrieval of the doc from the data source.",
impl_hasMarker( databaseDoc.getArgs() ) );
// on the other hand, closing and regurlarly re-loading the doc *without* the marker should indeed
// lose it
impl_closeDocument( databaseDoc );
databaseDoc = impl_loadDocument( documentURL, impl_getDefaultLoadArgs() );
- assure( "Reloading the document kept the old args, instead of the newly supplied ones.",
+ assertTrue( "Reloading the document kept the old args, instead of the newly supplied ones.",
!impl_hasMarker( databaseDoc.getArgs() ) );
// clean up
@@ -635,7 +623,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
}
// --------------------------------------------------------------------------------------------------------
- public void testDocumentEvents() throws Exception, IOException
+ @Test public void testDocumentEvents() throws Exception, IOException
{
// create an empty document
final String libName = "EventHandlers";
@@ -660,8 +648,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// bind the macro to the OnLoad event
final String macroURI = "vnd.sun.star.script:" + libName + "." + moduleName + ".OnLoad?language=Basic&location=document";
- final XEventsSupplier eventsSupplier = (XEventsSupplier) UnoRuntime.queryInterface(XEventsSupplier.class,
- databaseDoc);
+ final XEventsSupplier eventsSupplier = UnoRuntime.queryInterface(XEventsSupplier.class, databaseDoc);
eventsSupplier.getEvents().replaceByName("OnLoad", new PropertyValue[]
{
new PropertyValue("EventType", 0, "Script", PropertyState.DIRECT_VALUE),
@@ -694,7 +681,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
"OnLoad"
}, context);
- assureEquals("our provided interaction handler was not called", STATE_ON_LOAD_RECEIVED, m_loadDocState);
+ assertEquals("our provided interaction handler was not called", STATE_ON_LOAD_RECEIVED, m_loadDocState);
// restore macro security level
impl_setMacroSecurityLevel(oldSecurityLevel);
@@ -704,11 +691,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
}
// --------------------------------------------------------------------------------------------------------
- public void testGlobalEvents() throws Exception, IOException
+ @Test public void testGlobalEvents() throws Exception, IOException
{
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
- final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class,
- databaseDoc);
+ final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDoc);
String context, newURL;
@@ -717,7 +703,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
context = "store";
impl_startObservingEvents(context);
storeDoc.store();
- assureEquals("store is not expected to change the document URL", databaseDoc.getURL(), oldURL);
+ assertEquals("store is not expected to change the document URL", databaseDoc.getURL(), oldURL);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSave", "OnSaveDone"
@@ -727,7 +713,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
context = "storeToURL";
impl_startObservingEvents(context);
storeDoc.storeToURL(createTempFileURL(), new PropertyValue[0]);
- assureEquals("storetoURL is not expected to change the document URL", databaseDoc.getURL(), oldURL);
+ assertEquals("storetoURL is not expected to change the document URL", databaseDoc.getURL(), oldURL);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSaveTo", "OnSaveToDone"
@@ -738,19 +724,18 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
context = "storeAsURL";
impl_startObservingEvents(context);
storeDoc.storeAsURL(newURL, new PropertyValue[0]);
- assureEquals("storeAsURL is expected to change the document URL", databaseDoc.getURL(), newURL);
+ assertEquals("storeAsURL is expected to change the document URL", databaseDoc.getURL(), newURL);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSaveAs", "OnSaveAsDone"
}, context);
// XModifiable.setModified
- final XModifiable modifyDoc = (XModifiable) UnoRuntime.queryInterface(XModifiable.class,
- databaseDoc);
+ final XModifiable modifyDoc = UnoRuntime.queryInterface(XModifiable.class, databaseDoc);
context = "setModified";
impl_startObservingEvents(context);
modifyDoc.setModified(true);
- assureEquals("setModified didn't work", modifyDoc.isModified(), true);
+ assertEquals("setModified didn't work", modifyDoc.isModified(), true);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnModifyChanged"
@@ -760,7 +745,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
context = "store (2)";
impl_startObservingEvents(context);
storeDoc.store();
- assureEquals("'store' should implicitly reset the modified flag", modifyDoc.isModified(), false);
+ assertEquals("'store' should implicitly reset the modified flag", modifyDoc.isModified(), false);
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnSave", "OnSaveDone", "OnModifyChanged"
@@ -768,12 +753,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// XComponentLoader.loadComponentFromURL
newURL = copyToTempFile(databaseDoc.getURL());
- final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
- getORB().createInstance("com.sun.star.frame.Desktop"));
+ final XComponentLoader loader = UnoRuntime.queryInterface(XComponentLoader.class, getMSF().createInstance("com.sun.star.frame.Desktop"));
context = "loadComponentFromURL";
impl_startObservingEvents(context);
- databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
- loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ databaseDoc = UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
impl_stopObservingEvents(m_globalEvents,
new String[]
{
@@ -781,8 +764,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
}, context);
// closing a document by API
- final XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,
- databaseDoc);
+ final XCloseable closeDoc = UnoRuntime.queryInterface(XCloseable.class, databaseDoc);
context = "close (API)";
impl_startObservingEvents(context);
closeDoc.close(true);
@@ -795,13 +777,11 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// closing a document via UI
context = "close (UI)";
impl_startObservingEvents("prepare for '" + context + "'");
- databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
- loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ databaseDoc = UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
impl_waitForEvent(m_globalEvents, "OnLoad", 5000);
// wait for all events to arrive - OnLoad should be the last one
- final XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class,
- databaseDoc.getCurrentController().getFrame());
+ final XDispatchProvider dispatchProvider = UnoRuntime.queryInterface(XDispatchProvider.class, databaseDoc.getCurrentController().getFrame());
final URL url = impl_getURL(".uno:CloseDoc");
final XDispatch dispatcher = dispatchProvider.queryDispatch(url, "", 0);
impl_startObservingEvents(context);
@@ -814,8 +794,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// creating a new document
databaseDoc = impl_createDocument();
- final XLoadable loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class,
- databaseDoc);
+ final XLoadable loadDoc = UnoRuntime.queryInterface(XLoadable.class, databaseDoc);
context = "initNew";
impl_startObservingEvents(context);
loadDoc.initNew();
@@ -832,13 +811,11 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
context = "activation";
// for this, load a database document ...
impl_startObservingEvents("prepare for '" + context + "'");
- databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
- loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ databaseDoc = UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
final int previousOnLoadEventPos = impl_waitForEvent(m_globalEvents, "OnLoad", 5000);
// ... and another document ...
final String otherURL = copyToTempFile(databaseDoc.getURL());
- final XModel otherDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
- loader.loadComponentFromURL(otherURL, _BLANK, 0, impl_getDefaultLoadArgs()));
+ final XModel otherDoc = UnoRuntime.queryInterface(XModel.class, loader.loadComponentFromURL(otherURL, _BLANK, 0, impl_getDefaultLoadArgs()));
impl_raise(otherDoc);
impl_waitForEvent(m_globalEvents, "OnLoad", 5000, previousOnLoadEventPos + 1);
@@ -864,8 +841,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
new URL()
};
url[0].Complete = _completeURL;
- final XURLTransformer urlTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class,
- getORB().createInstance("com.sun.star.util.URLTransformer"));
+ final XURLTransformer urlTransformer = UnoRuntime.queryInterface(XURLTransformer.class, getMSF().createInstance("com.sun.star.util.URLTransformer"));
urlTransformer.parseStrict(url);
return url[0];
}
@@ -874,15 +850,14 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
private void impl_raise(XModel _document)
{
final XFrame frame = _document.getCurrentController().getFrame();
- final XTopWindow topWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class,
- frame.getContainerWindow());
+ final XTopWindow topWindow = UnoRuntime.queryInterface(XTopWindow.class, frame.getContainerWindow());
topWindow.toFront();
}
// --------------------------------------------------------------------------------------------------------
private void impl_startObservingEvents(String _context)
{
- log.println(" " + _context + " {");
+ System.out.println(" " + _context + " {");
synchronized (m_documentEvents)
{
m_documentEvents.clear();
@@ -923,19 +898,19 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
actualEventCount = _actualEvents.size();
}
- assureEquals("wrong event count for '" + _context + "'",
+ assertEquals("wrong event count for '" + _context + "'",
_expectedEvents.length, _actualEvents.size());
for (int i = 0; i < _expectedEvents.length; ++i)
{
- assureEquals("wrong event at positon " + (i + 1) + " for '" + _context + "'",
+ assertEquals("wrong event at positon " + (i + 1) + " for '" + _context + "'",
_expectedEvents[i], _actualEvents.get(i));
}
}
}
finally
{
- log.println(" }");
+ System.out.println(" }");
}
}
@@ -975,7 +950,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
}
}
- failed("expected event '" + _expectedEvent + "' did not arrive after " + _maxMilliseconds + " milliseconds");
+ fail("expected event '" + _expectedEvent + "' did not arrive after " + _maxMilliseconds + " milliseconds");
return -1;
}
@@ -994,7 +969,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
if ((_Event.EventName.equals("OnLoad")) && (m_loadDocState != STATE_NOT_STARTED))
{
- assureEquals("OnLoad event must come *after* invocation of the interaction handler / user!",
+ assertEquals("OnLoad event must come *after* invocation of the interaction handler / user!",
m_loadDocState, STATE_MACRO_EXEC_APPROVED);
m_loadDocState = STATE_ON_LOAD_RECEIVED;
}
@@ -1005,7 +980,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
m_documentEvents.notifyAll();
}
- log.println(" document event: " + _Event.EventName);
+ System.out.println(" document event: " + _Event.EventName);
}
// --------------------------------------------------------------------------------------------------------
@@ -1023,7 +998,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
m_globalEvents.notifyAll();
}
- log.println(" global event: " + _Event.EventName);
+ System.out.println(" global event: " + _Event.EventName);
}
// --------------------------------------------------------------------------------------------------------
diff --git a/dbaccess/qa/complex/dbaccess/Parser.java b/dbaccess/qa/complex/dbaccess/Parser.java
index 2b1b9342edcb..3b6b0b92e3ed 100644
--- a/dbaccess/qa/complex/dbaccess/Parser.java
+++ b/dbaccess/qa/complex/dbaccess/Parser.java
@@ -35,23 +35,34 @@ import com.sun.star.sdbc.SQLException;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
+
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
public class Parser extends CRMBasedTestCase
{
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[] {
- "checkJoinSyntax",
- "checkParameterTypes",
- "checkWhere",
- };
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[] {
+// "checkJoinSyntax",
+// "checkParameterTypes",
+// "checkWhere",
+// };
+// }
// --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return "Parser";
- }
+// public String getTestObjectName()
+// {
+// return "Parser";
+// }
// --------------------------------------------------------------------------------------------------------
protected void createTestCase()
@@ -64,11 +75,11 @@ public class Parser extends CRMBasedTestCase
catch ( Exception e )
{
e.printStackTrace( System.err );
- assure( "caught an exception (" + e.getMessage() + ") while creating the test case", false );
+ fail( "caught an exception (" + e.getMessage() + ") while creating the test case");
}
}
- public void checkWhere() throws Exception
+ @Test public void checkWhere() throws Exception
{
final XSingleSelectQueryComposer composer = createQueryComposer();
final String SELECT = "SELECT \"products\".\"Name\" FROM \"products\" WHERE ";
@@ -107,7 +118,7 @@ public class Parser extends CRMBasedTestCase
// --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected
*/
- public void checkJoinSyntax() throws Exception
+ @Test public void checkJoinSyntax() throws Exception
{
final XSingleSelectQueryComposer composer = createQueryComposer();
@@ -144,7 +155,7 @@ public class Parser extends CRMBasedTestCase
{
caughtExpected = true;
}
- assure( "pre-condition not met: parser should except on unparseable statements, else the complete" +
+ assertTrue( "pre-condition not met: parser should except on unparseable statements, else the complete" +
"test is bogus!", caughtExpected );
}
@@ -154,30 +165,28 @@ public class Parser extends CRMBasedTestCase
final XSingleSelectQueryComposer composer = createQueryComposer();
composer.setQuery( _statement );
- assureEquals( "checkParameterTypes: internal error", _expectedParameterNames.length, _expectedParameterTypes.length );
+ assertEquals( "checkParameterTypes: internal error", _expectedParameterNames.length, _expectedParameterTypes.length );
- final XParametersSupplier paramSupp = (XParametersSupplier)UnoRuntime.queryInterface(
- XParametersSupplier.class, composer );
+ final XParametersSupplier paramSupp = UnoRuntime.queryInterface(XParametersSupplier.class, composer);
final XIndexAccess parameters = paramSupp.getParameters();
- assureEquals( "(ctx: " + _context + ") unexpected parameter count", _expectedParameterNames.length, parameters.getCount() );
+ assertEquals( "(ctx: " + _context + ") unexpected parameter count", _expectedParameterNames.length, parameters.getCount() );
for ( int i=0; i<parameters.getCount(); ++i )
{
- final XPropertySet parameter = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
- parameters.getByIndex(i) );
+ final XPropertySet parameter = UnoRuntime.queryInterface(XPropertySet.class, parameters.getByIndex(i));
final String name = (String)parameter.getPropertyValue( "Name" );
- assureEquals( "(ctx: " + _context + ") unexpected parameter name for parameter number " + ( i + 1 ), _expectedParameterNames[i], name );
+ assertEquals( "(ctx: " + _context + ") unexpected parameter name for parameter number " + ( i + 1 ), _expectedParameterNames[i], name );
final int type = ((Integer)parameter.getPropertyValue( "Type" )).intValue();
- assureEquals( "(ctx: " + _context + ") unexpected data type for parameter number " + ( i + 1 ), _expectedParameterTypes[i], type );
+ assertEquals( "(ctx: " + _context + ") unexpected data type for parameter number " + ( i + 1 ), _expectedParameterTypes[i], type );
}
}
// --------------------------------------------------------------------------------------------------------
/** verifies that the parser properly recognizes the types of parameters
*/
- public void checkParameterTypes() throws Exception
+ @Test public void checkParameterTypes() throws Exception
{
impl_checkParameters(
"SELECT * FROM \"all orders\" " +
diff --git a/dbaccess/qa/complex/dbaccess/PropertyBag.java b/dbaccess/qa/complex/dbaccess/PropertyBag.java
index c686be886bba..4920f8fa0006 100644
--- a/dbaccess/qa/complex/dbaccess/PropertyBag.java
+++ b/dbaccess/qa/complex/dbaccess/PropertyBag.java
@@ -27,14 +27,24 @@
package complex.dbaccess;
-import complexlib.ComplexTestCase;
+// import complexlib.ComplexTestCase;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.beans.*;
-public class PropertyBag extends ComplexTestCase
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+public class PropertyBag extends TestCase
{
private static final String VALUE = "Value";
private XPropertyContainer m_bag;
@@ -42,30 +52,30 @@ public class PropertyBag extends ComplexTestCase
private XPropertyAccess m_access;
private XMultiServiceFactory m_orb = null;
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "checkBasics",
- "checkSequenceAccess",
- "checkDynamicSet"
- };
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "checkBasics",
+// "checkSequenceAccess",
+// "checkDynamicSet"
+// };
+// }
public String getTestObjectName()
{
return "PropertyBag";
}
- public void before()
+ @Before public void before()
{
- m_orb = (XMultiServiceFactory)param.getMSF();
+ m_orb = getMSF();
}
- public void checkBasics()
+ @Test public void checkBasics()
{
createEmptyBag();
- log.println("testing the basics");
+ System.out.println("testing the basics");
// check whether empty property names are rejected
boolean caughtExpected = false;
@@ -76,7 +86,9 @@ public class PropertyBag extends ComplexTestCase
catch(com.sun.star.lang.IllegalArgumentException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
if ( !caughtExpected )
- failed( "empty property names are not rejected by XPropertyContainer::addProperty" );
+ {
+ fail("empty property names are not rejected by XPropertyContainer::addProperty");
+ }
// check whether duplicate insertions are rejected
caughtExpected = false;
@@ -88,7 +100,9 @@ public class PropertyBag extends ComplexTestCase
catch(com.sun.star.beans.PropertyExistException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
if ( !caughtExpected )
- failed( "insertion of duplicate property names is not rejected" );
+ {
+ fail("insertion of duplicate property names is not rejected");
+ }
// try removing the property we just added - this should fail, as it does not have
// the REMOVEABLE attribute
@@ -100,7 +114,9 @@ public class PropertyBag extends ComplexTestCase
catch(com.sun.star.beans.NotRemoveableException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
if ( !caughtExpected )
- failed( "removing non-removeable properties is expected to fail - but it didn't" );
+ {
+ fail("removing non-removeable properties is expected to fail - but it didn't");
+ }
// try removing a non-existent property
caughtExpected = false;
@@ -111,7 +127,9 @@ public class PropertyBag extends ComplexTestCase
catch(com.sun.star.beans.UnknownPropertyException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
if ( !caughtExpected )
- failed( "removing non-existent properties is expected to fail - but it didn't" );
+ {
+ fail("removing non-existent properties is expected to fail - but it didn't");
+ }
// try writing and reading a value for the one property we have so far
try
@@ -120,11 +138,13 @@ public class PropertyBag extends ComplexTestCase
m_set.setPropertyValue( VALUE , testValue);
final String currentValue = (String)m_set.getPropertyValue( VALUE);
if ( !currentValue.equals( testValue ) )
- failed( "set property is not remembered" );
+ {
+ fail("set property is not remembered");
+ }
}
catch(com.sun.star.uno.Exception e)
{
- failed( "setting or getting a property value failed" );
+ fail( "setting or getting a property value failed" );
}
// try setting an illegal value for the property
@@ -136,12 +156,14 @@ public class PropertyBag extends ComplexTestCase
catch(com.sun.star.lang.IllegalArgumentException e) { caughtExpected = true; }
catch(com.sun.star.uno.Exception e) { }
if ( !caughtExpected )
- failed( "the bag does not respect the property type we declared for the property" );
+ {
+ fail("the bag does not respect the property type we declared for the property");
+ }
}
- public void checkSequenceAccess() throws com.sun.star.uno.Exception
+ @Test public void checkSequenceAccess() throws com.sun.star.uno.Exception
{
- log.println( "checking PropertySetAccess via sequences" );
+ System.out.println( "checking PropertySetAccess via sequences" );
createStandardBag( false );
// ---------------------------------
@@ -160,10 +182,10 @@ public class PropertyBag extends ComplexTestCase
final Object value = m_set.getPropertyValue( expectedValues[i].Name );
if ( !value.equals( expectedValues[i].Value ) )
{
- log.println( "property name : " + expectedValues[i].Name );
- log.println( "expected value: " + expectedValues[i].Value.toString() );
- log.println( "current value : " + value.toString() );
- failed( "retrieving a previously set property (" + expectedValues[i].Value.getClass().toString() + ") failed" );
+ System.out.println( "property name : " + expectedValues[i].Name );
+ System.out.println( "expected value: " + expectedValues[i].Value.toString() );
+ System.out.println( "current value : " + value.toString() );
+ fail( "retrieving a previously set property (" + expectedValues[i].Value.getClass().toString() + ") failed" );
}
}
@@ -180,23 +202,25 @@ public class PropertyBag extends ComplexTestCase
{
if ( !expectedValues[j].Value.equals( value ) )
{
- log.println( "property name : " + expectedValues[j].Name );
- log.println( "expected value: " + expectedValues[j].Value.toString() );
- log.println( "current value : " + value.toString() );
- failed( "getPropertyValues failed for property '" + name + "' failed" );
+ System.out.println( "property name : " + expectedValues[j].Name );
+ System.out.println( "expected value: " + expectedValues[j].Value.toString() );
+ System.out.println( "current value : " + value.toString() );
+ fail( "getPropertyValues failed for property '" + name + "' failed" );
}
break;
}
}
if ( !m_set.getPropertyValue( name ).equals( value ) )
- failed( "XPropertyAccess::getPropertyValues() and XPropertyset::getPropertyValue results are inconsistent" );
+ {
+ fail("XPropertyAccess::getPropertyValues() and XPropertyset::getPropertyValue results are inconsistent");
+ }
}
}
- public void checkDynamicSet() throws com.sun.star.uno.Exception
+ @Test public void checkDynamicSet() throws com.sun.star.uno.Exception
{
- log.println( "checking proper dynamic of the set" );
+ System.out.println( "checking proper dynamic of the set" );
createStandardBag( false );
final PropertyValue props[] =
@@ -215,7 +239,9 @@ public class PropertyBag extends ComplexTestCase
catch( com.sun.star.beans.UnknownPropertyException e ) { caughtExpected = true; }
catch( com.sun.star.uno.Exception e ) { }
if ( !caughtExpected )
- failed( "the set shouldn't accept unknown property values, if not explicitly told to do so" );
+ {
+ fail("the set shouldn't accept unknown property values, if not explicitly told to do so");
+ }
// re-create the bag, this time allow it to implicitly add properties
createStandardBag( true );
@@ -223,14 +249,18 @@ public class PropertyBag extends ComplexTestCase
try { m_access.setPropertyValues( props ); success = true; }
catch( com.sun.star.uno.Exception e ) { }
if ( !success )
- failed( "property bag failed to implicitly add unknown properties" );
+ {
+ fail("property bag failed to implicitly add unknown properties");
+ }
// see whether this property was really added, and not just ignored
final PropertyValue newlyAdded = props[ props.length - 1 ];
try
{
if ( !m_set.getPropertyValue( newlyAdded.Name ).equals( newlyAdded.Value ) )
- failed( "the new property was not really added, or not added with the proper value" );
+ {
+ fail("the new property was not really added, or not added with the proper value");
+ }
}
catch( com.sun.star.uno.Exception e ) { }
}
@@ -241,13 +271,13 @@ public class PropertyBag extends ComplexTestCase
{
m_bag = null;
final String serviceName = "com.sun.star.beans.PropertyBag";
- m_bag = (XPropertyContainer)UnoRuntime.queryInterface( XPropertyContainer.class,
- m_orb.createInstance( serviceName )
- );
+ m_bag = UnoRuntime.queryInterface(XPropertyContainer.class, m_orb.createInstance(serviceName));
if ( m_bag == null )
- failed( "could not create a " + serviceName + " instance" );
- m_set = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_bag );
- m_access = (XPropertyAccess)UnoRuntime.queryInterface( XPropertyAccess.class, m_bag );
+ {
+ fail("could not create a " + serviceName + " instance");
+ }
+ m_set = UnoRuntime.queryInterface(XPropertySet.class, m_bag);
+ m_access = UnoRuntime.queryInterface(XPropertyAccess.class, m_bag);
}
catch( com.sun.star.uno.Exception e )
{
@@ -263,13 +293,13 @@ public class PropertyBag extends ComplexTestCase
final Object initArgs[] = { new NamedValue( "AutomaticAddition", Boolean.valueOf( allowLazyAdding ) ) };
final String serviceName = "com.sun.star.beans.PropertyBag";
- m_bag = (XPropertyContainer)UnoRuntime.queryInterface( XPropertyContainer.class,
- m_orb.createInstanceWithArguments( serviceName, initArgs )
- );
+ m_bag = UnoRuntime.queryInterface(XPropertyContainer.class, m_orb.createInstanceWithArguments(serviceName, initArgs));
if ( m_bag == null )
- failed( "could not create a " + serviceName + " instance" );
- m_set = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_bag );
- m_access = (XPropertyAccess)UnoRuntime.queryInterface( XPropertyAccess.class, m_bag );
+ {
+ fail("could not create a " + serviceName + " instance");
+ }
+ m_set = UnoRuntime.queryInterface(XPropertySet.class, m_bag);
+ m_access = UnoRuntime.queryInterface(XPropertyAccess.class, m_bag);
final Object properties[][] =
{
diff --git a/dbaccess/qa/complex/dbaccess/Query.java b/dbaccess/qa/complex/dbaccess/Query.java
index 81a651fd5696..222a6668f705 100644
--- a/dbaccess/qa/complex/dbaccess/Query.java
+++ b/dbaccess/qa/complex/dbaccess/Query.java
@@ -36,22 +36,32 @@ import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.uno.UnoRuntime;
import connectivity.tools.CRMDatabase;
-public class Query extends complexlib.ComplexTestCase {
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+public class Query extends TestCase {
connectivity.tools.HsqlDatabase m_database;
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames() {
- return new String[]
- {
- "testQueryColumns"
- };
- }
+// public String[] getTestMethodNames() {
+// return new String[]
+// {
+// "testQueryColumns"
+// };
+// }
// --------------------------------------------------------------------------------------------------------
- public String getTestObjectName() {
- return "Query";
- }
+// public String getTestObjectName() {
+// return "Query";
+// }
// --------------------------------------------------------------------------------------------------------
private void createTestCase()
@@ -60,26 +70,26 @@ public class Query extends complexlib.ComplexTestCase {
{
if ( m_database == null )
{
- final CRMDatabase database = new CRMDatabase( getFactory(), false );
+ final CRMDatabase database = new CRMDatabase( getMSF(), false );
m_database = database.getDatabase();
}
}
catch( Exception e )
{
- log.println( "could not create the test case, error message:\n" + e.getMessage() );
+ System.out.println( "could not create the test case, error message:\n" + e.getMessage() );
e.printStackTrace( System.err );
- assure( "failed to created the test case", false );
+ fail( "failed to created the test case");
}
}
// --------------------------------------------------------------------------------------------------------
- private XMultiServiceFactory getFactory()
- {
- return (XMultiServiceFactory)param.getMSF();
- }
+// private XMultiServiceFactory getFactory()
+// {
+// return (XMultiServiceFactory)param.getMSF();
+// }
// --------------------------------------------------------------------------------------------------------
- public void testQueryColumns()
+ @Test public void testQueryColumns()
{
createTestCase();
@@ -107,20 +117,20 @@ public class Query extends complexlib.ComplexTestCase {
XIndexAccess.class, suppCols.getColumns());
// check whether the columns supplied by the query match what we expected
- assure( "invalid column count (found " + columns.getCount() + ", expected: " + expectedColumnNames[i].length + ") for query \"" + queryNames[i] + "\"",
+ assertTrue( "invalid column count (found " + columns.getCount() + ", expected: " + expectedColumnNames[i].length + ") for query \"" + queryNames[i] + "\"",
columns.getCount() == expectedColumnNames[i].length );
for ( int col = 0; col < columns.getCount(); ++col )
{
final XNamed columnName = UnoRuntime.queryInterface(
XNamed.class, columns.getByIndex(col) );
- assure( "column no. " + col + " of query \"" + queryNames[i] + "\" not matching",
+ assertTrue( "column no. " + col + " of query \"" + queryNames[i] + "\" not matching",
columnName.getName().equals( expectedColumnNames[i][col] ) );
}
}
}
catch ( Exception e )
{
- assure( "caught an unexpected exception: " + e.getMessage(), false );
+ fail( "caught an unexpected exception: " + e.getMessage() );
}
}
}
diff --git a/dbaccess/qa/complex/dbaccess/QueryInQuery.java b/dbaccess/qa/complex/dbaccess/QueryInQuery.java
index 002d0395b791..0cb0789b782c 100644
--- a/dbaccess/qa/complex/dbaccess/QueryInQuery.java
+++ b/dbaccess/qa/complex/dbaccess/QueryInQuery.java
@@ -37,26 +37,36 @@ import connectivity.tools.RowSet;
import com.sun.star.sdbc.XStatement;
import com.sun.star.sdbc.XResultSet;
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
public class QueryInQuery extends CRMBasedTestCase
{
private static final String QUERY_PRODUCTS = "query products";
- // --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[] {
- "executeSimpleSelect",
- "executeAliasedSelect",
- "checkNameCollisions",
- "checkCyclicReferences",
- "checkStatementQiQSupport"
- };
- }
-
- // --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return "QueryInQuery";
- }
+// // --------------------------------------------------------------------------------------------------------
+// public String[] getTestMethodNames()
+// {
+// return new String[] {
+// "executeSimpleSelect",
+// "executeAliasedSelect",
+// "checkNameCollisions",
+// "checkCyclicReferences",
+// "checkStatementQiQSupport"
+// };
+// }
+//
+// // --------------------------------------------------------------------------------------------------------
+// public String getTestObjectName()
+// {
+// return "QueryInQuery";
+// }
// --------------------------------------------------------------------------------------------------------
protected void createTestCase()
@@ -69,7 +79,7 @@ public class QueryInQuery extends CRMBasedTestCase
catch ( Exception e )
{
e.printStackTrace( System.err );
- assure( "caught an exception (" + e.getMessage() + ") while creating the test case", false );
+ fail( "caught an exception (" + e.getMessage() + ") while creating the test case" );
}
}
@@ -84,17 +94,17 @@ public class QueryInQuery extends CRMBasedTestCase
outerRowSet.last();
innerRowSet.last();
- assure( "wrong record counts", outerRowSet.getRow() == innerRowSet.getRow() );
+ assertTrue( "wrong record counts", outerRowSet.getRow() == innerRowSet.getRow() );
outerRowSet.beforeFirst();
innerRowSet.beforeFirst();
- assure( "wrong column counts", outerRowSet.getColumnCount() == innerRowSet.getColumnCount() );
+ assertTrue( "wrong column counts", outerRowSet.getColumnCount() == innerRowSet.getColumnCount() );
while ( outerRowSet.next() && innerRowSet.next() )
{
for ( int i=1; i <= outerRowSet.getColumnCount(); ++i )
{
- assure( "content of column " + i + " of row " + outerRowSet.getRow() + " not identical",
+ assertTrue( "content of column " + i + " of row " + outerRowSet.getRow() + " not identical",
innerRowSet.getString(i).equals( outerRowSet.getString(i) ) );
}
}
@@ -103,7 +113,7 @@ public class QueryInQuery extends CRMBasedTestCase
// --------------------------------------------------------------------------------------------------------
/** executes a SQL statement simply selecting all columns from a query
*/
- public void executeSimpleSelect() throws SQLException
+ @Test public void executeSimpleSelect() throws SQLException
{
verifyEqualRowSetContent(
CommandType.COMMAND, "SELECT * FROM \"query products\"",
@@ -113,7 +123,7 @@ public class QueryInQuery extends CRMBasedTestCase
// --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected
*/
- public void executeAliasedSelect() throws SQLException
+ @Test public void executeAliasedSelect() throws SQLException
{
verifyEqualRowSetContent(
CommandType.COMMAND, "SELECT \"PROD\".\"ID\" FROM \"query products\" AS \"PROD\"",
@@ -126,7 +136,7 @@ public class QueryInQuery extends CRMBasedTestCase
// --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected
*/
- public void checkNameCollisions()
+ @Test public void checkNameCollisions()
{
// create a query with a name which is used by a table
boolean caughtExpected = false;
@@ -137,7 +147,7 @@ public class QueryInQuery extends CRMBasedTestCase
catch ( WrappedTargetException e ) { caughtExpected = true; }
catch ( IllegalArgumentException e ) {}
catch ( ElementExistException e ) { caughtExpected = true; }
- assure( "creating queries with the name of an existing table should not be possible",
+ assertTrue( "creating queries with the name of an existing table should not be possible",
caughtExpected );
// create a table with a name which is used by a query
@@ -153,12 +163,12 @@ public class QueryInQuery extends CRMBasedTestCase
}
catch ( SQLException e ) { caughtExpected = true; }
catch ( ElementExistException ex ) { }
- assure( "creating tables with the name of an existing query should not be possible",
+ assertTrue( "creating tables with the name of an existing query should not be possible",
caughtExpected );
}
// --------------------------------------------------------------------------------------------------------
- public void checkCyclicReferences() throws ElementExistException, WrappedTargetException, IllegalArgumentException
+ @Test public void checkCyclicReferences() throws ElementExistException, WrappedTargetException, IllegalArgumentException
{
// some queries which create a cycle in the sub query tree
m_database.getDatabase().getDataSource().createQuery( "orders level 1", "SELECT * FROM \"orders level 0\"" );
@@ -172,21 +182,21 @@ public class QueryInQuery extends CRMBasedTestCase
try { rowSet.execute(); }
catch ( SQLException e ) { caughtExpected = ( e.ErrorCode == -com.sun.star.sdb.ErrorCondition.PARSER_CYCLIC_SUB_QUERIES ); }
- assure( "executing a query with cyclic nested sub queries should fail!", caughtExpected );
+ assertTrue( "executing a query with cyclic nested sub queries should fail!", caughtExpected );
}
// --------------------------------------------------------------------------------------------------------
- public void checkStatementQiQSupport()
+ @Test public void checkStatementQiQSupport()
{
try
{
final XStatement statement = m_database.getConnection().createStatement();
final XResultSet resultSet = statement.executeQuery( "SELECT * FROM \"query products\"" );
- assure( "Result Set is null", resultSet != null );
+ assertTrue( "Result Set is null", resultSet != null );
}
catch( SQLException e )
{
- assure( "SDB level statements do not allow for queries in queries", false );
+ fail( "SDB level statements do not allow for queries in queries" );
}
}
}
diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java
index 5a13f6724d1f..7a11a96d9b00 100644
--- a/dbaccess/qa/complex/dbaccess/RowSet.java
+++ b/dbaccess/qa/complex/dbaccess/RowSet.java
@@ -49,7 +49,7 @@ import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.sdbcx.XDeleteRows;
import com.sun.star.sdbcx.XRowLocate;
import com.sun.star.uno.UnoRuntime;
-import complexlib.ComplexTestCase;
+
import connectivity.tools.CRMDatabase;
import connectivity.tools.DataSource;
import connectivity.tools.HsqlDatabase;
@@ -57,7 +57,17 @@ import connectivity.tools.sdb.Connection;
import java.lang.reflect.Method;
import java.util.Random;
-public class RowSet extends ComplexTestCase
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+public class RowSet extends TestCase
{
static final int MAX_TABLE_ROWS = 100;
@@ -98,41 +108,41 @@ public class RowSet extends ComplexTestCase
{
int pos = m_resultSet.getRow();
// final int val = m_row.getInt(1);
-// log.println("Clone Move(" + m_id +") before i: " + (i+1) + " Pos: " + pos + " Val: " + val);
+// System.out.println("Clone Move(" + m_id +") before i: " + (i+1) + " Pos: " + pos + " Val: " + val);
testPosition(m_resultSet, m_row, i + 1, "clone move(" + m_id + ")");
// val = m_row.getInt(1);
-// log.println("Clone Move(" + m_id +") after i: " + (i+1) + " Pos: " + pos + " Val: " + val);
+// System.out.println("Clone Move(" + m_id +") after i: " + (i+1) + " Pos: " + pos + " Val: " + val);
int pos2 = m_resultSet.getRow();
- assure("ResultSetMovementStress wrong position: " + i + " Pos1: " + pos + " Pos2: " + pos2, pos == pos2);
+ assertTrue("ResultSetMovementStress wrong position: " + i + " Pos1: " + pos + " Pos2: " + pos2, pos == pos2);
}
}
catch (Exception e)
{
- assure("ResultSetMovementStress(" + m_id + ") failed: " + e, false);
+ fail("ResultSetMovementStress(" + m_id + ") failed: " + e);
}
}
}
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "testRowSet",
- "testRowSetEvents",
- "testDeleteBehavior",
- "testCloneMovesPlusDeletions",
- "testCloneMovesPlusInsertions",
- "testParameters"
- };
- }
-
- // --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return "RowSet";
- }
-
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "testRowSet",
+// "testRowSetEvents",
+// "testDeleteBehavior",
+// "testCloneMovesPlusDeletions",
+// "testCloneMovesPlusInsertions",
+// "testParameters"
+// };
+// }
+//
+// // --------------------------------------------------------------------------------------------------------
+// public String getTestObjectName()
+// {
+// return "RowSet";
+// }
+//
// --------------------------------------------------------------------------------------------------------
private void createTestCase(boolean _defaultRowSet)
{
@@ -140,13 +150,13 @@ public class RowSet extends ComplexTestCase
{
try
{
- final CRMDatabase database = new CRMDatabase( getFactory(), false );
+ final CRMDatabase database = new CRMDatabase( getMSF(), false );
m_database = database.getDatabase();
m_dataSource = m_database.getDataSource();
}
catch (Exception e)
{
- assure("could not create the embedded HSQL database: " + e.getMessage(), false);
+ fail("could not create the embedded HSQL database: " + e.getMessage());
}
}
@@ -156,7 +166,7 @@ public class RowSet extends ComplexTestCase
}
catch (SQLException e)
{
- assure("could not connect to the database/table structure, error message:\n" + e.getMessage(), false);
+ fail("could not connect to the database/table structure, error message:\n" + e.getMessage());
}
if (_defaultRowSet)
@@ -166,10 +176,10 @@ public class RowSet extends ComplexTestCase
}
// --------------------------------------------------------------------------------------------------------
- private XMultiServiceFactory getFactory()
- {
- return (XMultiServiceFactory) param.getMSF();
- }
+// private XMultiServiceFactory getFactory()
+// {
+// return (XMultiServiceFactory) param.getMSF();
+// }
// --------------------------------------------------------------------------------------------------------
/** creates a com.sun.star.sdb.RowSet to use during the test
@@ -200,7 +210,7 @@ public class RowSet extends ComplexTestCase
{
try
{
- m_rowSet = UnoRuntime.queryInterface( XRowSet.class, getFactory().createInstance( "com.sun.star.sdb.RowSet" ) );
+ m_rowSet = UnoRuntime.queryInterface( XRowSet.class, getMSF().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));
@@ -224,15 +234,15 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("caught an exception while creating the RowSet. Type:\n" + e.getClass().toString() + "\nMessage:\n" + e.getMessage(), false);
+ fail("caught an exception while creating the RowSet. Type:\n" + e.getClass().toString() + "\nMessage:\n" + e.getMessage());
}
}
// --------------------------------------------------------------------------------------------------------
- public void testRowSet() throws java.lang.Exception
+ @Test public void testRowSet() throws java.lang.Exception
{
- log.println("testing testRowSet");
+ System.out.println("testing testRowSet");
createTestCase(true);
// sequential postioning
@@ -282,8 +292,8 @@ public class RowSet extends ComplexTestCase
{
final int val = m_row.getInt(1);
final int pos = m_resultSet.getRow();
- assure(location + ": value/position do not match: " + pos + " (pos) != " + val + " (val)", val == pos);
- assure(location + ": value/position are not as expected: " + val + " (val) != " + expectedValue + " (expected)", val == expectedValue);
+ assertTrue(location + ": value/position do not match: " + pos + " (pos) != " + val + " (val)", val == pos);
+ assertTrue(location + ": value/position are not as expected: " + val + " (val) != " + expectedValue + " (expected)", val == expectedValue);
}
// --------------------------------------------------------------------------------------------------------
@@ -301,7 +311,7 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("testSequentialPositining failed: " + e, false);
+ fail("testSequentialPositining failed: " + e);
}
}
@@ -313,13 +323,13 @@ public class RowSet extends ComplexTestCase
for (int i = 1; i <= MAX_FETCH_ROWS; ++i)
{
final int calcPos = (MAX_TABLE_ROWS % i) + 1;
- assure("testAbsolutePositioning failed", _resultSet.absolute(calcPos));
+ assertTrue("testAbsolutePositioning failed", _resultSet.absolute(calcPos));
testPosition(_resultSet, _row, calcPos, "testAbsolutePositioning");
}
}
catch (Exception e)
{
- assure("testAbsolutePositioning failed: " + e, false);
+ fail("testAbsolutePositioning failed: " + e);
}
}
@@ -343,7 +353,7 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("test3 failed: " + e, false);
+ fail("test3 failed: " + e);
}
}
@@ -370,14 +380,14 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("test4 failed: " + e, false);
+ fail("test4 failed: " + e);
}
}
// --------------------------------------------------------------------------------------------------------
void testConcurrentAccess(XResultSet _resultSet)
{
- log.println("testing Thread");
+ System.out.println("testing Thread");
try
{
// final XRow _row = (XRow)UnoRuntime.queryInterface(XRow.class,_resultSet);
@@ -389,7 +399,7 @@ public class RowSet extends ComplexTestCase
for (int i = 0; i < numberOfThreads; ++i)
{
threads[i] = new Thread(new ResultSetMovementStress(createClone(), i));
- log.println("starting thread " + (i + 1) + " of " + (numberOfThreads));
+ System.out.println("starting thread " + (i + 1) + " of " + (numberOfThreads));
threads[i].start();
}
@@ -400,14 +410,14 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("testConcurrentAccess failed: " + e, false);
+ fail("testConcurrentAccess failed: " + e);
}
}
// --------------------------------------------------------------------------------------------------------
- public void testRowSetEvents() throws java.lang.Exception
+ @Test public void testRowSetEvents() throws java.lang.Exception
{
- log.println("testing RowSet Events");
+ System.out.println("testing RowSet Events");
createTestCase(true);
// first we create our RowSet object
@@ -552,26 +562,26 @@ public class RowSet extends ComplexTestCase
_evt.clearCalling();
_method.invoke(res, args);
- log.println("testing events for " + _method.getName());
+ System.out.println("testing events for " + _method.getName());
final int calling[] = _evt.getCalling();
int pos = 1;
- assure("Callings are not in the correct order for APPROVE_CURSOR_MOVE ",
+ assertTrue("Callings are not in the correct order for APPROVE_CURSOR_MOVE ",
(!_must[RowSetEventListener.APPROVE_CURSOR_MOVE] || calling[RowSetEventListener.APPROVE_CURSOR_MOVE] == -1) || calling[RowSetEventListener.APPROVE_CURSOR_MOVE] == pos++);
- assure("Callings are not in the correct order for APPROVE_ROW_CHANGE",
+ assertTrue("Callings are not in the correct order for APPROVE_ROW_CHANGE",
(!_must[RowSetEventListener.APPROVE_ROW_CHANGE] || calling[RowSetEventListener.APPROVE_ROW_CHANGE] == -1) || calling[RowSetEventListener.APPROVE_ROW_CHANGE] == pos++);
- assure("Callings are not in the correct order for COLUMN_VALUE",
+ assertTrue("Callings are not in the correct order for COLUMN_VALUE",
(!_must[RowSetEventListener.COLUMN_VALUE] || calling[RowSetEventListener.COLUMN_VALUE] == -1) || calling[RowSetEventListener.COLUMN_VALUE] == pos++);
- assure("Callings are not in the correct order for CURSOR_MOVED",
+ assertTrue("Callings are not in the correct order for CURSOR_MOVED",
(!_must[RowSetEventListener.CURSOR_MOVED] || calling[RowSetEventListener.CURSOR_MOVED] == -1) || calling[RowSetEventListener.CURSOR_MOVED] == pos++);
- assure("Callings are not in the correct order for ROW_CHANGED",
+ assertTrue("Callings are not in the correct order for ROW_CHANGED",
(!_must[RowSetEventListener.ROW_CHANGED] || calling[RowSetEventListener.ROW_CHANGED] == -1) || calling[RowSetEventListener.ROW_CHANGED] == pos++);
- assure("Callings are not in the correct order for IS_MODIFIED",
+ assertTrue("Callings are not in the correct order for IS_MODIFIED",
(!_must[RowSetEventListener.IS_MODIFIED] || calling[RowSetEventListener.IS_MODIFIED] == -1) || calling[RowSetEventListener.IS_MODIFIED] == pos++);
- assure("Callings are not in the correct order for IS_NEW",
+ assertTrue("Callings are not in the correct order for IS_NEW",
(!_must[RowSetEventListener.IS_NEW] || calling[RowSetEventListener.IS_NEW] == -1) || calling[RowSetEventListener.IS_NEW] == pos++);
- assure("Callings are not in the correct order for ROW_COUNT",
+ assertTrue("Callings are not in the correct order for ROW_COUNT",
(!_must[RowSetEventListener.ROW_COUNT] || calling[RowSetEventListener.ROW_COUNT] == -1) || calling[RowSetEventListener.ROW_COUNT] == pos++);
- assure("Callings are not in the correct order for IS_ROW_COUNT_FINAL",
+ assertTrue("Callings are not in the correct order for IS_ROW_COUNT_FINAL",
(!_must[RowSetEventListener.IS_ROW_COUNT_FINAL] || calling[RowSetEventListener.IS_ROW_COUNT_FINAL] == -1) || calling[RowSetEventListener.IS_ROW_COUNT_FINAL] == pos);
_evt.clearCalling();
@@ -592,7 +602,7 @@ public class RowSet extends ComplexTestCase
private int positionRandom() throws SQLException, UnknownPropertyException, WrappedTargetException
{
final int position = (new Random()).nextInt(currentRowCount() - 2) + 2;
- assure("sub task failed: could not position to row no. " + (Integer.valueOf(position)).toString(),
+ assertTrue("sub task failed: could not position to row no. " + (Integer.valueOf(position)).toString(),
m_resultSet.absolute(position));
return m_resultSet.getRow();
}
@@ -614,15 +624,15 @@ public class RowSet extends ComplexTestCase
final int positionAfter = m_resultSet.getRow();
final int rowCountAfter = currentRowCount();
- assure("position changed during |deleteRow| (it should not)", positionAfter == positionBefore);
- assure("row count changed with a |deleteRow| (it should not)", rowCountBefore == rowCountAfter);
- assure("RowSet does not report the current row as deleted after |deleteRow|", m_resultSet.rowDeleted());
+ assertTrue("position changed during |deleteRow| (it should not)", positionAfter == positionBefore);
+ assertTrue("row count changed with a |deleteRow| (it should not)", rowCountBefore == rowCountAfter);
+ assertTrue("RowSet does not report the current row as deleted after |deleteRow|", m_resultSet.rowDeleted());
return positionBefore;
}
// --------------------------------------------------------------------------------------------------------
- public void testDeleteBehavior() throws Exception
+ @Test public void testDeleteBehavior() throws Exception
{
createTestCase(true);
@@ -644,40 +654,40 @@ public class RowSet extends ComplexTestCase
{
caughtException = true;
}
- assure("asking for the bookmark of a deleted row should throw an exception", caughtException);
+ assertTrue("asking for the bookmark of a deleted row should throw an exception", caughtException);
// .....................................................................................................
// isXXX methods should return |false| on a deleted row
- assure("one of the isFoo failed after |deleteRow|", !m_resultSet.isBeforeFirst() && !m_resultSet.isAfterLast() && !m_resultSet.isFirst() && !m_resultSet.isLast());
+ assertTrue("one of the isFoo failed after |deleteRow|", !m_resultSet.isBeforeFirst() && !m_resultSet.isAfterLast() && !m_resultSet.isFirst() && !m_resultSet.isLast());
// note that we can assume that isFirst / isLast also return |false|, since deleteRandom did
// not position on the first or last record, but inbetween
// .....................................................................................................
// check if moving away from this row in either direction yields the expected results
- assure("|previous| after |deleteRow| failed", m_resultSet.previous());
+ assertTrue("|previous| after |deleteRow| failed", m_resultSet.previous());
final int positionPrevious = m_resultSet.getRow();
- assure("position after |previous| after |deleteRow| is not as expected", positionPrevious == deletedRow - 1);
+ assertTrue("position after |previous| after |deleteRow| is not as expected", positionPrevious == deletedRow - 1);
deletedRow = deleteRandom();
- assure("|next| after |deleteRow| failed", m_resultSet.next());
+ assertTrue("|next| after |deleteRow| failed", m_resultSet.next());
final int positionAfter = m_resultSet.getRow();
- assure("position after |next| after |deleteRow| is not as expected", positionAfter == deletedRow);
+ assertTrue("position after |next| after |deleteRow| is not as expected", positionAfter == deletedRow);
// since the deleted record "vanishs" as soon as the cursor is moved away from it, the absolute position does
// not change with a |next| call here
// .....................................................................................................
// check if the deleted rows really vanished after moving away from them
- assure("row count did not change as expected after two deletions", initialRowCount - 2 == currentRowCount());
+ assertTrue("row count did not change as expected after two deletions", initialRowCount - 2 == currentRowCount());
// .....................................................................................................
// check if the deleted row vanishes after moving to the insertion row
final int rowCountBefore = currentRowCount();
final int deletedPos = deleteRandom();
m_resultSetUpdate.moveToInsertRow();
- assure("moving to the insertion row immediately after |deleteRow| does not adjust the row count", rowCountBefore == currentRowCount() + 1);
+ assertTrue("moving to the insertion row immediately after |deleteRow| does not adjust the row count", rowCountBefore == currentRowCount() + 1);
m_resultSetUpdate.moveToCurrentRow();
- assure("|moveToCurrentRow| after |deleteRow| + |moveToInsertRow| results in unexpected position",
+ assertTrue("|moveToCurrentRow| after |deleteRow| + |moveToInsertRow| results in unexpected position",
(m_resultSet.getRow() == deletedPos) && !m_resultSet.rowDeleted());
// the same, but this time with deleting the first row (which is not covered by deleteRandom)
@@ -685,7 +695,7 @@ public class RowSet extends ComplexTestCase
m_resultSetUpdate.deleteRow();
m_resultSetUpdate.moveToInsertRow();
m_resultSetUpdate.moveToCurrentRow();
- assure("|last| + |deleteRow| + |moveToInsertRow| + |moveToCurrentRow| results in wrong state", m_resultSet.isAfterLast());
+ assertTrue("|last| + |deleteRow| + |moveToInsertRow| + |moveToCurrentRow| results in wrong state", m_resultSet.isAfterLast());
// .....................................................................................................
// check if deleting a deleted row fails as expected
@@ -699,7 +709,7 @@ public class RowSet extends ComplexTestCase
{
caughtException = true;
}
- assure("deleting a deleted row succeeded - it shouldn't", caughtException);
+ assertTrue("deleting a deleted row succeeded - it shouldn't", caughtException);
// .....................................................................................................
// check if deleteRows fails if it contains the bookmark of a previously-deleted row
@@ -713,7 +723,7 @@ public class RowSet extends ComplexTestCase
{
firstBookmark, deleteBookmark
});
- assure("XDeleteRows::deleteRows with the bookmark of an already-deleted row failed",
+ assertTrue("XDeleteRows::deleteRows with the bookmark of an already-deleted row failed",
(deleteSuccess.length == 2) && (deleteSuccess[0] != 0) && (deleteSuccess[1] == 0));
// .....................................................................................................
@@ -728,12 +738,12 @@ public class RowSet extends ComplexTestCase
{
caughtException = true;
}
- assure("refreshing a deleted row succeeded - it shouldn't", caughtException);
+ assertTrue("refreshing a deleted row succeeded - it shouldn't", caughtException);
// .....................................................................................................
// rowUpdated/rowDeleted
deleteRandom();
- assure("rowDeleted and/or rowUpdated are wrong on a deleted row", !m_resultSet.rowUpdated() && !m_resultSet.rowInserted());
+ assertTrue("rowDeleted and/or rowUpdated are wrong on a deleted row", !m_resultSet.rowUpdated() && !m_resultSet.rowInserted());
// .....................................................................................................
// updating values in a deleted row should fail
@@ -748,7 +758,7 @@ public class RowSet extends ComplexTestCase
{
caughtException = true;
}
- assure("updating values in a deleted row should not succeed", caughtException);
+ assertTrue("updating values in a deleted row should not succeed", caughtException);
}
// --------------------------------------------------------------------------------------------------------
@@ -756,7 +766,7 @@ public class RowSet extends ComplexTestCase
* on a clone of the RowSet
*/
@SuppressWarnings("empty-statement")
- public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException
+ @Test public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException
{
createTestCase(true);
// ensure that all records are known
@@ -773,20 +783,20 @@ public class RowSet extends ComplexTestCase
final int clonePosition = clone.getRow();
m_resultSetUpdate.deleteRow();
- assure("clone doesn't know that its current row has been deleted via the RowSet", clone.rowDeleted());
- assure("clone's position changed somehow during deletion", clonePosition == clone.getRow());
+ assertTrue("clone doesn't know that its current row has been deleted via the RowSet", clone.rowDeleted());
+ assertTrue("clone's position changed somehow during deletion", clonePosition == clone.getRow());
// .....................................................................................................
// move the row set away from the deleted record. This should still not touch the state of the clone
m_resultSet.previous();
- assure("clone doesn't know (anymore) that its current row has been deleted via the RowSet", clone.rowDeleted());
- assure("clone's position changed somehow during deletion and RowSet-movement", clonePosition == clone.getRow());
+ assertTrue("clone doesn't know (anymore) that its current row has been deleted via the RowSet", clone.rowDeleted());
+ assertTrue("clone's position changed somehow during deletion and RowSet-movement", clonePosition == clone.getRow());
// .....................................................................................................
// move the clone away from the deleted record
clone.next();
- assure("clone still assumes that its row is deleted - but we already moved it", !clone.rowDeleted());
+ assertTrue("clone still assumes that its row is deleted - but we already moved it", !clone.rowDeleted());
// .....................................................................................................
// check whether deleting the extremes (first / last) work
@@ -794,37 +804,37 @@ public class RowSet extends ComplexTestCase
cloneRowLocate.moveToBookmark(m_rowLocate.getBookmark());
m_resultSetUpdate.deleteRow();
clone.previous();
- assure("deleting the first record left the clone in a strange state (after |previous|)", clone.isBeforeFirst());
+ assertTrue("deleting the first record left the clone in a strange state (after |previous|)", clone.isBeforeFirst());
clone.next();
- assure("deleting the first record left the clone in a strange state (after |previous| + |next|)", clone.isFirst());
+ assertTrue("deleting the first record left the clone in a strange state (after |previous| + |next|)", clone.isFirst());
m_resultSet.last();
cloneRowLocate.moveToBookmark(m_rowLocate.getBookmark());
m_resultSetUpdate.deleteRow();
clone.next();
- assure("deleting the last record left the clone in a strange state (after |next|)", clone.isAfterLast());
+ assertTrue("deleting the last record left the clone in a strange state (after |next|)", clone.isAfterLast());
clone.previous();
- assure("deleting the first record left the clone in a strange state (after |next| + |previous|)", clone.isLast());
+ assertTrue("deleting the first record left the clone in a strange state (after |next| + |previous|)", clone.isLast());
// .....................................................................................................
// check whether movements of the clone interfere with movements of the RowSet, if the latter is on a deleted row
final int positionBefore = positionRandom();
m_resultSetUpdate.deleteRow();
- assure("|deleteRow|, but no |rowDeleted| (this should have been found much earlier!)", m_resultSet.rowDeleted());
+ assertTrue("|deleteRow|, but no |rowDeleted| (this should have been found much earlier!)", m_resultSet.rowDeleted());
clone.beforeFirst();
while (clone.next());
- assure("row set forgot that the current row is deleted", m_resultSet.rowDeleted());
+ assertTrue("row set forgot that the current row is deleted", m_resultSet.rowDeleted());
- assure("moving to the next record after |deleteRow| and clone moves failed", m_resultSet.next());
- assure("wrong position after |deleteRow| and clone movement", !m_resultSet.isAfterLast() && !m_resultSet.isBeforeFirst());
- assure("wrong absolute position after |deleteRow| and clone movement", m_resultSet.getRow() == positionBefore);
+ assertTrue("moving to the next record after |deleteRow| and clone moves failed", m_resultSet.next());
+ assertTrue("wrong position after |deleteRow| and clone movement", !m_resultSet.isAfterLast() && !m_resultSet.isBeforeFirst());
+ assertTrue("wrong absolute position after |deleteRow| and clone movement", m_resultSet.getRow() == positionBefore);
}
// --------------------------------------------------------------------------------------------------------
/** checks whether insertions on the main RowSet properly interfere (or don't interfere) with the movement
* on a clone of the RowSet
*/
- public void testCloneMovesPlusInsertions() throws SQLException, UnknownPropertyException, WrappedTargetException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException
+ @Test public void testCloneMovesPlusInsertions() throws SQLException, UnknownPropertyException, WrappedTargetException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException
{
createTestCase(true);
// ensure that all records are known
@@ -844,7 +854,7 @@ public class RowSet extends ComplexTestCase
final int rowValue1 = m_row.getInt(1);
final int rowPos = m_resultSet.getRow();
final int rowValue2 = m_row.getInt(1);
- assure("repeated query for the same column value delivers different values (" + rowValue1 + " and " + rowValue2 + ") on row: " + rowPos,
+ assertTrue("repeated query for the same column value delivers different values (" + rowValue1 + " and " + rowValue2 + ") on row: " + rowPos,
rowValue1 == rowValue2);
testPosition(clone, cloneRow, 1, "mixed clone/rowset move: clone check");
@@ -876,7 +886,7 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("testing the parameters of a table failed" + e.getMessage(), false);
+ fail("testing the parameters of a table failed" + e.getMessage());
}
}
// --------------------------------------------------------------------------------------------------------
@@ -893,7 +903,7 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("testing the parameters of a table failed" + e.getMessage(), false);
+ fail("testing the parameters of a table failed" + e.getMessage());
}
}
@@ -904,7 +914,7 @@ public class RowSet extends ComplexTestCase
final int expected = _paramNames.length;
final int found = params != null ? params.getCount() : 0;
- assure("wrong number of parameters (expected: " + expected + ", found: " + found + ") in " + _context,
+ assertTrue("wrong number of parameters (expected: " + expected + ", found: " + found + ") in " + _context,
found == expected);
if (found == 0)
@@ -918,7 +928,7 @@ public class RowSet extends ComplexTestCase
final String expectedName = _paramNames[i];
final String foundName = (String) parameter.getPropertyValue("Name");
- assure("wrong parameter name (expected: " + expectedName + ", found: " + foundName + ") in" + _context,
+ assertTrue("wrong parameter name (expected: " + expectedName + ", found: " + foundName + ") in" + _context,
expectedName.equals(foundName));
}
}
@@ -939,7 +949,7 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("testing the parameters of a parametrized query failed" + e.getMessage(), false);
+ fail("testing the parameters of a parametrized query failed" + e.getMessage());
}
}
@@ -958,7 +968,7 @@ public class RowSet extends ComplexTestCase
XPropertySet firstParam = UnoRuntime.queryInterface( XPropertySet.class, params.getByIndex( 0 ) );
Object firstParamValue = firstParam.getPropertyValue("Value");
- assure("XParameters and the parameters container do not properly interact",
+ assertTrue("XParameters and the parameters container do not properly interact",
"Apples".equals(firstParamValue));
// let's see whether this also survices an execute of the row set
@@ -972,12 +982,12 @@ public class RowSet extends ComplexTestCase
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",
+ assertTrue("XParameters and the parameters container do not properly interact, after the row set has been executed",
"Oranges".equals(firstParamValue));
}
catch (Exception e)
{
- assure("could not test the relationship between XParameters and XParametersSupplier" + e.getMessage(), false);
+ fail("could not test the relationship between XParameters and XParametersSupplier" + e.getMessage());
}
}
@@ -1002,14 +1012,14 @@ public class RowSet extends ComplexTestCase
}
catch (Exception e)
{
- assure("testing the parameters within a WHERE clause failed" + e.getMessage(), false);
+ fail("testing the parameters within a WHERE clause failed" + e.getMessage());
}
}
// --------------------------------------------------------------------------------------------------------
/** checks the XParametersSupplier functionality of a RowSet
*/
- public void testParameters()
+ @Test public void testParameters()
{
createTestCase(false);
// use an own RowSet instance, not the one which is also used for the other cases
diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
index bb3636100849..ec77f084063e 100755
--- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
+++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
@@ -36,6 +36,16 @@ import com.sun.star.sdbc.DataType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
public class SingleSelectQueryComposer extends CRMBasedTestCase
{
@@ -48,24 +58,24 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
private final static String INNERPRODUCTSQUERY = "products (inner)";
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "testSetCommand",
- "testAttributes",
- "testSubQueries",
- "testParameters",
- "testDisjunctiveNormalForm",
- "testConditionByColumn"
- };
- }
-
- // --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return "SingleSelectQueryComposer";
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[]
+// {
+// "testSetCommand",
+// "testAttributes",
+// "testSubQueries",
+// "testParameters",
+// "testDisjunctiveNormalForm",
+// "testConditionByColumn"
+// };
+// }
+
+// // --------------------------------------------------------------------------------------------------------
+// public String getTestObjectName()
+// {
+// return "SingleSelectQueryComposer";
+// }
// --------------------------------------------------------------------------------------------------------
private void createQueries() throws Exception
@@ -87,14 +97,14 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
}
catch (Exception e)
{
- assure("caught an exception (" + e.getMessage() + ") while creating the test case", false);
+ fail("caught an exception (" + e.getMessage() + ") while creating the test case");
}
}
// --------------------------------------------------------------------------------------------------------
private void checkAttributeAccess(String _attributeName, String _attributeValue)
{
- log.println("setting " + _attributeName + " to " + _attributeValue);
+ System.out.println("setting " + _attributeName + " to " + _attributeValue);
String realValue = null;
try
{
@@ -124,53 +134,53 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
catch (InvocationTargetException e)
{
}
- assure("set/get" + _attributeName + " not working as expected (set: " + _attributeValue + ", get: " + (realValue != null ? realValue : "null") + ")",
+ assertTrue("set/get" + _attributeName + " not working as expected (set: " + _attributeValue + ", get: " + (realValue != null ? realValue : "null") + ")",
realValue.equals(_attributeValue));
- log.println(" (results in " + (String) m_composer.getQuery() + ")");
+ System.out.println(" (results in " + m_composer.getQuery() + ")");
}
/** tests setCommand of the composer
*/
- public void testSetCommand()
+ @Test public void testSetCommand()
{
- log.println("testing SingleSelectQueryComposer's setCommand");
+ System.out.println("testing SingleSelectQueryComposer's setCommand");
try
{
final String table = "SELECT * FROM \"customers\"";
m_composer.setCommand("customers",CommandType.TABLE);
- assure("setCommand/getQuery TABLE inconsistent", m_composer.getQuery().equals(table));
+ assertTrue("setCommand/getQuery TABLE inconsistent", m_composer.getQuery().equals(table));
m_database.getDatabase().getDataSource().createQuery("set command test", "SELECT * FROM \"orders for customer\" \"a\", \"customers\" \"b\" WHERE \"a\".\"Product Name\" = \"b\".\"Name\"");
m_composer.setCommand("set command test",CommandType.QUERY);
- assure("setCommand/getQuery QUERY inconsistent", m_composer.getQuery().equals(m_database.getDatabase().getDataSource().getQueryDefinition("set command test").getCommand()));
+ assertTrue("setCommand/getQuery QUERY inconsistent", m_composer.getQuery().equals(m_database.getDatabase().getDataSource().getQueryDefinition("set command test").getCommand()));
final String sql = "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" = 'test'";
m_composer.setCommand(sql,CommandType.COMMAND);
- assure("setCommand/getQuery COMMAND inconsistent", m_composer.getQuery().equals(sql));
+ assertTrue("setCommand/getQuery COMMAND inconsistent", m_composer.getQuery().equals(sql));
}
catch (Exception e)
{
- assure("Exception caught: " + e, false);
+ fail("Exception caught: " + e);
}
}
/** tests accessing attributes of the composer (order, filter, group by, having)
*/
- public void testAttributes()
+ @Test public void testAttributes()
{
- log.println("testing SingleSelectQueryComposer's attributes (order, filter, group by, having)");
+ System.out.println("testing SingleSelectQueryComposer's attributes (order, filter, group by, having)");
try
{
- log.println("check setElementaryQuery");
+ System.out.println("check setElementaryQuery");
final String simpleQuery2 = "SELECT * FROM \"customers\" WHERE \"Name\" = 'oranges'";
m_composer.setElementaryQuery(simpleQuery2);
- assure("setElementaryQuery/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery2));
+ assertTrue("setElementaryQuery/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery2));
- log.println("check setQuery");
+ System.out.println("check setQuery");
final String simpleQuery = "SELECT * FROM \"customers\"";
m_composer.setQuery(simpleQuery);
- assure("set/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery));
+ assertTrue("set/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery));
checkAttributeAccess("Filter", "\"Name\" = 'oranges'");
checkAttributeAccess("Group", "\"City\"");
@@ -178,16 +188,16 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
checkAttributeAccess("HavingClause", "\"ID\" <> 4");
final XIndexAccess orderColumns = m_composer.getOrderColumns();
- assure("Order columns doesn't exist: \"Address\"",
+ assertTrue("Order columns doesn't exist: \"Address\"",
orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null);
final XIndexAccess groupColumns = m_composer.getGroupColumns();
- assure("Group columns doesn't exist: \"City\"",
+ assertTrue("Group columns doesn't exist: \"City\"",
groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null);
// XColumnsSupplier
- final XColumnsSupplier xSelectColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, m_composer);
- assure("no select columns, or wrong number of select columns",
+ final XColumnsSupplier xSelectColumns = UnoRuntime.queryInterface(XColumnsSupplier.class, m_composer);
+ assertTrue("no select columns, or wrong number of select columns",
xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 6);
// structured filter
@@ -196,41 +206,40 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
final PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter();
m_composer.setFilter("");
m_composer.setStructuredFilter(aStructuredFilter);
- assure("Structured Filter not identical", m_composer.getFilter().equals(COMPLEXFILTER));
+ assertTrue("Structured Filter not identical", m_composer.getFilter().equals(COMPLEXFILTER));
// structured having clause
m_composer.setHavingClause(COMPLEXFILTER);
final PropertyValue[][] aStructuredHaving = m_composer.getStructuredHavingClause();
m_composer.setHavingClause("");
m_composer.setStructuredHavingClause(aStructuredHaving);
- assure("Structured Having Clause not identical", m_composer.getHavingClause().equals(COMPLEXFILTER));
+ assertTrue("Structured Having Clause not identical", m_composer.getHavingClause().equals(COMPLEXFILTER));
}
catch (Exception e)
{
- assure("Exception caught: " + e, false);
+ fail("Exception caught: " + e);
}
}
/** test various sub query related features ("queries in queries")
*/
- public void testSubQueries() throws Exception
+ @Test public void testSubQueries() throws Exception
{
m_composer.setQuery("SELECT * from \"" + INNERPRODUCTSQUERY + "\"");
- final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(
- XTablesSupplier.class, m_composer);
+ final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_composer);
final XNameAccess tables = suppTables.getTables();
- assure("a simple SELECT * FROM <query> could not be parsed",
+ assertTrue("a simple SELECT * FROM <query> could not be parsed",
tables != null && tables.hasByName(INNERPRODUCTSQUERY));
final String sInnerCommand = m_database.getDatabase().getDataSource().getQueryDefinition(INNERPRODUCTSQUERY).getCommand();
final String sExecutableQuery = m_composer.getQueryWithSubstitution();
- assure("simple query containing a sub query improperly parsed to SDBC level statement: \n1. " + sExecutableQuery + "\n2. " + "SELECT * FROM ( " + sInnerCommand + " ) AS \"" + INNERPRODUCTSQUERY + "\"",
+ assertTrue("simple query containing a sub query improperly parsed to SDBC level statement: \n1. " + sExecutableQuery + "\n2. " + "SELECT * FROM ( " + sInnerCommand + " ) AS \"" + INNERPRODUCTSQUERY + "\"",
sExecutableQuery.equals("SELECT * FROM ( " + sInnerCommand + " ) AS \"" + INNERPRODUCTSQUERY + "\""));
}
/** tests the XParametersSupplier functionality
*/
- public void testParameters()
+ @Test public void testParameters()
{
try
{
@@ -241,8 +250,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
m_database.getDatabase().getDataSource().createQuery("orders for customer and product", "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" LIKE ?");
m_composer.setQuery(m_database.getDatabase().getDataSource().getQueryDefinition("orders for customer and product").getCommand());
- final XParametersSupplier suppParams = (XParametersSupplier) UnoRuntime.queryInterface(
- XParametersSupplier.class, m_composer);
+ final XParametersSupplier suppParams = UnoRuntime.queryInterface(XParametersSupplier.class, m_composer);
final XIndexAccess parameters = suppParams.getParameters();
final String expectedParamNames[] =
@@ -252,26 +260,25 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
};
final int paramCount = parameters.getCount();
- assure("composer did find wrong number of parameters in the nested queries.",
+ assertTrue("composer did find wrong number of parameters in the nested queries.",
paramCount == expectedParamNames.length);
for (int i = 0; i < paramCount; ++i)
{
- final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface(
- XPropertySet.class, parameters.getByIndex(i));
+ final XPropertySet parameter = UnoRuntime.queryInterface(XPropertySet.class, parameters.getByIndex(i));
final String paramName = (String) parameter.getPropertyValue("Name");
- assure("wrong parameter name at position " + (i + 1) + " (expected: " + expectedParamNames[i] + ", found: " + paramName + ")",
+ assertTrue("wrong parameter name at position " + (i + 1) + " (expected: " + expectedParamNames[i] + ", found: " + paramName + ")",
paramName.equals(expectedParamNames[i]));
}
}
catch (Exception e)
{
- assure("caught an exception: " + e, false);
+ fail("caught an exception: " + e);
}
}
- public void testConditionByColumn()
+ @Test public void testConditionByColumn()
{
try
{
@@ -282,23 +289,22 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
new NamedValue("AutomaticAddition", Boolean.valueOf(true))
};
final String serviceName = "com.sun.star.beans.PropertyBag";
- final XPropertyContainer filter = (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class,
- getORB().createInstanceWithArguments(serviceName, initArgs));
+ final XPropertyContainer filter = UnoRuntime.queryInterface(XPropertyContainer.class, getMSF().createInstanceWithArguments(serviceName, initArgs));
filter.addProperty("Name", PropertyAttribute.MAYBEVOID, "Comment");
filter.addProperty("RealName", PropertyAttribute.MAYBEVOID, "Comment");
filter.addProperty("TableName", PropertyAttribute.MAYBEVOID, "customers");
filter.addProperty("Value", PropertyAttribute.MAYBEVOID, "Good one.");
filter.addProperty("Type", PropertyAttribute.MAYBEVOID, Integer.valueOf(DataType.LONGVARCHAR));
- final XPropertySet column = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,filter);
+ final XPropertySet column = UnoRuntime.queryInterface(XPropertySet.class, filter);
m_composer.appendFilterByColumn(column, true,SQLFilterOperator.LIKE);
- assure("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next());
+ assertTrue("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next());
}
catch (Exception e)
{
// this is an error: the query is expected to be parseable
- assure("caught an exception: " + e, false);
+ fail("caught an exception: " + e);
}
}
@@ -311,18 +317,18 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
catch (Exception e)
{
// this is an error: the query is expected to be parseable
- assure("caught an exception: " + e, false);
+ fail("caught an exception: " + e);
}
final PropertyValue[][] disjunctiveNormalForm = m_composer.getStructuredFilter();
- assureEquals("DNF: wrong number of rows", _expectedDNF.length, disjunctiveNormalForm.length);
+ assertEquals("DNF: wrong number of rows", _expectedDNF.length, disjunctiveNormalForm.length);
for (int i = 0; i < _expectedDNF.length; ++i)
{
- assureEquals("DNF: wrong number of columns in row " + i, _expectedDNF[i].length, disjunctiveNormalForm[i].length);
+ assertEquals("DNF: wrong number of columns in row " + i, _expectedDNF[i].length, disjunctiveNormalForm[i].length);
for (int j = 0; j < _expectedDNF[i].length; ++j)
{
- assureEquals("DNF: wrong content in column " + j + ", row " + i,
+ assertEquals("DNF: wrong content in column " + j + ", row " + i,
_expectedDNF[i][j].Name, disjunctiveNormalForm[i][j].Name);
}
}
@@ -331,7 +337,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
/** tests the disjunctive normal form functionality, aka the structured filter,
* of the composer
*/
- public void testDisjunctiveNormalForm()
+ @Test public void testDisjunctiveNormalForm()
{
// a simple case: WHERE clause simply is a combination of predicates knitted with AND
String query =
diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java
index b8dae3f6f350..ba899a114205 100644
--- a/dbaccess/qa/complex/dbaccess/TestCase.java
+++ b/dbaccess/qa/complex/dbaccess/TestCase.java
@@ -31,7 +31,7 @@ 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.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import helper.FileTools;
@@ -40,13 +40,24 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-public abstract class TestCase extends complexlib.ComplexTestCase
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
+
+public abstract class TestCase
{
// --------------------------------------------------------------------------------------------------------
- protected final XMultiServiceFactory getORB()
- {
- return (XMultiServiceFactory)param.getMSF();
- }
+// protected final XMultiServiceFactory getORB()
+// {
+// return (XMultiServiceFactory)param.getMSF();
+// }
// --------------------------------------------------------------------------------------------------------
protected final XComponentContext getComponentContext()
@@ -54,13 +65,13 @@ public abstract class TestCase extends complexlib.ComplexTestCase
XComponentContext context = null;
try
{
- final XPropertySet orbProps = UnoRuntime.queryInterface( XPropertySet.class, getORB() );
+ final XPropertySet orbProps = UnoRuntime.queryInterface( XPropertySet.class, getMSF() );
context = UnoRuntime.queryInterface( XComponentContext.class,
orbProps.getPropertyValue( "DefaultContext" ) );
}
catch ( Exception ex )
{
- failed( "could not retrieve the ComponentContext" );
+ fail( "could not retrieve the ComponentContext" );
}
return context;
}
@@ -83,9 +94,11 @@ public abstract class TestCase extends complexlib.ComplexTestCase
*/
protected final String createTempFileURL() throws IOException
{
- final File documentFile = java.io.File.createTempFile( getTestObjectName(), ".odb" ).getAbsoluteFile();
+ final File documentFile = java.io.File.createTempFile( "dbaccess_test", ".odb" ).getAbsoluteFile();
if ( documentFile.exists() )
+ {
documentFile.delete();
+ }
return FileHelper.getOOoCompatibleFileURL( documentFile.toURI().toURL().toString() );
}
@@ -111,16 +124,40 @@ 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" ) );
+ getMSF().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 )
+// protected void assureException( Object _object, Class _unoInterfaceClass, String _methodName, Object[] _methodArgs,
+// Class _expectedExceptionClass )
+// {
+// assureException( UnoRuntime.queryInterface( _unoInterfaceClass, _object ), _methodName,
+// _methodArgs, _expectedExceptionClass );
+// }
+
+
+
+ protected XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
{
- assureException( UnoRuntime.queryInterface( _unoInterfaceClass, _object ), _methodName,
- _methodArgs, _expectedExceptionClass );
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
}
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
}
diff --git a/dbaccess/qa/complex/dbaccess/UISettings.java b/dbaccess/qa/complex/dbaccess/UISettings.java
index fc772b158f5f..8733f000f644 100644
--- a/dbaccess/qa/complex/dbaccess/UISettings.java
+++ b/dbaccess/qa/complex/dbaccess/UISettings.java
@@ -32,37 +32,45 @@ import com.sun.star.beans.XPropertySet;
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.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;
+// ---------- junit imports -----------------
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+// ------------------------------------------
+
public class UISettings extends TestCase
{
// --------------------------------------------------------------------------------------------------------
- public String[] getTestMethodNames()
- {
- return new String[] {
- "checkTableFormattingPersistence",
- "checkTransparentQueryColumnSettings"
- };
- }
-
- // --------------------------------------------------------------------------------------------------------
- public String getTestObjectName()
- {
- return "UISettings";
- }
+// public String[] getTestMethodNames()
+// {
+// return new String[] {
+// "checkTableFormattingPersistence",
+// "checkTransparentQueryColumnSettings"
+// };
+// }
+//
+// // --------------------------------------------------------------------------------------------------------
+// public String getTestObjectName()
+// {
+// return "UISettings";
+// }
// --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected
*/
- public void checkTableFormattingPersistence() throws java.lang.Exception
+ @Test public void checkTableFormattingPersistence() throws java.lang.Exception
{
// create, load, and connect a DB doc
- CRMDatabase database = new CRMDatabase( getORB(), true );
+ CRMDatabase database = new CRMDatabase( getMSF(), true );
// display a table
XFormController tableViewController = UnoRuntime.queryInterface( XFormController.class,
@@ -89,7 +97,7 @@ public class UISettings extends TestCase
// stay alive, and subsequent requests to load the doc will just reuse it, without really loading it.
docURL = copyToTempFile( docURL );
loadDocument( docURL );
- database = new CRMDatabase( getORB(), docURL );
+ database = new CRMDatabase( getMSF(), docURL );
// display the table, again
tableViewController = UnoRuntime.queryInterface( XFormController.class,
@@ -98,9 +106,9 @@ public class UISettings extends TestCase
tableViewController.getCurrentControl().getModel() );
// verify the properties
- assureEquals( "wrong font name", "Andale Sans UI", (String)tableControlModel.getPropertyValue( "FontName" ) );
- assureEquals( "wrong font height", (float)20, ((Float)tableControlModel.getPropertyValue( "FontHeight" )).floatValue() );
- assureEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) );
+ assertEquals( "wrong font name", "Andale Sans UI", (String)tableControlModel.getPropertyValue( "FontName" ) );
+ assertEquals( "wrong font height", (float)20, ((Float)tableControlModel.getPropertyValue( "FontHeight" )).floatValue() );
+ assertEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) );
// close the doc
database.saveAndClose();
@@ -111,10 +119,10 @@ public class UISettings extends TestCase
* settings
* @throws java.lang.Exception
*/
- public void checkTransparentQueryColumnSettings() throws java.lang.Exception
+ @Test public void checkTransparentQueryColumnSettings() throws java.lang.Exception
{
// create, load, and connect a DB doc
- CRMDatabase database = new CRMDatabase( getORB(), true );
+ CRMDatabase database = new CRMDatabase( getMSF(), true );
// display a table
XController tableView = database.loadSubComponent( DatabaseObject.TABLE, "customers" );
@@ -125,7 +133,7 @@ public class UISettings extends TestCase
// change the formatting of a table column
XPropertySet idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) );
- assure( "precondition not met: column already centered",
+ assertTrue( "precondition not met: column already centered",
((Short)idColumn.getPropertyValue( "Align" )).shortValue() != TextAlign.CENTER );
idColumn.setPropertyValue( "Align", TextAlign.CENTER );
@@ -143,7 +151,7 @@ public class UISettings extends TestCase
queryViewController.getCurrentControl().getModel() );
idColumn = UnoRuntime.queryInterface( XPropertySet.class, tableControlModel.getByName( "ID" ) );
- assure( "table column alignment was not propagated to the query column",
+ assertTrue( "table column alignment was not propagated to the query column",
((Short)idColumn.getPropertyValue( "Align" )).shortValue() == TextAlign.CENTER );
// save close the database document
diff --git a/dbaccess/qa/complex/dbaccess/makefile.mk b/dbaccess/qa/complex/dbaccess/makefile.mk
index 56a24c0292fc..4a3e0426fe1d 100755
--- a/dbaccess/qa/complex/dbaccess/makefile.mk
+++ b/dbaccess/qa/complex/dbaccess/makefile.mk
@@ -25,54 +25,109 @@
#
#*************************************************************************
-PRJ = ..$/..$/..
-TARGET = DbaComplexTests
-PRJNAME = $(TARGET)
-PACKAGE = complex$/dbaccess
-
-# --- Settings -----------------------------------------------------
-.INCLUDE: settings.mk
-
-.IF "$(SOLAR_JAVA)" == ""
-all:
- @echo "Java not available. Build skipped"
-
-.INCLUDE : target.mk
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
.ELSE
-#----- compile .java files -----------------------------------------
-
-JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar ConnectivityTools.jar
-JAVAFILES := $(shell @$(FIND) ./*.java)
-JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-#----- make a jar from compiled files ------------------------------
-
-MAXLINELENGTH = 100000
-
-JARCLASSDIRS = $(PACKAGE)
-JARTARGET = $(TARGET).jar
-JARCOMPRESS = TRUE
-
-RUNNER_ARGS = -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex
+PRJ = ../../..
+PRJNAME = dbaccess
+TARGET = qa_complex_dbaccess
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/dbaccess
+
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ ApplicationController.java \
+ Beamer.java \
+ CRMBasedTestCase.java \
+ CopyTableWizard.java \
+ DataSource.java \
+ DatabaseDocument.java \
+ Parser.java \
+ PropertyBag.java \
+ Query.java \
+ QueryInQuery.java \
+ RowSet.java \
+ SingleSelectQueryComposer.java \
+ UISettings.java \
+ TestCase.java
+
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ CopyTableInterActionHandler.java \
+ DatabaseApplication.java \
+ FileHelper.java \
+ RowSetEventListener.java
+
+
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar ConnectivityTools.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
+
+.END
-RUNNER_CALL = $(AUGMENT_LIBRARY_PATH) java
-
-# --- Targets ------------------------------------------------------
-
-.IF "$(depend)" == ""
-ALL : ALLTAR
-.ELSE
-ALL: ALLDEP
-.ENDIF
-
-.INCLUDE : target.mk
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+ALLTAR : javatest
-run: $(CLASSDIR)$/$(JARTARGET)
- +$(RUNNER_CALL) $(RUNNER_ARGS) -sce dbaccess.sce
+.END
-run_%: $(CLASSDIR)$/$(JARTARGET)
- +$(RUNNER_CALL) $(RUNNER_ARGS) -o complex.dbaccess.$(@:s/run_//)
-.ENDIF # "$(SOLAR_JAVA)" == ""
+#
+#
+# PRJ = ..$/..$/..
+# TARGET = DbaComplexTests
+# PRJNAME = $(TARGET)
+# PACKAGE = complex$/dbaccess
+#
+# # --- Settings -----------------------------------------------------
+# .INCLUDE: settings.mk
+#
+# .IF "$(SOLAR_JAVA)" == ""
+# all:
+# @echo "Java not available. Build skipped"
+#
+# .INCLUDE : target.mk
+# .ELSE
+#
+# #----- compile .java files -----------------------------------------
+#
+# JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar ConnectivityTools.jar
+# JAVAFILES := $(shell @$(FIND) ./*.java)
+# JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+#
+# #----- make a jar from compiled files ------------------------------
+#
+# MAXLINELENGTH = 100000
+#
+# JARCLASSDIRS = $(PACKAGE)
+# JARTARGET = $(TARGET).jar
+# JARCOMPRESS = TRUE
+#
+# RUNNER_ARGS = -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex
+#
+# RUNNER_CALL = $(AUGMENT_LIBRARY_PATH) java
+#
+# # --- Targets ------------------------------------------------------
+#
+# .IF "$(depend)" == ""
+# ALL : ALLTAR
+# .ELSE
+# ALL: ALLDEP
+# .ENDIF
+#
+# .INCLUDE : target.mk
+#
+#
+# run: $(CLASSDIR)$/$(JARTARGET)
+# +$(RUNNER_CALL) $(RUNNER_ARGS) -sce dbaccess.sce
+#
+# run_%: $(CLASSDIR)$/$(JARTARGET)
+# +$(RUNNER_CALL) $(RUNNER_ARGS) -o complex.dbaccess.$(@:s/run_//)
+#
+# .ENDIF # "$(SOLAR_JAVA)" == ""
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 6ee7a2b8ea4c..5de2c497c031 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -197,9 +197,10 @@ void OKeySet::initColumns()
m_pParameterNames.reset( new SelectColumnsMetaData(bCase) );
m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) );
}
-void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable
- ,const Reference<XDatabaseMetaData>& i_xMeta
- ,const Reference<XNameAccess>& i_xQueryColumns)
+void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable,
+ const ::rtl::OUString& i_rUpdateTableName,
+ const Reference<XDatabaseMetaData>& i_xMeta,
+ const Reference<XNameAccess>& i_xQueryColumns)
{
// first ask the database itself for the best columns which can be used
Sequence< ::rtl::OUString> aBestColumnNames;
@@ -220,37 +221,48 @@ void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable
xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i];
}
- if ( m_sUpdateTableName.getLength() )
+ ::rtl::OUString sUpdateTableName( i_rUpdateTableName );
+ if ( sUpdateTableName.getLength() == 0 )
{
- ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames),true);
- ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames),true);
- ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,m_sUpdateTableName,(*m_pParameterNames),true);
+ OSL_ENSURE( false, "OKeySet::findTableColumnsMatching_throw: This is a fallback only - it won't work when the table has an alias name." );
+ // If i_aTable originates from a query composer, and is a table which appears with an alias in the SELECT statement,
+ // then the below code will not produce correct results.
+ // For instance, imagine a "SELECT alias.col FROM table AS alias". Now i_aTable would be the table named
+ // "table", so our sUpdateTableName would be "table" as well - not the information about the "alias" is
+ // already lost here.
+ // now getColumnPositions would travers the columns, and check which of them belong to the table denoted
+ // by sUpdateTableName. Since the latter is "table", but the columns only know that they belong to a table
+ // named "alias", there will be no matching - so getColumnPositions wouldn't find anything.
+
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ Reference<XPropertySet> xTableProp( i_aTable, UNO_QUERY_THROW );
+ xTableProp->getPropertyValue( PROPERTY_CATALOGNAME )>>= sCatalog;
+ xTableProp->getPropertyValue( PROPERTY_SCHEMANAME ) >>= sSchema;
+ xTableProp->getPropertyValue( PROPERTY_NAME ) >>= sTable;
+ sUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
}
- else
+
+ ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sUpdateTableName,(*m_pKeyColumnNames),true);
+ ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sUpdateTableName,(*m_pColumnNames),true);
+ ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sUpdateTableName,(*m_pParameterNames),true);
+
+ if ( m_pKeyColumnNames->empty() )
{
- ::rtl::OUString sCatalog,sSchema,sTable;
- Reference<XPropertySet> xTableProp(i_aTable,UNO_QUERY);
- Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME);
- aCatalog >>= sCatalog;
- xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema;
- xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable;
- const ::rtl::OUString sComposedUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
- ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sComposedUpdateTableName,(*m_pKeyColumnNames),true);
- ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sComposedUpdateTableName,(*m_pColumnNames),true);
- ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sComposedUpdateTableName,(*m_pParameterNames),true);
+ ::dbtools::throwGenericSQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not find any key column." ) ), *this );
}
- SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin();
- SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end();
- for(;aPosIter != aPosEnd;++aPosIter)
+ for ( SelectColumnsMetaData::const_iterator keyColumn = m_pKeyColumnNames->begin();
+ keyColumn != m_pKeyColumnNames->end();
+ ++keyColumn
+ )
{
- if ( xTblColumns->hasByName(aPosIter->second.sRealName) )
- {
- Reference<XPropertySet> xProp(xTblColumns->getByName(aPosIter->second.sRealName),UNO_QUERY);
- sal_Bool bAuto = sal_False;
- if( (xProp->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAuto) && bAuto)
- m_aAutoColumns.push_back(aPosIter->first);
- }
+ if ( !xTblColumns->hasByName( keyColumn->second.sRealName ) )
+ continue;
+
+ Reference<XPropertySet> xProp( xTblColumns->getByName( keyColumn->second.sRealName ), UNO_QUERY );
+ sal_Bool bAuto = sal_False;
+ if ( ( xProp->getPropertyValue( PROPERTY_ISAUTOINCREMENT ) >>= bAuto ) && bAuto )
+ m_aAutoColumns.push_back( keyColumn->first );
}
}
::rtl::OUStringBuffer OKeySet::createKeyFilter()
@@ -286,7 +298,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
Reference<XColumnsSupplier> xQueryColSup(m_xComposer,UNO_QUERY);
const Reference<XNameAccess> xQueryColumns = xQueryColSup->getColumns();
- findTableColumnsMatching_throw(makeAny(m_xTable),xMeta,xQueryColumns);
+ findTableColumnsMatching_throw(makeAny(m_xTable),m_sUpdateTableName,xMeta,xQueryColumns);
// the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
// without extra varaible to be set
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 212ec237699e..1266c271040a 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -142,9 +142,10 @@ namespace dbaccess
void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData);
void initColumns();
- void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns);
+ void findTableColumnsMatching_throw( const ::com::sun::star::uno::Any& i_aTable,
+ const ::rtl::OUString& i_rUpdateTableName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& i_xMeta,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns);
::rtl::OUStringBuffer createKeyFilter();
void tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch);
void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions = ::std::vector<sal_Int32>());
diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx
index 2a9ac96ce82b..99bbc17f1f0f 100644
--- a/dbaccess/source/core/api/OptimisticSet.cxx
+++ b/dbaccess/source/core/api/OptimisticSet.cxx
@@ -133,7 +133,7 @@ void OptimisticSet::construct(const Reference< XResultSet>& _xDriverSet,const ::
const ::rtl::OUString* pTableNameEnd = pTableNameIter + aTableNames.getLength();
for( ; pTableNameIter != pTableNameEnd ; ++pTableNameIter)
{
- findTableColumnsMatching_throw(xTables->getByName(*pTableNameIter),xMeta,xQueryColumns);
+ findTableColumnsMatching_throw(xTables->getByName(*pTableNameIter),*pTableNameIter,xMeta,xQueryColumns);
}
// the first row is empty because it's now easier for us to distinguish when we are beforefirst or first
diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx
index 92e29ac784ba..be9984938e01 100644
--- a/dbaccess/source/core/api/RowSetCache.cxx
+++ b/dbaccess/source/core/api/RowSetCache.cxx
@@ -28,84 +28,44 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
-#ifndef _COMPHELPER_SEQSTREAM_HXX
-#include <comphelper/seqstream.hxx>
-#endif
-#ifndef _COMPHELPER_UNO3_HXX_
-#include <comphelper/uno3.hxx>
-#endif
-#ifndef _COMPHELPER_EXTRACT_HXX_
-#include <comphelper/extract.hxx>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
-#include <com/sun/star/sdbcx/KeyType.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_RESULTSETCONCURRENCY_HPP_
-#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
-#include <com/sun/star/sdbc/ColumnValue.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
-#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
-#include <com/sun/star/sdbcx/Privilege.hpp>
-#endif
-#ifndef _DBACORE_DATACOLUMN_HXX_
-#include "CRowSetDataColumn.hxx"
-#endif
-#ifndef DBACCESS_CORE_API_CROWSETCOLUMN_HXX
+
+#include "BookmarkSet.hxx"
#include "CRowSetColumn.hxx"
-#endif
-#ifndef DBACCESS_CORE_API_ROWSETBASE_HXX
+#include "CRowSetDataColumn.hxx"
+#include "KeySet.hxx"
+#include "OptimisticSet.hxx"
#include "RowSetBase.hxx"
-#endif
+#include "RowSetCache.hxx"
+#include "StaticSet.hxx"
+#include "WrappedResultSet.hxx"
+#include "core_resource.hrc"
+#include "core_resource.hxx"
+#include "dbastrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/uno3.hxx>
#include <connectivity/dbexception.hxx>
-#include <connectivity/sqlparse.hxx>
-#include <connectivity/sqlnode.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/sqliterator.hxx>
-#ifndef _COMPHELPER_PROPERTY_HXX_
-#include <comphelper/property.hxx>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
-#include <com/sun/star/sdbcx/CompareBookmark.hpp>
-#endif
-#ifndef _TOOLS_DEBUG_HXX
+#include <connectivity/sqlnode.hxx>
+#include <connectivity/sqlparse.hxx>
#include <tools/debug.hxx>
-#endif
+#include <tools/diagnose_ex.h>
#include <algorithm>
-#ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX
-#include "RowSetCache.hxx"
-#endif
-#ifndef _DBA_CORE_RESOURCE_HXX_
-#include "core_resource.hxx"
-#endif
-#ifndef _DBA_CORE_RESOURCE_HRC_
-#include "core_resource.hrc"
-#endif
-#ifndef DBACCESS_CORE_API_BOOKMARKSET_HXX
-#include "BookmarkSet.hxx"
-#endif
-#ifndef DBACCESS_CORE_API_STATICSET_HXX
-#include "StaticSet.hxx"
-#endif
-#ifndef DBACCESS_CORE_API_KEYSET_HXX
-#include "KeySet.hxx"
-#endif
-#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
-#include "dbastrings.hrc"
-#endif
-#include "WrappedResultSet.hxx"
-#include "OptimisticSet.hxx"
using namespace dbaccess;
using namespace dbtools;
@@ -228,7 +188,10 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs,
}
catch(const Exception&)
{
+ DBG_UNHANDLED_EXCEPTION();
}
+ m_pCacheSet = NULL;
+ m_xCacheSet.clear();
}
else
{
diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
index e75c980e2a93..5d7a4a4e368e 100644
--- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx
+++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx
@@ -223,7 +223,7 @@ private:
void impl_fillRowSet_throw();
void impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies);
bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies);
- void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >& i_aColumnNames);
+ void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_aColumnNames);
void impl_invalidateParameter_nothrow();
::com::sun::star::uno::Any impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const;
diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
index 802e052297f9..ab0ccc737a11 100644
--- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx
+++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx
@@ -31,10 +31,12 @@
#include "dbastrings.hrc"
#include "cppuhelper/implbase1.hxx"
#include <comphelper/types.hxx>
+#include <comphelper/namedvaluecollection.hxx>
#include <connectivity/FValue.hxx>
#include <connectivity/dbtools.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx>
+#include <tools/diagnose_ex.h>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/sdb/XCompletedExecution.hpp>
@@ -205,22 +207,24 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
osl::ResettableMutexGuard aClearForNotifies(m_aMutex);
if ( createDataSourcePossible(_aArguments) )
{
- sal_Bool bHasCategories = sal_True;
- uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames;
- const beans::PropertyValue* pArgIter = _aArguments.getConstArray();
- const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength();
- for(;pArgIter != pArgEnd;++pArgIter)
+ try
{
- if ( pArgIter->Name.equalsAscii("HasCategories") )
- {
- pArgIter->Value >>= bHasCategories;
-
- }
- else if ( pArgIter->Name.equalsAscii("ComplexColumnDescriptions") )
- {
- pArgIter->Value >>= aColumnNames;
- }
+ uno::Reference< chart::XChartDataArray> xChartData( m_xInternal, uno::UNO_QUERY_THROW );
+ xChartData->setData( uno::Sequence< uno::Sequence< double > >() );
+ xChartData->setColumnDescriptions( uno::Sequence< ::rtl::OUString >() );
+ if ( m_xInternal->hasDataByRangeRepresentation( ::rtl::OUString::valueOf( sal_Int32(0) ) ) )
+ m_xInternal->deleteSequence(0);
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
}
+
+ ::comphelper::NamedValueCollection aArgs( _aArguments );
+ const sal_Bool bHasCategories = aArgs.getOrDefault( "HasCategories", sal_True );
+ uno::Sequence< ::rtl::OUString > aColumnNames =
+ aArgs.getOrDefault( "ColumnDescriptions", uno::Sequence< ::rtl::OUString >() );
+
bool bRet = false;
if ( m_Command.getLength() != 0 && m_xActiveConnection.is() )
{
@@ -240,10 +244,10 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY);
if ( xIni.is() )
{
- uno::Sequence< uno::Any > aArgs(1);
+ uno::Sequence< uno::Any > aInitArgs(1);
beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
- aArgs[0] <<= aParam;
- xIni->initialize(aArgs);
+ aInitArgs[0] <<= aParam;
+ xIni->initialize(aInitArgs);
}
}
@@ -254,41 +258,36 @@ uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::creat
uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & _xDataSource) throw (uno::RuntimeException)
{
- uno::Sequence< beans::PropertyValue > aArguments( 4 );
- aArguments[0] = beans::PropertyValue(
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellRangeRepresentation")), -1, uno::Any(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ),
- beans::PropertyState_DIRECT_VALUE );
- aArguments[1] = beans::PropertyValue(
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")), -1, uno::makeAny( chart::ChartDataRowSource_COLUMNS ),
- beans::PropertyState_DIRECT_VALUE );
+ ::comphelper::NamedValueCollection aArguments;
+ aArguments.put( "CellRangeRepresentation", uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) );
+ aArguments.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
// internal data always contains labels and categories
- aArguments[2] = beans::PropertyValue(
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
+ aArguments.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
+
sal_Bool bHasCategories = sal_False;
if( _xDataSource.is())
{
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences());
- const sal_Int32 nCount( aSequences.getLength());
- for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
- {
- if( aSequences[nIdx].is() )
- {
- uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY );
- ::rtl::OUString aRole;
- if( xSeqProp.is() &&
- (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) &&
- aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
- {
- bHasCategories = sal_True;
- break;
- }
- }
- }
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences());
+ const sal_Int32 nCount( aSequences.getLength());
+ for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+ {
+ if( aSequences[nIdx].is() )
+ {
+ uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY );
+ ::rtl::OUString aRole;
+ if ( xSeqProp.is()
+ && ( xSeqProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" ) ) ) >>= aRole )
+ && aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "categories" ) )
+ )
+ {
+ bHasCategories = sal_True;
+ break;
+ }
+ }
+ }
}
-
- aArguments[3] = beans::PropertyValue(
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1, uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
- return aArguments;
+ aArguments.put( "HasCategories", uno::makeAny( bHasCategories ) );
+ return aArguments.getPropertyValues();
}
// -----------------------------------------------------------------------------
@@ -649,66 +648,136 @@ void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard&
if ( impl_fillParameters_nothrow(_rClearForNotifies) )
m_xRowSet->execute();
}
+
// -----------------------------------------------------------------------------
-void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< uno::Sequence< ::rtl::OUString > >& i_aColumnNames)
+namespace
{
- // clear the data before fill the new one
- uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY);
- if ( xChartData.is() )
+ struct ColumnDescription
{
- xChartData->setData(uno::Sequence< uno::Sequence<double> >());
- xChartData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >());
- if ( m_xInternal->hasDataByRangeRepresentation(::rtl::OUString::valueOf(sal_Int32(0))) )
- m_xInternal->deleteSequence(0);
- }
+ ::rtl::OUString sName;
+ sal_Int32 nResultSetPosition;
+ sal_Int32 nDataType;
+
+ ColumnDescription()
+ :sName()
+ ,nResultSetPosition( 0 )
+ ,nDataType( sdbc::DataType::VARCHAR )
+ {
+ }
+ explicit ColumnDescription( const ::rtl::OUString& i_rName )
+ :sName( i_rName )
+ ,nResultSetPosition( 0 )
+ ,nDataType( sdbc::DataType::VARCHAR )
+ {
+ }
+ };
- uno::Reference< sdbcx::XColumnsSupplier> xColSup(m_xRowSet,uno::UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xColumns = xColSup->getColumns();
- uno::Sequence< ::rtl::OUString > aColumns;
+ struct CreateColumnDescription : public ::std::unary_function< ::rtl::OUString, ColumnDescription >
+ {
+ ColumnDescription operator()( const ::rtl::OUString& i_rName )
+ {
+ return ColumnDescription( i_rName );
+ }
+ };
+
+ struct SelectColumnName : public ::std::unary_function< ColumnDescription, ::rtl::OUString >
+ {
+ const ::rtl::OUString& operator()( const ColumnDescription& i_rColumn )
+ {
+ return i_rColumn.sName;
+ }
+ };
+}
+
+// -----------------------------------------------------------------------------
+void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories,const uno::Sequence< ::rtl::OUString >& i_aColumnNames)
+{
+ // clear the data before fill the new one
+ uno::Reference< sdbcx::XColumnsSupplier > xColSup(m_xRowSet,uno::UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xColumns( xColSup->getColumns(), uno::UNO_SET_THROW );
+ const uno::Sequence< ::rtl::OUString > aRowSetColumnNames( xColumns->getElementNames() );
+
+ typedef ::std::vector< ColumnDescription > ColumnDescriptions;
+ ColumnDescriptions aColumns;
+ bool bFirstColumnIsCategory = _bHasCategories;
if ( i_aColumnNames.getLength() )
{
- aColumns.realloc(1);
- aColumns[0] = xColumns->getElementNames()[0];
- for(sal_Int32 i = 0 ; i < i_aColumnNames.getLength();++i)
+ // some normalizations ...
+ uno::Sequence< ::rtl::OUString > aImposedColumnNames( i_aColumnNames );
+
+ // strangely, there exist documents where the ColumnDescriptions end with a number of empty strings. /me
+ // thinks they're generated when you have a chart based on a result set with n columns, but remove some
+ // of those columns from the chart - it looks like a bug in the report XML export to me.
+ // So, get rid of the "trailing" empty columns
+ sal_Int32 nLastNonEmptyColName = aImposedColumnNames.getLength() - 1;
+ for ( ; nLastNonEmptyColName >= 0; --nLastNonEmptyColName )
{
- if ( i_aColumnNames[i].getLength() )
+ if ( aImposedColumnNames[ nLastNonEmptyColName ].getLength() != 0 )
+ break;
+ }
+ aImposedColumnNames.realloc( nLastNonEmptyColName + 1 );
+
+ // second, for X-Y-charts the ColumnDescriptions exported by chart miss the name of the first (non-category)
+ // column. This, this results in a ColumnDescriptions array like <"", "col2", "col3">, where you'd expect
+ // <"col1", "col2", "col3">.
+ // Fix this with some heuristics:
+ if ( ( aImposedColumnNames.getLength() > 0 ) && ( aImposedColumnNames[0].getLength() == 0 ) )
+ {
+ const sal_Int32 nAssumedRowSetColumnIndex = _bHasCategories ? 1 : 0;
+ if ( nAssumedRowSetColumnIndex < aRowSetColumnNames.getLength() )
+ aImposedColumnNames[0] = aRowSetColumnNames[ nAssumedRowSetColumnIndex ];
+ }
+
+ const sal_Int32 nCount = aImposedColumnNames.getLength();
+ for ( sal_Int32 i = 0 ; i < nCount; ++i )
+ {
+ const ::rtl::OUString sColumnName( aImposedColumnNames[i] );
+ if ( !xColumns->hasByName( sColumnName ) )
+ continue;
+
+ if ( _bHasCategories && aColumns.empty() )
{
- sal_Int32 nCount = aColumns.getLength();
- aColumns.realloc(nCount+1);
- aColumns[nCount] = i_aColumnNames[i][0];
+ if ( aRowSetColumnNames.getLength() )
+ aColumns.push_back( ColumnDescription( aRowSetColumnNames[0] ) );
+ else
+ aColumns.push_back( ColumnDescription( sColumnName ) );
+ bFirstColumnIsCategory = true;
}
+ aColumns.push_back( ColumnDescription( sColumnName ) );
}
}
- else
+ if ( aColumns.empty() )
{
- aColumns = xColumns->getElementNames();
+ aColumns.resize( aRowSetColumnNames.getLength() );
+ ::std::transform(
+ aRowSetColumnNames.getConstArray(),
+ aRowSetColumnNames.getConstArray() + aRowSetColumnNames.getLength(),
+ aColumns.begin(),
+ CreateColumnDescription()
+ );
}
+
// fill the data
- uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY_THROW);
- uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY_THROW);
- uno::Reference< sdbc::XResultSetMetaData> xResultSetMetaData = uno::Reference< sdbc::XResultSetMetaDataSupplier>(m_xRowSet,uno::UNO_QUERY)->getMetaData();
- uno::Reference< sdbc::XColumnLocate> xColumnLocate(m_xRowSet,uno::UNO_QUERY_THROW);
-
- ::std::vector<sal_Int32> aColumnTypes;
- uno::Sequence< uno::Any > aLabelArgs(1);
- const sal_Int32 nCount = aColumns.getLength();
- if ( nCount )
- aColumnTypes.push_back(xResultSetMetaData->getColumnType(1));
-
- ::std::vector< sal_Int32 > aColumnPositions;
- const ::rtl::OUString* pIter = aColumns.getConstArray();
- const ::rtl::OUString* pEnd = pIter + aColumns.getLength();
- for(sal_Int32 k = 0;pIter != pEnd;++pIter,++k)
+ uno::Reference< sdbc::XResultSet> xRes( m_xRowSet, uno::UNO_QUERY_THROW );
+ uno::Reference< sdbc::XRow> xRow( m_xRowSet,uno::UNO_QUERY_THROW );
+ uno::Reference< sdbc::XResultSetMetaDataSupplier > xSuppMeta( m_xRowSet,uno::UNO_QUERY_THROW );
+ uno::Reference< sdbc::XResultSetMetaData > xResultSetMetaData( xSuppMeta->getMetaData(), uno::UNO_SET_THROW );
+ uno::Reference< sdbc::XColumnLocate > xColumnLocate( m_xRowSet, uno::UNO_QUERY_THROW );
+
+ for ( ColumnDescriptions::iterator col = aColumns.begin();
+ col != aColumns.end();
+ ++col
+ )
{
- aColumnPositions.push_back(xColumnLocate->findColumn(*pIter));
- uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(*pIter),uno::UNO_QUERY);
- sal_Int32 nType = sdbc::DataType::VARCHAR;
- if ( xColumn.is() )
- {
- m_aNumberFormats.insert( ::std::map< ::rtl::OUString,uno::Any>::value_type(::rtl::OUString::valueOf(k),xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT)));
- xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
- }
- aColumnTypes.push_back(nType);
+ col->nResultSetPosition = xColumnLocate->findColumn( col->sName );
+
+ const uno::Reference< beans::XPropertySet > xColumn( xColumns->getByName( col->sName ), uno::UNO_QUERY_THROW );
+ const uno::Any aNumberFormat( xColumn->getPropertyValue( PROPERTY_NUMBERFORMAT ) );
+ OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= col->nDataType );
+
+ const sal_Int32 columnIndex = col - aColumns.begin();
+ const ::rtl::OUString sRangeName = ::rtl::OUString::valueOf( columnIndex );
+ m_aNumberFormats.insert( ::std::map< ::rtl::OUString, uno::Any >::value_type( sRangeName, aNumberFormat ) );
}
::std::vector< ::rtl::OUString > aRowLabels;
@@ -719,31 +788,31 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat
{
++nRowCount;
- aValue.fill(1,aColumnTypes[0],xRow);
- aRowLabels.push_back(aValue.getString());
+ aValue.fill( aColumns[0].nResultSetPosition, aColumns[0].nDataType, xRow );
+ aRowLabels.push_back( aValue.getString() );
+
::std::vector< double > aRow;
- ::std::vector< sal_Int32 >::iterator aColumnPosIter = aColumnPositions.begin();
- ::std::vector< sal_Int32 >::iterator aColumnPosEnd = aColumnPositions.end();
- sal_Int32 i = 0;
- if ( _bHasCategories )
+ for ( ColumnDescriptions::const_iterator col = aColumns.begin();
+ col != aColumns.end();
+ ++col
+ )
{
- ++aColumnPosIter;
- ++i;
- }
- for (; aColumnPosIter != aColumnPosEnd; ++aColumnPosIter,++i)
- {
- aValue.fill(*aColumnPosIter,aColumnTypes[i],xRow);
+ if ( bFirstColumnIsCategory && ( col == aColumns.begin() ) )
+ continue;
+
+ aValue.fill( col->nResultSetPosition, col->nDataType, xRow );
if ( aValue.isNull() )
{
double nValue;
::rtl::math::setNan( &nValue );
- aRow.push_back(nValue);
+ aRow.push_back( nValue );
}
else
- aRow.push_back(aValue.getDouble());
+ aRow.push_back( aValue.getDouble() );
}
- aDataValues.push_back(aRow);
- } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) )
+
+ aDataValues.push_back( aRow );
+ }
// insert default data when no rows exist
if ( !nRowCount )
@@ -759,19 +828,29 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCat
aRowLabels.push_back(::rtl::OUString::valueOf(h+1));
::std::vector< double > aRow;
const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]);
- for (sal_Int32 j = 0; j < (nCount-1); ++j,++k)
+ for (size_t j = 0; j < (aColumns.size()-1); ++j,++k)
{
if ( k >= nSize )
k = 0;
aRow.push_back(fDefaultData[k]);
- } // for (sal_Int32 j = 0,k = 0; j < (nCount-1); ++j,++k)
+ } // for (sal_Int32 j = 0,k = 0; j < (aColumns.size()-1); ++j,++k)
aDataValues.push_back(aRow);
}
} // if ( !nRowCount )
uno::Reference< chart::XChartDataArray> xData(m_xInternal,uno::UNO_QUERY);
xData->setRowDescriptions(uno::Sequence< ::rtl::OUString >(&(*aRowLabels.begin()),aRowLabels.size()));
- xData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >(aColumns.getArray()+ (_bHasCategories ? 1 : 0),aColumns.getLength() - (_bHasCategories ? 1 : 0) ));
+
+ const size_t nOffset = bFirstColumnIsCategory ? 1 : 0;
+ uno::Sequence< ::rtl::OUString > aColumnDescriptions( aColumns.size() - nOffset );
+ ::std::transform(
+ aColumns.begin() + nOffset,
+ aColumns.end(),
+ aColumnDescriptions.getArray(),
+ SelectColumnName()
+ );
+ xData->setColumnDescriptions( aColumnDescriptions );
+
uno::Sequence< uno::Sequence< double > > aData(aDataValues.size());
uno::Sequence< double >* pDataIter = aData.getArray();
uno::Sequence< double >* pDataEnd = pDataIter + aData.getLength();
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index 9d659c26e707..595d9b412851 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -1789,7 +1789,7 @@ bool OApplicationController::onEntryDoubleClick( SvTreeListBox& _rTree )
}
catch(const Exception&)
{
- OSL_ENSURE(0,"Could not open element!");
+ DBG_UNHANDLED_EXCEPTION();
}
}
return false; // not handled
@@ -1842,12 +1842,20 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const
getContainer()->showPreview(NULL);
}
+ bool isStandaloneDocument = false;
switch ( _eType )
{
case E_REPORT:
+ if ( _eOpenMode != E_OPEN_DESIGN )
+ {
+ // reports which are opened in a mode other than design are no sub components of our application
+ // component, but standalone documents.
+ isStandaloneDocument = true;
+ }
+ // NO break!
case E_FORM:
{
- if ( !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) )
+ if ( isStandaloneDocument || !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) )
{
::std::auto_ptr< OLinkedDocumentsAccess > aHelper = getDocumentsAccess( _eType );
if ( !aHelper->isConnected() )
@@ -1856,7 +1864,8 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const
Reference< XComponent > xDefinition;
xRet = aHelper->open( _sName, xDefinition, _eOpenMode, _rAdditionalArguments );
- onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition );
+ if ( !isStandaloneDocument )
+ onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition );
}
}
break;
@@ -2781,9 +2790,9 @@ void OApplicationController::containerFound( const Reference< XContainer >& _xCo
_xContainer->addContainerListener(this);
}
}
- catch(Exception)
+ catch(const Exception&)
{
- OSL_ENSURE(0,"Could not listener on the container!");
+ DBG_UNHANDLED_EXCEPTION();
}
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx
index 435c6ff25fef..9965f00dbd21 100644
--- a/dbaccess/source/ui/app/AppControllerGen.cxx
+++ b/dbaccess/source/ui/app/AppControllerGen.cxx
@@ -676,7 +676,8 @@ void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, co
try
{
- m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _rxDefinition.is() ? _rxDefinition : _xDocument );
+ OSL_ENSURE( _xDocument.is(), "OApplicationController::onDocumentOpened: is there any *valid* scenario where this fails?" );
+ m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument.is() ? _xDocument : _rxDefinition );
if ( _rxDefinition.is() )
{
diff --git a/reportdesign/prj/build.lst b/reportdesign/prj/build.lst
index 781eb91eccb3..aa73b032fafa 100644
--- a/reportdesign/prj/build.lst
+++ b/reportdesign/prj/build.lst
@@ -13,3 +13,6 @@ rd reportdesign\source\ui\inspection nmake
rd reportdesign\source\filter\xml nmake - all rd_filter_xml rd_inc NULL
rd reportdesign\util nmake - all rd_util rd_api rd_res rd_shared rd_uimisc rd_uidlg rd_uireport rd_uiinspection rd_sdr rd_misc rd_filter_xml NULL
+# has problems in m78, in m83 also
+# rd reportdesign\qa\complex\reportdesign nmake - all rd_qa_complex NULL
+
diff --git a/reportdesign/qa/complex/reportdesign/FileURL.java b/reportdesign/qa/complex/reportdesign/FileURL.java
new file mode 100644
index 000000000000..9d2cdb89bd0e
--- /dev/null
+++ b/reportdesign/qa/complex/reportdesign/FileURL.java
@@ -0,0 +1,62 @@
+/*
+ * ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 complex.reportdesign;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ *
+ * @author ll93751
+ */
+public class FileURL
+{
+ String m_sFileURL;
+
+ public FileURL(String _sFileURL)
+ {
+ m_sFileURL = _sFileURL;
+ }
+ public boolean exists()
+ {
+ try
+ {
+ final URI aURI = new URI(m_sFileURL);
+ final File aFile = new File(aURI);
+ return aFile.exists();
+ }
+ catch (URISyntaxException ex)
+ {
+ System.out.println("Error: URI is wrong. '" + m_sFileURL + "': " + ex.getMessage());
+ }
+ return false;
+ }
+}
diff --git a/reportdesign/qa/complex/ReportDesignerTest.java b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java
index 3bbb9a42fe26..346c28569929 100755
--- a/reportdesign/qa/complex/ReportDesignerTest.java
+++ b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java
@@ -25,7 +25,7 @@
*
************************************************************************/
-package complex;
+package complex.reportdesign;
import java.io.File;
import java.util.ArrayList;
@@ -50,11 +50,11 @@ import com.sun.star.util.XCloseable;
// import util.BasicMacroTools;
// import util.DesktopTools;
// import util.dbg;
-import complexlib.ComplexTestCase;
-import util.utils;
+// import complexlib.ComplexTestCase;
+// import util.utils;
import helper.OfficeProvider;
import helper.URLHelper;
-import helper.OfficeWatcher;
+// import helper.OfficeWatcher;
import convwatch.DB;
@@ -76,7 +76,13 @@ import convwatch.DB;
// import util.DynamicClassLoader;
// import java.util.StringTokenizer;
-
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
class PropertySetHelper
@@ -84,7 +90,7 @@ class PropertySetHelper
XPropertySet m_xPropertySet;
public PropertySetHelper(Object _aObj)
{
- m_xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, _aObj);
+ m_xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _aObj);
}
/**
@@ -152,57 +158,73 @@ class PropertyHelper
}
}
-public class ReportDesignerTest extends ComplexTestCase {
+public class ReportDesignerTest
+{
String mTestDocumentPath;
- public String[] getTestMethodNames()
- {
- return new String[] {"firsttest"};
- }
-
- private void checkIfOfficeExists(String _sOfficePathWithTrash)
- {
- String sOfficePath = "";
- int nIndex = _sOfficePathWithTrash.indexOf("soffice.exe");
- if (nIndex > 0)
- {
- sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 11);
- }
- else
- {
- nIndex = _sOfficePathWithTrash.indexOf("soffice");
- if (nIndex > 0)
- {
- sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 7);
- }
- }
-
- log.println(sOfficePath);
- File sOffice = new File(sOfficePath);
- if (! sOffice.exists())
- {
- log.println("ERROR: There exists no office installation at given path: '" + sOfficePath + "'");
- System.exit(0);
- }
- }
-
-
- private static XDesktop m_xDesktop = null;
- public static XDesktop getXDesktop()
+// public String[] getTestMethodNames()
+// {
+// return new String[] {"firsttest"};
+// }
+
+ @Before public void before()
+ {
+ System.out.println("before");
+ // String tempdir = System.getProperty("java.io.tmpdir");
+ //
+ int dummy = 0;
+ // m_xXMultiServiceFactory = getMSF();
+ }
+
+ @After public void after()
+ {
+ System.out.println("after");
+ }
+
+// private void checkIfOfficeExists(String _sOfficePathWithTrash)
+// {
+// String sOfficePath = "";
+// int nIndex = _sOfficePathWithTrash.indexOf("soffice.exe");
+// if (nIndex > 0)
+// {
+// sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 11);
+// }
+// else
+// {
+// nIndex = _sOfficePathWithTrash.indexOf("soffice");
+// if (nIndex > 0)
+// {
+// sOfficePath = _sOfficePathWithTrash.substring(0, nIndex + 7);
+// }
+// }
+//
+// System.out.println(sOfficePath);
+// File sOffice = new File(sOfficePath);
+// if (! sOffice.exists())
+// {
+// System.out.println("ERROR: There exists no office installation at given path: '" + sOfficePath + "'");
+// System.exit(0);
+// }
+// }
+
+
+ private XDesktop m_xDesktop = null;
+ public XDesktop getXDesktop()
{
if (m_xDesktop == null)
{
try
{
- XInterface xInterface = (XInterface) m_xXMultiServiceFactory.createInstance( "com.sun.star.frame.Desktop" );
- m_xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ XInterface xInterface = (XInterface) getMSF().createInstance( "com.sun.star.frame.Desktop" );
+ m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ assertNotNull("Can't get XDesktop", m_xDesktop);
}
catch (com.sun.star.uno.Exception e)
{
- log.println("ERROR: uno.Exception caught");
- log.println("Message: " + e.getMessage());
+ System.out.println("ERROR: uno.Exception caught");
+ System.out.println("Message: " + e.getMessage());
}
}
return m_xDesktop;
@@ -226,28 +248,27 @@ public class ReportDesignerTest extends ComplexTestCase {
private OfficeProvider m_aProvider = null;
- private static XMultiServiceFactory m_xXMultiServiceFactory = null;
- private void startOffice()
- {
- // int tempTime = param.getInt("SingleTimeOut");
- param.put("TimeOut", new Integer(300000));
- System.out.println("TimeOut: " + param.getInt("TimeOut"));
- System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut"));
-
- // OfficeProvider aProvider = null;
- m_aProvider = new OfficeProvider();
- m_xXMultiServiceFactory = (XMultiServiceFactory) m_aProvider.getManager(param);
- param.put("ServiceFactory", m_xXMultiServiceFactory);
- }
-
- private void stopOffice()
- {
- if (m_aProvider != null)
- {
- m_aProvider.closeExistingOffice(param, true);
- m_aProvider = null;
- }
- }
+// private void startOffice()
+// {
+// // int tempTime = param.getInt("SingleTimeOut");
+// param.put("TimeOut", new Integer(300000));
+// System.out.println("TimeOut: " + param.getInt("TimeOut"));
+// System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut"));
+//
+// // OfficeProvider aProvider = null;
+// m_aProvider = new OfficeProvider();
+// m_xXMultiServiceFactory = (XMultiServiceFactory) m_aProvider.getManager(param);
+// param.put("ServiceFactory", m_xXMultiServiceFactory);
+// }
+//
+// private void stopOffice()
+// {
+// if (m_aProvider != null)
+// {
+// m_aProvider.closeExistingOffice(param, true);
+// m_aProvider = null;
+// }
+// }
private String m_sMailAddress = null;
private String m_sUPDMinor;
@@ -256,78 +277,77 @@ public class ReportDesignerTest extends ComplexTestCase {
private static final int WRITER = 1;
private static final int CALC = 2;
- public void firsttest()
+ @Test public void firsttest()
{
- convwatch.GlobalLogWriter.set(log);
- try
- {
+ // convwatch.GlobalLogWriter.set(log);
- // -------------------- preconditions, try to find an office --------------------
+ // -------------------- preconditions, try to find an office --------------------
- String sAppExecutionCommand = (String) param.get("AppExecutionCommand");
+// String sAppExecutionCommand = (String) param.get("AppExecutionCommand");
- String sUser = System.getProperty("user.name");
- log.println("user.name='" + sUser + "'");
+ String sUser = System.getProperty("user.name");
+ System.out.println("user.name='" + sUser + "'");
- String sVCSID = System.getProperty("VCSID");
- log.println("VCSID='" + sVCSID + "'");
- m_sMailAddress = sVCSID + "@openoffice.org";
- log.println("Assumed mail address: " + m_sMailAddress);
+ String sVCSID = System.getProperty("VCSID");
+ System.out.println("VCSID='" + sVCSID + "'");
+ m_sMailAddress = sVCSID + "@openoffice.org";
+ System.out.println("Assumed mail address: " + m_sMailAddress);
- m_sUPDMinor = System.getProperty("UPDMINOR");
- m_sCWS_WORK_STAMP = System.getProperty("CWS_WORK_STAMP");
- // createDBEntry();
- log.println("Current CWS: " + m_sCWS_WORK_STAMP);
- log.println("Current MWS: " + m_sUPDMinor);
+ m_sUPDMinor = System.getProperty("UPDMINOR");
+ m_sCWS_WORK_STAMP = System.getProperty("CWS_WORK_STAMP");
+ // createDBEntry();
+ System.out.println("Current CWS: " + m_sCWS_WORK_STAMP);
+ System.out.println("Current MWS: " + m_sUPDMinor);
- // System.exit(1);
-
- sAppExecutionCommand = sAppExecutionCommand.replaceAll( "\\$\\{USERNAME\\}", sUser);
- log.println("sAppExecutionCommand='" + sAppExecutionCommand + "'");
-
- // an other way to replace strings
- // sAppExecutionCommand = utils.replaceAll13(sAppExecutionCommand, "${USERNAME}", sUser);
-
- checkIfOfficeExists(sAppExecutionCommand);
- param.put("AppExecutionCommand", new String(sAppExecutionCommand));
+ // System.exit(1);
- // --------------------------- Start the given Office ---------------------------
+// sAppExecutionCommand = sAppExecutionCommand.replaceAll( "\\$\\{USERNAME\\}", sUser);
+// System.out.println("sAppExecutionCommand='" + sAppExecutionCommand + "'");
+//
+ // an other way to replace strings
+ // sAppExecutionCommand = utils.replaceAll13(sAppExecutionCommand, "${USERNAME}", sUser);
- startOffice();
+// checkIfOfficeExists(sAppExecutionCommand);
+// param.put("AppExecutionCommand", new String(sAppExecutionCommand));
- // ------------------------------ Start a test run ------------------------------
+ // --------------------------- Start the given Office ---------------------------
- String sCurrentDirectory = System.getProperty("user.dir");
- log.println("Current Dir: " + sCurrentDirectory);
+// startOffice();
- String sWriterDocument = sCurrentDirectory + "/" + "RPTWriterTests.odb";
- startTestForFile(sWriterDocument, WRITER);
-
- String sCalcDocument = sCurrentDirectory + "/" + "RPTCalcTests.odb";
- startTestForFile(sCalcDocument, CALC);
- }
- catch (AssureException e)
- {
- stopOffice();
- throw new AssureException(e.getMessage());
- }
+ // ------------------------------ Start a test run ------------------------------
+// String sCurrentDirectory = System.getProperty("user.dir");
+// System.out.println("Current Dir: " + sCurrentDirectory);
+//
+ String sWriterDocument = TestDocument.getUrl("RPTWriterTests.odb");
+ startTestForFile(sWriterDocument, WRITER);
+
+ String sCalcDocument = TestDocument.getUrl("RPTCalcTests.odb");
+ startTestForFile(sCalcDocument, CALC);
+// catch (AssureException e)
+// {
+// stopOffice();
+// throw new AssureException(e.getMessage());
+// }
+//
// ------------------------------ Office shutdown ------------------------------
- stopOffice();
+// stopOffice();
}
// -----------------------------------------------------------------------------
private void startTestForFile(String _sDocument, int _nType)
{
- File aFile = new File(_sDocument);
- assure("Test File doesn't '" + _sDocument + "'exist.", aFile.exists());
+ FileURL aFileURL = new FileURL(_sDocument);
+ assertTrue("Test File doesn't '" + _sDocument + "'exist.", aFileURL.exists());
- String sFileURL = URLHelper.getFileURLFromSystemPath(_sDocument);
- log.println("File URL: " + sFileURL);
+ String sFileURL = _sDocument; // URLHelper.getFileURLFromSystemPath(_sDocument);
+ System.out.println("File URL: " + sFileURL);
XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), null);
- log.println("Load done");
-// context = createUnoService("com.sun.star.sdb.DatabaseContext")
+ System.out.println("Load done");
+ assertNotNull("Can't load document ", xDocComponent);
+
+ // context = createUnoService("com.sun.star.sdb.DatabaseContext")
// oDataBase = context.getByName("hh")
// oDBDoc = oDataBase.DatabaseDocument
//
@@ -339,31 +359,33 @@ public class ReportDesignerTest extends ComplexTestCase {
try
{
- XInterface x = (XInterface)m_xXMultiServiceFactory.createInstance("com.sun.star.sdb.DatabaseContext");
- assure("can't create instance of com.sun.star.sdb.DatabaseContext", x != null);
- log.println("createInstance com.sun.star.sdb.DatabaseContext done");
+ XInterface x = (XInterface)getMSF().createInstance("com.sun.star.sdb.DatabaseContext");
+ assertNotNull("can't create instance of com.sun.star.sdb.DatabaseContext", x);
+ System.out.println("createInstance com.sun.star.sdb.DatabaseContext done");
- XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, x);
+ XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, x);
showElements(xNameAccess);
Object aObj = xNameAccess.getByName(sFileURL);
-// log.println("1");
+// System.out.println("1");
// PropertySetHelper aHelper = new PropertySetHelper(aObj);
- XDocumentDataSource xDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(XDocumentDataSource.class, aObj);
+ XDocumentDataSource xDataSource = UnoRuntime.queryInterface(XDocumentDataSource.class, aObj);
// Object aDatabaseDocmuent = aHelper.getPropertyValueAsObject("DatabaseDocument");
XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument();
// XOfficeDatabaseDocument xOfficeDBDoc = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, aDatabaseDocument);
- assure("can't access DatabaseDocument", xOfficeDBDoc != null);
-// log.println("2");
+ assertNotNull("can't access DatabaseDocument", xOfficeDBDoc);
+// System.out.println("2");
- XModel xDBSource = (XModel)UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc);
+ XModel xDBSource = UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc);
Object aController = xDBSource.getCurrentController();
- assure("Controller of xOfficeDatabaseDocument is empty!", aController != null);
-// log.println("3");
+ assertNotNull("Controller of xOfficeDatabaseDocument is empty!", aController);
+// System.out.println("3");
- XDatabaseDocumentUI aDBDocUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController);
- boolean isConnect = aDBDocUI.connect();
+ XDatabaseDocumentUI aDBDocUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController);
+ /* boolean isConnect = */
+// TODO: throws an exception in DEV300m78
+ aDBDocUI.connect();
// if (isConnect)
// {
// System.out.println("true");
@@ -372,23 +394,23 @@ public class ReportDesignerTest extends ComplexTestCase {
// {
// System.out.println("false");
// }
-// log.println("4");
+// System.out.println("4");
// aHelper = new PropertySetHelper(aController);
// Object aActiveConnectionObj = aHelper.getPropertyValueAsObject("ActiveConnection");
Object aActiveConnectionObj = aDBDocUI.getActiveConnection();
- assure("ActiveConnection is empty", aActiveConnectionObj != null);
-// log.println("5");
+ assertNotNull("ActiveConnection is empty", aActiveConnectionObj);
+// System.out.println("5");
- XReportDocumentsSupplier xSupplier = (XReportDocumentsSupplier)UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc);
+ XReportDocumentsSupplier xSupplier = UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc);
xNameAccess = xSupplier.getReportDocuments();
- assure("xOfficeDatabaseDocument returns no Report Document", xNameAccess != null);
-// log.println("5");
+ assertNotNull("xOfficeDatabaseDocument returns no Report Document", xNameAccess);
+// System.out.println("5");
showElements(xNameAccess);
- ArrayList aPropertyList = new ArrayList();
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>();
PropertyValue aActiveConnection = new PropertyValue();
aActiveConnection.Name = "ActiveConnection";
@@ -400,7 +422,7 @@ public class ReportDesignerTest extends ComplexTestCase {
}
catch(com.sun.star.uno.Exception e)
{
- log.println("ERROR: Exception caught");
+ fail("ERROR: Exception caught" + e.getMessage());
}
// String mTestDocumentPath = (String) param.get("TestDocumentPath");
@@ -421,8 +443,8 @@ public class ReportDesignerTest extends ComplexTestCase {
private void createDBEntry(int _nType)
{
// try to connect the database
- String sDBConnection = (String)param.get( convwatch.PropertyName.DB_CONNECTION_STRING );
- log.println("DBConnection: " + sDBConnection);
+ String sDBConnection = ""; // (String)param.get( convwatch.PropertyName.DB_CONNECTION_STRING );
+ System.out.println("DBConnection: " + sDBConnection);
DB.init(sDBConnection);
String sDestinationVersion = m_sCWS_WORK_STAMP;
if (sDestinationVersion.length() == 0)
@@ -436,10 +458,10 @@ public class ReportDesignerTest extends ComplexTestCase {
String sSpecial = "";
String sFixRefSubDirectory = "ReportDesign_qa_complex_" + getFileFormat(_nType);
- DB.insertinto_documentcompare(sFixRefSubDirectory, "", "fixref",
- sDestinationVersion, sDestinationName, sDestinationCreatorType,
- sDocumentPoolDir, sDocumentPoolName, m_sMailAddress,
- sSpecial);
+// DB.insertinto_documentcompare(sFixRefSubDirectory, "", "fixref",
+// sDestinationVersion, sDestinationName, sDestinationCreatorType,
+// sDocumentPoolDir, sDocumentPoolName, m_sMailAddress,
+// sSpecial);
// DB.test();
// System.exit(1);
}
@@ -495,7 +517,7 @@ public class ReportDesignerTest extends ComplexTestCase {
private String getOutputPath(int _nType)
{
- String sOutputPath = (String)param.get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
+ String sOutputPath = util.utils.getOfficeTemp/*Dir*/(getMSF());// (String)param.get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
if (!sOutputPath.endsWith("/") || // construct the output file name
!sOutputPath.endsWith("\\"))
@@ -533,7 +555,7 @@ public class ReportDesignerTest extends ComplexTestCase {
String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath);
- ArrayList aPropertyList = new ArrayList(); // set some properties for storeAsURL
+ ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); // set some properties for storeAsURL
PropertyValue aFileFormat = new PropertyValue();
aFileFormat.Name = "FilterName";
@@ -546,19 +568,19 @@ public class ReportDesignerTest extends ComplexTestCase {
aPropertyList.add(aOverwrite);
// store the document in an other directory
- XStorable aStorable = (XStorable) UnoRuntime.queryInterface( XStorable.class, _xComponent);
+ XStorable aStorable = UnoRuntime.queryInterface(XStorable.class, _xComponent);
if (aStorable != null)
{
- log.println("store document as URL: '" + sOutputURL + "'");
+ System.out.println("store document as URL: '" + sOutputURL + "'");
try
{
aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
}
catch (com.sun.star.io.IOException e)
{
- log.println("ERROR: Exception caught");
- log.println("Can't write document URL: '" + sOutputURL + "'");
- log.println("Message: " + e.getMessage());
+ System.out.println("ERROR: Exception caught");
+ System.out.println("Can't write document URL: '" + sOutputURL + "'");
+ System.out.println("Message: " + e.getMessage());
}
}
}
@@ -566,25 +588,25 @@ public class ReportDesignerTest extends ComplexTestCase {
private XComponent loadComponent(String _sName, Object _xComponent, ArrayList _aPropertyList)
{
XComponent xDocComponent = null;
- XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, _xComponent );
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, _xComponent);
try
{
PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList);
- log.println("Load component: '" + _sName + "'");
+ System.out.println("Load component: '" + _sName + "'");
xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", 0, aLoadProperties);
}
catch (com.sun.star.io.IOException e)
{
- log.println("ERROR: Exception caught");
- log.println("Can't load document '" + _sName + "'");
- log.println("Message: " + e.getMessage());
+ System.out.println("ERROR: Exception caught");
+ System.out.println("Can't load document '" + _sName + "'");
+ System.out.println("Message: " + e.getMessage());
}
catch (com.sun.star.lang.IllegalArgumentException e)
{
- log.println("ERROR: Exception caught");
- log.println("Illegal Arguments given to loadComponentFromURL.");
- log.println("Message: " + e.getMessage());
+ System.out.println("ERROR: Exception caught");
+ System.out.println("Illegal Arguments given to loadComponentFromURL.");
+ System.out.println("Message: " + e.getMessage());
}
return xDocComponent;
}
@@ -592,17 +614,39 @@ public class ReportDesignerTest extends ComplexTestCase {
private void closeComponent(XComponent _xDoc)
{
// Close the document
- XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, _xDoc);
+ XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, _xDoc);
try
{
xCloseable.close(true);
}
catch (com.sun.star.util.CloseVetoException e)
{
- log.println("ERROR: CloseVetoException caught");
- log.println("CloseVetoException occured Can't close document.");
- log.println("Message: " + e.getMessage());
+ System.out.println("ERROR: CloseVetoException caught");
+ System.out.println("CloseVetoException occured Can't close document.");
+ System.out.println("Message: " + e.getMessage());
}
}
+
+ private XMultiServiceFactory getMSF()
+ {
+ final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
+ return xMSF1;
+ }
+
+ // setup and close connections
+ @BeforeClass public static void setUpConnection() throws Exception {
+ System.out.println("setUpConnection()");
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ System.out.println("tearDownConnection()");
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
+
}
diff --git a/reportdesign/qa/complex/reportdesign/TestDocument.java b/reportdesign/qa/complex/reportdesign/TestDocument.java
new file mode 100644
index 000000000000..a6e294d4d3ec
--- /dev/null
+++ b/reportdesign/qa/complex/reportdesign/TestDocument.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* 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 complex.reportdesign;
+
+import java.io.File;
+import org.openoffice.test.OfficeFileUrl;
+
+final class TestDocument
+{
+ public static String getUrl(String name)
+ {
+ return OfficeFileUrl.getAbsolute(new File("test_documents", name));
+ }
+
+ private TestDocument() {}
+}
diff --git a/reportdesign/qa/complex/makefile.mk b/reportdesign/qa/complex/reportdesign/makefile.mk
index 9d1b7667c125..4174eb02ce3a 100755
--- a/reportdesign/qa/complex/makefile.mk
+++ b/reportdesign/qa/complex/reportdesign/makefile.mk
@@ -25,34 +25,38 @@
#
#*************************************************************************
-PRJ=..$/..
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+PRJ = ../../..
PRJNAME = reportdesign
-PACKAGE = complex
-TARGET = rptdesigntest
+TARGET = qa_complex_reportdesign
-# --- Settings -----------------------------------------------------
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = complex/reportdesign
-.INCLUDE : settings.mk
+# here store only Files which contain a @Test
+JAVATESTFILES = \
+ ReportDesignerTest.java
-# --- Files --------------------------------------------------------
+# put here all other files
+JAVAFILES = $(JAVATESTFILES) \
+ TestDocument.java \
+ FileURL.java
-JARFILES = ridl.jar jurt.jar unoil.jar juh.jar OOoRunner.jar
+JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
-JAVAFILES = ReportDesignerTest.java
+# Sample how to debug
+# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
-# --- Targets ------------------------------------------------------
+.END
-.INCLUDE : target.mk
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
-# JAVADEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8502,suspend=y
-JAVADEBUG=
+ALLTAR : javatest
-MYSQL_CONNECTOR=$(PWD)$/mysql-connector-java-5.0.6-bin.jar
-CLASSPATH!:=$(CLASSPATH)$(PATH_SEPERATOR)$(MYSQL_CONNECTOR)
-
-run: ALLTAR
- $(PERL) mysql-connector-exists.pl $(MYSQL_CONNECTOR)
-# @echo $(CLASSPATH)
-# @echo $(VCSID)
- @java $(JAVADEBUG) -cp $(CLASSPATH) -DVCSID=$(VCSID) -DCWS_WORK_STAMP=$(CWS_WORK_STAMP) -DUPDMINOR=$(UPDMINOR) org.openoffice.Runner -ini runner.props
+.END
diff --git a/reportdesign/qa/complex/mysql-connector-exists.pl b/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl
index 6eefe2bb0639..6eefe2bb0639 100644
--- a/reportdesign/qa/complex/mysql-connector-exists.pl
+++ b/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl
diff --git a/reportdesign/qa/complex/runner.props b/reportdesign/qa/complex/reportdesign/runner.props
index d894366ce006..d894366ce006 100755
--- a/reportdesign/qa/complex/runner.props
+++ b/reportdesign/qa/complex/reportdesign/runner.props
diff --git a/reportdesign/qa/complex/RPTCalcTests.odb b/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb
index 0e91d633d4e7..0e91d633d4e7 100755
--- a/reportdesign/qa/complex/RPTCalcTests.odb
+++ b/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb
Binary files differ
diff --git a/reportdesign/qa/complex/RPTWriterTests.odb b/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb
index 86228f457f0b..7099b1abf2b5 100755
--- a/reportdesign/qa/complex/RPTWriterTests.odb
+++ b/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb
Binary files differ
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 2299fff10f98..7d1cdbc6db30 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -1221,20 +1221,12 @@ void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel)
OReportModel* pRptModel = static_cast<OReportModel*>(GetModel());
pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj));
- uno::Sequence< beans::PropertyValue > aArgs( 4 );
- aArgs[0] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
- uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE );
- aArgs[1] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("HasCategories"), -1,
- uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE );
- aArgs[2] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
- uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE );
- aArgs[3] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("DataRowSource"), -1,
- uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
- xReceiver->setArguments( aArgs );
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) );
+ aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
+ aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
+ aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
+ xReceiver->setArguments( aArgs.getPropertyValues() );
if( xChartModel.is() )
xChartModel->unlockControllers();
diff --git a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
index d3a557c3ff6b..be664b5694e1 100644
--- a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
+++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx
@@ -349,14 +349,14 @@ void SAL_CALL ExportDocumentHandler::initialize( const uno::Sequence< uno::Any >
if ( xDataProvider.is() )
{
m_aColumns.realloc(1);
- uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames = xDataProvider->getComplexColumnDescriptions();
+ uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions();
for(sal_Int32 i = 0 ; i < aColumnNames.getLength();++i)
{
if ( aColumnNames[i].getLength() )
{
sal_Int32 nCount = m_aColumns.getLength();
m_aColumns.realloc(nCount+1);
- m_aColumns[nCount] = aColumnNames[i][0];
+ m_aColumns[nCount] = aColumnNames[i];
}
}
}
diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
index c92eecc1084d..92ee79509dea 100644
--- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
+++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.cxx
@@ -37,6 +37,7 @@
#include <comphelper/sequence.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <comphelper/documentconstants.hxx>
+#include <comphelper/namedvaluecollection.hxx>
#include <xmloff/attrlist.hxx>
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmlement.hxx>
@@ -56,8 +57,9 @@ using namespace ::xmloff::token;
::rtl::OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute);
-ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context) :
- m_xContext(context)
+ImportDocumentHandler::ImportDocumentHandler(uno::Reference< uno::XComponentContext > const & context)
+ :m_bImportedChart( false )
+ ,m_xContext(context)
{
}
// -----------------------------------------------------------------------------
@@ -121,35 +123,24 @@ void SAL_CALL ImportDocumentHandler::endDocument() throw (uno::RuntimeException,
{
m_xDelegatee->endDocument();
uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xModel,uno::UNO_QUERY_THROW);
- if ( xReceiver.is() )
+ if ( xReceiver.is() && m_bImportedChart )
{
// this fills the chart again
- uno::Sequence< beans::PropertyValue > aArgs( 4 );
- aArgs[0] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
- uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE );
- aArgs[1] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("HasCategories"), -1,
- uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE );
- aArgs[2] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
- uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE );
- aArgs[3] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("DataRowSource"), -1,
- uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "CellRangeRepresentation", ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) );
+ aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
+ aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
+ aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
uno::Reference< chart::XComplexDescriptionAccess > xDataProvider(m_xModel->getDataProvider(),uno::UNO_QUERY);
if ( xDataProvider.is() )
{
- aArgs.realloc(5);
- uno::Sequence< uno::Sequence< ::rtl::OUString > > aColumnNames = xDataProvider->getComplexColumnDescriptions();
- aArgs[4] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("ComplexColumnDescriptions"), -1,
- uno::makeAny( aColumnNames ), beans::PropertyState_DIRECT_VALUE );
+ const uno::Sequence< ::rtl::OUString > aColumnNames = xDataProvider->getColumnDescriptions();
+ aArgs.put( "ColumnDescriptions", uno::makeAny( aColumnNames ) );
}
- xReceiver->attachDataProvider(m_xDatabaseDataProvider.get());
- xReceiver->setArguments( aArgs );
+ xReceiver->attachDataProvider( m_xDatabaseDataProvider.get() );
+ xReceiver->setArguments( aArgs.getPropertyValues() );
}
}
@@ -204,6 +195,7 @@ void SAL_CALL ImportDocumentHandler::startElement(const ::rtl::OUString & _sName
}
m_xDelegatee->startElement(lcl_createAttribute(XML_NP_OFFICE,XML_CHART),NULL);
bExport = false;
+ m_bImportedChart = true;
}
else if ( _sName.equalsAscii("rpt:master-detail-field") )
{
diff --git a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx
index 3f0fdebfc111..579a1b79b231 100644
--- a/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx
+++ b/reportdesign/source/filter/xml/xmlImportDocumentHandler.hxx
@@ -85,6 +85,7 @@ private:
virtual ~ImportDocumentHandler();
::osl::Mutex m_aMutex;
+ bool m_bImportedChart;
::std::vector< ::rtl::OUString> m_aMasterFields;
::std::vector< ::rtl::OUString> m_aDetailFields;
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aArguments;
diff --git a/reportdesign/source/ui/inspection/DataProviderHandler.cxx b/reportdesign/source/ui/inspection/DataProviderHandler.cxx
index 66f75fa090ed..8ac5053ff39f 100644
--- a/reportdesign/source/ui/inspection/DataProviderHandler.cxx
+++ b/reportdesign/source/ui/inspection/DataProviderHandler.cxx
@@ -27,6 +27,7 @@
#include "precompiled_reportdesign.hxx"
#include "DataProviderHandler.hxx"
#include <com/sun/star/lang/XInitialization.hpp>
+#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/property.hxx>
#include <comphelper/types.hxx>
@@ -469,21 +470,13 @@ void SAL_CALL DataProviderHandler::actuatingPropertyChanged(const ::rtl::OUStrin
sal_Bool bModified = xReport->isModified();
// this fills the chart again
- uno::Sequence< beans::PropertyValue > aArgs( 4 );
- aArgs[0] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
- uno::makeAny( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("all")) ), beans::PropertyState_DIRECT_VALUE );
- aArgs[1] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("HasCategories"), -1,
- uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE );
- aArgs[2] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
- uno::makeAny( sal_True ), beans::PropertyState_DIRECT_VALUE );
- aArgs[3] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("DataRowSource"), -1,
- uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "CellRangeRepresentation", uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ) );
+ aArgs.put( "HasCategories", uno::makeAny( sal_True ) );
+ aArgs.put( "FirstCellAsLabel", uno::makeAny( sal_True ) );
+ aArgs.put( "DataRowSource", uno::makeAny( chart::ChartDataRowSource_COLUMNS ) );
uno::Reference< chart2::data::XDataReceiver > xReceiver(m_xChartModel,uno::UNO_QUERY_THROW);
- xReceiver->setArguments( aArgs );
+ xReceiver->setArguments( aArgs.getPropertyValues() );
if ( !bModified )
xReport->setModified(sal_False);
} // if ( NewValue != OldValue )