diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-03-09 23:17:51 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-03-09 23:17:51 -0600 |
commit | 256f6ca67d03b875e8e6a355a6cf5130ea7404a3 (patch) | |
tree | c1916add744093d07466b54d6af832cd87891d8e /dbaccess/qa | |
parent | Remove 'added by' comments (diff) | |
parent | masterfix DEV300: #i10000# usage of L10N build_type (diff) | |
download | core-256f6ca67d03b875e8e6a355a6cf5130ea7404a3.tar.gz core-256f6ca67d03b875e8e6a355a6cf5130ea7404a3.zip |
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101
* commit 'ooo/DEV300_m101': (76 commits)
masterfix DEV300: #i10000# usage of L10N build_type
removetooltypes01: Fix build problems after rebase to DEV300m99 in basctl, cui, reportdesign, sw
hr75: #i116747#: remove obsolete copyright notices
gnumake3: remove comphelper version; fix including extract.hxx
removetooltypes01: #i112600# Replace missing tools types replacement
removetooltypes01: #i112600# remove tooltypes from reportdesign
removetooltypes01: #i112600# remove tooltypes from dbaccess
undoapi: don't use deprecated JUnit API, this seems to fail now (but didn't before the rebase)
undoapi: those two classes do not belong into JAVATESTFILES, but JAVAFILES only
undoapi: (I|Sfx)UndoManager now working with size_t instead of USHORT
gridsort: give the UnoControl(Model/Base) classes a ctor taking a service factory, so we have access to the factory which created us, and don't need to resort to the process'es service factory
dba34b: #109956# notify column value in correct order
dba34b: #i114309# set default values for bit boolean and reset when we are on the insertrow
undoapi: assert unknown slots in ImplInvalidateFeature
dba34b: #i110907# check if design handle event
dba34b: #i109956# notify column values when row is refreshed
dba34b: #i115753# add test again
undoapi: renamed Undo.* to RptUndo.*, to not confuse a certain IDE with different same-named files in the source tree ...
undoapi: migrated report designer to use an own, model-bound UndoManager, instead of the UndoManager formerly bound to the controller
undoapi: split OSingleDocumentController into DBSubComponentController (which the report design's controller will be derived from) and the still-so-named OSingleDocumentController. Module reportdesign does not compile with this change, this is yet to come.
...
Conflicts:
dbaccess/inc/IEnvironment.hxx
dbaccess/inc/dataview.hxx
dbaccess/qa/complex/dbaccess/RowSet.java
dbaccess/source/core/api/CacheSet.cxx
dbaccess/source/core/api/KeySet.hxx
dbaccess/source/core/api/OptimisticSet.hxx
dbaccess/source/core/api/RowSet.cxx
dbaccess/source/core/api/RowSetCache.cxx
dbaccess/source/ext/adabas/Acomponentmodule.cxx
dbaccess/source/ext/adabas/Aservices.cxx
dbaccess/source/filter/migration/cfgimport.cxx
dbaccess/source/filter/migration/cfgimport.hxx
dbaccess/source/filter/migration/cfgservices.cxx
dbaccess/source/filter/migration/makefile.mk
dbaccess/source/inc/cfg_reghelper.hxx
dbaccess/source/sdbtools/misc/sdbt_services.cxx
dbaccess/source/shared/cfg_reghelper.cxx
dbaccess/source/shared/cfgstrings.cxx
dbaccess/source/shared/registrationhelper.cxx
dbaccess/source/ui/app/AppController.cxx
dbaccess/source/ui/app/AppDetailPageHelper.cxx
dbaccess/source/ui/app/AppDetailPageHelper.hxx
dbaccess/source/ui/app/AppDetailView.cxx
dbaccess/source/ui/app/AppIconControl.cxx
dbaccess/source/ui/app/AppSwapWindow.cxx
dbaccess/source/ui/browser/brwctrlr.cxx
dbaccess/source/ui/browser/dataview.cxx
dbaccess/source/ui/browser/unodatbr.cxx
dbaccess/source/ui/control/dbtreelistbox.cxx
dbaccess/source/ui/control/opendoccontrols.cxx
dbaccess/source/ui/control/tabletree.cxx
dbaccess/source/ui/dlg/ConnectionHelper.cxx
dbaccess/source/ui/dlg/ConnectionPage.src
dbaccess/source/ui/dlg/ExtensionNotPresent.cxx
dbaccess/source/ui/dlg/ExtensionNotPresent.hrc
dbaccess/source/ui/dlg/ExtensionNotPresent.src
dbaccess/source/ui/dlg/TablesSingleDlg.cxx
dbaccess/source/ui/dlg/adodatalinks.hxx
dbaccess/source/ui/dlg/dbadmin2.src
dbaccess/source/ui/dlg/dbadminsetup.src
dbaccess/source/ui/dlg/dlgattr.cxx
dbaccess/source/ui/dlg/dlgsize.src
dbaccess/source/ui/dlg/makefile.mk
dbaccess/source/ui/dlg/sqlmessage.cxx
dbaccess/source/ui/inc/ExtensionNotPresent.hxx
dbaccess/source/ui/inc/TokenWriter.hxx
dbaccess/source/ui/inc/imageprovider.hxx
dbaccess/source/ui/misc/DExport.cxx
dbaccess/source/ui/misc/HtmlReader.cxx
dbaccess/source/ui/misc/RowSetDrop.cxx
dbaccess/source/ui/misc/RtfReader.cxx
dbaccess/source/ui/misc/TokenWriter.cxx
dbaccess/source/ui/misc/imageprovider.cxx
dbaccess/source/ui/misc/linkeddocuments.cxx
dbaccess/source/ui/misc/singledoccontroller.cxx
dbaccess/source/ui/querydesign/ConnectionData.hxx
dbaccess/source/ui/querydesign/JoinTableView.cxx
dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
dbaccess/source/ui/querydesign/TableConnectionData.cxx
dbaccess/source/ui/querydesign/TableWindowListBox.cxx
dbaccess/source/ui/relationdesign/RelationController.cxx
dbaccess/source/ui/relationdesign/RelationTableView.cxx
dbaccess/source/ui/tabledesign/table.src
reportdesign/inc/RptPage.hxx
reportdesign/qa/complex/reportdesign/ReportDesignerTest.java
reportdesign/source/core/api/ReportDefinition.cxx
reportdesign/source/core/sdr/ReportUndoFactory.cxx
reportdesign/source/core/sdr/UndoEnv.cxx
reportdesign/source/filter/xml/xmlservices.cxx
reportdesign/source/ui/dlg/GroupsSorting.cxx
reportdesign/source/ui/dlg/Navigator.cxx
reportdesign/source/ui/inspection/metadata.cxx
reportdesign/source/ui/misc/RptUndo.cxx
reportdesign/source/ui/misc/UITools.cxx
reportdesign/source/ui/misc/rptuiservices.cxx
reportdesign/source/ui/report/DesignView.cxx
reportdesign/source/ui/report/FixedTextColor.cxx
reportdesign/source/ui/report/ReportController.cxx
reportdesign/source/ui/report/ReportSection.cxx
reportdesign/source/ui/report/SectionView.cxx
reportdesign/source/ui/report/SectionWindow.cxx
reportdesign/source/ui/report/StartMarker.cxx
reportdesign/source/ui/report/ViewsWindow.cxx
reportdesign/source/ui/report/dlgedfunc.cxx
reportdesign/source/ui/report/report.src
Diffstat (limited to 'dbaccess/qa')
19 files changed, 704 insertions, 691 deletions
diff --git a/dbaccess/qa/complex/dbaccess/ApplicationController.java b/dbaccess/qa/complex/dbaccess/ApplicationController.java index 4c964e82dc06..f8a57b8f6efb 100644 --- a/dbaccess/qa/complex/dbaccess/ApplicationController.java +++ b/dbaccess/qa/complex/dbaccess/ApplicationController.java @@ -27,27 +27,30 @@ package complex.dbaccess; import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.frame.FrameSearchFlag; import com.sun.star.frame.XComponentLoader; 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.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 connectivity.tools.HsqlColumnDescriptor; import connectivity.tools.HsqlDatabase; import connectivity.tools.HsqlTableDescriptor; -import helper.URLHelper; -import java.io.File; import java.io.IOException; + +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ + /** complex test case for Base's application UI */ public class ApplicationController extends TestCase @@ -63,16 +66,6 @@ public class ApplicationController extends TestCase } // -------------------------------------------------------------------------------------------------------- - - public String[] getTestMethodNames() - { - return new String[] - { - "checkSaveAs" - }; - } - - // -------------------------------------------------------------------------------------------------------- public String getTestObjectName() { return getClass().getName(); @@ -98,16 +91,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,6 +111,8 @@ public class ApplicationController extends TestCase } // -------------------------------------------------------------------------------------------------------- + @Before + @Override public void before() throws java.lang.Exception { super.before(); @@ -125,6 +120,8 @@ public class ApplicationController extends TestCase } // -------------------------------------------------------------------------------------------------------- + @After + @Override public void after() throws java.lang.Exception { impl_closeDocument(); @@ -132,6 +129,7 @@ public class ApplicationController extends TestCase } // -------------------------------------------------------------------------------------------------------- + @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, @@ -146,7 +144,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 +157,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 503db8090f88..6052c308dbdf 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; @@ -77,82 +71,44 @@ public class Beamer extends complexlib.ComplexTestCase } // -------------------------------------------------------------------------------------------------------- - 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 getTestObjectName() - { - return getClass().getName(); - } - - // -------------------------------------------------------------------------------------------------------- - protected final XMultiServiceFactory getORB() - { - return (XMultiServiceFactory) param.getMSF(); - } - - // -------------------------------------------------------------------------------------------------------- - private void impl_closeDocument() - { - } - - // -------------------------------------------------------------------------------------------------------- + @Before + @Override 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); } // -------------------------------------------------------------------------------------------------------- + @After + @Override public void after() { } - // -------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------- + @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 = ".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[] @@ -163,8 +119,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()) @@ -172,9 +128,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(); @@ -185,6 +141,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..aa74ea87a3f6 100644 --- a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java +++ b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java @@ -26,13 +26,17 @@ ************************************************************************/ 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.Before; +import static org.junit.Assert.*; +// ------------------------------------------ + public abstract class CRMBasedTestCase extends TestCase { protected CRMDatabase m_database; @@ -42,16 +46,17 @@ 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"); } } // -------------------------------------------------------------------------------------------------------- + @Before @Override public void before() { @@ -59,13 +64,16 @@ public abstract class CRMBasedTestCase extends TestCase } // -------------------------------------------------------------------------------------------------------- + @After @Override public void after() { try { if ( m_database != null ) + { m_database.saveAndClose(); + } } catch ( Exception ex ) { diff --git a/dbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java b/dbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java index 53527e356f78..7f88028f72c9 100755 --- a/dbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java +++ b/dbaccess/qa/complex/dbaccess/CopyTableInterActionHandler.java @@ -30,6 +30,8 @@ import com.sun.star.lib.uno.helper.WeakBase; import com.sun.star.task.XInteractionHandler; import com.sun.star.task.XInteractionRequest; +import static org.junit.Assert.*; + /** * * @author oj93728 @@ -37,14 +39,12 @@ import com.sun.star.task.XInteractionRequest; class CopyTableInterActionHandler extends WeakBase implements XInteractionHandler { - private final CopyTableWizard test; - public CopyTableInterActionHandler(CopyTableWizard testCase) + CopyTableInterActionHandler() { - test = testCase; } public void handle(XInteractionRequest xRequest) { - test.assure(xRequest.toString()); + fail( "interaction handler is not expected to be called" ); } } diff --git a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java index 7c3db7f6020d..1facca3d8497 100755 --- a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java +++ b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java @@ -46,6 +46,13 @@ import connectivity.tools.DbaseDatabase; import java.io.IOException; import util.UITools; +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ + /** complex test case for Base's application UI */ public class CopyTableWizard extends CRMBasedTestCase @@ -60,23 +67,8 @@ public class CopyTableWizard extends CRMBasedTestCase } // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] - { - "copyTable", "copyTableDbase" - }; - } - - // -------------------------------------------------------------------------------------------------------- - @Override - public String getTestObjectName() - { - return getClass().getName(); - } -// -------------------------------------------------------------------------------------------------------- - // -------------------------------------------------------------------------------------------------------- + @After @Override public void after() { @@ -84,6 +76,7 @@ public class CopyTableWizard extends CRMBasedTestCase super.after(); } + @Before @Override public void before() { @@ -91,23 +84,21 @@ public class CopyTableWizard extends CRMBasedTestCase { 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(""); } } - // -------------------------------------------------------------------------------------------------------- - - + // -------------------------------------------------------------------------------------------------------- class CopyThread implements Runnable { final XCopyTableWizard copyWizard; - public CopyThread(final XCopyTableWizard copyWizard) + CopyThread(final XCopyTableWizard copyWizard) { this.copyWizard = copyWizard; } @@ -123,33 +114,35 @@ 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) { return null; } - XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(XExtendedToolkit.class, toolKit); + XExtendedToolkit tk = UnoRuntime.queryInterface( XExtendedToolkit.class, toolKit ); Object atw = tk.getActiveTopWindow(); - return (XWindow) UnoRuntime.queryInterface(XWindow.class, atw); + return UnoRuntime.queryInterface( XWindow.class, atw ); } + @Test public void copyTable() throws Exception, IOException, java.lang.Exception { copyTable(source,source); } + @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(); @@ -159,15 +152,10 @@ public class CopyTableWizard extends CRMBasedTestCase } } - public void assure(final String message) - { - assure(message, false); - } - private void copyTable(final String tableName, final XConnection sourceConnection, final XConnection destConnection) throws Exception, IOException, java.lang.Exception { - final XInteractionHandler interAction = new CopyTableInterActionHandler(this); + final XInteractionHandler interAction = new CopyTableInterActionHandler(); final XComponentContext context = getComponentContext(); final XPropertySet sourceDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor(); sourceDescriptor.setPropertyValue("CommandType", CommandType.TABLE); @@ -177,7 +165,8 @@ public class CopyTableWizard extends CRMBasedTestCase final XPropertySet destDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor(); destDescriptor.setPropertyValue("ActiveConnection", destConnection); - final XCopyTableWizard copyWizard = com.sun.star.sdb.application.CopyTableWizard.createWithInteractionHandler(context, sourceDescriptor, destDescriptor, interAction); + final XCopyTableWizard copyWizard = com.sun.star.sdb.application.CopyTableWizard.createWithInteractionHandler( + context, sourceDescriptor, destDescriptor, interAction); copyWizard.setOperation((short) 0); // com.sun.star.sdb.application.CopyDefinitionAndData Optional<String> auto = new Optional<String>(); @@ -194,7 +183,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(); @@ -211,7 +200,7 @@ public class CopyTableWizard extends CRMBasedTestCase } catch (java.lang.Exception exception) { - exception.printStackTrace(); + exception.printStackTrace( System.err ); } } catch (com.sun.star.lang.IndexOutOfBoundsException indexOutOfBoundsException) diff --git a/dbaccess/qa/complex/dbaccess/DataSource.java b/dbaccess/qa/complex/dbaccess/DataSource.java index f74d5af8d8f0..ae5d131c1e20 100644 --- a/dbaccess/qa/complex/dbaccess/DataSource.java +++ b/dbaccess/qa/complex/dbaccess/DataSource.java @@ -26,66 +26,49 @@ ************************************************************************/ package complex.dbaccess; -import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.container.XNameAccess; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XNamingService; -import complexlib.ComplexTestCase; import connectivity.tools.CRMDatabase; import connectivity.tools.HsqlDatabase; -import java.util.logging.Level; -import java.util.logging.Logger; -public class DataSource extends ComplexTestCase +// ---------- junit imports ----------------- +import org.junit.Test; +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"; - } - - // -------------------------------------------------------------------------------------------------------- private void createTestCase() { try { 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(); - } - - // -------------------------------------------------------------------------------------------------------- + @Test public void testRegistrationName() { try @@ -93,18 +76,22 @@ public class DataSource extends ComplexTestCase 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")); + final XNamingService dataSourceRegistrations = UnoRuntime.queryInterface( + XNamingService.class, getMSF().createInstance( "com.sun.star.sdb.DatabaseContext" ) ); + final XNameAccess existenceCheck = UnoRuntime.queryInterface( XNameAccess.class, dataSourceRegistrations ); + if ( existenceCheck.hasByName( "someDataSource" ) ) + dataSourceRegistrations.revokeObject( "someDataSource" ); 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 0c712086d2fe..b22671fa2f18 100644 --- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java +++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java @@ -26,6 +26,8 @@ ************************************************************************/ package complex.dbaccess; +import com.sun.star.lang.NotInitializedException; +import com.sun.star.frame.DoubleInitializationException; import com.sun.star.awt.XTopWindow; import com.sun.star.beans.PropertyState; import com.sun.star.document.DocumentEvent; @@ -33,7 +35,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 +47,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 +57,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 +83,13 @@ import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; +// ---------- junit imports ----------------- +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ + public class DatabaseDocument extends TestCase implements com.sun.star.document.XDocumentEventListener { @@ -145,12 +152,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 +216,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 +233,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,24 +252,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // ======================================================================================================== // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] - { - "testLoadable", - "testDocumentRevenants", - "testDocumentEvents", - "testGlobalEvents" - }; - } - - // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return "DatabaseDocument"; - } - - // -------------------------------------------------------------------------------------------------------- + @Before public void before() throws java.lang.Exception { super.before(); @@ -274,25 +262,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"); } } // -------------------------------------------------------------------------------------------------------- + @After public void after() throws java.lang.Exception { try @@ -302,15 +289,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(); @@ -323,7 +309,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. public Class unoInterfaceClass = null; public String methodName = null; - public UnoMethodDescriptor(Class _class, String _method) + UnoMethodDescriptor(Class _class, String _method) { unoInterfaceClass = _class; methodName = _method; @@ -356,8 +342,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // -------------------------------------------------------------------------------------------------------- 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 +353,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 +371,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 +385,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,6 +393,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- + @Test public void testLoadable() throws Exception, IOException { XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); @@ -426,18 +408,17 @@ 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 @@ -450,9 +431,9 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // 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 @@ -478,7 +459,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 +482,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 +509,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 +518,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 +530,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,6 +555,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. */ + @Test public void testDocumentRevenants() throws Exception, IOException { // create an empty document @@ -592,42 +569,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,6 +608,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- + @Test public void testDocumentEvents() throws Exception, IOException { // create an empty document @@ -660,8 +634,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 +667,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 +677,11 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. } // -------------------------------------------------------------------------------------------------------- + @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 +690,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 +700,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 +711,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 +732,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 +740,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 +751,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 +764,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 +781,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 +798,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 +828,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 +837,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 +885,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 +937,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 +956,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 +967,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 +985,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..588755a8c29c 100644 --- a/dbaccess/qa/complex/dbaccess/Parser.java +++ b/dbaccess/qa/complex/dbaccess/Parser.java @@ -35,25 +35,16 @@ import com.sun.star.sdbc.SQLException; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; -public class Parser extends CRMBasedTestCase -{ - // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] { - "checkJoinSyntax", - "checkParameterTypes", - "checkWhere", - }; - } - // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return "Parser"; - } +// ---------- junit imports ----------------- +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ +public class Parser extends CRMBasedTestCase +{ // -------------------------------------------------------------------------------------------------------- + @Override protected void createTestCase() { try @@ -64,10 +55,12 @@ 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"); } } + // -------------------------------------------------------------------------------------------------------- + @Test public void checkWhere() throws Exception { final XSingleSelectQueryComposer composer = createQueryComposer(); @@ -107,6 +100,7 @@ public class Parser extends CRMBasedTestCase // -------------------------------------------------------------------------------------------------------- /** verifies that aliases for inner queries work as expected */ + @Test public void checkJoinSyntax() throws Exception { final XSingleSelectQueryComposer composer = createQueryComposer(); @@ -144,7 +138,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,29 +148,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 */ + @Test public void checkParameterTypes() throws Exception { impl_checkParameters( diff --git a/dbaccess/qa/complex/dbaccess/PropertyBag.java b/dbaccess/qa/complex/dbaccess/PropertyBag.java index c686be886bba..9f77559eab0b 100644 --- a/dbaccess/qa/complex/dbaccess/PropertyBag.java +++ b/dbaccess/qa/complex/dbaccess/PropertyBag.java @@ -27,14 +27,26 @@ package complex.dbaccess; -import complexlib.ComplexTestCase; +// import complexlib.ComplexTestCase; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyState; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertyAccess; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertyContainer; 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.Before; +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ + +public class PropertyBag extends TestCase { private static final String VALUE = "Value"; private XPropertyContainer m_bag; @@ -42,30 +54,23 @@ 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 getTestObjectName() { return "PropertyBag"; } + @Before + @Override public void before() { - m_orb = (XMultiServiceFactory)param.getMSF(); + m_orb = getMSF(); } + @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 +81,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 +95,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 +109,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 +122,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 +133,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 +151,15 @@ 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"); + } } + @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 +178,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 +198,26 @@ 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"); + } } } + @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 +236,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 +246,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 +268,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 +290,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..e78f6859fb88 100644 --- a/dbaccess/qa/complex/dbaccess/Query.java +++ b/dbaccess/qa/complex/dbaccess/Query.java @@ -30,28 +30,19 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.container.XIndexAccess; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNamed; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.XQueriesSupplier; import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.uno.UnoRuntime; import connectivity.tools.CRMDatabase; -public class Query extends complexlib.ComplexTestCase { +// ---------- junit imports ----------------- +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ - connectivity.tools.HsqlDatabase m_database; - - // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() { - return new String[] - { - "testQueryColumns" - }; - } +public class Query extends TestCase { - // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() { - return "Query"; - } + connectivity.tools.HsqlDatabase m_database; // -------------------------------------------------------------------------------------------------------- private void createTestCase() @@ -60,25 +51,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(); +// } // -------------------------------------------------------------------------------------------------------- + @Test public void testQueryColumns() { createTestCase(); @@ -107,20 +99,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..ad78eb37718b 100644 --- a/dbaccess/qa/complex/dbaccess/QueryInQuery.java +++ b/dbaccess/qa/complex/dbaccess/QueryInQuery.java @@ -37,28 +37,17 @@ import connectivity.tools.RowSet; import com.sun.star.sdbc.XStatement; import com.sun.star.sdbc.XResultSet; +// ---------- junit imports ----------------- +import org.junit.Test; +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"; - } // -------------------------------------------------------------------------------------------------------- + @Override protected void createTestCase() { try @@ -69,7 +58,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 +73,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,6 +92,7 @@ public class QueryInQuery extends CRMBasedTestCase // -------------------------------------------------------------------------------------------------------- /** executes a SQL statement simply selecting all columns from a query */ + @Test public void executeSimpleSelect() throws SQLException { verifyEqualRowSetContent( @@ -113,6 +103,7 @@ public class QueryInQuery extends CRMBasedTestCase // -------------------------------------------------------------------------------------------------------- /** verifies that aliases for inner queries work as expected */ + @Test public void executeAliasedSelect() throws SQLException { verifyEqualRowSetContent( @@ -126,6 +117,7 @@ public class QueryInQuery extends CRMBasedTestCase // -------------------------------------------------------------------------------------------------------- /** verifies that aliases for inner queries work as expected */ + @Test public void checkNameCollisions() { // create a query with a name which is used by a table @@ -137,7 +129,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,11 +145,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 ); } // -------------------------------------------------------------------------------------------------------- + @Test public void checkCyclicReferences() throws ElementExistException, WrappedTargetException, IllegalArgumentException { // some queries which create a cycle in the sub query tree @@ -172,21 +165,22 @@ 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 ); } // -------------------------------------------------------------------------------------------------------- + @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 3ebfb2263148..90531b29f9ed 100644 --- a/dbaccess/qa/complex/dbaccess/RowSet.java +++ b/dbaccess/qa/complex/dbaccess/RowSet.java @@ -32,7 +32,6 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.container.XIndexAccess; import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.CommandType; import com.sun.star.sdb.XParametersSupplier; import com.sun.star.sdb.XResultSetAccess; @@ -49,7 +48,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 +56,12 @@ import connectivity.tools.sdb.Connection; import java.lang.reflect.Method; import java.util.Random; -public class RowSet extends ComplexTestCase +// ---------- junit imports ----------------- +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ + +public class RowSet extends TestCase { static final int MAX_TABLE_ROWS = 100; @@ -82,7 +86,7 @@ public class RowSet extends ComplexTestCase XRow m_row; int m_id; - public ResultSetMovementStress(XResultSet _resultSet, int _id) throws java.lang.Exception + ResultSetMovementStress(XResultSet _resultSet, int _id) throws java.lang.Exception { m_resultSet = _resultSet; m_row = UnoRuntime.queryInterface( XRow.class, m_resultSet ); @@ -99,50 +103,29 @@ public class RowSet extends ComplexTestCase int pos = m_resultSet.getRow(); testPosition(m_resultSet, m_row, i + 1, "clone move(" + m_id + ")"); 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"; - } - - // -------------------------------------------------------------------------------------------------------- private void createTestCase(boolean _defaultRowSet) { if (m_database == null) { 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()); } } @@ -152,7 +135,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) @@ -162,12 +145,6 @@ public class RowSet extends ComplexTestCase } // -------------------------------------------------------------------------------------------------------- - private XMultiServiceFactory getFactory() - { - return (XMultiServiceFactory) param.getMSF(); - } - - // -------------------------------------------------------------------------------------------------------- /** creates a com.sun.star.sdb.RowSet to use during the test * @param command * the command to use for the RowSet @@ -196,7 +173,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)); @@ -220,15 +197,16 @@ 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()); } } // -------------------------------------------------------------------------------------------------------- + @Test public void testRowSet() throws java.lang.Exception { - log.println("testing testRowSet"); + System.out.println("testing testRowSet"); createTestCase(true); // sequential postioning @@ -278,8 +256,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); } // -------------------------------------------------------------------------------------------------------- @@ -297,7 +275,7 @@ public class RowSet extends ComplexTestCase } catch (Exception e) { - assure("testSequentialPositining failed: " + e, false); + fail("testSequentialPositining failed: " + e); } } @@ -309,13 +287,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); } } @@ -339,7 +317,7 @@ public class RowSet extends ComplexTestCase } catch (Exception e) { - assure("test3 failed: " + e, false); + fail("test3 failed: " + e); } } @@ -366,14 +344,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 { _resultSet.beforeFirst(); @@ -384,7 +362,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(); } @@ -395,14 +373,15 @@ public class RowSet extends ComplexTestCase } catch (Exception e) { - assure("testConcurrentAccess failed: " + e, false); + fail("testConcurrentAccess failed: " + e); } } // -------------------------------------------------------------------------------------------------------- + @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 @@ -547,26 +526,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(); @@ -587,7 +566,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(); } @@ -609,14 +588,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; } // -------------------------------------------------------------------------------------------------------- + @Test public void testDeleteBehavior() throws Exception { createTestCase(true); @@ -639,40 +619,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) @@ -680,7 +660,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 @@ -694,7 +674,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 @@ -708,7 +688,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)); // ..................................................................................................... @@ -723,12 +703,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 @@ -743,14 +723,14 @@ 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); } // -------------------------------------------------------------------------------------------------------- /** checks whether deletions on the main RowSet properly interfere (or don't interfere) with the movement * on a clone of the RowSet */ - @SuppressWarnings("empty-statement") + @Test public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException { createTestCase(true); @@ -768,20 +748,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 @@ -789,36 +769,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 */ + @Test public void testCloneMovesPlusInsertions() throws SQLException, UnknownPropertyException, WrappedTargetException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException { createTestCase(true); @@ -839,7 +820,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"); @@ -871,7 +852,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()); } } // -------------------------------------------------------------------------------------------------------- @@ -888,7 +869,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()); } } @@ -899,7 +880,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) @@ -913,7 +894,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)); } } @@ -934,7 +915,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()); } } @@ -953,7 +934,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 @@ -967,12 +948,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()); } } @@ -997,13 +978,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 */ + @Test public void testParameters() { createTestCase(false); diff --git a/dbaccess/qa/complex/dbaccess/RowSetEventListener.java b/dbaccess/qa/complex/dbaccess/RowSetEventListener.java index c4569986a5d7..2f1d642c19b3 100644 --- a/dbaccess/qa/complex/dbaccess/RowSetEventListener.java +++ b/dbaccess/qa/complex/dbaccess/RowSetEventListener.java @@ -33,7 +33,7 @@ import com.sun.star.sdb.RowChangeEvent; import com.sun.star.lang.EventObject; import com.sun.star.beans.XPropertyChangeListener; -public class RowSetEventListener implements XRowSetApproveListener,XRowSetListener,XPropertyChangeListener +public final class RowSetEventListener implements XRowSetApproveListener,XRowSetListener,XPropertyChangeListener { public static final int APPROVE_CURSOR_MOVE = 0; public static final int APPROVE_ROW_CHANGE = 1; diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java index bb3636100849..89d107ed5bb1 100755 --- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java +++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java @@ -26,16 +26,31 @@ ************************************************************************/ package complex.dbaccess; +import com.sun.star.beans.PropertyState; +import com.sun.star.sdb.SQLFilterOperator; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertyContainer; +import com.sun.star.beans.NamedValue; +import com.sun.star.container.XNameAccess; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.sdb.XParametersSupplier; +import com.sun.star.beans.PropertyValue; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.container.XIndexAccess; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.XSingleSelectQueryComposer; import com.sun.star.uno.UnoRuntime; -import com.sun.star.beans.*; -import com.sun.star.sdbcx.*; -import com.sun.star.sdb.*; -import com.sun.star.container.*; import com.sun.star.sdbc.DataType; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +// ---------- junit imports ----------------- +import org.junit.Test; +import static org.junit.Assert.*; +// ------------------------------------------ + public class SingleSelectQueryComposer extends CRMBasedTestCase { @@ -48,32 +63,13 @@ 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"; - } - - // -------------------------------------------------------------------------------------------------------- private void createQueries() throws Exception { m_database.getDatabase().getDataSource().createQuery(INNERPRODUCTSQUERY, "SELECT * FROM \"products\""); } // -------------------------------------------------------------------------------------------------------- + @Override protected void createTestCase() { try @@ -87,14 +83,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 +120,55 @@ 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 */ + @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) */ + @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 +176,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,40 +194,41 @@ 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") */ + @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 */ + @Test public void testParameters() { try @@ -241,8 +240,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,25 +250,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); } } + @Test public void testConditionByColumn() { try @@ -282,23 +280,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 +308,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,6 +328,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase /** tests the disjunctive normal form functionality, aka the structured filter, * of the composer */ + @Test public void testDisjunctiveNormalForm() { // a simple case: WHERE clause simply is a combination of predicates knitted with AND diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java index b8dae3f6f350..f2cbdf988b38 100644 --- a/dbaccess/qa/complex/dbaccess/TestCase.java +++ b/dbaccess/qa/complex/dbaccess/TestCase.java @@ -26,12 +26,14 @@ ************************************************************************/ package complex.dbaccess; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XModel; import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.Exception; +// import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import helper.FileTools; @@ -40,27 +42,29 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -public abstract class TestCase extends complexlib.ComplexTestCase -{ - // -------------------------------------------------------------------------------------------------------- - protected final XMultiServiceFactory getORB() - { - return (XMultiServiceFactory)param.getMSF(); - } +// ---------- junit imports ----------------- +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; +// ------------------------------------------ + +public abstract class TestCase +{ // -------------------------------------------------------------------------------------------------------- protected final XComponentContext getComponentContext() { 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 +87,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 +117,138 @@ 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[] {} ) ); } // -------------------------------------------------------------------------------------------------------- + /** invokes a given method on a given object, and assures a certain exception is caught + * @param _message + * is the message to print when the check fails + * @param _object + * is the object to invoke the method on + * @param _methodName + * is the name of the method to invoke + * @param _methodArgs + * are the arguments to pass to the method. + * @param _argClasses + * are the classes to assume for the arguments of the methods + * @param _expectedExceptionClass + * is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + protected void assureException( final String _message, final Object _object, final String _methodName, + final Class[] _argClasses, final Object[] _methodArgs, final Class _expectedExceptionClass ) + { + Class objectClass = _object.getClass(); + + boolean noExceptionAllowed = ( _expectedExceptionClass == null ); + + boolean caughtExpected = noExceptionAllowed ? true : false; + try + { + Method method = objectClass.getMethod( _methodName, _argClasses ); + method.invoke(_object, _methodArgs ); + } + catch ( InvocationTargetException e ) + { + caughtExpected = noExceptionAllowed + ? false + : ( e.getTargetException().getClass().equals( _expectedExceptionClass ) ); + } + catch( Exception e ) + { + caughtExpected = false; + } + + assertTrue( _message, caughtExpected ); + } + + /** invokes a given method on a given object, and assures a certain exception is caught + * @param _message is the message to print when the check fails + * @param _object is the object to invoke the method on + * @param _methodName is the name of the method to invoke + * @param _methodArgs are the arguments to pass to the method. Those implicitly define + * the classes of the arguments of the method which is called. + * @param _expectedExceptionClass is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + protected void assureException( final String _message, final Object _object, final String _methodName, + final Object[] _methodArgs, final Class _expectedExceptionClass ) + { + Class[] argClasses = new Class[ _methodArgs.length ]; + for ( int i=0; i<_methodArgs.length; ++i ) + argClasses[i] = _methodArgs[i].getClass(); + assureException( _message, _object, _methodName, argClasses, _methodArgs, _expectedExceptionClass ); + } + + /** invokes a given method on a given object, and assures a certain exception is caught + * @param _object is the object to invoke the method on + * @param _methodName is the name of the method to invoke + * @param _methodArgs are the arguments to pass to the method. Those implicitly define + * the classes of the arguments of the method which is called. + * @param _expectedExceptionClass is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + protected void assureException( final Object _object, final String _methodName, final Object[] _methodArgs, + final Class _expectedExceptionClass ) + { + assureException( + "did not catch the expected exception (" + + ( ( _expectedExceptionClass == null ) ? "none" : _expectedExceptionClass.getName() ) + + ") while calling " + _object.getClass().getName() + "." + _methodName, + _object, _methodName, _methodArgs, _expectedExceptionClass ); + } + + /** invokes a given method on a given object, and assures a certain exception is caught + * @param _object is the object to invoke the method on + * @param _methodName is the name of the method to invoke + * @param _methodArgs are the arguments to pass to the method + * @param _argClasses are the classes to assume for the arguments of the methods + * @param _expectedExceptionClass is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + protected void assureException( final Object _object, final String _methodName, final Class[] _argClasses, + final Object[] _methodArgs, final Class _expectedExceptionClass ) + { + assureException( + "did not catch the expected exception (" + + ( ( _expectedExceptionClass == null ) ? "none" : _expectedExceptionClass.getName() ) + + ") while calling " + _object.getClass().getName() + "." + _methodName, + _object, _methodName, _argClasses, _methodArgs, _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 + { + connection.setUp(); + } + + // -------------------------------------------------------------------------------------------------------- + @AfterClass + public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception + { + 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..536d66025deb 100644 --- a/dbaccess/qa/complex/dbaccess/UISettings.java +++ b/dbaccess/qa/complex/dbaccess/UISettings.java @@ -32,37 +32,26 @@ 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.Test; +import static org.junit.Assert.*; +// ------------------------------------------ + public class UISettings extends TestCase { // -------------------------------------------------------------------------------------------------------- - public String[] getTestMethodNames() - { - return new String[] { - "checkTableFormattingPersistence", - "checkTransparentQueryColumnSettings" - }; - } - - // -------------------------------------------------------------------------------------------------------- - public String getTestObjectName() - { - return "UISettings"; - } - - // -------------------------------------------------------------------------------------------------------- /** verifies that aliases for inner queries work as expected */ + @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 +78,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 +87,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(), 0 ); + assertEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) ); // close the doc database.saveAndClose(); @@ -111,10 +100,11 @@ public class UISettings extends TestCase * settings * @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 +115,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 +133,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/dbaccess.sce b/dbaccess/qa/complex/dbaccess/dbaccess.sce deleted file mode 100644 index c5fa408ff273..000000000000 --- a/dbaccess/qa/complex/dbaccess/dbaccess.sce +++ /dev/null @@ -1,12 +0,0 @@ --o complex.dbaccess.SingleSelectQueryComposer --o complex.dbaccess.RowSet --o complex.dbaccess.PropertyBag --o complex.dbaccess.Query --o complex.dbaccess.QueryInQuery --o complex.dbaccess.DatabaseDocument --o complex.dbaccess.DataSource --o complex.dbaccess.Parser --o complex.dbaccess.ApplicationController --o complex.dbaccess.CopyTableWizard --o complex.dbaccess.UISettings --o complex.dbaccess.Beamer diff --git a/dbaccess/qa/complex/dbaccess/makefile.mk b/dbaccess/qa/complex/dbaccess/makefile.mk index 56a24c0292fc..760f94a294fa 100755 --- a/dbaccess/qa/complex/dbaccess/makefile.mk +++ b/dbaccess/qa/complex/dbaccess/makefile.mk @@ -25,54 +25,78 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = DbaComplexTests -PRJNAME = $(TARGET) -PACKAGE = complex$/dbaccess +.IF "$(OOO_JUNIT_JAR)" == "" +nothing .PHONY: + @echo ----------------------------------------------------- + @echo - JUnit not available, not building anything + @echo ----------------------------------------------------- +.ELSE + +PRJ = ../../.. +PRJNAME = dbaccess +TARGET = qa_complex_dbaccess +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 ------------------------------ +JARFILES = OOoRunner.jar ridl.jar test.jar juh.jar unoil.jar ConnectivityTools.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) -MAXLINELENGTH = 100000 +#----- create a jar from compiled files ---------------------------- -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 +#----- Java files -------------------------------------------------- + +# here store only Files which contain a @Test +JAVATESTFILES = \ + ApplicationController.java \ + Beamer.java \ + DataSource.java \ + DatabaseDocument.java \ + Parser.java \ + PropertyBag.java \ + Query.java \ + QueryInQuery.java \ + RowSet.java \ + SingleSelectQueryComposer.java \ + UISettings.java \ + CopyTableWizard.java \ + +# put here all other files +JAVAFILES = $(JAVATESTFILES) \ + CRMBasedTestCase.java \ + CopyTableInterActionHandler.java \ + DatabaseApplication.java \ + FileHelper.java \ + RowSetEventListener.java \ + TestCase.java \ + + +# Sample how to debug +# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y # --- Targets ------------------------------------------------------ -.IF "$(depend)" == "" +.INCLUDE: target.mk + ALL : ALLTAR -.ELSE -ALL: ALLDEP -.ENDIF -.INCLUDE : target.mk +# --- subsequent tests --------------------------------------------- + +.IF "$(OOO_SUBSEQUENT_TESTS)" != "" + +.INCLUDE: installationtest.mk + +ALLTAR : javatest + # Sample how to debug + # JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y -run: $(CLASSDIR)$/$(JARTARGET) - +$(RUNNER_CALL) $(RUNNER_ARGS) -sce dbaccess.sce +.END # "$(OOO_SUBSEQUENT_TESTS)" == "" -run_%: $(CLASSDIR)$/$(JARTARGET) - +$(RUNNER_CALL) $(RUNNER_ARGS) -o complex.dbaccess.$(@:s/run_//) +.END # ELSE "$(OOO_JUNIT_JAR)" != "" -.ENDIF # "$(SOLAR_JAVA)" == "" |