diff --git a/testsrc/org/olap4j/CellSetFormatterTest.java b/testsrc/org/olap4j/CellSetFormatterTest.java index 259946a..d0862b1 100644 --- a/testsrc/org/olap4j/CellSetFormatterTest.java +++ b/testsrc/org/olap4j/CellSetFormatterTest.java @@ -31,9 +31,10 @@ * @version $Id$ */ public class CellSetFormatterTest extends TestCase { - final TestContext.Tester tester = TestContext.instance().getTester(); + private final TestContext testContext = TestContext.instance(); + private final TestContext.Tester tester = testContext.getTester(); - static final String query1 = + private static final String query1 = "select\n" + " crossjoin(\n" + " {[Time].[1997].[Q1], [Time].[1997].[Q2].[4]},\n" @@ -43,7 +44,6 @@ public class CellSetFormatterTest extends TestCase { + " [USA].[CA].[San Francisco]} on 1\n" + "FROM [Sales]"; - /** * Asserts that a query is formatted to an expected piece of text. * diff --git a/testsrc/org/olap4j/ConnectionTest.java b/testsrc/org/olap4j/ConnectionTest.java index 8386d87..111c1ec 100644 --- a/testsrc/org/olap4j/ConnectionTest.java +++ b/testsrc/org/olap4j/ConnectionTest.java @@ -39,8 +39,8 @@ * @version $Id$ */ public class ConnectionTest extends TestCase { - private final TestContext.Tester tester = - TestContext.instance().getTester(); + private final TestContext testContext = TestContext.instance(); + private final TestContext.Tester tester = testContext.getTester(); private static final boolean IS_JDK_16 = System.getProperty("java.version").startsWith("1.6."); @@ -1914,13 +1914,13 @@ public void testMetadata() throws Exception { break; default: assertNull(member.getDescription()); + // mondrian does not set ordinals correctly assertEquals(-1, member.getOrdinal()); assertEquals(1, member.getDepth()); assertEquals(-1, member.getSolveOrder()); assertFalse(member.isHidden()); assertNull(member.getDataMember()); assertFalse(member.isCalculatedInQuery()); - break; } final NamedList propertyList = member.getProperties(); diff --git a/testsrc/org/olap4j/MetadataTest.java b/testsrc/org/olap4j/MetadataTest.java index 52e70b2..2aa5e65 100644 --- a/testsrc/org/olap4j/MetadataTest.java +++ b/testsrc/org/olap4j/MetadataTest.java @@ -25,7 +25,8 @@ public class MetadataTest extends TestCase { private static final String NL = System.getProperty("line.separator"); - private final TestContext.Tester tester; + private final TestContext testContext = TestContext.instance(); + private final TestContext.Tester tester = testContext.getTester(); private Connection connection; private String catalogName; private OlapConnection olapConnection; @@ -100,7 +101,6 @@ public class MetadataTest extends TestCase { "COORDINATE_TYPE"); public MetadataTest() throws SQLException { - tester = TestContext.instance().getTester(); } protected void setUp() throws SQLException { diff --git a/testsrc/org/olap4j/XmlaConnectionTest.java b/testsrc/org/olap4j/XmlaConnectionTest.java index 6787d77..6294c7d 100644 --- a/testsrc/org/olap4j/XmlaConnectionTest.java +++ b/testsrc/org/olap4j/XmlaConnectionTest.java @@ -20,6 +20,7 @@ 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(URL url, String request) throws IOException { @@ -215,7 +216,7 @@ public void testNoNonTrivalCallsOnConnect() throws Exception { * @throws Exception If the test fails. */ public void testNoDoubleQuerySubmission() throws Exception { - if (!TestContext.instance().getProperties() + if (!testContext.getProperties() .get(TestContext.Property.HELPER_CLASS_NAME.path) .equals("org.olap4j.XmlaTester")) { @@ -227,7 +228,7 @@ public void testNoDoubleQuerySubmission() throws Exception { DoubleSubmissionTestProxy.setProxyClassName(oldValue); try { final TestContext.Tester tester = - TestContext.instance().getTester(); + testContext.getTester(); Connection connection = tester.createConnection(); Statement statement = connection.createStatement(); final OlapStatement olapStatement = diff --git a/testsrc/org/olap4j/test/TestContext.java b/testsrc/org/olap4j/test/TestContext.java index 04861b7..66d244d 100644 --- a/testsrc/org/olap4j/test/TestContext.java +++ b/testsrc/org/olap4j/test/TestContext.java @@ -39,7 +39,6 @@ public class TestContext { public static final String NL = System.getProperty("line.separator"); private static final String indent = " "; - private static final TestContext INSTANCE = new TestContext(); private static final String lineBreak2 = "\\\\n\"" + NL + indent + "+ \""; private static final String lineBreak3 = "\\n\"" + NL + indent + "+ \""; private static final Pattern LineBreakPattern = @@ -47,7 +46,11 @@ public class TestContext { private static final Pattern TabPattern = Pattern.compile("\t"); private static Properties testProperties; private static final ThreadLocal THREAD_INSTANCE = - new ThreadLocal(); + new ThreadLocal() { + protected TestContext initialValue() { + return new TestContext(); + } + }; /** * The following classes are part of the TCK. Each driver should call them. @@ -177,11 +180,7 @@ public static String toString(CellSet cellSet) { * @return default TestContext */ public static TestContext instance() { - final TestContext i = THREAD_INSTANCE.get(); - if (i != null) { - return i; - } - return INSTANCE; + return THREAD_INSTANCE.get(); } /** @@ -333,6 +332,13 @@ private static Tester createTester( testProperties.getProperty(Property.HELPER_CLASS_NAME.path); if (helperClassName == null) { helperClassName = "org.olap4j.XmlaTester"; + if (!testProperties.containsKey( + TestContext.Property.XMLA_CATALOG_URL.path)) + { + testProperties.setProperty( + TestContext.Property.XMLA_CATALOG_URL.path, + "dummy_xmla_catalog_url"); + } } Tester tester; try {