Skip to content

Commit

Permalink
Change how tests in TCK get their context.
Browse files Browse the repository at this point in the history
Delete directories for obsolete mondrian.olap4j package.


git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@380 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Dec 17, 2010
1 parent 6c1e790 commit ddaf934
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
6 changes: 3 additions & 3 deletions testsrc/org/olap4j/CellSetFormatterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
*
Expand Down
6 changes: 3 additions & 3 deletions testsrc/org/olap4j/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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<Property> propertyList = member.getProperties();
Expand Down
4 changes: 2 additions & 2 deletions testsrc/org/olap4j/MetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,7 +101,6 @@ public class MetadataTest extends TestCase {
"COORDINATE_TYPE");

public MetadataTest() throws SQLException {
tester = TestContext.instance().getTester();
}

protected void setUp() throws SQLException {
Expand Down
5 changes: 3 additions & 2 deletions testsrc/org/olap4j/XmlaConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"))
{
Expand All @@ -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 =
Expand Down
20 changes: 13 additions & 7 deletions testsrc/org/olap4j/test/TestContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@
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 =
Pattern.compile("\r\n|\r|\n");
private static final Pattern TabPattern = Pattern.compile("\t");
private static Properties testProperties;
private static final ThreadLocal<TestContext> THREAD_INSTANCE =
new ThreadLocal<TestContext>();
new ThreadLocal<TestContext>() {
protected TestContext initialValue() {
return new TestContext();
}
};

/**
* The following classes are part of the TCK. Each driver should call them.
Expand Down Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ddaf934

Please sign in to comment.