Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MONDRIAN: Allow default members to be specified using a name which do…
…es not include the name of the all member, for example, [Gender].[F] and [Gender].[All gender].[F] both work. (Bug 1534593, "Non-All default member incompatible with All member".) [git-p4: depot-paths = "//open/mondrian/": change = 7349]
- Loading branch information
1 parent
611b403
commit d8ce4a5
Showing
4 changed files
with
160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
// $Id$ | ||
// 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) 2006-2006 Julian Hyde | ||
// All Rights Reserved. | ||
// You must accept the terms of that agreement to use this software. | ||
*/ | ||
package mondrian.test; | ||
|
||
/** | ||
* Unit tests for various schema features. | ||
* | ||
* @author jhyde | ||
* @since August 7, 2006 | ||
* @version $Id$ | ||
*/ | ||
public class SchemaTest extends FoodMartTestCase { | ||
|
||
public SchemaTest(String name) { | ||
super(name); | ||
} | ||
|
||
public void testHierarchyDefaultMember() { | ||
final TestContext testContext = TestContext.createSubstitutingCube( | ||
"Sales", | ||
" <Dimension name=\"Gender with default\" foreignKey=\"customer_id\">\n" + | ||
" <Hierarchy hasAll=\"true\" " + | ||
"primaryKey=\"customer_id\" " + | ||
// Define a default member's whose unique name includes the | ||
// 'all' member. | ||
"defaultMember=\"[Gender with default].[All Gender with defaults].[M]\" >\n" + | ||
" <Table name=\"customer\"/>\n" + | ||
" <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\" />\n" + | ||
" </Hierarchy>\n" + | ||
" </Dimension>"); | ||
testContext.assertQueryReturns( | ||
"select {[Gender with default]} on columns from [Sales]", | ||
fold("Axis #0:\n" + | ||
"{}\n" + | ||
"Axis #1:\n" + | ||
"{[Gender with default].[All Gender with defaults].[M]}\n" + | ||
"Row #0: 135,215\n")); | ||
} | ||
|
||
public void testHierarchyAbbreviatedDefaultMember() { | ||
final TestContext testContext = TestContext.createSubstitutingCube( | ||
"Sales", | ||
" <Dimension name=\"Gender with default\" foreignKey=\"customer_id\">\n" + | ||
" <Hierarchy hasAll=\"true\" " + | ||
"primaryKey=\"customer_id\" " + | ||
// Default member unique name does not include 'All'. | ||
"defaultMember=\"[Gender with default].[F]\" >\n" + | ||
" <Table name=\"customer\"/>\n" + | ||
" <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\" />\n" + | ||
" </Hierarchy>\n" + | ||
" </Dimension>"); | ||
testContext.assertQueryReturns( | ||
"select {[Gender with default]} on columns from [Sales]", | ||
fold("Axis #0:\n" + | ||
"{}\n" + | ||
"Axis #1:\n" + | ||
// Note that the 'all' member is named according to the rule | ||
// '[<hierarchy>].[All <hierarchy>s]'. | ||
"{[Gender with default].[All Gender with defaults].[F]}\n" + | ||
"Row #0: 131,558\n")); | ||
} | ||
|
||
public void testHierarchyBadDefaultMember() { | ||
final TestContext testContext = TestContext.createSubstitutingCube( | ||
"Sales", | ||
" <Dimension name=\"Gender with default\" foreignKey=\"customer_id\">\n" + | ||
" <Hierarchy hasAll=\"true\" " + | ||
"primaryKey=\"customer_id\" " + | ||
// Default member unique name does not include 'All'. | ||
"defaultMember=\"[Gender with default].[Non].[Existent]\" >\n" + | ||
" <Table name=\"customer\"/>\n" + | ||
" <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\" />\n" + | ||
" </Hierarchy>\n" + | ||
" </Dimension>"); | ||
testContext.assertThrows( | ||
"select {[Gender with default]} on columns from [Sales]", | ||
"Can not find Default Member with name \"[Gender with default].[Non].[Existent]\" in Hierarchy \"Gender with default\""); | ||
} | ||
} | ||
|
||
// End SchemaTest.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters