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 formatters
andmember 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 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.FooBarCellFormatter
Cell formatter for test purposes.static class
UdfTest.FooBarMemberFormatter
Member formatter for test purposes.static class
UdfTest.FooBarPropertyFormatter
Property formatter for test purposes.static class
UdfTest.MdcUdf
A simple UDF that checks the object inside of the MDC logging context.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TestContext
getTestContext()
Returns the test context.protected void
setUp()
protected void
tearDown()
void
testAnotherMemberFun()
Tests a UDF whose return type is not the same as its first parameter.void
testBadFun()
void
testCachingCurrentDate()
void
testCellFormatter()
Unit test for a cell formatter defined in the old way -- a 'formatter' attribute of a Measure element.void
testCellFormatterNested()
AstestCellFormatter()
, but using new-style nested CellFormatter element.void
testCellFormatterOnCalcMember()
Unit test for a cell formatter defined against a calculated member, using the old syntax (a member property called "CELL_FORMATTER").void
testCellFormatterOnCalcMemberNested()
Unit test for a cell formatter defined against a calculated member, using the new syntax (a nested CellFormatter element).void
testCellFormatterOnCalcMemberScript()
Unit test for a cell formatter defined against a calculated member, using a script.void
testCellFormatterScript()
AstestCellFormatterNested()
, but using a script.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
testFunWithProfiling()
Test case for bug MONDRIAN-1200, "User-defined function + profiling causes NPE in CalcWriter".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
testMdc()
This is a test for MONDRIAN-994.void
testMemberFormatter()
Unit test for a member formatter defined in the old way -- a 'formatter' attribute of a Measure element.void
testMemberFormatterNested()
AstestMemberFormatter()
, but using new-style nested memberFormatter element.void
testMemberFormatterScript()
AstestMemberFormatterNested()
, but using a script.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 ofFunDefBase.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
testPropertyFormatter()
Unit test for a property formatter defined in the old way -- a 'formatter' attribute of a Property element.void
testPropertyFormatterNested()
AstestPropertyFormatter()
, but using new-style nested PropertyFormatter element.void
testPropertyFormatterScript()
AstestPropertyFormatterNested()
, but using a script.void
testSanity()
void
testScriptUdf()
Unit test for a UDF defined in JavaScript.void
testScriptUdfFactorial()
Unit test for a UDF defined in JavaScript, this time the factorial function.void
testScriptUdfInvalid()
Unit test that we get a nice error if a script UDF contains an error.void
testUdfBothScriptAndClassname()
Unit test that ensures that a UDF does not have both a script and a className.void
testUdfNeitherScriptNorClassname()
Unit test that ensures that a UDF has either a script or a className.void
testUdfScriptBadLanguage()
Unit test that ensures that a UDF has either a script or a className.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, isDefaultNullMemberRepresentation, isGroupingSetsSupported, member, productMembersPotScrubbersPotsAndPans, storeMembersCAAndOR, storeMembersUsaAndCanada, verifySameNativeAndNot, warehouseMembersCanadaMexicoUsa
-
-
-
-
Method Detail
-
setUp
protected void setUp() throws java.lang.Exception
- Throws:
java.lang.Exception
-
tearDown
protected void tearDown() throws java.lang.Exception
- Overrides:
tearDown
in classFoodMartTestCase
- Throws:
java.lang.Exception
-
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 classFoodMartTestCase
-
testSanity
public void testSanity()
-
testFun
public void testFun()
-
testFunWithProfiling
public void testFunWithProfiling() throws java.sql.SQLException
Test 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:
java.sql.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.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 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 java.sql.SQLException
Unit test for a property formatter defined in the old way -- a 'formatter' attribute of a Property element.- Throws:
java.sql.SQLException
- on error
-
testPropertyFormatterNested
public void testPropertyFormatterNested() throws java.sql.SQLException
AstestPropertyFormatter()
, but using new-style nested PropertyFormatter element.- Throws:
java.sql.SQLException
- on error
-
testPropertyFormatterScript
public void testPropertyFormatterScript() throws java.sql.SQLException
AstestPropertyFormatterNested()
, but using a script.- Throws:
java.sql.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.
-
-