mondrian.test
Class UdfTest

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

public class UdfTest
extends FoodMartTestCase

Unit-test for user-defined functions.

TODO: 1. test that function which does not return a name, description etc. gets a sensible error 2. document UDFs

Since:
Apr 29, 2005
Version:
$Id: //open/mondrian/testsrc/main/mondrian/test/UdfTest.java#47 $
Author:
jhyde

Nested Class Summary
static class UdfTest.AnotherMemberErrorUdf
          A user-defined function which returns ignores its first parameter (a member) and returns the default member from the second parameter (a hierarchy).
static class UdfTest.BadPlusOneUdf
          A simple user-defined function which adds one to its argument.
static class UdfTest.MemberNameFunction
          Function that takes a member and returns a name.
static class UdfTest.PlusOneUdf
          A simple user-defined function which adds one to its argument.
static class UdfTest.PlusOrMinusOneUdf
          A user-defined function which, depending on its given name, either adds one to, or subtracts one from, its argument.
static class UdfTest.ReverseFunction
          Function that reverses a list of members.
 class UdfTest.ReverseFunctionNotStatic
          Function that is non-static.
static class UdfTest.ReverseIterableFunction
          Function that takes a set of members as argument, and returns a set of members.
static class UdfTest.StringMultUdf
          The "TimesString" user-defined function.
 
Nested classes/interfaces inherited from class mondrian.test.FoodMartTestCase
FoodMartTestCase.QueryAndResult
 
Field Summary
 
Fields inherited from class mondrian.test.FoodMartTestCase
propSaver
 
Constructor Summary
UdfTest()
           
UdfTest(String name)
           
 
Method Summary
 TestContext getTestContext()
          Returns the test context.
 void testAnotherMemberFun()
          Tests a UDF whose return type is not the same as its first parameter.
 void testBadFun()
           
 void testCachingCurrentDate()
           
 void testChildMemberIn()
           
 void testComplexFun()
           
 void testCurrentDateLag()
           
 void testCurrentDateMemberAfter()
           
 void testCurrentDateMemberBefore()
           
 void testCurrentDateMemberBeforeUsingQuotes()
           
 void testCurrentDateMemberExact()
           
 void testCurrentDateMemberHierarchy()
           
 void testCurrentDateMemberHierarchyNullReturn()
           
 void testCurrentDateMemberNoFindArg()
           
 void testCurrentDateMemberPrev()
           
 void testCurrentDateMemberRealAfter()
           
 void testCurrentDateMemberRealExact1()
           
 void testCurrentDateMemberRealExact2()
           
 void testCurrentDateString()
           
 void testException()
           
 void testFun()
           
 void testGenericFun()
           
 void testIn()
           
 void testLastNonEmpty()
           
 void testLastNonEmptyBig()
          Tests a performance issue with LastNonEmpty (bug 1533677).
 void testListUdf()
          Test case for a UDF that returns a list.
 void testMatches()
           
 void testMemberUdfDoesNotEvaluateToScalar()
          Tests a function that takes a member as argument.
 void testNonGuessableReturnType()
          Tests that the inferred return type is correct for a UDF whose return type is not the same as would be guessed by the default implementation of FunDefBase.getResultType(mondrian.olap.Validator, mondrian.olap.Exp[]), which simply guesses based on the type of the first argument.
 void testNonStaticUdfFails()
          Tests that a non-static function gives an error.
 void testNotIn()
           
 void testNotMatches()
           
 void testSanity()
           
 void testUdfToString()
          Test case for the problem where a string expression gave a ClassCastException because it was evaluating to a member, whereas the member should have been evaluated to a scalar.
 
Methods inherited from class mondrian.test.FoodMartTestCase
allMember, assertAxisReturns, assertAxisThrows, assertBooleanExprReturns, assertExprReturns, assertExprThrows, assertQueriesReturnSimilarResults, assertQueryReturns, assertQueryThrows, assertSize, cubeByName, execute, executeExpr, executeQuery, executeSingletonAxis, genderMembersIncludingAll, getConnection, getDimensionWithName, getTestContext, isDefaultNullMemberRepresentation, isGroupingSetsSupported, member, productMembersPotScrubbersPotsAndPans, storeMembersCAAndOR, storeMembersUsaAndCanada, tearDown, warehouseMembersCanadaMexicoUsa
 
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, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UdfTest

public UdfTest()

UdfTest

public UdfTest(String name)
Method Detail

getTestContext

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

Overrides:
getTestContext in class FoodMartTestCase

testSanity

public void testSanity()

testFun

public void testFun()

testLastNonEmpty

public void testLastNonEmpty()

testLastNonEmptyBig

public void testLastNonEmptyBig()
Tests a performance issue with LastNonEmpty (bug 1533677). The naive implementation of LastNonEmpty crawls backward one period at a time, generates a cache miss, and the next iteration reads precisely one cell. So the query soon exceeds the MondrianProperties.MaxEvalDepth property.


testBadFun

public void testBadFun()

testGenericFun

public void testGenericFun()

testComplexFun

public void testComplexFun()

testException

public void testException()

testCurrentDateString

public void testCurrentDateString()

testCurrentDateMemberBefore

public void testCurrentDateMemberBefore()

testCurrentDateMemberBeforeUsingQuotes

public void testCurrentDateMemberBeforeUsingQuotes()

testCurrentDateMemberAfter

public void testCurrentDateMemberAfter()

testCurrentDateMemberExact

public void testCurrentDateMemberExact()

testCurrentDateMemberNoFindArg

public void testCurrentDateMemberNoFindArg()

testCurrentDateMemberHierarchy

public void testCurrentDateMemberHierarchy()

testCurrentDateMemberHierarchyNullReturn

public void testCurrentDateMemberHierarchyNullReturn()

testCurrentDateMemberRealAfter

public void testCurrentDateMemberRealAfter()

testCurrentDateMemberRealExact1

public void testCurrentDateMemberRealExact1()

testCurrentDateMemberRealExact2

public void testCurrentDateMemberRealExact2()

testCurrentDateMemberPrev

public void testCurrentDateMemberPrev()

testCurrentDateLag

public void testCurrentDateLag()

testMatches

public void testMatches()

testNotMatches

public void testNotMatches()

testIn

public void testIn()

testNotIn

public void testNotIn()

testChildMemberIn

public void testChildMemberIn()

testNonGuessableReturnType

public void testNonGuessableReturnType()
Tests that the inferred return type is correct for a UDF whose return type is not the same as would be guessed by the default implementation of FunDefBase.getResultType(mondrian.olap.Validator, mondrian.olap.Exp[]), which simply guesses based on the type of the first argument.


testUdfToString

public void testUdfToString()
Test case for the problem where a string expression gave a ClassCastException because it was evaluating to a member, whereas the member should have been evaluated to a scalar.


testAnotherMemberFun

public void testAnotherMemberFun()
Tests a UDF whose return type is not the same as its first parameter. The return type needs to have full dimensional information; in this case, HierarchyType(dimension=Time, hierarchy=unknown).

Also tests applying a UDF to arguments of coercible type. In this case, applies f(member,dimension) to args(member,hierarchy).


testCachingCurrentDate

public void testCachingCurrentDate()

testListUdf

public void testListUdf()
Test case for a UDF that returns a list.

Test case for bug MONDRIAN-588, "UDF returning List works under 2.4, fails under 3.1.1".

Also test case for bug MONDRIAN-589, "UDF expecting List gets anonymous mondrian.rolap.RolapNamedSetEvaluator$1 instead".


testNonStaticUdfFails

public void testNonStaticUdfFails()
Tests that a non-static function gives an error.


testMemberUdfDoesNotEvaluateToScalar

public void testMemberUdfDoesNotEvaluateToScalar()
Tests a function that takes a member as argument. Want to make sure that Mondrian leaves it as a member, does not try to evaluate it to a scalar value.


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