Skip to content

Commit

Permalink
MONDRIAN: Change test mechanism so that tests no longer need to call …
Browse files Browse the repository at this point in the history
…fold();

    Reformat strings in test classes to comply with coding standard.
    No other functionality changes.

[git-p4: depot-paths = "//open/mondrian/": change = 12630]
  • Loading branch information
julianhyde committed Apr 20, 2009
1 parent 9aa0a9e commit 369bdf1
Show file tree
Hide file tree
Showing 72 changed files with 26,474 additions and 25,898 deletions.
11 changes: 6 additions & 5 deletions testsrc/main/mondrian/olap/CustomizedParserTest.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2004-2008 Julian Hyde and others.
// Copyright (C) 2004-2009 Julian Hyde and others.
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -38,17 +38,18 @@ CustomizedFunctionTable getCustomizedFunctionTable(Set<String> funNameSet) {
}

private String wrapExpr(String expr) {
return "with member [Measures].[Foo] as " +
expr +
"\n select from [Sales]";
return
"with member [Measures].[Foo] as "
+ expr
+ "\n select from [Sales]";
}

private void checkErrorMsg(Throwable e, String expectedErrorMsg) {
while (e.getCause() != null && !e.getCause().equals(e)) {
e = e.getCause();
}
String actualMsg = e.getMessage();
assertEquals(fold(expectedErrorMsg), actualMsg);
assertEquals(expectedErrorMsg, actualMsg);
}

private Query getParsedQueryForExpr(
Expand Down
23 changes: 12 additions & 11 deletions testsrc/main/mondrian/olap/HierarchyBugTest.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2003-2006 Julian Hyde
// Copyright (C) 2003-2009 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
//
Expand Down Expand Up @@ -36,14 +36,14 @@ when it tries to access the (null) hierarchy's name.
*/
public void testNoHierarchy() {
String queryString =
"select NON EMPTY " +
"Crossjoin(Hierarchize(Union({[Time].LastSibling}, " +
"[Time].LastSibling.Children)), " +
"{[Measures].[Unit Sales], " +
"[Measures].[Store Cost]}) ON columns, " +
"NON EMPTY Hierarchize(Union({[Store].[All Stores]}, " +
"[Store].[All Stores].Children)) ON rows " +
"from [Sales]";
"select NON EMPTY "
+ "Crossjoin(Hierarchize(Union({[Time].LastSibling}, "
+ "[Time].LastSibling.Children)), "
+ "{[Measures].[Unit Sales], "
+ "[Measures].[Store Cost]}) ON columns, "
+ "NON EMPTY Hierarchize(Union({[Store].[All Stores]}, "
+ "[Store].[All Stores].Children)) ON rows "
+ "from [Sales]";

Connection conn = getConnection();
Query query = conn.parseQuery(queryString);
Expand All @@ -60,8 +60,9 @@ public void testNoHierarchy() {
for (Hierarchy h : hs) {
// This should NEVER be null, but it is.
if (h == null) {
failStr = "Got a null Hierarchy, " +
"Should be Time Hierarchy";
failStr =
"Got a null Hierarchy, "
+ "Should be Time Hierarchy";
}
}
}
Expand Down
65 changes: 34 additions & 31 deletions testsrc/main/mondrian/olap/NullMemberRepresentationTest.java
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2007-2008 Julian Hyde
// Copyright (C) 2007-2009 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -25,43 +25,46 @@ public class NullMemberRepresentationTest extends FoodMartTestCase {

public void testClosingPeriodMemberLeafWithCustomNullRepresentation() {
assertQueryReturns(
"with member [Measures].[Foo] as ' ClosingPeriod().uniquename '\n" +
"select {[Measures].[Foo]} on columns,\n" +
" {[Time].[1997],\n" +
" [Time].[1997].[Q2],\n" +
" [Time].[1997].[Q2].[4]} on rows\n" +
"from Sales",
fold(
"Axis #0:\n" +
"{}\n" +
"Axis #1:\n" +
"{[Measures].[Foo]}\n" +
"Axis #2:\n" +
"{[Time].[1997]}\n" +
"{[Time].[1997].[Q2]}\n" +
"{[Time].[1997].[Q2].[4]}\n" +
"Row #0: [Time].[1997].[Q4]\n" +
"Row #1: [Time].[1997].[Q2].[6]\n" +
"Row #2: [Time].[" +
getNullMemberRepresentation() +
"]\n" +
""));
"with member [Measures].[Foo] as ' ClosingPeriod().uniquename '\n"
+ "select {[Measures].[Foo]} on columns,\n"
+ " {[Time].[1997],\n"
+ " [Time].[1997].[Q2],\n"
+ " [Time].[1997].[Q2].[4]} on rows\n"
+ "from Sales",
"Axis #0:\n"
+ "{}\n"
+ "Axis #1:\n"
+ "{[Measures].[Foo]}\n"
+ "Axis #2:\n"
+ "{[Time].[1997]}\n"
+ "{[Time].[1997].[Q2]}\n"
+ "{[Time].[1997].[Q2].[4]}\n"
+ "Row #0: [Time].[1997].[Q4]\n"
+ "Row #1: [Time].[1997].[Q2].[6]\n"
+ "Row #2: [Time].["
+ getNullMemberRepresentation()
+ "]\n"
+ "");
}

public void testItemMemberWithCustomNullMemberRepresentation()
throws IOException {
assertExprReturns("[Time].[1997].Children.Item(6).UniqueName",
"[Time].[" + getNullMemberRepresentation() + "]");
assertExprReturns("[Time].[1997].Children.Item(-1).UniqueName",
"[Time].[" + getNullMemberRepresentation() + "]");
throws IOException
{
assertExprReturns(
"[Time].[1997].Children.Item(6).UniqueName",
"[Time].[" + getNullMemberRepresentation() + "]");
assertExprReturns(
"[Time].[1997].Children.Item(-1).UniqueName",
"[Time].[" + getNullMemberRepresentation() + "]");
}

public void testNullMemberWithCustomRepresentation() throws IOException {
assertExprReturns("[Gender].[All Gender].Parent.UniqueName",
"[Gender].[" + getNullMemberRepresentation() + "]");
assertExprReturns(
"[Gender].[All Gender].Parent.UniqueName",
"[Gender].[" + getNullMemberRepresentation() + "]");

assertExprReturns("[Gender].[All Gender].Parent.Name",
getNullMemberRepresentation());
assertExprReturns(
"[Gender].[All Gender].Parent.Name", getNullMemberRepresentation());
}

private String getNullMemberRepresentation() {
Expand Down

0 comments on commit 369bdf1

Please sign in to comment.