Skip to content

Commit

Permalink
may use testcontainers to get a proper mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
stbischof committed Dec 1, 2021
1 parent 068daea commit 3b5abe8
Show file tree
Hide file tree
Showing 15 changed files with 3,262 additions and 16 deletions.
12 changes: 6 additions & 6 deletions mondrian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,18 @@
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.mockito</groupId> -->
<!-- <artifactId>mockito-all</artifactId> -->
<!-- <version>${mockito-all.version}</version> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>1.16.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javacup</groupId>
<artifactId>javacup</artifactId>
Expand Down
381 changes: 381 additions & 0 deletions mondrian/src/test/java/mondrian/olap/fun/CachedExistsTest.java

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions mondrian/src/test/java/mondrian/olap4j/MondrianInprocProxy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* This software is subject to the terms of the Eclipse Public License v1.0
* Agreement, available at the following URL:
* http://www.eclipse.org/legal/epl-v10.html.
* You must accept the terms of that agreement to use this software.
*
* Copyright (c) 2002-2017 Hitachi Vantara.. All rights reserved.
*/

package mondrian.olap4j;

import mondrian.olap.Util;
import mondrian.tui.XmlaSupport;

import org.apache.commons.collections.map.ReferenceMap;

import org.olap4j.driver.xmla.XmlaOlap4jServerInfos;
import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;

import java.util.*;
import java.util.concurrent.*;

/**
* Proxy which implements XMLA requests by talking to mondrian
* in-process. This is more convenient to debug than an inter-process
* request using HTTP.
*
* @author jhyde
*/
public class MondrianInprocProxy
implements XmlaOlap4jProxy
{
private final ExecutorService executor =
Util.getExecutorService(
1, 1, 1, "MondrianInprocProxy$executor",
new ThreadPoolExecutor.CallerRunsPolicy());
private final Map<String, String> catalogNameUrls;
private final String urlString;
private final Map servletCache =
new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK);

/**
* Creates and initializes a MondrianInprocProxy.
*
* @param catalogNameUrls Collection of catalog names and the URL where
* their catalog is to be found. For testing purposes, this should contain
* a catalog called "FoodMart".
*
* @param urlString JDBC connect string; must begin with "jdbc:mondrian:"
*/
public MondrianInprocProxy(
Map<String, String> catalogNameUrls,
String urlString)
{
this.catalogNameUrls = catalogNameUrls;
if (!urlString.startsWith("jdbc:mondrian:")) {
throw new IllegalArgumentException();
}
this.urlString = urlString.substring("jdbc:mondrian:".length());
}

public byte[] get(
XmlaOlap4jServerInfos infos,
String request)
{
try {
return XmlaSupport.processSoapXmla(
request, urlString, catalogNameUrls, null, null, servletCache);
} catch (Exception e) {
throw new RuntimeException(
"Error while reading '" + infos.getUrl() + "'", e);
}
}

public Future<byte[]> submit(
final XmlaOlap4jServerInfos infos,
final String request)
{
return this.executor.submit(
new Callable<byte[]>() {
public byte[] call() throws Exception {
return get(infos, request);
}
});
}

public String getEncodingCharsetName() {
return "UTF-8";
}
}

// End MondrianInprocProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Statement;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.mysql.jdbc.Statement;

import mondrian.olap.Util;
import mondrian.spi.Dialect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Statement;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.mysql.jdbc.Statement;


import mondrian.spi.Dialect;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Statement;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.mysql.jdbc.Statement;

import mondrian.spi.Dialect;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Statement;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.mysql.jdbc.Statement;

import mondrian.spi.Dialect;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Statement;


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.mysql.jdbc.Statement;

import mondrian.spi.Dialect;

public class PostgreSqlDialectTest{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Statement;


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.mysql.jdbc.Statement;

import mondrian.spi.Dialect;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Statement;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.mysql.jdbc.Statement;

import mondrian.spi.Dialect;

Expand Down
45 changes: 45 additions & 0 deletions mondrian/src/test/java/mondrian/test/DelegatingTestContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* This software is subject to the terms of the Eclipse Public License v1.0
* Agreement, available at the following URL:
* http://www.eclipse.org/legal/epl-v10.html.
* You must accept the terms of that agreement to use this software.
*
* Copyright (c) 2002-2017 Hitachi Vantara.. All rights reserved.
*/

package mondrian.test;

import mondrian.olap.Util;

import java.io.PrintWriter;

/**
* Extension of {@link TestContext} which delegates all behavior to
* a parent test context.
*
* <p>Derived classes can selectively override methods.
*
* @author jhyde
* @since 7 September, 2005
*/
public class DelegatingTestContext extends TestContext {
protected final TestContext context;

protected DelegatingTestContext(TestContext context) {
this.context = context;
}

public Util.PropertyList getConnectionProperties() {
return context.getConnectionProperties();
}

public String getDefaultCubeName() {
return context.getDefaultCubeName();
}

public PrintWriter getWriter() {
return context.getWriter();
}
}

// End DelegatingTestContext.java
Loading

0 comments on commit 3b5abe8

Please sign in to comment.