Suppress tests currently untestable under Java 9 (when building on Java 9).

pull/876/head
Brett Wooldridge 8 years ago
parent 9e9a97508c
commit 25fde9c11d

@ -192,6 +192,12 @@
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-assembly</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
@ -362,10 +368,14 @@
<version>2.19.1</version>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
<argLine>${surefireArgLine}
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/java.security=ALL-UNNAMED
--add-exports java.base/sun.net.www.protocol.http=ALL-UNNAMED
--add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED</argLine>
<!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests>
<reuseForks>false</reuseForks>
<reuseForks>true</reuseForks>
</configuration>
</plugin>

@ -17,6 +17,10 @@ package com.zaxxer.hikari.osgi;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.NoTestsRemainException;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.InitializationError;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
@ -24,9 +28,9 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import javax.inject.Inject;
import java.io.File;
import static com.zaxxer.hikari.pool.TestElf.isJava9;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.*;
@ -34,58 +38,76 @@ import static org.ops4j.pax.exam.CoreOptions.*;
/**
* @author lburgazzoli
*/
@RunWith(PaxExam.class)
@RunWith(OSGiBundleTest.ConditionalPaxExam.class)
public class OSGiBundleTest
{
@Inject
BundleContext context;
@Test
public void checkInject()
{
assertNotNull(context);
}
@Test
public void checkBundle()
{
Boolean bundleFound = false;
Boolean bundleActive = false;
@Configuration
public Option[] config()
{
return options(
systemProperty("org.osgi.framework.storage.clean").value("true"),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN"),
mavenBundle("org.slf4j","slf4j-api","1.7.5"),
mavenBundle("org.slf4j","slf4j-simple","1.7.5").noStart(),
mavenBundle("org.javassist", "javassist", "3.19.0-GA"),
new File("target/classes").exists()
? bundle("reference:file:target/classes")
: bundle("reference:file:../target/classes"),
junitBundles(),
cleanCaches()
);
}
Bundle[] bundles = context.getBundles();
for (Bundle bundle : bundles) {
if (bundle != null) {
if (bundle.getSymbolicName().equals("com.zaxxer.HikariCP")) {
bundleFound = true;
if (bundle.getState() == Bundle.ACTIVE) {
bundleActive = true;
}
}
}
}
@Test
public void checkInject()
{
assertNotNull(context);
}
assertTrue(bundleFound);
assertTrue(bundleActive);
}
@Test
public void checkBundle()
{
Boolean bundleFound = false;
Boolean bundleActive = false;
@Inject
BundleContext context;
Bundle[] bundles = context.getBundles();
for(Bundle bundle : bundles)
{
if(bundle != null)
{
if(bundle.getSymbolicName().equals("com.zaxxer.HikariCP"))
{
bundleFound = true;
if(bundle.getState() == Bundle.ACTIVE)
{
bundleActive = true;
}
}
}
}
@Configuration
public Option[] config()
{
return options(
systemProperty("org.osgi.framework.storage.clean").value("true"),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN"),
mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
mavenBundle("org.slf4j", "slf4j-simple", "1.7.5").noStart(),
new File("target/classes").exists()
? bundle("reference:file:target/classes")
: bundle("reference:file:../target/classes"),
junitBundles(),
cleanCaches()
);
}
public static class ConditionalPaxExam extends PaxExam
{
public ConditionalPaxExam(Class<?> klass) throws InitializationError {
super(klass);
}
@Override
public void run(RunNotifier notifier) {
if (!isJava9()) {
super.run(notifier);
}
}
@Override
public void filter(Filter filter) throws NoTestsRemainException {
if (isJava9()) {
throw new NoTestsRemainException();
}
assertTrue(bundleFound);
assertTrue(bundleActive);
}
super.filter(filter);
}
}
}

@ -44,6 +44,10 @@ public final class TestElf
// default constructor
}
public static boolean isJava9() {
return System.getProperty("java.version").startsWith("9");
}
public static HikariPool getPool(HikariDataSource ds)
{
try {

@ -44,8 +44,6 @@ import com.zaxxer.hikari.metrics.MetricsTrackerFactory;
import com.zaxxer.hikari.metrics.dropwizard.CodahaleMetricsTrackerFactory;
import com.zaxxer.hikari.util.UtilityElf;
import shaded.org.codehaus.plexus.interpolation.os.Os;
/**
* Test HikariCP/CodaHale metrics integration.
*
@ -85,7 +83,7 @@ public class TestMetrics
@Test
public void testMetricUsage() throws SQLException
{
assumeFalse(Os.isFamily(Os.FAMILY_WINDOWS));
assumeFalse(System.getProperty("os.name").contains("Windows"));
MetricRegistry metricRegistry = new MetricRegistry();
HikariConfig config = newHikariConfig();
@ -156,19 +154,19 @@ public class TestMetrics
try (HikariDataSource ds = newHikariDataSource()) {
ds.setMaximumPoolSize(1);
ds.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
MetricRegistry metricRegistry = new MetricRegistry();
HealthCheckRegistry healthRegistry = new HealthCheckRegistry();
try {
try (Connection connection = ds.getConnection()) {
// close immediately
}
// After the pool as started, we can only set them once...
ds.setMetricRegistry(metricRegistry);
ds.setHealthCheckRegistry(healthRegistry);
// and never again...
ds.setMetricRegistry(metricRegistry);
fail("Should not have been allowed to set registry after pool started");
@ -192,19 +190,19 @@ public class TestMetrics
try (HikariDataSource ds = newHikariDataSource()) {
ds.setMaximumPoolSize(1);
ds.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
MetricRegistry metricRegistry = new MetricRegistry();
HealthCheckRegistry healthRegistry = new HealthCheckRegistry();
ds.setMetricRegistry(metricRegistry);
ds.setHealthCheckRegistry(healthRegistry);
// before the pool is started, we can set it any number of times...
ds.setMetricRegistry(metricRegistry);
ds.setHealthCheckRegistry(healthRegistry);
try (Connection connection = ds.getConnection()) {
// after the pool is started, we cannot set it any more
ds.setMetricRegistry(metricRegistry);
fail("Should not have been allowed to set registry after pool started");
@ -221,15 +219,15 @@ public class TestMetrics
try (HikariDataSource ds = newHikariDataSource()) {
ds.setMaximumPoolSize(1);
ds.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
MetricRegistry metricRegistry = new MetricRegistry();
MetricsTrackerFactory metricsTrackerFactory = new CodahaleMetricsTrackerFactory(metricRegistry);
try (Connection connection = ds.getConnection()) {
// After the pool as started, we can only set them once...
ds.setMetricsTrackerFactory(metricsTrackerFactory);
// and never again...
ds.setMetricsTrackerFactory(metricsTrackerFactory);
fail("Should not have been allowed to set metricsTrackerFactory after pool started");
@ -254,16 +252,16 @@ public class TestMetrics
try (HikariDataSource ds = newHikariDataSource()) {
ds.setMaximumPoolSize(1);
ds.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
MetricRegistry metricRegistry = new MetricRegistry();
// before the pool is started, we can set it any number of times using either setter
ds.setMetricRegistry(metricRegistry);
ds.setMetricRegistry(metricRegistry);
ds.setMetricRegistry(metricRegistry);
try (Connection connection = ds.getConnection()) {
// after the pool is started, we cannot set it any more
ds.setMetricRegistry(metricRegistry);
fail("Should not have been allowed to set registry after pool started");
@ -280,17 +278,17 @@ public class TestMetrics
try (HikariDataSource ds = newHikariDataSource()) {
ds.setMaximumPoolSize(1);
ds.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");
MetricRegistry metricRegistry = new MetricRegistry();
MetricsTrackerFactory metricsTrackerFactory = new CodahaleMetricsTrackerFactory(metricRegistry);
// before the pool is started, we can set it any number of times using either setter
ds.setMetricsTrackerFactory(metricsTrackerFactory);
ds.setMetricsTrackerFactory(metricsTrackerFactory);
ds.setMetricsTrackerFactory(metricsTrackerFactory);
try (Connection connection = ds.getConnection()) {
// after the pool is started, we cannot set it any more
ds.setMetricsTrackerFactory(metricsTrackerFactory);
fail("Should not have been allowed to set registry factory after pool started");

@ -16,9 +16,11 @@
package com.zaxxer.hikari.util;
import static com.zaxxer.hikari.pool.TestElf.isJava9;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assume.assumeTrue;
import java.io.DataInputStream;
import java.io.IOException;
@ -28,6 +30,9 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.concurrent.CompletableFuture;
import com.zaxxer.hikari.pool.TestElf;
import org.junit.Assume;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@ -45,6 +50,8 @@ public class TomcatConcurrentBagLeakTest
@Test
public void testConcurrentBagForLeaks() throws Exception
{
assumeTrue(!isJava9());
ClassLoader cl = new FauxWebClassLoader();
Class<?> clazz = cl.loadClass(this.getClass().getName() + "$FauxWebContext");
Object fauxWebContext = clazz.newInstance();
@ -60,6 +67,8 @@ public class TomcatConcurrentBagLeakTest
@Test
public void testConcurrentBagForLeaks2() throws Exception
{
assumeTrue(!isJava9());
ClassLoader cl = this.getClass().getClassLoader();
Class<?> clazz = cl.loadClass(this.getClass().getName() + "$FauxWebContext");
Object fauxWebContext = clazz.newInstance();

Loading…
Cancel
Save