From ea8b51d3f173cff8e7974fba3d886f13f62b80b4 Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Fri, 21 Dec 2007 23:55:30 +0000 Subject: [PATCH] Update MetadataTest now mondrian has 2 extra functions; fix drill-through test for Derby's JDBC driver weirdness. git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@55 c6a108a4-781c-0410-a6c6-c2d559e19af0 --- testsrc/org/olap4j/ConnectionTest.java | 35 +++++++++++++++----------- testsrc/org/olap4j/MetadataTest.java | 4 +-- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/testsrc/org/olap4j/ConnectionTest.java b/testsrc/org/olap4j/ConnectionTest.java index afa444c..f29e00b 100644 --- a/testsrc/org/olap4j/ConnectionTest.java +++ b/testsrc/org/olap4j/ConnectionTest.java @@ -738,31 +738,36 @@ public void testCell() throws Exception { break; default: final ResultSet resultSet = cell.drillThrough(); - assertEquals(5, resultSet.getMetaData().getColumnCount()); + final ResultSetMetaData metaData = resultSet.getMetaData(); + // Most databases return 5 columns. Derby returns 9 because of + // 4 columns in the ORDER BY clause. + assertTrue(metaData.getColumnCount() >= 5); + assertEquals("Year", metaData.getColumnLabel(1)); + assertEquals("Store Sales", metaData.getColumnLabel(5)); resultSet.close(); break; } // cell out of range using getCell(int) try { - cellSet.getCell(-5); - fail("expected exception"); + Cell cell2 = cellSet.getCell(-5); + fail("expected exception, got " + cell2); } catch (IndexOutOfBoundsException e) { // ok } // cell out of range using getCell(int) try { - cellSet.getCell(105); - fail("expected exception"); + Cell cell2 = cellSet.getCell(105); + fail("expected exception, got " + cell2); } catch (IndexOutOfBoundsException e) { // ok } // cell out of range using getCell(List) try { - cellSet.getCell(Arrays.asList(2, 1)); - fail("expected exception"); + Cell cell2 = cellSet.getCell(Arrays.asList(2, 1)); + fail("expected exception, got " + cell2); } catch (IndexOutOfBoundsException e) { // ok } @@ -771,18 +776,20 @@ public void testCell() throws Exception { // number of positions might be wrong try { // too few dimensions - cellSet.getCell(cellSet.getAxes().get(0).getPositions().get(0)); - fail("expected exception"); + Cell cell2 = + cellSet.getCell(cellSet.getAxes().get(0).getPositions().get(0)); + fail("expected exception, got " + cell2); } catch (IllegalArgumentException e) { // ok } try { // too many dimensions - cellSet.getCell( - cellSet.getAxes().get(0).getPositions().get(0), - cellSet.getAxes().get(1).getPositions().get(0), - cellSet.getAxes().get(0).getPositions().get(0)); - fail("expected exception"); + Cell cell2 = + cellSet.getCell( + cellSet.getAxes().get(0).getPositions().get(0), + cellSet.getAxes().get(1).getPositions().get(0), + cellSet.getAxes().get(0).getPositions().get(0)); + fail("expected exception, got " + cell2); } catch (IllegalArgumentException e) { // ok } diff --git a/testsrc/org/olap4j/MetadataTest.java b/testsrc/org/olap4j/MetadataTest.java index 8b7ba37..d29bb9d 100644 --- a/testsrc/org/olap4j/MetadataTest.java +++ b/testsrc/org/olap4j/MetadataTest.java @@ -301,12 +301,12 @@ public void testDatabaseMetaDataGetFunctions() throws SQLException { olapDatabaseMetaData.getOlapFunctions(null), FUNCTIONS_COLUMN_NAMES); assertContains("FUNCTION_NAME=Name, DESCRIPTION=Returns the name of a member., PARAMETER_LIST=Member, RETURN_TYPE=8, ORIGIN=1, INTERFACE_NAME=, LIBRARY_NAME=null, CAPTION=Name", s); - assertEquals(272, linecount(s)); + assertEquals(274, linecount(s)); s = checkResultSet( olapDatabaseMetaData.getOlapFunctions("%scendants"), FUNCTIONS_COLUMN_NAMES); - assertEquals(s, 6, linecount(s)); + assertEquals(s, 7, linecount(s)); } public void testDatabaseMetaDataGetHierarchies() throws SQLException {