forked from pentaho/mondrian
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pentaho#797 from stanislau-strelchanka/MONDRIAN-2529
[MONDRIAN-2529] ChooseByVolume=true can fail due to integer overflow
- Loading branch information
Showing
12 changed files
with
115 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
// This software is subject to the terms of the Eclipse Public License v1.0 | ||
// Agreement, available at the following URL: | ||
// http://www.eclipse.org/legal/epl-v10.html. | ||
// You must accept the terms of that agreement to use this software. | ||
// | ||
// Copyright (C) 2003-2005 Julian Hyde | ||
// Copyright (C) 2005-2016 Pentaho | ||
// All Rights Reserved. | ||
*/ | ||
package mondrian.rolap.agg; | ||
|
||
import junit.framework.Assert; | ||
import mondrian.recorder.MessageRecorder; | ||
import mondrian.rolap.RolapStar; | ||
import mondrian.rolap.aggmatcher.AggStar; | ||
import mondrian.rolap.aggmatcher.JdbcSchema; | ||
import mondrian.test.PropertyRestoringTestCase; | ||
import org.mockito.Mockito; | ||
|
||
public class AggStarTest extends PropertyRestoringTestCase { | ||
|
||
private AggStar aggStar; | ||
private RolapStar star; | ||
private JdbcSchema.Table table; | ||
private MessageRecorder messageRecorder; | ||
private static final Long BIG_NUMBER = Integer.MAX_VALUE + 1L; | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
star = Mockito.mock(RolapStar.class); | ||
table = Mockito.mock(JdbcSchema.Table.class); | ||
messageRecorder = Mockito.mock(MessageRecorder.class); | ||
|
||
Mockito.when(table.getColumnUsages(Mockito.any())).thenCallRealMethod(); | ||
Mockito.when(table.getName()).thenReturn("TestAggTable"); | ||
Mockito.when(table.getTotalColumnSize()).thenReturn(1); | ||
Mockito.when(table.getNumberOfRows()).thenReturn(BIG_NUMBER); | ||
|
||
aggStar = AggStar.makeAggStar(star, table, messageRecorder, 0L); | ||
aggStar = Mockito.spy(aggStar); | ||
|
||
propSaver.set(propSaver.properties.ChooseAggregateByVolume, false); | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
super.tearDown(); | ||
} | ||
|
||
public void testSizeIntegerOverflow() { | ||
Assert.assertEquals(BIG_NUMBER.longValue(), aggStar.getSize()); | ||
} | ||
|
||
public void testVolumeIntegerOverflow() { | ||
propSaver.set(propSaver.properties.ChooseAggregateByVolume, true); | ||
Assert.assertEquals(BIG_NUMBER.longValue(), aggStar.getSize()); | ||
} | ||
} |
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
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
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
Oops, something went wrong.