Kaydet (Commit) 9cd619e2 authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs]

dba34b: massaged the dbaccess complex test cases a bit, made them running,…

dba34b: massaged the dbaccess complex test cases a bit, made them running, again, re-implemented functionality which got list in the recent refactoring (assureException)
üst 088b7d62
ba dbaccess : l10n BOOST:boost connectivity svx stoc qadevOOo xmlscript NULL ba dbaccess : l10n BOOST:boost connectivity svx stoc qadevOOo xmlscript test NULL
ba dbaccess usr1 - all ba_mkout NULL ba dbaccess usr1 - all ba_mkout NULL
ba dbaccess\inc nmake - all ba_inc NULL ba dbaccess\inc nmake - all ba_inc NULL
ba dbaccess\source\ui\inc nmake - all ba_uiinc ba_inc NULL ba dbaccess\source\ui\inc nmake - all ba_uiinc ba_inc NULL
......
...@@ -27,35 +27,27 @@ ...@@ -27,35 +27,27 @@
package complex.dbaccess; package complex.dbaccess;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.frame.FrameSearchFlag; import com.sun.star.frame.FrameSearchFlag;
import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XModel; import com.sun.star.frame.XModel;
import com.sun.star.frame.XStorable; import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent; import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdb.XOfficeDatabaseDocument;
import com.sun.star.sdb.application.XDatabaseDocumentUI; import com.sun.star.sdb.application.XDatabaseDocumentUI;
import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.uno.Exception; import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import connectivity.tools.HsqlColumnDescriptor; import connectivity.tools.HsqlColumnDescriptor;
import connectivity.tools.HsqlDatabase; import connectivity.tools.HsqlDatabase;
import connectivity.tools.HsqlTableDescriptor; import connectivity.tools.HsqlTableDescriptor;
import helper.URLHelper;
import java.io.File;
import java.io.IOException; import java.io.IOException;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -74,16 +66,6 @@ public class ApplicationController extends TestCase ...@@ -74,16 +66,6 @@ public class ApplicationController extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// public String[] getTestMethodNames()
// {
// return new String[]
// {
// "checkSaveAs"
// };
// }
// --------------------------------------------------------------------------------------------------------
public String getTestObjectName() public String getTestObjectName()
{ {
return getClass().getName(); return getClass().getName();
...@@ -129,21 +111,26 @@ public class ApplicationController extends TestCase ...@@ -129,21 +111,26 @@ public class ApplicationController extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Before public void before() throws java.lang.Exception @Before
@Override
public void before() throws java.lang.Exception
{ {
super.before(); super.before();
impl_switchToDocument(null); impl_switchToDocument(null);
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@After public void after() throws java.lang.Exception @After
@Override
public void after() throws java.lang.Exception
{ {
impl_closeDocument(); impl_closeDocument();
super.after(); super.after();
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void checkSaveAs() throws Exception, IOException, java.lang.Exception @Test
public void checkSaveAs() throws Exception, IOException, java.lang.Exception
{ {
// issue 93737 describes the problem that when you save-as a database document, and do changes to it, // issue 93737 describes the problem that when you save-as a database document, and do changes to it,
// then those changes are saved in the old document, actually // then those changes are saved in the old document, actually
......
...@@ -70,51 +70,10 @@ public class Beamer extends TestCase ...@@ -70,51 +70,10 @@ public class Beamer extends TestCase
super(); super();
} }
// // --------------------------------------------------------------------------------------------------------
// protected final XComponentContext getComponentContext()
// {
// XComponentContext context = null;
// try
// {
// final XPropertySet orbProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getORB());
// context = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class,
// orbProps.getPropertyValue("DefaultContext"));
// }
// catch (Exception ex)
// {
// failed("could not retrieve the ComponentContext");
// }
// return context;
// }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Before
// public String[] getTestMethodNames() @Override
// { public void before() throws Exception, java.lang.Exception
// return new String[]
// {
// "testBeamer"
// };
// }
// // --------------------------------------------------------------------------------------------------------
// public String getTestObjectName()
// {
// return getClass().getName();
// }
// --------------------------------------------------------------------------------------------------------
// protected final XMultiServiceFactory getORB()
// {
// return (XMultiServiceFactory) param.getMSF();
// }
// --------------------------------------------------------------------------------------------------------
private void impl_closeDocument()
{
}
// --------------------------------------------------------------------------------------------------------
@Before public void before() throws Exception, java.lang.Exception
{ {
// load it into a frame // load it into a frame
final Object object = getMSF().createInstance("com.sun.star.frame.Desktop"); final Object object = getMSF().createInstance("com.sun.star.frame.Desktop");
...@@ -125,18 +84,20 @@ public class Beamer extends TestCase ...@@ -125,18 +84,20 @@ public class Beamer extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@After public void after() @After
@Override
public void after()
{ {
} }
// --------------------------------------------------------------------------------------------------------
@Test public void testBeamer() throws Exception, IOException, java.lang.Exception // --------------------------------------------------------------------------------------------------------
@Test
public void testBeamer() throws Exception, IOException, java.lang.Exception
{ {
final XController controller = docModel.getCurrentController(); final XController controller = docModel.getCurrentController();
final XFrame frame = controller.getFrame(); final XFrame frame = controller.getFrame();
final XDispatchProvider dispatchP = UnoRuntime.queryInterface(XDispatchProvider.class, frame); final XDispatchProvider dispatchP = UnoRuntime.queryInterface(XDispatchProvider.class, frame);
URL command = new URL(); URL command = new URL();
// command.Complete = ".component:DB/DataSourceBrowser";
command.Complete = ".uno:ViewDataSourceBrowser"; command.Complete = ".uno:ViewDataSourceBrowser";
Object instance = getMSF().createInstance("com.sun.star.util.URLTransformer"); Object instance = getMSF().createInstance("com.sun.star.util.URLTransformer");
......
...@@ -33,11 +33,7 @@ import java.util.logging.Logger; ...@@ -33,11 +33,7 @@ import java.util.logging.Logger;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -60,13 +56,17 @@ public abstract class CRMBasedTestCase extends TestCase ...@@ -60,13 +56,17 @@ public abstract class CRMBasedTestCase extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Before public void before() @Before
@Override
public void before()
{ {
createTestCase(); createTestCase();
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@After public void after() @After
@Override
public void after()
{ {
try try
{ {
......
...@@ -30,6 +30,8 @@ import com.sun.star.lib.uno.helper.WeakBase; ...@@ -30,6 +30,8 @@ import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.task.XInteractionHandler; import com.sun.star.task.XInteractionHandler;
import com.sun.star.task.XInteractionRequest; import com.sun.star.task.XInteractionRequest;
import static org.junit.Assert.*;
/** /**
* *
* @author oj93728 * @author oj93728
...@@ -37,14 +39,12 @@ import com.sun.star.task.XInteractionRequest; ...@@ -37,14 +39,12 @@ import com.sun.star.task.XInteractionRequest;
class CopyTableInterActionHandler extends WeakBase class CopyTableInterActionHandler extends WeakBase
implements XInteractionHandler implements XInteractionHandler
{ {
private final CopyTableWizard test; CopyTableInterActionHandler()
public CopyTableInterActionHandler(CopyTableWizard testCase)
{ {
test = testCase;
} }
public void handle(XInteractionRequest xRequest) public void handle(XInteractionRequest xRequest)
{ {
test.assure(xRequest.toString()); fail( "interaction handler is not expected to be called" );
} }
} }
...@@ -48,11 +48,8 @@ import util.UITools; ...@@ -48,11 +48,8 @@ import util.UITools;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -70,30 +67,18 @@ public class CopyTableWizard extends CRMBasedTestCase ...@@ -70,30 +67,18 @@ public class CopyTableWizard extends CRMBasedTestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// public String[] getTestMethodNames()
// {
// return new String[]
// {
// "copyTable", "copyTableDbase"
// };
// }
// -------------------------------------------------------------------------------------------------------- @After
// @Override @Override
// public String getTestObjectName() public void after()
// {
// return getClass().getName();
// }
// --------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------
@After public void after()
{ {
dest.store(); dest.store();
super.after(); super.after();
} }
@Before public void before() @Before
@Override
public void before()
{ {
try try
{ {
...@@ -106,16 +91,14 @@ public class CopyTableWizard extends CRMBasedTestCase ...@@ -106,16 +91,14 @@ public class CopyTableWizard extends CRMBasedTestCase
fail(""); fail("");
} }
} }
// --------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------
class CopyThread implements Runnable class CopyThread implements Runnable
{ {
final XCopyTableWizard copyWizard; final XCopyTableWizard copyWizard;
public CopyThread(final XCopyTableWizard copyWizard) CopyThread(final XCopyTableWizard copyWizard)
{ {
this.copyWizard = copyWizard; this.copyWizard = copyWizard;
} }
...@@ -138,17 +121,19 @@ public class CopyTableWizard extends CRMBasedTestCase ...@@ -138,17 +121,19 @@ public class CopyTableWizard extends CRMBasedTestCase
return null; return null;
} }
XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface(XExtendedToolkit.class, toolKit); XExtendedToolkit tk = UnoRuntime.queryInterface( XExtendedToolkit.class, toolKit );
Object atw = tk.getActiveTopWindow(); 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 @Test
public void copyTable() throws Exception, IOException, java.lang.Exception
{ {
copyTable(source,source); copyTable(source,source);
} }
@Test public void copyTableDbase() throws Exception, IOException, java.lang.Exception @Test
public void copyTableDbase() throws Exception, IOException, java.lang.Exception
{ {
copyTable(source,dest); copyTable(source,dest);
} }
...@@ -167,15 +152,10 @@ public class CopyTableWizard extends CRMBasedTestCase ...@@ -167,15 +152,10 @@ public class CopyTableWizard extends CRMBasedTestCase
} }
} }
public void assure(final String message)
{
fail(message);
}
private void copyTable(final String tableName, final XConnection sourceConnection, final XConnection destConnection) throws Exception, IOException, java.lang.Exception 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 XComponentContext context = getComponentContext();
final XPropertySet sourceDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor(); final XPropertySet sourceDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor();
sourceDescriptor.setPropertyValue("CommandType", CommandType.TABLE); sourceDescriptor.setPropertyValue("CommandType", CommandType.TABLE);
...@@ -185,7 +165,8 @@ public class CopyTableWizard extends CRMBasedTestCase ...@@ -185,7 +165,8 @@ public class CopyTableWizard extends CRMBasedTestCase
final XPropertySet destDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor(); final XPropertySet destDescriptor = DataAccessDescriptorFactory.get(context).createDataAccessDescriptor();
destDescriptor.setPropertyValue("ActiveConnection", destConnection); 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 copyWizard.setOperation((short) 0); // com.sun.star.sdb.application.CopyDefinitionAndData
Optional<String> auto = new Optional<String>(); Optional<String> auto = new Optional<String>();
...@@ -219,7 +200,7 @@ public class CopyTableWizard extends CRMBasedTestCase ...@@ -219,7 +200,7 @@ public class CopyTableWizard extends CRMBasedTestCase
} }
catch (java.lang.Exception exception) catch (java.lang.Exception exception)
{ {
exception.printStackTrace(); exception.printStackTrace( System.err );
} }
} }
catch (com.sun.star.lang.IndexOutOfBoundsException indexOutOfBoundsException) catch (com.sun.star.lang.IndexOutOfBoundsException indexOutOfBoundsException)
......
...@@ -27,23 +27,14 @@ ...@@ -27,23 +27,14 @@
package complex.dbaccess; package complex.dbaccess;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
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.UnoRuntime;
import com.sun.star.uno.XNamingService; import com.sun.star.uno.XNamingService;
// import complexlib.ComplexTestCase;
import connectivity.tools.CRMDatabase; import connectivity.tools.CRMDatabase;
import connectivity.tools.HsqlDatabase; import connectivity.tools.HsqlDatabase;
//import java.util.logging.Level;
//import java.util.logging.Logger;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -54,21 +45,6 @@ public class DataSource extends TestCase ...@@ -54,21 +45,6 @@ public class DataSource extends TestCase
HsqlDatabase m_database; HsqlDatabase m_database;
connectivity.tools.DataSource m_dataSource; connectivity.tools.DataSource m_dataSource;
// --------------------------------------------------------------------------------------------------------
// public String[] getTestMethodNames()
// {
// return new String[]
// {
// "testRegistrationName"
// };
// }
//
// // --------------------------------------------------------------------------------------------------------
// public String getTestObjectName()
// {
// return "DataSource";
// }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
private void createTestCase() private void createTestCase()
{ {
...@@ -92,13 +68,8 @@ public class DataSource extends TestCase ...@@ -92,13 +68,8 @@ public class DataSource extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// private XMultiServiceFactory getFactory() @Test
// { public void testRegistrationName()
// return (XMultiServiceFactory) param.getMSF();
// }
// --------------------------------------------------------------------------------------------------------
@Test public void testRegistrationName()
{ {
try try
{ {
...@@ -109,8 +80,8 @@ public class DataSource extends TestCase ...@@ -109,8 +80,8 @@ public class DataSource extends TestCase
assertEquals("pre-registered database has a wrong name!", dataSourceName, bibliography.getName()); 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 // 2. register a newly created data source, and verify it has the proper name
dataSourceName = "someDataSource"; dataSourceName = "someDataSource";
final XNamingService dataSourceRegistrations = (XNamingService) UnoRuntime.queryInterface( final XNamingService dataSourceRegistrations = UnoRuntime.queryInterface(
XNamingService.class, getMSF().createInstance("com.sun.star.sdb.DatabaseContext")); XNamingService.class, getMSF().createInstance( "com.sun.star.sdb.DatabaseContext" ) );
final XNameAccess existenceCheck = UnoRuntime.queryInterface( XNameAccess.class, dataSourceRegistrations ); final XNameAccess existenceCheck = UnoRuntime.queryInterface( XNameAccess.class, dataSourceRegistrations );
if ( existenceCheck.hasByName( "someDataSource" ) ) if ( existenceCheck.hasByName( "someDataSource" ) )
dataSourceRegistrations.revokeObject( "someDataSource" ); dataSourceRegistrations.revokeObject( "someDataSource" );
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
************************************************************************/ ************************************************************************/
package complex.dbaccess; 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.awt.XTopWindow;
import com.sun.star.beans.PropertyState; import com.sun.star.beans.PropertyState;
import com.sun.star.document.DocumentEvent; import com.sun.star.document.DocumentEvent;
...@@ -83,11 +85,8 @@ import java.util.logging.Logger; ...@@ -83,11 +85,8 @@ import java.util.logging.Logger;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -253,25 +252,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -253,25 +252,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
// ======================================================================================================== // ========================================================================================================
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// public String[] getTestMethodNames() @Before
// { public void before() throws java.lang.Exception
// return new String[]
// {
// "testLoadable",
// "testDocumentRevenants",
// "testDocumentEvents",
// "testGlobalEvents"
// };
// }
//
// // --------------------------------------------------------------------------------------------------------
// public String getTestObjectName()
// {
// return "DatabaseDocument";
// }
// --------------------------------------------------------------------------------------------------------
@Before public void before() throws java.lang.Exception
{ {
super.before(); super.before();
...@@ -297,7 +279,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -297,7 +279,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@After public void after() throws java.lang.Exception @After
public void after() throws java.lang.Exception
{ {
try try
{ {
...@@ -326,7 +309,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -326,7 +309,7 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
public Class unoInterfaceClass = null; public Class unoInterfaceClass = null;
public String methodName = null; public String methodName = null;
public UnoMethodDescriptor(Class _class, String _method) UnoMethodDescriptor(Class _class, String _method)
{ {
unoInterfaceClass = _class; unoInterfaceClass = _class;
methodName = _method; methodName = _method;
...@@ -351,8 +334,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -351,8 +334,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
for (int i = 0; i < unsupportedMethods.length; ++i) for (int i = 0; i < unsupportedMethods.length; ++i)
{ {
// assureException( _document, unsupportedMethods[i].unoInterfaceClass, assureException( _document, unsupportedMethods[i].unoInterfaceClass,
// unsupportedMethods[i].methodName, new Object[]{}, _isInitialized ? null : NotInitializedException.class ); unsupportedMethods[i].methodName, new Object[]{}, _isInitialized ? null : NotInitializedException.class );
} }
} }
...@@ -410,7 +393,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -410,7 +393,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void testLoadable() throws Exception, IOException @Test
public void testLoadable() throws Exception, IOException
{ {
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
String documentURL = databaseDoc.getURL(); String documentURL = databaseDoc.getURL();
...@@ -438,10 +422,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -438,10 +422,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
impl_checkDocumentInitState(databaseDoc, true); impl_checkDocumentInitState(databaseDoc, true);
// and while we are here ... initilizing the same document again should not be possible // and while we are here ... initilizing the same document again should not be possible
// assureException( databaseDoc, XLoadable.class, "initNew", new Object[0], assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
// DoubleInitializationException.class ); DoubleInitializationException.class );
// assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] }, assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] },
// DoubleInitializationException.class ); DoubleInitializationException.class );
// .................................................................... // ....................................................................
// 3. XLoadable::initNew // 3. XLoadable::initNew
...@@ -453,10 +437,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -453,10 +437,10 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
impl_checkDocumentInitState(databaseDoc, true); impl_checkDocumentInitState(databaseDoc, true);
// same as above - initializing the document a second time must fail // same as above - initializing the document a second time must fail
// assureException( databaseDoc, XLoadable.class, "initNew", new Object[0], assureException( databaseDoc, XLoadable.class, "initNew", new Object[0],
// DoubleInitializationException.class ); DoubleInitializationException.class );
// assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] }, assureException( databaseDoc, XLoadable.class, "load", new Object[] { new PropertyValue[0] },
// DoubleInitializationException.class ); DoubleInitializationException.class );
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
...@@ -571,7 +555,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -571,7 +555,8 @@ 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 * 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. * instance and re-creation as a revenant.
*/ */
@Test public void testDocumentRevenants() throws Exception, IOException @Test
public void testDocumentRevenants() throws Exception, IOException
{ {
// create an empty document // create an empty document
XModel databaseDoc = impl_createDocWithMacro( "Lib", "Module", XModel databaseDoc = impl_createDocWithMacro( "Lib", "Module",
...@@ -623,7 +608,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -623,7 +608,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void testDocumentEvents() throws Exception, IOException @Test
public void testDocumentEvents() throws Exception, IOException
{ {
// create an empty document // create an empty document
final String libName = "EventHandlers"; final String libName = "EventHandlers";
...@@ -691,7 +677,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. ...@@ -691,7 +677,8 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document.
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void testGlobalEvents() throws Exception, IOException @Test
public void testGlobalEvents() throws Exception, IOException
{ {
XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument();
final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDoc); final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, databaseDoc);
......
...@@ -37,34 +37,14 @@ import com.sun.star.uno.UnoRuntime; ...@@ -37,34 +37,14 @@ import com.sun.star.uno.UnoRuntime;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
public class Parser extends CRMBasedTestCase public class Parser extends CRMBasedTestCase
{ {
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// public String[] getTestMethodNames() @Override
// {
// return new String[] {
// "checkJoinSyntax",
// "checkParameterTypes",
// "checkWhere",
// };
// }
// --------------------------------------------------------------------------------------------------------
// public String getTestObjectName()
// {
// return "Parser";
// }
// --------------------------------------------------------------------------------------------------------
protected void createTestCase() protected void createTestCase()
{ {
try try
...@@ -79,7 +59,9 @@ public class Parser extends CRMBasedTestCase ...@@ -79,7 +59,9 @@ public class Parser extends CRMBasedTestCase
} }
} }
@Test public void checkWhere() throws Exception // --------------------------------------------------------------------------------------------------------
@Test
public void checkWhere() throws Exception
{ {
final XSingleSelectQueryComposer composer = createQueryComposer(); final XSingleSelectQueryComposer composer = createQueryComposer();
final String SELECT = "SELECT \"products\".\"Name\" FROM \"products\" WHERE "; final String SELECT = "SELECT \"products\".\"Name\" FROM \"products\" WHERE ";
...@@ -118,7 +100,8 @@ public class Parser extends CRMBasedTestCase ...@@ -118,7 +100,8 @@ public class Parser extends CRMBasedTestCase
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected /** verifies that aliases for inner queries work as expected
*/ */
@Test public void checkJoinSyntax() throws Exception @Test
public void checkJoinSyntax() throws Exception
{ {
final XSingleSelectQueryComposer composer = createQueryComposer(); final XSingleSelectQueryComposer composer = createQueryComposer();
...@@ -186,7 +169,8 @@ public class Parser extends CRMBasedTestCase ...@@ -186,7 +169,8 @@ public class Parser extends CRMBasedTestCase
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
/** verifies that the parser properly recognizes the types of parameters /** verifies that the parser properly recognizes the types of parameters
*/ */
@Test public void checkParameterTypes() throws Exception @Test
public void checkParameterTypes() throws Exception
{ {
impl_checkParameters( impl_checkParameters(
"SELECT * FROM \"all orders\" " + "SELECT * FROM \"all orders\" " +
......
...@@ -29,18 +29,20 @@ package complex.dbaccess; ...@@ -29,18 +29,20 @@ 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.UnoRuntime;
import com.sun.star.uno.XInterface; import com.sun.star.uno.XInterface;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.beans.*;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -52,27 +54,20 @@ public class PropertyBag extends TestCase ...@@ -52,27 +54,20 @@ public class PropertyBag extends TestCase
private XPropertyAccess m_access; private XPropertyAccess m_access;
private XMultiServiceFactory m_orb = null; private XMultiServiceFactory m_orb = null;
// public String[] getTestMethodNames()
// {
// return new String[]
// {
// "checkBasics",
// "checkSequenceAccess",
// "checkDynamicSet"
// };
// }
public String getTestObjectName() public String getTestObjectName()
{ {
return "PropertyBag"; return "PropertyBag";
} }
@Before public void before() @Before
@Override
public void before()
{ {
m_orb = getMSF(); m_orb = getMSF();
} }
@Test public void checkBasics() @Test
public void checkBasics()
{ {
createEmptyBag(); createEmptyBag();
System.out.println("testing the basics"); System.out.println("testing the basics");
...@@ -161,7 +156,8 @@ public class PropertyBag extends TestCase ...@@ -161,7 +156,8 @@ public class PropertyBag extends TestCase
} }
} }
@Test public void checkSequenceAccess() throws com.sun.star.uno.Exception @Test
public void checkSequenceAccess() throws com.sun.star.uno.Exception
{ {
System.out.println( "checking PropertySetAccess via sequences" ); System.out.println( "checking PropertySetAccess via sequences" );
createStandardBag( false ); createStandardBag( false );
...@@ -218,7 +214,8 @@ public class PropertyBag extends TestCase ...@@ -218,7 +214,8 @@ public class PropertyBag extends TestCase
} }
} }
@Test public void checkDynamicSet() throws com.sun.star.uno.Exception @Test
public void checkDynamicSet() throws com.sun.star.uno.Exception
{ {
System.out.println( "checking proper dynamic of the set" ); System.out.println( "checking proper dynamic of the set" );
createStandardBag( false ); createStandardBag( false );
......
...@@ -30,19 +30,13 @@ import com.sun.star.beans.XPropertySet; ...@@ -30,19 +30,13 @@ import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XIndexAccess; import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNamed; import com.sun.star.container.XNamed;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.XQueriesSupplier; import com.sun.star.sdb.XQueriesSupplier;
import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.sdbcx.XColumnsSupplier;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import connectivity.tools.CRMDatabase; import connectivity.tools.CRMDatabase;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -50,19 +44,6 @@ public class Query extends TestCase { ...@@ -50,19 +44,6 @@ public class Query extends TestCase {
connectivity.tools.HsqlDatabase m_database; connectivity.tools.HsqlDatabase m_database;
// --------------------------------------------------------------------------------------------------------
// public String[] getTestMethodNames() {
// return new String[]
// {
// "testQueryColumns"
// };
// }
// --------------------------------------------------------------------------------------------------------
// public String getTestObjectName() {
// return "Query";
// }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
private void createTestCase() private void createTestCase()
{ {
...@@ -89,7 +70,8 @@ public class Query extends TestCase { ...@@ -89,7 +70,8 @@ public class Query extends TestCase {
// } // }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void testQueryColumns() @Test
public void testQueryColumns()
{ {
createTestCase(); createTestCase();
......
...@@ -38,37 +38,16 @@ import com.sun.star.sdbc.XStatement; ...@@ -38,37 +38,16 @@ import com.sun.star.sdbc.XStatement;
import com.sun.star.sdbc.XResultSet; import com.sun.star.sdbc.XResultSet;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
public class QueryInQuery extends CRMBasedTestCase public class QueryInQuery extends CRMBasedTestCase
{ {
private static final String QUERY_PRODUCTS = "query products"; 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() protected void createTestCase()
{ {
try try
...@@ -113,7 +92,8 @@ public class QueryInQuery extends CRMBasedTestCase ...@@ -113,7 +92,8 @@ public class QueryInQuery extends CRMBasedTestCase
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
/** executes a SQL statement simply selecting all columns from a query /** executes a SQL statement simply selecting all columns from a query
*/ */
@Test public void executeSimpleSelect() throws SQLException @Test
public void executeSimpleSelect() throws SQLException
{ {
verifyEqualRowSetContent( verifyEqualRowSetContent(
CommandType.COMMAND, "SELECT * FROM \"query products\"", CommandType.COMMAND, "SELECT * FROM \"query products\"",
...@@ -123,7 +103,8 @@ public class QueryInQuery extends CRMBasedTestCase ...@@ -123,7 +103,8 @@ public class QueryInQuery extends CRMBasedTestCase
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected /** verifies that aliases for inner queries work as expected
*/ */
@Test public void executeAliasedSelect() throws SQLException @Test
public void executeAliasedSelect() throws SQLException
{ {
verifyEqualRowSetContent( verifyEqualRowSetContent(
CommandType.COMMAND, "SELECT \"PROD\".\"ID\" FROM \"query products\" AS \"PROD\"", CommandType.COMMAND, "SELECT \"PROD\".\"ID\" FROM \"query products\" AS \"PROD\"",
...@@ -136,7 +117,8 @@ public class QueryInQuery extends CRMBasedTestCase ...@@ -136,7 +117,8 @@ public class QueryInQuery extends CRMBasedTestCase
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
/** verifies that aliases for inner queries work as expected /** verifies that aliases for inner queries work as expected
*/ */
@Test public void checkNameCollisions() @Test
public void checkNameCollisions()
{ {
// create a query with a name which is used by a table // create a query with a name which is used by a table
boolean caughtExpected = false; boolean caughtExpected = false;
...@@ -168,7 +150,8 @@ public class QueryInQuery extends CRMBasedTestCase ...@@ -168,7 +150,8 @@ public class QueryInQuery extends CRMBasedTestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void checkCyclicReferences() throws ElementExistException, WrappedTargetException, IllegalArgumentException @Test
public void checkCyclicReferences() throws ElementExistException, WrappedTargetException, IllegalArgumentException
{ {
// some queries which create a cycle in the sub query tree // some queries which create a cycle in the sub query tree
m_database.getDatabase().getDataSource().createQuery( "orders level 1", "SELECT * FROM \"orders level 0\"" ); m_database.getDatabase().getDataSource().createQuery( "orders level 1", "SELECT * FROM \"orders level 0\"" );
...@@ -186,7 +169,8 @@ public class QueryInQuery extends CRMBasedTestCase ...@@ -186,7 +169,8 @@ public class QueryInQuery extends CRMBasedTestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void checkStatementQiQSupport() @Test
public void checkStatementQiQSupport()
{ {
try try
{ {
......
...@@ -32,7 +32,6 @@ import com.sun.star.beans.XPropertySet; ...@@ -32,7 +32,6 @@ import com.sun.star.beans.XPropertySet;
import com.sun.star.container.XIndexAccess; import com.sun.star.container.XIndexAccess;
import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.WrappedTargetException;
import com.sun.star.lang.XComponent; import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.sdb.CommandType; import com.sun.star.sdb.CommandType;
import com.sun.star.sdb.XParametersSupplier; import com.sun.star.sdb.XParametersSupplier;
import com.sun.star.sdb.XResultSetAccess; import com.sun.star.sdb.XResultSetAccess;
...@@ -58,12 +57,7 @@ import java.lang.reflect.Method; ...@@ -58,12 +57,7 @@ import java.lang.reflect.Method;
import java.util.Random; import java.util.Random;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -92,7 +86,7 @@ public class RowSet extends TestCase ...@@ -92,7 +86,7 @@ public class RowSet extends TestCase
XRow m_row; XRow m_row;
int m_id; 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_resultSet = _resultSet;
m_row = UnoRuntime.queryInterface( XRow.class, m_resultSet ); m_row = UnoRuntime.queryInterface( XRow.class, m_resultSet );
...@@ -123,27 +117,6 @@ public class RowSet extends TestCase ...@@ -123,27 +117,6 @@ public class RowSet extends TestCase
} }
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// public String[] getTestMethodNames()
// {
// return new String[]
// {
// "testRowSet",
// "testRowSetEvents",
// "testDeleteBehavior",
// "testCloneMovesPlusDeletions",
// "testCloneMovesPlusInsertions",
// "testParameters"
// };
// }
//
// // --------------------------------------------------------------------------------------------------------
// public String getTestObjectName()
// {
// return "RowSet";
// }
//
// --------------------------------------------------------------------------------------------------------
private void createTestCase(boolean _defaultRowSet) private void createTestCase(boolean _defaultRowSet)
{ {
if (m_database == null) if (m_database == null)
...@@ -175,12 +148,6 @@ public class RowSet extends TestCase ...@@ -175,12 +148,6 @@ public class RowSet extends TestCase
} }
} }
// --------------------------------------------------------------------------------------------------------
// private XMultiServiceFactory getFactory()
// {
// return (XMultiServiceFactory) param.getMSF();
// }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
/** creates a com.sun.star.sdb.RowSet to use during the test /** creates a com.sun.star.sdb.RowSet to use during the test
* @param command * @param command
...@@ -239,7 +206,8 @@ public class RowSet extends TestCase ...@@ -239,7 +206,8 @@ public class RowSet extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void testRowSet() throws java.lang.Exception @Test
public void testRowSet() throws java.lang.Exception
{ {
System.out.println("testing testRowSet"); System.out.println("testing testRowSet");
...@@ -415,7 +383,8 @@ public class RowSet extends TestCase ...@@ -415,7 +383,8 @@ public class RowSet extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void testRowSetEvents() throws java.lang.Exception @Test
public void testRowSetEvents() throws java.lang.Exception
{ {
System.out.println("testing RowSet Events"); System.out.println("testing RowSet Events");
createTestCase(true); createTestCase(true);
...@@ -632,7 +601,8 @@ public class RowSet extends TestCase ...@@ -632,7 +601,8 @@ public class RowSet extends TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Test public void testDeleteBehavior() throws Exception @Test
public void testDeleteBehavior() throws Exception
{ {
createTestCase(true); createTestCase(true);
...@@ -765,8 +735,8 @@ public class RowSet extends TestCase ...@@ -765,8 +735,8 @@ public class RowSet extends TestCase
/** checks whether deletions on the main RowSet properly interfere (or don't interfere) with the movement /** checks whether deletions on the main RowSet properly interfere (or don't interfere) with the movement
* on a clone of the RowSet * on a clone of the RowSet
*/ */
@SuppressWarnings("empty-statement") @Test
@Test public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException public void testCloneMovesPlusDeletions() throws SQLException, UnknownPropertyException, WrappedTargetException
{ {
createTestCase(true); createTestCase(true);
// ensure that all records are known // ensure that all records are known
...@@ -834,7 +804,8 @@ public class RowSet extends TestCase ...@@ -834,7 +804,8 @@ public class RowSet extends TestCase
/** checks whether insertions on the main RowSet properly interfere (or don't interfere) with the movement /** checks whether insertions on the main RowSet properly interfere (or don't interfere) with the movement
* on a clone of the RowSet * on a clone of the RowSet
*/ */
@Test public void testCloneMovesPlusInsertions() throws SQLException, UnknownPropertyException, WrappedTargetException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException @Test
public void testCloneMovesPlusInsertions() throws SQLException, UnknownPropertyException, WrappedTargetException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException
{ {
createTestCase(true); createTestCase(true);
// ensure that all records are known // ensure that all records are known
...@@ -1019,7 +990,8 @@ public class RowSet extends TestCase ...@@ -1019,7 +990,8 @@ public class RowSet extends TestCase
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
/** checks the XParametersSupplier functionality of a RowSet /** checks the XParametersSupplier functionality of a RowSet
*/ */
@Test public void testParameters() @Test
public void testParameters()
{ {
createTestCase(false); createTestCase(false);
// use an own RowSet instance, not the one which is also used for the other cases // use an own RowSet instance, not the one which is also used for the other cases
......
...@@ -33,7 +33,7 @@ import com.sun.star.sdb.RowChangeEvent; ...@@ -33,7 +33,7 @@ import com.sun.star.sdb.RowChangeEvent;
import com.sun.star.lang.EventObject; import com.sun.star.lang.EventObject;
import com.sun.star.beans.XPropertyChangeListener; 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_CURSOR_MOVE = 0;
public static final int APPROVE_ROW_CHANGE = 1; public static final int APPROVE_ROW_CHANGE = 1;
......
...@@ -26,23 +26,28 @@ ...@@ -26,23 +26,28 @@
************************************************************************/ ************************************************************************/
package complex.dbaccess; 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.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 com.sun.star.sdbc.DataType;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -57,26 +62,6 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -57,26 +62,6 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
" OR ( \"Postal\" = '9' )"; " OR ( \"Postal\" = '9' )";
private final static String INNERPRODUCTSQUERY = "products (inner)"; 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 private void createQueries() throws Exception
{ {
...@@ -84,6 +69,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -84,6 +69,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
@Override
protected void createTestCase() protected void createTestCase()
{ {
try try
...@@ -141,7 +127,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -141,7 +127,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
/** tests setCommand of the composer /** tests setCommand of the composer
*/ */
@Test public void testSetCommand() @Test
public void testSetCommand()
{ {
System.out.println("testing SingleSelectQueryComposer's setCommand"); System.out.println("testing SingleSelectQueryComposer's setCommand");
...@@ -166,7 +153,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -166,7 +153,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
} }
/** tests accessing attributes of the composer (order, filter, group by, having) /** tests accessing attributes of the composer (order, filter, group by, having)
*/ */
@Test public void testAttributes() @Test
public void testAttributes()
{ {
System.out.println("testing SingleSelectQueryComposer's attributes (order, filter, group by, having)"); System.out.println("testing SingleSelectQueryComposer's attributes (order, filter, group by, having)");
...@@ -223,7 +211,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -223,7 +211,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
/** test various sub query related features ("queries in queries") /** test various sub query related features ("queries in queries")
*/ */
@Test public void testSubQueries() throws Exception @Test
public void testSubQueries() throws Exception
{ {
m_composer.setQuery("SELECT * from \"" + INNERPRODUCTSQUERY + "\""); m_composer.setQuery("SELECT * from \"" + INNERPRODUCTSQUERY + "\"");
final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_composer); final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_composer);
...@@ -239,7 +228,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -239,7 +228,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
/** tests the XParametersSupplier functionality /** tests the XParametersSupplier functionality
*/ */
@Test public void testParameters() @Test
public void testParameters()
{ {
try try
{ {
...@@ -278,7 +268,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -278,7 +268,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
} }
} }
@Test public void testConditionByColumn() @Test
public void testConditionByColumn()
{ {
try try
{ {
...@@ -337,7 +328,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase ...@@ -337,7 +328,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
/** tests the disjunctive normal form functionality, aka the structured filter, /** tests the disjunctive normal form functionality, aka the structured filter,
* of the composer * of the composer
*/ */
@Test public void testDisjunctiveNormalForm() @Test
public void testDisjunctiveNormalForm()
{ {
// a simple case: WHERE clause simply is a combination of predicates knitted with AND // a simple case: WHERE clause simply is a combination of predicates knitted with AND
String query = String query =
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
************************************************************************/ ************************************************************************/
package complex.dbaccess; package complex.dbaccess;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XComponentLoader;
...@@ -41,11 +43,8 @@ import java.net.URI; ...@@ -41,11 +43,8 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test;
import org.openoffice.test.OfficeConnection; import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
...@@ -54,12 +53,6 @@ import static org.junit.Assert.*; ...@@ -54,12 +53,6 @@ import static org.junit.Assert.*;
public abstract class TestCase public abstract class TestCase
{ {
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// protected final XMultiServiceFactory getORB()
// {
// return (XMultiServiceFactory)param.getMSF();
// }
// --------------------------------------------------------------------------------------------------------
protected final XComponentContext getComponentContext() protected final XComponentContext getComponentContext()
{ {
XComponentContext context = null; XComponentContext context = null;
...@@ -130,31 +123,129 @@ public abstract class TestCase ...@@ -130,31 +123,129 @@ public abstract class TestCase
} }
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// protected void assureException( Object _object, Class _unoInterfaceClass, String _methodName, Object[] _methodArgs, /** invokes a given method on a given object, and assures a certain exception is caught
// Class _expectedExceptionClass ) * @param _message
// { * is the message to print when the check fails
// assureException( UnoRuntime.queryInterface( _unoInterfaceClass, _object ), _methodName, * @param _object
// _methodArgs, _expectedExceptionClass ); * 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() protected XMultiServiceFactory getMSF()
{ {
final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
return xMSF1; return xMSF1;
} }
// --------------------------------------------------------------------------------------------------------
// setup and close connections // setup and close connections
@BeforeClass public static void setUpConnection() throws Exception { @BeforeClass
System.out.println("setUpConnection()"); public static void setUpConnection() throws Exception
{
connection.setUp(); connection.setUp();
} }
@AfterClass public static void tearDownConnection() // --------------------------------------------------------------------------------------------------------
throws InterruptedException, com.sun.star.uno.Exception @AfterClass
public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
{ {
System.out.println("tearDownConnection()");
connection.tearDown(); connection.tearDown();
} }
......
...@@ -38,36 +38,17 @@ import com.sun.star.util.XCloseable; ...@@ -38,36 +38,17 @@ import com.sun.star.util.XCloseable;
import connectivity.tools.CRMDatabase; import connectivity.tools.CRMDatabase;
// ---------- junit imports ----------------- // ---------- junit imports -----------------
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*; import static org.junit.Assert.*;
// ------------------------------------------ // ------------------------------------------
public class UISettings extends TestCase 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 /** verifies that aliases for inner queries work as expected
*/ */
@Test public void checkTableFormattingPersistence() throws java.lang.Exception @Test
public void checkTableFormattingPersistence() throws java.lang.Exception
{ {
// create, load, and connect a DB doc // create, load, and connect a DB doc
CRMDatabase database = new CRMDatabase( getMSF(), true ); CRMDatabase database = new CRMDatabase( getMSF(), true );
...@@ -107,7 +88,7 @@ public class UISettings extends TestCase ...@@ -107,7 +88,7 @@ public class UISettings extends TestCase
// verify the properties // verify the properties
assertEquals( "wrong font name", "Andale Sans UI", (String)tableControlModel.getPropertyValue( "FontName" ) ); assertEquals( "wrong font name", "Andale Sans UI", (String)tableControlModel.getPropertyValue( "FontName" ) );
assertEquals( "wrong font height", (float)20, ((Float)tableControlModel.getPropertyValue( "FontHeight" )).floatValue() ); assertEquals( "wrong font height", (float)20, ((Float)tableControlModel.getPropertyValue( "FontHeight" )).floatValue(), 0 );
assertEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) ); assertEquals( "wrong font slant", FontSlant.ITALIC, (FontSlant)tableControlModel.getPropertyValue( "FontSlant" ) );
// close the doc // close the doc
...@@ -119,7 +100,8 @@ public class UISettings extends TestCase ...@@ -119,7 +100,8 @@ public class UISettings extends TestCase
* settings * settings
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@Test public void checkTransparentQueryColumnSettings() throws java.lang.Exception @Test
public void checkTransparentQueryColumnSettings() throws java.lang.Exception
{ {
// create, load, and connect a DB doc // create, load, and connect a DB doc
CRMDatabase database = new CRMDatabase( getMSF(), true ); CRMDatabase database = new CRMDatabase( getMSF(), true );
......
-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
...@@ -25,22 +25,36 @@ ...@@ -25,22 +25,36 @@
# #
#************************************************************************* #*************************************************************************
.IF "$(OOO_SUBSEQUENT_TESTS)" == "" .IF "$(OOO_JUNIT_JAR)" == ""
nothing .PHONY: nothing .PHONY:
@echo -----------------------------------------------------
@echo - JUnit not available, not building anything
@echo -----------------------------------------------------
.ELSE .ELSE
PRJ = ../../.. PRJ = ../../..
PRJNAME = dbaccess PRJNAME = dbaccess
TARGET = qa_complex_dbaccess TARGET = qa_complex_dbaccess
.IF "$(OOO_JUNIT_JAR)" != ""
PACKAGE = complex/dbaccess PACKAGE = complex/dbaccess
# --- Settings -----------------------------------------------------
.INCLUDE: settings.mk
#----- compile .java files -----------------------------------------
JARFILES = OOoRunner.jar ridl.jar test.jar juh.jar unoil.jar ConnectivityTools.jar
EXTRAJARFILES = $(OOO_JUNIT_JAR)
#----- create a jar from compiled files ----------------------------
JARTARGET = $(TARGET).jar
#----- Java files --------------------------------------------------
# here store only Files which contain a @Test # here store only Files which contain a @Test
JAVATESTFILES = \ JAVATESTFILES = \
ApplicationController.java \ ApplicationController.java \
Beamer.java \ Beamer.java \
CRMBasedTestCase.java \
CopyTableWizard.java \ CopyTableWizard.java \
DataSource.java \ DataSource.java \
DatabaseDocument.java \ DatabaseDocument.java \
...@@ -51,83 +65,38 @@ JAVATESTFILES = \ ...@@ -51,83 +65,38 @@ JAVATESTFILES = \
RowSet.java \ RowSet.java \
SingleSelectQueryComposer.java \ SingleSelectQueryComposer.java \
UISettings.java \ UISettings.java \
TestCase.java
# put here all other files # put here all other files
JAVAFILES = $(JAVATESTFILES) \ JAVAFILES = $(JAVATESTFILES) \
CRMBasedTestCase.java \
CopyTableInterActionHandler.java \ CopyTableInterActionHandler.java \
DatabaseApplication.java \ DatabaseApplication.java \
FileHelper.java \ FileHelper.java \
RowSetEventListener.java RowSetEventListener.java \
TestCase.java
JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar ConnectivityTools.jar
EXTRAJARFILES = $(OOO_JUNIT_JAR)
# Sample how to debug # Sample how to debug
# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y # JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
.END # --- Targets ------------------------------------------------------
.INCLUDE: settings.mk
.INCLUDE: target.mk .INCLUDE: target.mk
ALL : ALLTAR
# --- subsequent tests ---------------------------------------------
.IF "$(OOO_SUBSEQUENT_TESTS)" != ""
.INCLUDE: installationtest.mk .INCLUDE: installationtest.mk
ALLTAR : javatest ALLTAR : javatest
.END # Sample how to debug
# JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y
.END # "$(OOO_SUBSEQUENT_TESTS)" == ""
.END # ELSE "$(OOO_JUNIT_JAR)" != ""
#
#
# PRJ = ..$/..$/..
# TARGET = DbaComplexTests
# PRJNAME = $(TARGET)
# PACKAGE = complex$/dbaccess
#
# # --- Settings -----------------------------------------------------
# .INCLUDE: settings.mk
#
# .IF "$(SOLAR_JAVA)" == ""
# all:
# @echo "Java not available. Build skipped"
#
# .INCLUDE : target.mk
# .ELSE
#
# #----- compile .java files -----------------------------------------
#
# JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar ConnectivityTools.jar
# JAVAFILES := $(shell @$(FIND) ./*.java)
# JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
#
# #----- make a jar from compiled files ------------------------------
#
# MAXLINELENGTH = 100000
#
# JARCLASSDIRS = $(PACKAGE)
# JARTARGET = $(TARGET).jar
# JARCOMPRESS = TRUE
#
# RUNNER_ARGS = -cp "$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar" org.openoffice.Runner -TestBase java_complex
#
# RUNNER_CALL = $(AUGMENT_LIBRARY_PATH) java
#
# # --- Targets ------------------------------------------------------
#
# .IF "$(depend)" == ""
# ALL : ALLTAR
# .ELSE
# ALL: ALLDEP
# .ENDIF
#
# .INCLUDE : target.mk
#
#
# run: $(CLASSDIR)$/$(JARTARGET)
# +$(RUNNER_CALL) $(RUNNER_ARGS) -sce dbaccess.sce
#
# run_%: $(CLASSDIR)$/$(JARTARGET)
# +$(RUNNER_CALL) $(RUNNER_ARGS) -o complex.dbaccess.$(@:s/run_//)
#
# .ENDIF # "$(SOLAR_JAVA)" == ""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment