Package mondrian.test
Class UdfTest
- java.lang.Object
-
- TestCase
-
- mondrian.test.FoodMartTestCase
-
- mondrian.test.UdfTest
-
public class UdfTest extends FoodMartTestCase
Unit-test foruser-defined functions. Also testscell formattersandmember formatters.TODO: 1. test that function which does not return a name, description etc. gets a sensible error 2. document UDFs
- Since:
- Apr 29, 2005
- Author:
- jhyde
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUdfTest.AnotherMemberErrorUdfA user-defined function which returns ignores its first parameter (a member) and returns the default member from the second parameter (a hierarchy).static classUdfTest.BadPlusOneUdfA simple user-defined function which adds one to its argument.static classUdfTest.FooBarCellFormatterCell formatter for test purposes.static classUdfTest.FooBarMemberFormatterMember formatter for test purposes.static classUdfTest.FooBarPropertyFormatterProperty formatter for test purposes.static classUdfTest.MdcUdfA simple UDF that checks the object inside of the MDC logging context.static classUdfTest.MemberNameFunctionFunction that takes a member and returns a name.static classUdfTest.PlusOneUdfA simple user-defined function which adds one to its argument.static classUdfTest.PlusOrMinusOneUdfA user-defined function which, depending on its given name, either adds one to, or subtracts one from, its argument.static classUdfTest.ReverseFunctionFunction that reverses a list of members.classUdfTest.ReverseFunctionNotStaticFunction that is non-static.static classUdfTest.ReverseIterableFunctionFunction that takes a set of members as argument, and returns a set of members.static classUdfTest.StringMultUdfThe "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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TestContextgetTestContext()Returns the test context.protected voidsetUp()protected voidtearDown()voidtestAnotherMemberFun()Tests a UDF whose return type is not the same as its first parameter.voidtestBadFun()voidtestCachingCurrentDate()voidtestCellFormatter()Unit test for a cell formatter defined in the old way -- a 'formatter' attribute of a Measure element.voidtestCellFormatterNested()AstestCellFormatter(), but using new-style nested CellFormatter element.voidtestCellFormatterOnCalcMember()Unit test for a cell formatter defined against a calculated member, using the old syntax (a member property called "CELL_FORMATTER").voidtestCellFormatterOnCalcMemberNested()Unit test for a cell formatter defined against a calculated member, using the new syntax (a nested CellFormatter element).voidtestCellFormatterOnCalcMemberScript()Unit test for a cell formatter defined against a calculated member, using a script.voidtestCellFormatterScript()AstestCellFormatterNested(), but using a script.voidtestChildMemberIn()voidtestComplexFun()voidtestCurrentDateLag()voidtestCurrentDateMemberAfter()voidtestCurrentDateMemberBefore()voidtestCurrentDateMemberBeforeUsingQuotes()voidtestCurrentDateMemberExact()voidtestCurrentDateMemberHierarchy()voidtestCurrentDateMemberHierarchyNullReturn()voidtestCurrentDateMemberNoFindArg()voidtestCurrentDateMemberPrev()voidtestCurrentDateMemberRealAfter()voidtestCurrentDateMemberRealExact1()voidtestCurrentDateMemberRealExact2()voidtestCurrentDateString()voidtestException()voidtestFun()voidtestFunWithProfiling()Test case for bug MONDRIAN-1200, "User-defined function + profiling causes NPE in CalcWriter".voidtestGenericFun()voidtestIn()voidtestLastNonEmpty()voidtestLastNonEmptyBig()Tests a performance issue with LastNonEmpty (bug 1533677).voidtestListUdf()Test case for a UDF that returns a list.voidtestMatches()voidtestMdc()This is a test for MONDRIAN-994.voidtestMemberFormatter()Unit test for a member formatter defined in the old way -- a 'formatter' attribute of a Measure element.voidtestMemberFormatterNested()AstestMemberFormatter(), but using new-style nested memberFormatter element.voidtestMemberFormatterScript()AstestMemberFormatterNested(), but using a script.voidtestMemberUdfDoesNotEvaluateToScalar()Tests a function that takes a member as argument.voidtestNonGuessableReturnType()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 ofFunDefBase.getResultType(mondrian.olap.Validator, mondrian.olap.Exp[]), which simply guesses based on the type of the first argument.voidtestNonStaticUdfFails()Tests that a non-static function gives an error.voidtestNotIn()voidtestNotMatches()voidtestPropertyFormatter()Unit test for a property formatter defined in the old way -- a 'formatter' attribute of a Property element.voidtestPropertyFormatterNested()AstestPropertyFormatter(), but using new-style nested PropertyFormatter element.voidtestPropertyFormatterScript()AstestPropertyFormatterNested(), but using a script.voidtestSanity()voidtestScriptUdf()Unit test for a UDF defined in JavaScript.voidtestScriptUdfFactorial()Unit test for a UDF defined in JavaScript, this time the factorial function.voidtestScriptUdfInvalid()Unit test that we get a nice error if a script UDF contains an error.voidtestUdfBothScriptAndClassname()Unit test that ensures that a UDF does not have both a script and a className.voidtestUdfNeitherScriptNorClassname()Unit test that ensures that a UDF has either a script or a className.voidtestUdfScriptBadLanguage()Unit test that ensures that a UDF has either a script or a className.voidtestUdfToString()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, isDefaultNullMemberRepresentation, isGroupingSetsSupported, member, productMembersPotScrubbersPotsAndPans, storeMembersCAAndOR, storeMembersUsaAndCanada, verifySameNativeAndNot, warehouseMembersCanadaMexicoUsa
-
-
-
-
Constructor Detail
-
UdfTest
public UdfTest()
-
UdfTest
public UdfTest(String name)
-
-
Method Detail
-
tearDown
protected void tearDown() throws Exception- Overrides:
tearDownin classFoodMartTestCase- Throws:
Exception
-
getTestContext
public TestContext getTestContext()
Description copied from class:FoodMartTestCaseReturns the test context. Override this method if you wish to use a different source for your FoodMart connection.- Overrides:
getTestContextin classFoodMartTestCase
-
testSanity
public void testSanity()
-
testFun
public void testFun()
-
testFunWithProfiling
public void testFunWithProfiling() throws SQLExceptionTest case for bug MONDRIAN-1200, "User-defined function + profiling causes NPE in CalcWriter". The bug only occurs if manually enable "mondrian.profile" logger before running this test. (The bug requires olap4j, plus profiling, plus a query that calls a UDF with one or more arguments on an axis.)- Throws:
SQLException- on error
-
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 theMondrianProperties.MaxEvalDepthproperty.
-
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 ofFunDefBase.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.
-
testUdfNeitherScriptNorClassname
public void testUdfNeitherScriptNorClassname()
Unit test that ensures that a UDF has either a script or a className.
-
testUdfBothScriptAndClassname
public void testUdfBothScriptAndClassname()
Unit test that ensures that a UDF does not have both a script and a className.
-
testUdfScriptBadLanguage
public void testUdfScriptBadLanguage()
Unit test that ensures that a UDF has either a script or a className.
-
testScriptUdf
public void testScriptUdf()
Unit test for a UDF defined in JavaScript.
-
testScriptUdfFactorial
public void testScriptUdfFactorial()
Unit test for a UDF defined in JavaScript, this time the factorial function. We also use 'CDATA' section to mask the '<' symbol.
-
testScriptUdfInvalid
public void testScriptUdfInvalid()
Unit test that we get a nice error if a script UDF contains an error.
-
testCellFormatter
public void testCellFormatter()
Unit test for a cell formatter defined in the old way -- a 'formatter' attribute of a Measure element.
-
testCellFormatterNested
public void testCellFormatterNested()
AstestCellFormatter(), but using new-style nested CellFormatter element.
-
testCellFormatterScript
public void testCellFormatterScript()
AstestCellFormatterNested(), but using a script.
-
testCellFormatterOnCalcMember
public void testCellFormatterOnCalcMember()
Unit test for a cell formatter defined against a calculated member, using the old syntax (a member property called "CELL_FORMATTER").
-
testCellFormatterOnCalcMemberNested
public void testCellFormatterOnCalcMemberNested()
Unit test for a cell formatter defined against a calculated member, using the new syntax (a nested CellFormatter element).
-
testCellFormatterOnCalcMemberScript
public void testCellFormatterOnCalcMemberScript()
Unit test for a cell formatter defined against a calculated member, using a script.
-
testMemberFormatter
public void testMemberFormatter()
Unit test for a member formatter defined in the old way -- a 'formatter' attribute of a Measure element.
-
testMemberFormatterNested
public void testMemberFormatterNested()
AstestMemberFormatter(), but using new-style nested memberFormatter element.
-
testMemberFormatterScript
public void testMemberFormatterScript()
AstestMemberFormatterNested(), but using a script.
-
testPropertyFormatter
public void testPropertyFormatter() throws SQLExceptionUnit test for a property formatter defined in the old way -- a 'formatter' attribute of a Property element.- Throws:
SQLException- on error
-
testPropertyFormatterNested
public void testPropertyFormatterNested() throws SQLExceptionAstestPropertyFormatter(), but using new-style nested PropertyFormatter element.- Throws:
SQLException- on error
-
testPropertyFormatterScript
public void testPropertyFormatterScript() throws SQLExceptionAstestPropertyFormatterNested(), but using a script.- Throws:
SQLException- on error
-
testMdc
public void testMdc()
This is a test for MONDRIAN-994. It checks that the MDC logging context is passed through all the threads.
-
-