mondrian.test
Class FoodMartTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by mondrian.test.FoodMartTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AccessControlTest, AggGenTest, BasicQueryTest, BatchTestCase, CacheControlTest, CacheHitTest, CacheTest, CellKeyTest, CmdRunnerTest, CompatibilityTest, CompoundSlicerTest, ConcurrentMdxTest, CrossJoinTest, CsvDBTestCase, CurrentDateMemberUdfTest, CustomizedParserTest, CVConcurrentMdxTest, DataSourceChangeListenerTest, DrillThroughTest, FilteredIterableTest, FunctionTest, HierarchyBugTest, HighDimensionsTest, I18nTest, IgnoreMeasureForNonJoiningDimensionInAggregationTest, IgnoreUnrelatedDimensionsTest, IndexedValuesTest, InlineTableTest, MemberCacheControlTest, MemoryMonitorTest, MonitorTest, MultipleHierarchyTest, NamedSetTest, NonEmptyPropertyForAllAxisTest, NullMemberRepresentationTest, NullValueTest, Olap4jTest, ParallelTest, ParameterTest, ParentChildHierarchyTest, ParserTest, PerformanceTest, PropertiesTest, QueryTest, RaggedHierarchyTest, ResultComparatorTest, RolapAxisTest, RolapCubeTest, RolapSchemaPoolTest, RolapSchemaReaderTest, RolapStarTest, ScenarioTest, SchemaTest, SchemaVersionTest, SetFunDefTest, SharedDimensionTest, SolveOrderScopeIsolationTest, SortTest, Ssas2005CompatibilityTest, TupleListTest, UdfTest, XmlaBaseTestCase, XmlaTests

public class FoodMartTestCase
extends junit.framework.TestCase

FoodMartTestCase is a unit test which runs against the FoodMart database.

Since:
29 March, 2002
Author:
jhyde

Nested Class Summary
(package private) static class FoodMartTestCase.QueryAndResult
           
 
Field Summary
protected  PropertySaver propSaver
          Access properties via this object and their values will be reset on tearDown().
 
Constructor Summary
FoodMartTestCase()
           
FoodMartTestCase(String name)
           
 
Method Summary
protected  Member allMember(String dimensionName, Cube salesCube)
           
 void assertAxisReturns(String expression, String expected)
          Runs a query on the "Sales" cube with a given expression on an axis, and asserts that it returns the expected string.
 void assertAxisThrows(String expression, String pattern)
          Runs a query with a given expression on an axis, and asserts that it throws an error which matches a particular pattern.
 void assertBooleanExprReturns(String expression, boolean expected)
          Executes an expression which yields a boolean result, and asserts that the result is the expected one.
 void assertExprReturns(String expression, String expected)
          Runs an expression and asserts that it returns a given result.
 void assertExprThrows(String expression, String pattern)
          Runs an expression, and asserts that it gives an error which contains a particular pattern.
protected  void assertQueriesReturnSimilarResults(String query1, String query2, TestContext testContext)
          Executes query1 and query2 and Compares the obtained measure values.
 void assertQueryReturns(String query, String desiredResult)
          Runs a query and checks that the result is a given string.
 void assertQueryThrows(String queryString, String pattern)
          Runs a query, and asserts that it throws an exception which contains the given pattern.
protected  void assertSize(String queryString, int columnCount, int rowCount)
          Runs a query, and asserts that the result has a given number of columns and rows.
protected  Cube cubeByName(Connection connection, String cubeName)
           
 Result execute(Connection connection, String queryString)
          Executes a query in a given connection.
 String executeExpr(String expression)
          Executes an expression against the Sales cube in the FoodMart database to form a single cell result set, then returns that cell's formatted value.
 Result executeQuery(String queryString)
          Runs a query.
 Member executeSingletonAxis(String expression)
          Executes a set expression which is expected to return 0 or 1 members.
protected  TupleList genderMembersIncludingAll(boolean includeAllMember, SchemaReader salesCubeSchemaReader, Cube salesCube)
           
protected  Connection getConnection()
           
protected  Dimension getDimensionWithName(String name, Dimension[] dimensions)
           
 TestContext getTestContext()
          Returns the test context.
protected  boolean isDefaultNullMemberRepresentation()
           
protected  boolean isGroupingSetsSupported()
           
protected  Member member(List<Id.Segment> segmentList, SchemaReader salesCubeSchemaReader)
           
protected  TupleList productMembersPotScrubbersPotsAndPans(SchemaReader salesCubeSchemaReader)
           
protected  TupleList storeMembersCAAndOR(SchemaReader salesCubeSchemaReader)
           
protected  TupleList storeMembersUsaAndCanada(boolean includeAllMember, SchemaReader salesCubeSchemaReader, Cube salesCube)
           
protected  void tearDown()
           
protected  List<Member> warehouseMembersCanadaMexicoUsa(SchemaReader reader)
           
 
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
 

Field Detail

propSaver

protected final PropertySaver propSaver
Access properties via this object and their values will be reset on tearDown().

Constructor Detail

FoodMartTestCase

public FoodMartTestCase(String name)

FoodMartTestCase

public FoodMartTestCase()
Method Detail

tearDown

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

getTestContext

public TestContext getTestContext()
Returns the test context. Override this method if you wish to use a different source for your FoodMart connection.


getConnection

protected Connection getConnection()

assertSize

protected void assertSize(String queryString,
                          int columnCount,
                          int rowCount)
Runs a query, and asserts that the result has a given number of columns and rows.


assertQueryThrows

public void assertQueryThrows(String queryString,
                              String pattern)
Runs a query, and asserts that it throws an exception which contains the given pattern.


execute

public Result execute(Connection connection,
                      String queryString)
Executes a query in a given connection.


executeSingletonAxis

public Member executeSingletonAxis(String expression)
Executes a set expression which is expected to return 0 or 1 members. It is an error if the expression returns tuples (as opposed to members), or if it returns two or more members.

Parameters:
expression - Expression
Returns:
Null if axis returns the empty set, member if axis returns one member. Throws otherwise.

assertQueryReturns

public void assertQueryReturns(String query,
                               String desiredResult)
Runs a query and checks that the result is a given string.


executeQuery

public Result executeQuery(String queryString)
Runs a query.


assertAxisThrows

public void assertAxisThrows(String expression,
                             String pattern)
Runs a query with a given expression on an axis, and asserts that it throws an error which matches a particular pattern. The expression is evaulated against the Sales cube.


assertAxisReturns

public void assertAxisReturns(String expression,
                              String expected)
Runs a query on the "Sales" cube with a given expression on an axis, and asserts that it returns the expected string.


executeExpr

public String executeExpr(String expression)
Executes an expression against the Sales cube in the FoodMart database to form a single cell result set, then returns that cell's formatted value.


assertBooleanExprReturns

public void assertBooleanExprReturns(String expression,
                                     boolean expected)
Executes an expression which yields a boolean result, and asserts that the result is the expected one.


assertExprThrows

public void assertExprThrows(String expression,
                             String pattern)
Runs an expression, and asserts that it gives an error which contains a particular pattern. The error might occur during parsing, or might be contained within the cell value.


assertExprReturns

public void assertExprReturns(String expression,
                              String expected)
Runs an expression and asserts that it returns a given result.


assertQueriesReturnSimilarResults

protected void assertQueriesReturnSimilarResults(String query1,
                                                 String query2,
                                                 TestContext testContext)
Executes query1 and query2 and Compares the obtained measure values.


isGroupingSetsSupported

protected boolean isGroupingSetsSupported()

isDefaultNullMemberRepresentation

protected boolean isDefaultNullMemberRepresentation()

member

protected Member member(List<Id.Segment> segmentList,
                        SchemaReader salesCubeSchemaReader)

storeMembersCAAndOR

protected TupleList storeMembersCAAndOR(SchemaReader salesCubeSchemaReader)

productMembersPotScrubbersPotsAndPans

protected TupleList productMembersPotScrubbersPotsAndPans(SchemaReader salesCubeSchemaReader)

genderMembersIncludingAll

protected TupleList genderMembersIncludingAll(boolean includeAllMember,
                                              SchemaReader salesCubeSchemaReader,
                                              Cube salesCube)

allMember

protected Member allMember(String dimensionName,
                           Cube salesCube)

getDimensionWithName

protected Dimension getDimensionWithName(String name,
                                         Dimension[] dimensions)

warehouseMembersCanadaMexicoUsa

protected List<Member> warehouseMembersCanadaMexicoUsa(SchemaReader reader)

cubeByName

protected Cube cubeByName(Connection connection,
                          String cubeName)

storeMembersUsaAndCanada

protected TupleList storeMembersUsaAndCanada(boolean includeAllMember,
                                             SchemaReader salesCubeSchemaReader,
                                             Cube salesCube)

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