Skip to content

Commit

Permalink
Different way to fix the memory leaks. When running the TCK in an emb…
Browse files Browse the repository at this point in the history
…eded mode, the test context must be dereferenced or the configuration doesn't pass through.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@498 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Jan 30, 2012
1 parent cbc6665 commit d914472
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 36 deletions.
12 changes: 10 additions & 2 deletions testsrc/org/olap4j/CellSetFormatterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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();
Expand Down
25 changes: 4 additions & 21 deletions testsrc/org/olap4j/MetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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 =
Expand All @@ -131,6 +130,8 @@ protected void tearDown() throws Exception {
connection = null;
olapConnection = null;
olapDatabaseMetaData = null;
testContext = null;
tester = null;
}

// ~ Helper methods ----------
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions testsrc/org/olap4j/OlapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
Expand All @@ -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";
Expand Down
15 changes: 8 additions & 7 deletions testsrc/org/olap4j/XmlaConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions testsrc/org/olap4j/transform/TransformTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
}
Expand Down

0 comments on commit d914472

Please sign in to comment.