bye bye Derby tests, only use mariadb via container

Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
olivier lamy 2020-05-26 18:32:14 +10:00 committed by Olivier Lamy
parent 1249763aad
commit 389f46c826
3 changed files with 29 additions and 66 deletions

View File

@ -26,9 +26,7 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<systemPropertyVariables> <skip>true</skip>
<mariadb.enabled>false</mariadb.enabled>
</systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
@ -54,16 +52,6 @@
<artifactId>test-sessions-common</artifactId> <artifactId>test-sessions-common</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.toolchain</groupId> <groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId> <artifactId>jetty-test-helper</artifactId>
@ -112,9 +100,9 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<skip>false</skip>
<systemPropertyVariables> <systemPropertyVariables>
<mariadb.docker.version>${mariadb.docker.version}</mariadb.docker.version> <mariadb.docker.version>${mariadb.docker.version}</mariadb.docker.version>
<mariadb.enabled>true</mariadb.enabled>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -47,14 +47,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/ */
public class JdbcTestHelper public class JdbcTestHelper
{ {
public static final boolean USE_MARIADB = Boolean.getBoolean("mariadb.enabled");
private static final Logger LOG = LoggerFactory.getLogger(JdbcTestHelper.class); private static final Logger LOG = LoggerFactory.getLogger(JdbcTestHelper.class);
private static final Logger MARIADB_LOG = LoggerFactory.getLogger("org.eclipse.jetty.server.session.MariaDbLogs"); private static final Logger MARIADB_LOG = LoggerFactory.getLogger("org.eclipse.jetty.server.session.MariaDbLogs");
public static String DRIVER_CLASS = "org.apache.derby.jdbc.EmbeddedDriver"; public static String DRIVER_CLASS;
public static String DEFAULT_CONNECTION_URL = "jdbc:derby:memory:sessions;create=true"; public static String DEFAULT_CONNECTION_URL;
public static String DEFAULT_SHUTDOWN_URL = "jdbc:derby:memory:sessions;drop=true";
public static final int STALE_INTERVAL = 1; public static final int STALE_INTERVAL = 1;
public static final String EXPIRY_COL = "extime"; public static final String EXPIRY_COL = "extime";
@ -76,8 +74,6 @@ public class JdbcTestHelper
static final String MARIA_DB_PASSWORD = "pacific_ale"; static final String MARIA_DB_PASSWORD = "pacific_ale";
static static
{
if (USE_MARIADB)
{ {
try try
{ {
@ -104,7 +100,6 @@ public class JdbcTestHelper
throw new RuntimeException(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e);
} }
} }
}
static static
{ {
@ -113,29 +108,11 @@ public class JdbcTestHelper
public static void shutdown(String connectionUrl) public static void shutdown(String connectionUrl)
throws Exception throws Exception
{
if (USE_MARIADB)
{ {
try (Connection connection = getConnection()) try (Connection connection = getConnection())
{ {
connection.prepareStatement("truncate table " + TABLE).executeUpdate(); connection.prepareStatement("truncate table " + TABLE).executeUpdate();
} }
return;
}
if (connectionUrl == null)
connectionUrl = DEFAULT_SHUTDOWN_URL;
try
{
DriverManager.getConnection(connectionUrl);
}
catch (SQLException expected)
{
if (!"08006".equals(expected.getSQLState()))
{
throw expected;
}
}
} }
public static DatabaseAdaptor buildDatabaseAdaptor() public static DatabaseAdaptor buildDatabaseAdaptor()

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.server.session;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -29,7 +28,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.eclipse.jetty.server.session.JdbcTestHelper.USE_MARIADB;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;