summaryrefslogtreecommitdiff
path: root/dbaccess/qa
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-06-05 10:24:36 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-06-05 13:17:50 +0000
commit275f0c7b250d448a8e2658ee2f26d4010628237b (patch)
tree9537d17adfe0f098a27f84c0f0710b6ba2592aeb /dbaccess/qa
parent9eb1bfcbb164a8d029d7ba92947e0c9caf8e0826 (diff)
Let JUnit take care of exceptions
Inspired by commit 4dd0ac62855c5b9382cac004c7eebb9bed983a2b Change-Id: I6ca29aecde357a3cb5852acfc9b5443761052960 Reviewed-on: https://gerrit.libreoffice.org/16094 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'dbaccess/qa')
-rw-r--r--dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java31
-rw-r--r--dbaccess/qa/complex/dbaccess/CopyTableWizard.java21
-rw-r--r--dbaccess/qa/complex/dbaccess/DataSource.java59
-rw-r--r--dbaccess/qa/complex/dbaccess/Parser.java15
-rw-r--r--dbaccess/qa/complex/dbaccess/PropertyBag.java19
-rw-r--r--dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java257
6 files changed, 148 insertions, 254 deletions
diff --git a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
index 81ffdbebf514..a61ffdfa74dc 100644
--- a/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
+++ b/dbaccess/qa/complex/dbaccess/CRMBasedTestCase.java
@@ -19,37 +19,25 @@ package complex.dbaccess;
import com.sun.star.sdb.XSingleSelectQueryComposer;
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;
-
- protected void createTestCase()
+ protected void createTestCase() throws Exception
{
- try
- {
- m_database = new CRMDatabase( getMSF(), false );
- }
- catch ( Exception e )
- {
- e.printStackTrace( System.err );
- fail( "caught an exception (" + e.getMessage() + ") while creating the test case");
- }
+ m_database = new CRMDatabase( getMSF(), false );
}
@Before
@Override
- public void before()
+ public void before() throws Exception
{
createTestCase();
}
@@ -57,18 +45,11 @@ public abstract class CRMBasedTestCase extends TestCase
@After
@Override
- public void after()
+ public void after() throws Exception
{
- try
- {
- if ( m_database != null )
- {
- m_database.saveAndClose();
- }
- }
- catch ( Exception ex )
+ if ( m_database != null )
{
- Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex );
+ m_database.saveAndClose();
}
}
diff --git a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
index 97c63d2de335..20454d24b0ee 100644
--- a/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
+++ b/dbaccess/qa/complex/dbaccess/CopyTableWizard.java
@@ -30,7 +30,6 @@ import com.sun.star.sdb.DataAccessDescriptorFactory;
import com.sun.star.sdbc.XConnection;
import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.task.XInteractionHandler;
-import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import connectivity.tools.DbaseDatabase;
@@ -41,7 +40,6 @@ import util.UITools;
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
@@ -55,7 +53,7 @@ public class CopyTableWizard extends CRMBasedTestCase
@After
@Override
- public void after()
+ public void after() throws Exception
{
dest.store();
if ( destinationDB != null )
@@ -66,19 +64,12 @@ public class CopyTableWizard extends CRMBasedTestCase
@Before
@Override
- public void before()
+ public void before() throws Exception
{
- try
- {
- createTestCase();
- source = new DatabaseApplication(m_database.getDatabase());
- destinationDB = new DbaseDatabase( getMSF() );
- dest = new DatabaseApplication( destinationDB );
- }
- catch (java.lang.Exception ex)
- {
- fail("");
- }
+ createTestCase();
+ source = new DatabaseApplication(m_database.getDatabase());
+ destinationDB = new DbaseDatabase( getMSF() );
+ dest = new DatabaseApplication( destinationDB );
}
diff --git a/dbaccess/qa/complex/dbaccess/DataSource.java b/dbaccess/qa/complex/dbaccess/DataSource.java
index 3b18cd2fae8d..0413a6e07b69 100644
--- a/dbaccess/qa/complex/dbaccess/DataSource.java
+++ b/dbaccess/qa/complex/dbaccess/DataSource.java
@@ -18,7 +18,6 @@
package complex.dbaccess;
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 connectivity.tools.CRMDatabase;
@@ -37,51 +36,33 @@ public class DataSource extends TestCase
connectivity.tools.DataSource m_dataSource;
- private void createTestCase()
+ private void createTestCase() throws Exception
{
- try
+ if (m_database == null)
{
- if (m_database == null)
- {
- final CRMDatabase database = new CRMDatabase( getMSF(), false );
- m_database = database.getDatabase();
- m_dataSource = m_database.getDataSource();
- }
- }
- catch (Exception e)
- {
- fail("could not create the test case, error message:\n" + e.getMessage());
- }
- catch (java.lang.Exception e)
- {
- fail("could not create the test case, error message:\n" + e.getMessage());
+ final CRMDatabase database = new CRMDatabase( getMSF(), false );
+ m_database = database.getDatabase();
+ m_dataSource = m_database.getDataSource();
}
}
@Test
- public void testRegistrationName()
+ public void testRegistrationName() throws Exception
{
- try
- {
- createTestCase();
- // 1. check the existing "Bibliography" data source whether it has the proper name
- String dataSourceName = "Bibliography";
- final connectivity.tools.DataSource bibliography = new connectivity.tools.DataSource(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 = 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());
- assertEquals("registration name of a newly registered data source is wrong", dataSourceName, m_dataSource.getName());
- }
- catch (Exception ex)
- {
- fail();
- }
+ 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(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 = 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());
+ assertEquals("registration name of a newly registered data source is wrong", dataSourceName, m_dataSource.getName());
}
}
diff --git a/dbaccess/qa/complex/dbaccess/Parser.java b/dbaccess/qa/complex/dbaccess/Parser.java
index 2c72173548dd..8025e1d379c3 100644
--- a/dbaccess/qa/complex/dbaccess/Parser.java
+++ b/dbaccess/qa/complex/dbaccess/Parser.java
@@ -23,7 +23,6 @@ import com.sun.star.sdb.XParametersSupplier;
import com.sun.star.sdb.XSingleSelectQueryComposer;
import com.sun.star.sdbc.DataType;
import com.sun.star.sdbc.SQLException;
-import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
@@ -36,18 +35,10 @@ public class Parser extends CRMBasedTestCase
{
@Override
- protected void createTestCase()
+ protected void createTestCase() throws Exception
{
- try
- {
- super.createTestCase();
- m_database.getDatabase().getDataSource().createQuery( "query products", "SELECT * FROM \"products\"" );
- }
- catch ( Exception e )
- {
- e.printStackTrace( System.err );
- fail( "caught an exception (" + e.getMessage() + ") while creating the test case");
- }
+ super.createTestCase();
+ m_database.getDatabase().getDataSource().createQuery( "query products", "SELECT * FROM \"products\"" );
}
diff --git a/dbaccess/qa/complex/dbaccess/PropertyBag.java b/dbaccess/qa/complex/dbaccess/PropertyBag.java
index 2c313df7d5c8..6807569ec5a6 100644
--- a/dbaccess/qa/complex/dbaccess/PropertyBag.java
+++ b/dbaccess/qa/complex/dbaccess/PropertyBag.java
@@ -55,7 +55,7 @@ public class PropertyBag extends TestCase
}
@Test
- public void checkBasics()
+ public void checkBasics() throws Exception
{
createEmptyBag();
System.out.println("testing the basics");
@@ -115,19 +115,12 @@ public class PropertyBag extends TestCase
}
// try writing and reading a value for the one property we have so far
- try
- {
- final String testValue = "someArbitraryValue";
- m_set.setPropertyValue( VALUE , testValue);
- final String currentValue = (String)m_set.getPropertyValue( VALUE);
- if ( !currentValue.equals( testValue ) )
- {
- fail("set property is not remembered");
- }
- }
- catch(com.sun.star.uno.Exception e)
+ final String testValue = "someArbitraryValue";
+ m_set.setPropertyValue( VALUE , testValue);
+ final String currentValue = (String)m_set.getPropertyValue( VALUE);
+ if ( !currentValue.equals( testValue ) )
{
- fail( "setting or getting a property value failed" );
+ fail("set property is not remembered");
}
// try setting an illegal value for the property
diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
index 08eea00988ef..581677c91c57 100644
--- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
+++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java
@@ -32,13 +32,16 @@ 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.sdbc.DataType;
+import com.sun.star.sdbc.SQLException;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+
// ---------- junit imports -----------------
import org.junit.Test;
+
import static org.junit.Assert.*;
@@ -62,21 +65,13 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
@Override
- protected void createTestCase()
+ protected void createTestCase() throws Exception
{
- try
- {
- super.createTestCase();
-
- createQueries();
+ super.createTestCase();
- m_composer = createQueryComposer();
+ createQueries();
- }
- catch (Exception e)
- {
- fail("caught an exception (" + e.getMessage() + ") while creating the test case");
- }
+ m_composer = createQueryComposer();
}
@@ -120,92 +115,78 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
/** tests setCommand of the composer
*/
@Test
- public void testSetCommand()
+ public void testSetCommand() throws Exception
{
System.out.println("testing SingleSelectQueryComposer's setCommand");
- try
- {
- final String table = "SELECT * FROM \"customers\"";
- m_composer.setCommand("customers", CommandType.TABLE);
- assertTrue("setCommand/getQuery TABLE inconsistent", m_composer.getQuery().equals(table));
+ final String table = "SELECT * FROM \"customers\"";
+ m_composer.setCommand("customers", CommandType.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);
- assertTrue("setCommand/getQuery QUERY inconsistent", m_composer.getQuery().equals(m_database.getDatabase().getDataSource().getQueryDefinition("set command test").getCommand()));
+ 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);
+ 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);
- assertTrue("setCommand/getQuery COMMAND inconsistent", m_composer.getQuery().equals(sql));
- }
- catch (Exception e)
- {
- fail("Exception caught: " + e);
- }
+ final String sql = "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" = 'test'";
+ m_composer.setCommand(sql, CommandType.COMMAND);
+ assertTrue("setCommand/getQuery COMMAND inconsistent", m_composer.getQuery().equals(sql));
}
/** tests accessing attributes of the composer (order, filter, group by, having)
*/
@Test
- public void testAttributes()
+ public void testAttributes() throws Exception
{
System.out.println("testing SingleSelectQueryComposer's attributes (order, filter, group by, having)");
- try
- {
- System.out.println("check setElementaryQuery");
-
- final String simpleQuery2 = "SELECT * FROM \"customers\" WHERE \"Name\" = 'oranges'";
- m_composer.setElementaryQuery(simpleQuery2);
- assertTrue("setElementaryQuery/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery2));
-
- System.out.println("check setQuery");
- final String simpleQuery = "SELECT * FROM \"customers\"";
- m_composer.setQuery(simpleQuery);
- assertTrue("set/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery));
-
- checkAttributeAccess("Filter", "\"Name\" = 'oranges'");
- checkAttributeAccess("Group", "\"City\"");
- checkAttributeAccess("Order", "\"Address\"");
- checkAttributeAccess("HavingClause", "\"ID\" <> 4");
-
- final XIndexAccess orderColumns = m_composer.getOrderColumns();
- assertTrue("Order columns doesn't exist: \"Address\"",
- orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null);
-
- final XIndexAccess groupColumns = m_composer.getGroupColumns();
- assertTrue("Group columns doesn't exist: \"City\"",
- groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null);
-
- // XColumnsSupplier
- 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
- m_composer.setQuery("SELECT \"ID\", \"Postal\", \"Address\" FROM \"customers\"");
- m_composer.setFilter(COMPLEXFILTER);
- final PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter();
- m_composer.setFilter("");
- m_composer.setStructuredFilter(aStructuredFilter);
- if (!m_composer.getFilter().equals(COMPLEXFILTER))
- {
- System.out.println(COMPLEXFILTER);
- System.out.println(m_composer.getFilter());
- }
- 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);
- assertTrue("Structured Having Clause not identical", m_composer.getHavingClause().equals(COMPLEXFILTER));
- }
- catch (Exception e)
+ System.out.println("check setElementaryQuery");
+
+ final String simpleQuery2 = "SELECT * FROM \"customers\" WHERE \"Name\" = 'oranges'";
+ m_composer.setElementaryQuery(simpleQuery2);
+ assertTrue("setElementaryQuery/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery2));
+
+ System.out.println("check setQuery");
+ final String simpleQuery = "SELECT * FROM \"customers\"";
+ m_composer.setQuery(simpleQuery);
+ assertTrue("set/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery));
+
+ checkAttributeAccess("Filter", "\"Name\" = 'oranges'");
+ checkAttributeAccess("Group", "\"City\"");
+ checkAttributeAccess("Order", "\"Address\"");
+ checkAttributeAccess("HavingClause", "\"ID\" <> 4");
+
+ final XIndexAccess orderColumns = m_composer.getOrderColumns();
+ assertTrue("Order columns doesn't exist: \"Address\"",
+ orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null);
+
+ final XIndexAccess groupColumns = m_composer.getGroupColumns();
+ assertTrue("Group columns doesn't exist: \"City\"",
+ groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null);
+
+ // XColumnsSupplier
+ 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
+ m_composer.setQuery("SELECT \"ID\", \"Postal\", \"Address\" FROM \"customers\"");
+ m_composer.setFilter(COMPLEXFILTER);
+ final PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter();
+ m_composer.setFilter("");
+ m_composer.setStructuredFilter(aStructuredFilter);
+ if (!m_composer.getFilter().equals(COMPLEXFILTER))
{
- fail("Exception caught: " + e);
+ System.out.println(COMPLEXFILTER);
+ System.out.println(m_composer.getFilter());
}
+ 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);
+ assertTrue("Structured Having Clause not identical", m_composer.getHavingClause().equals(COMPLEXFILTER));
}
/** test various sub query related features ("queries in queries")
@@ -228,89 +209,65 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
/** tests the XParametersSupplier functionality
*/
@Test
- public void testParameters()
+ public void testParameters() throws Exception
{
- try
- {
- // "orders for customers" is a query with a named parameter (based on another query)
- m_database.getDatabase().getDataSource().createQuery("orders for customer", "SELECT * FROM \"all orders\" WHERE \"Customer Name\" LIKE :cname");
- // "orders for customer and product" is query based on "orders for customers", adding an additional,
- // anonymous parameter
- m_database.getDatabase().getDataSource().createQuery("orders for customer and product", "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" LIKE ?");
+ // "orders for customers" is a query with a named parameter (based on another query)
+ m_database.getDatabase().getDataSource().createQuery("orders for customer", "SELECT * FROM \"all orders\" WHERE \"Customer Name\" LIKE :cname");
+ // "orders for customer and product" is query based on "orders for customers", adding an additional,
+ // anonymous parameter
+ 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 = UnoRuntime.queryInterface(XParametersSupplier.class, m_composer);
- final XIndexAccess parameters = suppParams.getParameters();
+ m_composer.setQuery(m_database.getDatabase().getDataSource().getQueryDefinition("orders for customer and product").getCommand());
+ final XParametersSupplier suppParams = UnoRuntime.queryInterface(XParametersSupplier.class, m_composer);
+ final XIndexAccess parameters = suppParams.getParameters();
- final String expectedParamNames[] =
+ final String expectedParamNames[] =
- {
- "cname",
- "Product Name"
- };
-
- final int paramCount = parameters.getCount();
- assertTrue("composer did find wrong number of parameters in the nested queries.",
- paramCount == expectedParamNames.length);
+ {
+ "cname",
+ "Product Name"
+ };
- for (int i = 0; i < paramCount; ++i)
- {
- final XPropertySet parameter = UnoRuntime.queryInterface(XPropertySet.class, parameters.getByIndex(i));
- final String paramName = (String) parameter.getPropertyValue("Name");
- assertTrue("wrong parameter name at position " + (i + 1) + " (expected: " + expectedParamNames[i] + ", found: " + paramName + ")",
- paramName.equals(expectedParamNames[i]));
+ final int paramCount = parameters.getCount();
+ assertTrue("composer did find wrong number of parameters in the nested queries.",
+ paramCount == expectedParamNames.length);
- }
- }
- catch (Exception e)
+ for (int i = 0; i < paramCount; ++i)
{
- fail("caught an exception: " + e);
+ final XPropertySet parameter = UnoRuntime.queryInterface(XPropertySet.class, parameters.getByIndex(i));
+ final String paramName = (String) parameter.getPropertyValue("Name");
+ assertTrue("wrong parameter name at position " + (i + 1) + " (expected: " + expectedParamNames[i] + ", found: " + paramName + ")",
+ paramName.equals(expectedParamNames[i]));
+
}
}
@Test
- public void testConditionByColumn()
+ public void testConditionByColumn() throws Exception
{
- try
- {
- m_composer.setQuery("SELECT * FROM \"customers\"");
-
- final Object initArgs[] =
+ m_composer.setQuery("SELECT * FROM \"customers\"");
- {
- new NamedValue("AutomaticAddition", Boolean.TRUE)
- };
- final String serviceName = "com.sun.star.beans.PropertyBag";
- 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 = UnoRuntime.queryInterface(XPropertySet.class, filter);
-
- m_composer.appendFilterByColumn(column, true, SQLFilterOperator.LIKE);
- assertTrue("At least one row should exist", m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next());
+ final Object initArgs[] =
- }
- catch (Exception e)
{
- // this is an error: the query is expected to be parseable
- fail("caught an exception: " + e);
- }
+ new NamedValue("AutomaticAddition", Boolean.TRUE)
+ };
+ final String serviceName = "com.sun.star.beans.PropertyBag";
+ 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 = UnoRuntime.queryInterface(XPropertySet.class, filter);
+
+ m_composer.appendFilterByColumn(column, true, SQLFilterOperator.LIKE);
+ assertTrue("At least one row should exist", m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next());
}
- private void impl_testDisjunctiveNormalForm(String _query, PropertyValue[][] _expectedDNF)
+ private void impl_testDisjunctiveNormalForm(String _query, PropertyValue[][] _expectedDNF) throws SQLException
{
- try
- {
- m_composer.setQuery(_query);
- }
- catch (Exception e)
- {
- // this is an error: the query is expected to be parseable
- fail("caught an exception: " + e);
- }
+ m_composer.setQuery(_query);
final PropertyValue[][] disjunctiveNormalForm = m_composer.getStructuredFilter();
@@ -330,7 +287,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase
* of the composer
*/
@Test
- public void testDisjunctiveNormalForm()
+ public void testDisjunctiveNormalForm() throws Exception
{
// a simple case: WHERE clause simply is a combination of predicates knitted with AND
String query =