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> <version>${pax.exam.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-assembly</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.ops4j.pax.exam</groupId> <groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId> <artifactId>pax-exam-link-mvn</artifactId>
@ -362,10 +368,14 @@
<version>2.19.1</version> <version>2.19.1</version>
<configuration> <configuration>
<!-- Sets the VM argument line used when unit tests are run. --> <!-- 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 --> <!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests> <skipTests>${skip.unit.tests}</skipTests>
<reuseForks>false</reuseForks> <reuseForks>true</reuseForks>
</configuration> </configuration>
</plugin> </plugin>

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

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

@ -44,8 +44,6 @@ import com.zaxxer.hikari.metrics.MetricsTrackerFactory;
import com.zaxxer.hikari.metrics.dropwizard.CodahaleMetricsTrackerFactory; import com.zaxxer.hikari.metrics.dropwizard.CodahaleMetricsTrackerFactory;
import com.zaxxer.hikari.util.UtilityElf; import com.zaxxer.hikari.util.UtilityElf;
import shaded.org.codehaus.plexus.interpolation.os.Os;
/** /**
* Test HikariCP/CodaHale metrics integration. * Test HikariCP/CodaHale metrics integration.
* *
@ -85,7 +83,7 @@ public class TestMetrics
@Test @Test
public void testMetricUsage() throws SQLException public void testMetricUsage() throws SQLException
{ {
assumeFalse(Os.isFamily(Os.FAMILY_WINDOWS)); assumeFalse(System.getProperty("os.name").contains("Windows"));
MetricRegistry metricRegistry = new MetricRegistry(); MetricRegistry metricRegistry = new MetricRegistry();
HikariConfig config = newHikariConfig(); HikariConfig config = newHikariConfig();

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

Loading…
Cancel
Save