diff --git a/testsrc/org/olap4j/CellSetFormatterTest.java b/testsrc/org/olap4j/CellSetFormatterTest.java index 877a6f2..4b2b9e2 100644 --- a/testsrc/org/olap4j/CellSetFormatterTest.java +++ b/testsrc/org/olap4j/CellSetFormatterTest.java @@ -41,8 +41,6 @@ * @version $Id$ */ public class CellSetFormatterTest extends TestCase { - private final TestContext testContext = TestContext.instance(); - private final TestContext.Tester tester = testContext.getTester(); private static final String query1 = "select\n" @@ -67,6 +65,8 @@ 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/ConnectionTest.java b/testsrc/org/olap4j/ConnectionTest.java index 93d06b5..451ed92 100644 --- a/testsrc/org/olap4j/ConnectionTest.java +++ b/testsrc/org/olap4j/ConnectionTest.java @@ -51,8 +51,8 @@ * @version $Id$ */ public class ConnectionTest extends TestCase { - private final TestContext testContext = TestContext.instance(); - private final TestContext.Tester tester = testContext.getTester(); + private TestContext testContext = TestContext.instance(); + private TestContext.Tester tester = testContext.getTester(); private static final boolean IS_JDK_16 = System.getProperty("java.version").startsWith("1.6."); @@ -72,6 +72,8 @@ protected void tearDown() throws Exception { connection.close(); connection = null; } + testContext = null; + tester = null; } /** diff --git a/testsrc/org/olap4j/MetadataTest.java b/testsrc/org/olap4j/MetadataTest.java index d5c94e1..53429d5 100644 --- a/testsrc/org/olap4j/MetadataTest.java +++ b/testsrc/org/olap4j/MetadataTest.java @@ -22,6 +22,7 @@ import org.olap4j.impl.Olap4jUtil; import org.olap4j.metadata.*; import org.olap4j.test.TestContext; +import org.olap4j.test.TestContext.Tester; import junit.framework.TestCase; @@ -36,8 +37,6 @@ public class MetadataTest extends TestCase { private static final String NL = System.getProperty("line.separator"); - private final TestContext testContext = TestContext.instance(); - private final TestContext.Tester tester = testContext.getTester(); private Connection connection; private String catalogName; private OlapConnection olapConnection; @@ -115,6 +114,8 @@ 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 = @@ -127,6 +128,9 @@ protected void tearDown() throws Exception { connection.close(); connection = null; } + connection = null; + olapConnection = null; + olapDatabaseMetaData = null; } // ~ Helper methods ---------- @@ -186,6 +190,8 @@ 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(); @@ -242,6 +248,8 @@ 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( @@ -282,6 +290,8 @@ 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.", @@ -323,6 +333,8 @@ 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() @@ -391,6 +403,8 @@ 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); @@ -424,6 +438,8 @@ 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); @@ -445,6 +461,8 @@ 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); @@ -517,6 +535,8 @@ 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, @@ -700,6 +720,8 @@ 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 9f242a8..ec4e246 100644 --- a/testsrc/org/olap4j/OlapTest.java +++ b/testsrc/org/olap4j/OlapTest.java @@ -43,7 +43,6 @@ * @version $Id$ */ public class OlapTest extends TestCase { - final TestContext.Tester tester = TestContext.instance().getTester(); private Connection connection; public OlapTest() { @@ -61,6 +60,8 @@ protected void tearDown() throws Exception { } 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); @@ -86,6 +87,8 @@ 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 095d5e4..c398b40 100644 --- a/testsrc/org/olap4j/XmlaConnectionTest.java +++ b/testsrc/org/olap4j/XmlaConnectionTest.java @@ -43,7 +43,6 @@ public class XmlaConnectionTest extends TestCase { public static final String DRIVER_CLASS_NAME = "org.olap4j.driver.xmla.XmlaOlap4jDriver"; - private final TestContext testContext = TestContext.instance(); static class XmlaOlap4jProxyMock implements XmlaOlap4jProxy { public byte[] get( @@ -235,6 +234,8 @@ 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)) { @@ -273,8 +274,6 @@ public byte[] get( Proxy.class.getName()); DoubleSubmissionTestProxy.setProxyClassName(oldValue); try { - final TestContext.Tester tester = - testContext.getTester(); Connection connection = tester.createConnection(); OlapConnection oConn = tester.getWrapper().unwrap(connection, OlapConnection.class); @@ -295,6 +294,8 @@ 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() @@ -307,8 +308,6 @@ public void testNoDoubleQuerySubmission() throws Exception { DoubleSubmissionTestProxy.class.getName()); DoubleSubmissionTestProxy.setProxyClassName(oldValue); try { - final TestContext.Tester tester = - testContext.getTester(); Connection connection = tester.createConnection(); Statement statement = connection.createStatement(); final OlapStatement olapStatement = @@ -343,6 +342,8 @@ 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() @@ -358,8 +359,6 @@ public void testPropertyList() throws Exception { try { XmlaTester.setProxyClassName( PropertyListTestProxy.class.getName()); - final TestContext.Tester tester = - testContext.getTester(); OlapConnection connection = tester.getWrapper().unwrap( diff --git a/testsrc/org/olap4j/transform/TransformTest.java b/testsrc/org/olap4j/transform/TransformTest.java index 68ad1da..9a81d20 100644 --- a/testsrc/org/olap4j/transform/TransformTest.java +++ b/testsrc/org/olap4j/transform/TransformTest.java @@ -38,7 +38,6 @@ * @since Jul 28, 2008 */ public class TransformTest extends TestCase { - final TestContext.Tester tester = TestContext.instance().getTester(); private Connection connection = null; public TransformTest() { @@ -61,6 +60,8 @@ protected void tearDown() throws Exception { } protected OlapConnection getConnection() throws SQLException { + final TestContext testContext = TestContext.instance(); + final TestContext.Tester tester = testContext.getTester(); if (connection == null) { connection = tester.createConnection(); }