mondrian.test
Class DialectTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by mondrian.test.DialectTest
All Implemented Interfaces:
junit.framework.Test

public class DialectTest
extends junit.framework.TestCase

Unit test which checks that Dialect accurately represents the capabilities of the underlying database.

The existing mondrian tests, when run on various databases and drivers, make sure that Dialect never over-states the capabilities of a particular database. But sometimes they under-state a database's capabilities: for example, MySQL version 3 did not allow subqueries in the FROM clause, but version 4 does. This test helps ensure that mondrian is using the full capabilities of each database.

NOTE: If you see failures in this test, let the mondrian developers know! You may be running a version of a database which no one has tried before, and which has more capabilities than we expect. If you tell us about them, we can change mondrian to use those features.

Since:
May 18, 2007
Author:
jhyde

Constructor Summary
DialectTest(String name)
          Creates a DialectTest.
 
Method Summary
protected  void assertQueryFails(String sql, String[] patterns)
          Asserts that a query fails.
protected  void assertQuerySucceeds(String sql)
          Asserts that a query succeeds and produces at least one row.
protected  Connection getConnection()
           
protected  DataSource getDataSource()
           
protected  Dialect getDialect()
           
protected  void tearDown()
           
 void testAllowsCompoundCountDistinct()
           
 void testAllowsCountDistinct()
           
 void testAllowsDdl()
           
 void testAllowsFromQuery()
           
 void testAllowsGroupingSets()
          Tests that the Dialect.supportsGroupingSets() dialect property is accurate.
 void testAllowsMultipleCountDistinct()
           
 void testAllowsOrderByAlias()
           
 void testAllowsRegularExpressionInWhereClause()
           
 void testAllowsSelectNotInGroupBy()
          Unit test for Dialect.allowsSelectNotInGroupBy().
 void testComplexRegularExpression()
          This is a test for http://jira.pentaho.com/browse/MONDRIAN-1057 Some dialects are not removing the \Q and \E markers if they are in the middle of the regexp.
 void testDialectVsDatabaseProduct()
           
 void testForceNullCollation()
          Tests that the dialect can generate a valid query to sort ascending and descending, with NULL values appearing last in both cases.
 void testGenerateInline()
           
 void testHavingRequiresAlias()
           
 void testRegularExpressionSqlInjection()
           
 void testRequiresFromQueryAlias()
           
 void testRequiresOrderByAlias()
           
 void testRequiresUnionOrderByExprToBeInSelectClause()
           
 void testResultSetConcurrency()
           
 void testSupportsGroupByExpressions()
           
 void testSupportsMultiValueInExpr()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DialectTest

public DialectTest(String name)
Creates a DialectTest.

Parameters:
name - Test case name
Method Detail

getDataSource

protected DataSource getDataSource()

tearDown

protected void tearDown()
                 throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

getDialect

protected Dialect getDialect()

getConnection

protected Connection getConnection()

testDialectVsDatabaseProduct

public void testDialectVsDatabaseProduct()
                                  throws SQLException
Throws:
SQLException

testAllowsCompoundCountDistinct

public void testAllowsCompoundCountDistinct()

testAllowsCountDistinct

public void testAllowsCountDistinct()

testAllowsMultipleCountDistinct

public void testAllowsMultipleCountDistinct()

testAllowsDdl

public void testAllowsDdl()

testAllowsFromQuery

public void testAllowsFromQuery()

testRequiresFromQueryAlias

public void testRequiresFromQueryAlias()

testRequiresOrderByAlias

public void testRequiresOrderByAlias()

testAllowsOrderByAlias

public void testAllowsOrderByAlias()

testRequiresUnionOrderByExprToBeInSelectClause

public void testRequiresUnionOrderByExprToBeInSelectClause()

testSupportsGroupByExpressions

public void testSupportsGroupByExpressions()

testAllowsGroupingSets

public void testAllowsGroupingSets()
Tests that the Dialect.supportsGroupingSets() dialect property is accurate.


testSupportsMultiValueInExpr

public void testSupportsMultiValueInExpr()

testResultSetConcurrency

public void testResultSetConcurrency()

testGenerateInline

public void testGenerateInline()
                        throws SQLException
Throws:
SQLException

testForceNullCollation

public void testForceNullCollation()
                            throws SQLException
Tests that the dialect can generate a valid query to sort ascending and descending, with NULL values appearing last in both cases.

Throws:
SQLException

assertQuerySucceeds

protected void assertQuerySucceeds(String sql)
Asserts that a query succeeds and produces at least one row.

Parameters:
sql - SQL query in current dialect

assertQueryFails

protected void assertQueryFails(String sql,
                                String[] patterns)
Asserts that a query fails.

Parameters:
sql - SQL query
patterns - Array of expected patterns, generally one for each SQL dialect for which the test is expected to fail

testAllowsSelectNotInGroupBy

public void testAllowsSelectNotInGroupBy()
                                  throws SQLException
Unit test for Dialect.allowsSelectNotInGroupBy().

Throws:
SQLException

testHavingRequiresAlias

public void testHavingRequiresAlias()
                             throws Exception
Throws:
Exception

testAllowsRegularExpressionInWhereClause

public void testAllowsRegularExpressionInWhereClause()
                                              throws Exception
Throws:
Exception

testComplexRegularExpression

public void testComplexRegularExpression()
                                  throws Exception
This is a test for http://jira.pentaho.com/browse/MONDRIAN-1057 Some dialects are not removing the \Q and \E markers if they are in the middle of the regexp.

Throws:
Exception

testRegularExpressionSqlInjection

public void testRegularExpressionSqlInjection()
                                       throws SQLException
Throws:
SQLException

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads