diff --git a/testsrc/org/olap4j/CellSetFormatterTest.java b/testsrc/org/olap4j/CellSetFormatterTest.java index 4b2b9e2..79da6e4 100644 --- a/testsrc/org/olap4j/CellSetFormatterTest.java +++ b/testsrc/org/olap4j/CellSetFormatterTest.java @@ -42,6 +42,16 @@ */ public class CellSetFormatterTest extends TestCase { + private TestContext testContext = TestContext.instance(); + private TestContext.Tester tester = testContext.getTester(); + + @Override + protected void tearDown() throws Exception { + testContext = null; + tester = null; + super.tearDown(); + } + private static final String query1 = "select\n" + " crossjoin(\n" @@ -65,8 +75,6 @@ private void assertFormat( Format format, String expected) throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); Connection connection = null; try { connection = tester.createConnection(); diff --git a/testsrc/org/olap4j/MetadataTest.java b/testsrc/org/olap4j/MetadataTest.java index 53429d5..d469e0b 100644 --- a/testsrc/org/olap4j/MetadataTest.java +++ b/testsrc/org/olap4j/MetadataTest.java @@ -22,7 +22,6 @@ import org.olap4j.impl.Olap4jUtil; import org.olap4j.metadata.*; import org.olap4j.test.TestContext; -import org.olap4j.test.TestContext.Tester; import junit.framework.TestCase; @@ -35,6 +34,8 @@ * @version $Id$ */ public class MetadataTest extends TestCase { + private TestContext testContext = TestContext.instance(); + private TestContext.Tester tester = testContext.getTester(); private static final String NL = System.getProperty("line.separator"); private Connection connection; @@ -114,8 +115,6 @@ public MetadataTest() throws SQLException { } protected void setUp() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); connection = tester.createConnection(); catalogName = connection.getCatalog(); olapConnection = @@ -131,6 +130,8 @@ protected void tearDown() throws Exception { connection = null; olapConnection = null; olapDatabaseMetaData = null; + testContext = null; + tester = null; } // ~ Helper methods ---------- @@ -190,8 +191,6 @@ private int linecount(String s) { // ~ Tests follow ------------- public void testDatabaseMetaData() throws SQLException { - final TestContext context = TestContext.instance(); - final Tester tester = context.getTester(); assertEquals("" + catalogName + "", catalogName); DatabaseMetaData databaseMetaData = connection.getMetaData(); @@ -248,8 +247,6 @@ public void testDatabaseMetaData() throws SQLException { } public void testSchemas() throws OlapException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); // check schema auto detection final Schema schema1 = olapConnection.getOlapSchema(); assertEquals( @@ -290,8 +287,6 @@ public void testSchemas() throws OlapException { } public void testCatalogs() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); final Catalog catalog = olapConnection.getOlapCatalog(); assertEquals( "Failed to auto detect the catalog.", @@ -333,8 +328,6 @@ public void testCatalogs() throws SQLException { public void testDatabases() throws SQLException { final Database database = olapConnection.getOlapDatabase(); - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); assertTrue( "Failed to auto detect the database.", database.getName() @@ -403,8 +396,6 @@ public void testDatabaseMetaDataGetActions() throws SQLException { } public void testDatabaseMetaDataGetDatasources() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); String s = checkResultSet( olapDatabaseMetaData.getDatabases(), DATASOURCES_COLUMN_NAMES); @@ -438,8 +429,6 @@ public void testDatabaseMetaDataGetDatasources() throws SQLException { } public void testDatabaseMetaDataGetCatalogs() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); String s = checkResultSet( olapDatabaseMetaData.getCatalogs(), CATALOGS_COLUMN_NAMES); @@ -461,8 +450,6 @@ public void testDatabaseMetaDataGetCatalogs() throws SQLException { } public void testDatabaseMetaDataGetSchemas() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); String s = checkResultSet( olapDatabaseMetaData.getSchemas(), SCHEMAS_COLUMN_NAMES); @@ -535,8 +522,6 @@ public void testDatabaseMetaDataGetMdxKeywords() throws SQLException { } public void testDatabaseMetaDataGetCubes() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); String s = checkResultSet( olapDatabaseMetaData.getCubes( catalogName, @@ -720,8 +705,6 @@ public void testDatabaseMetaDataGetMeasures() throws SQLException { } public void testDatabaseMetaDataGetMembers() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); String s = checkResultSet( olapDatabaseMetaData.getMembers( catalogName, "FoodMart", "Sales", null, "[Gender]", null, null, diff --git a/testsrc/org/olap4j/OlapTest.java b/testsrc/org/olap4j/OlapTest.java index ec4e246..a181618 100644 --- a/testsrc/org/olap4j/OlapTest.java +++ b/testsrc/org/olap4j/OlapTest.java @@ -43,6 +43,8 @@ * @version $Id$ */ public class OlapTest extends TestCase { + private TestContext testContext = TestContext.instance(); + private TestContext.Tester tester = testContext.getTester(); private Connection connection; public OlapTest() { @@ -57,11 +59,11 @@ protected void tearDown() throws Exception { connection.close(); connection = null; } + testContext = null; + tester = null; } public Cube getFoodmartCube(String cubeName) throws Exception { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); connection = tester.createConnection(); OlapConnection olapConnection = tester.getWrapper().unwrap(connection, OlapConnection.class); @@ -87,8 +89,6 @@ public Cube getFoodmartCube(String cubeName) throws Exception { } public void testModel() throws Exception { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); if (false) { // define the connection information String schemaUri = "file:/open/mondrian/demo/FoodMart.xml"; diff --git a/testsrc/org/olap4j/XmlaConnectionTest.java b/testsrc/org/olap4j/XmlaConnectionTest.java index c398b40..df554e7 100644 --- a/testsrc/org/olap4j/XmlaConnectionTest.java +++ b/testsrc/org/olap4j/XmlaConnectionTest.java @@ -40,7 +40,8 @@ * @version $Id$ */ public class XmlaConnectionTest extends TestCase { - + private TestContext testContext = TestContext.instance(); + private TestContext.Tester tester = testContext.getTester(); public static final String DRIVER_CLASS_NAME = "org.olap4j.driver.xmla.XmlaOlap4jDriver"; @@ -204,6 +205,12 @@ private void checkup(String request) { } } + protected void tearDown() throws Exception { + testContext = null; + tester = null; + super.tearDown(); + } + /** * Verifies that the construction of the necessary * XMLA objects during DriverManager.getConnection() do not make @@ -234,8 +241,6 @@ public void testNoNonTrivalCallsOnConnect() throws Exception { } public void testDbSchemaSchemata() throws Exception { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); if (!testContext.getTester().getFlavor() .equals(Tester.Flavor.XMLA)) { @@ -294,8 +299,6 @@ public byte[] get( * @throws Exception If the test fails. */ public void testNoDoubleQuerySubmission() throws Exception { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); if (!testContext.getTester().getFlavor() .equals(Tester.Flavor.XMLA) && !testContext.getTester().getFlavor() @@ -342,8 +345,6 @@ public void testNoDoubleQuerySubmission() throws Exception { * not be sent to the server. */ public void testPropertyList() throws Exception { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); if (!testContext.getTester().getFlavor() .equals(Tester.Flavor.XMLA) && !testContext.getTester().getFlavor() diff --git a/testsrc/org/olap4j/transform/TransformTest.java b/testsrc/org/olap4j/transform/TransformTest.java index 9a81d20..4728594 100644 --- a/testsrc/org/olap4j/transform/TransformTest.java +++ b/testsrc/org/olap4j/transform/TransformTest.java @@ -38,6 +38,8 @@ * @since Jul 28, 2008 */ public class TransformTest extends TestCase { + private TestContext testContext = TestContext.instance(); + private TestContext.Tester tester = testContext.getTester(); private Connection connection = null; public TransformTest() { @@ -57,11 +59,11 @@ protected void tearDown() throws Exception { connection.close(); connection = null; } + testContext = null; + tester = null; } protected OlapConnection getConnection() throws SQLException { - final TestContext testContext = TestContext.instance(); - final TestContext.Tester tester = testContext.getTester(); if (connection == null) { connection = tester.createConnection(); }