diff --git a/jdbc42-test/pom.xml b/jdbc42-test/pom.xml deleted file mode 100644 index 1890cba..0000000 --- a/jdbc42-test/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - project - dev.jfr4jdbc - 1.1.0 - - 4.0.0 - - jdbc42-test - - - UTF-8 - 1.8 - 1.8 - - - - - dev.jfr4jdbc - jfr4jdbc-driver - - - org.junit.jupiter - junit-jupiter-api - - - org.junit.jupiter - junit-jupiter-engine - - - org.mockito - mockito-junit-jupiter - - - - - - org.apache.maven.plugins - maven-toolchains-plugin - 3.0.0 - - - - toolchain - - - - - - - 1.8 - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - \ No newline at end of file diff --git a/jdbc42/pom.xml b/jdbc42/pom.xml index a16c5c3..9db62cd 100644 --- a/jdbc42/pom.xml +++ b/jdbc42/pom.xml @@ -5,15 +5,59 @@ project dev.jfr4jdbc - 1.1.0 + 1.3.0 4.0.0 - jfr4jdbc42-driver + jdbc42 UTF-8 8 8 + true + + + + + + maven-deploy-plugin + 3.0.0-M2 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + false + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + + + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.mockito + mockito-junit-jupiter + test + + \ No newline at end of file diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/FlightRecording.java b/jdbc42/src/test/java/dev/jfr4jdbc/FlightRecording.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/FlightRecording.java rename to jdbc42/src/test/java/dev/jfr4jdbc/FlightRecording.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcDriverTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/Jfr4JdbcDriverTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcDriverTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/Jfr4JdbcDriverTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcTestRuntimeException.java b/jdbc42/src/test/java/dev/jfr4jdbc/Jfr4JdbcTestRuntimeException.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcTestRuntimeException.java rename to jdbc42/src/test/java/dev/jfr4jdbc/Jfr4JdbcTestRuntimeException.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4jdbcTestException.java b/jdbc42/src/test/java/dev/jfr4jdbc/Jfr4jdbcTestException.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/Jfr4jdbcTestException.java rename to jdbc42/src/test/java/dev/jfr4jdbc/Jfr4jdbcTestException.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/JfrCallableStatementTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/JfrCallableStatementTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/JfrCallableStatementTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/JfrCallableStatementTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/JfrPreparedStatementTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/JfrPreparedStatementTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/JfrPreparedStatementTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/JfrPreparedStatementTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/JfrResourceMonitorTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/JfrResourceMonitorTest.java similarity index 99% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/JfrResourceMonitorTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/JfrResourceMonitorTest.java index 8183875..12e3aa0 100644 --- a/jdbc42-test/src/test/java/dev/jfr4jdbc/JfrResourceMonitorTest.java +++ b/jdbc42/src/test/java/dev/jfr4jdbc/JfrResourceMonitorTest.java @@ -246,6 +246,7 @@ void eachDatasourceWaitCount() throws Exception { fr.stop(); List events = fr.getEvents("ConnectionResource", e -> e.getString("label").equals("ds" + labelId)); + events.sort((o1, o2) -> o1.getStartTime().compareTo(o2.getStartTime())); assertEquals(6, events.size()); RecordedEvent e1 = events.get(0); assertEquals(0, e1.getInt("wait")); diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/JfrResultSetTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/JfrResultSetTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/JfrResultSetTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/JfrResultSetTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/JfrStatementTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/JfrStatementTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/JfrStatementTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/JfrStatementTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/LinkageIdTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/LinkageIdTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/LinkageIdTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/LinkageIdTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/MockJDBC.java b/jdbc42/src/test/java/dev/jfr4jdbc/MockJDBC.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/MockJDBC.java rename to jdbc42/src/test/java/dev/jfr4jdbc/MockJDBC.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/OneStopTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/OneStopTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/OneStopTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/OneStopTest.java diff --git a/jdbc42-test/src/test/java/dev/jfr4jdbc/ParameterTest.java b/jdbc42/src/test/java/dev/jfr4jdbc/ParameterTest.java similarity index 100% rename from jdbc42-test/src/test/java/dev/jfr4jdbc/ParameterTest.java rename to jdbc42/src/test/java/dev/jfr4jdbc/ParameterTest.java diff --git a/jdbc43-test/pom.xml b/jdbc43-test/pom.xml deleted file mode 100644 index b9ead3f..0000000 --- a/jdbc43-test/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - project - dev.jfr4jdbc - 1.1.0 - - 4.0.0 - - jdbc43-test - - - UTF-8 - 11 - 11 - - - - - dev.jfr4jdbc - jfr4jdbc-driver - - - org.junit.jupiter - junit-jupiter-api - - - org.junit.jupiter - junit-jupiter-engine - - - org.mockito - mockito-junit-jupiter - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - \ No newline at end of file diff --git a/jdbc43/pom.xml b/jdbc43/pom.xml index 0716e1b..84bf749 100644 --- a/jdbc43/pom.xml +++ b/jdbc43/pom.xml @@ -5,23 +5,63 @@ project dev.jfr4jdbc - 1.1.0 + 1.3.0 4.0.0 - jfr4jdbc43-driver + jdbc43 UTF-8 - 11 - 11 + 11 + true + + + + + maven-deploy-plugin + 3.0.0-M2 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + false + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + + + dev.jfr4jdbc - jfr4jdbc42-driver - compile + jdbc42 + ${project.version} + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.mockito + mockito-junit-jupiter + test \ No newline at end of file diff --git a/jdbc43-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java b/jdbc43/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java similarity index 100% rename from jdbc43-test/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java rename to jdbc43/src/test/java/dev/jfr4jdbc/Jfr4JdbcDataSourceTest.java diff --git a/jdbc43-test/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java b/jdbc43/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java similarity index 100% rename from jdbc43-test/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java rename to jdbc43/src/test/java/dev/jfr4jdbc/JfrConnectionTest.java diff --git a/jdbc43-test/src/test/java/dev/jfr4jdbc/JfrStatementTest.java b/jdbc43/src/test/java/dev/jfr4jdbc/JfrStatementTest.java similarity index 100% rename from jdbc43-test/src/test/java/dev/jfr4jdbc/JfrStatementTest.java rename to jdbc43/src/test/java/dev/jfr4jdbc/JfrStatementTest.java diff --git a/jfr4jdbc-driver/pom.xml b/jfr4jdbc-driver/pom.xml index f6add0a..5176a5e 100644 --- a/jfr4jdbc-driver/pom.xml +++ b/jfr4jdbc-driver/pom.xml @@ -2,14 +2,14 @@ - - project - dev.jfr4jdbc - 1.1.0 - 4.0.0 + dev.jfr4jdbc jfr4jdbc-driver + 1.3.0 + jfr4jdbc + A JDBC wrapper driver recording JDK Flight Recorder events + https://github.com/chiroito/Jfr4Jdbc UTF-8 @@ -17,6 +17,31 @@ 1.8 + + + Apache License 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + repo + + + + scm:git:https://github.com/chiroito/Jfr4Jdbc.git + scm:git:https://github.com/chiroito/Jfr4Jdbc.git + https://github.com/chiroito/Jfr4Jdbc + + + + chiroito + Chihiro Ito + https://github.com/chiroito + + lead + architect + developer + + 9 + + ossrh @@ -27,13 +52,30 @@ https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + ${project.basedir}/target/generated-sources/copied-java target/generated-sources/gen-resources true + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + + + + org.apache.maven.plugins @@ -47,8 +89,8 @@ - - + + @@ -56,8 +98,8 @@ - - + + @@ -81,8 +123,7 @@ 1.8 1.8 - ${project.basedir}/target/generated-sources/gen-java - + ${project.basedir}/target/generated-sources/copied-java ${project.build.outputDirectory} @@ -97,8 +138,7 @@ 11 11 - ${project.basedir}/target/generated-sources/gen-java11 - + ${project.basedir}/target/generated-sources/copied-java11 ${project.build.outputDirectory}/META-INF/versions/11 @@ -140,7 +180,7 @@ jar - ${project.basedir}/target/generated-sources/gen-java + ${project.basedir}/target/generated-sources/copied-java @@ -153,7 +193,7 @@ ossrh https://oss.sonatype.org/ - true + false diff --git a/pom.xml b/pom.xml index 072d344..9fc11c9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,55 +4,17 @@ dev.jfr4jdbc project - 1.1.0 + 1.3.0 jdbc42 jdbc43 - jfr4jdbc-driver - jdbc42-test - jdbc43-test + pom jfr4jdbc - A JDBC wrapper driver recording JDK Flight Recorder events - https://github.com/chiroito/Jfr4Jdbc - - - Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - repo - - - - scm:git:https://github.com/chiroito/Jfr4Jdbc.git - scm:git:https://github.com/chiroito/Jfr4Jdbc.git - https://github.com/chiroito/Jfr4Jdbc - - - - chiroito - Chihiro Ito - https://github.com/chiroito - - lead - architect - developer - - 9 - - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + @@ -61,6 +23,11 @@ maven-surefire-plugin 2.22.2 + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.1 + @@ -68,41 +35,20 @@ - - dev.jfr4jdbc - jfr4jdbc42-driver - ${project.version} - jar - - - dev.jfr4jdbc - jfr4jdbc43-driver - ${project.version} - jar - - - dev.jfr4jdbc - jfr4jdbc-driver - ${project.version} - jar - org.junit.jupiter junit-jupiter-api 5.5.1 - test org.junit.jupiter junit-jupiter-engine 5.5.1 - test org.mockito mockito-junit-jupiter 3.0.0 - test diff --git a/src/test/groovy/verifyArtifact.groovy b/src/test/groovy/verifyArtifact.groovy new file mode 100644 index 0000000..fe6f85d --- /dev/null +++ b/src/test/groovy/verifyArtifact.groovy @@ -0,0 +1,46 @@ +import java.util.jar.JarFile + +def version = "1.3.0" + +def multiReleaseJar = new JarFile(new File('./jfr4jdbc-driver/target/jfr4jdbc-driver-' + version + '.jar')) + +assert multiReleaseJar.manifest.mainAttributes.getValue('Multi-Release') == 'true' + +testFileExist(multiReleaseJar, 'services/java.sql.Driver') + +// Java 8 (JDBC 4.2) +testMajorVersion(multiReleaseJar, 'dev/jfr4jdbc/Jfr4JdbcDataSource.class', 52) +testMajorVersion(multiReleaseJar, 'dev/jfr4jdbc/Jfr4JdbcDataSource42.class', 52) +testFileNotExist(multiReleaseJar, 'dev/jfr4jdbc/Jfr4JdbcDataSource43.class') + +// Java 11 (JDBC 4.3 + JFR) +testMajorVersion(multiReleaseJar, 'META-INF/versions/11/dev/jfr4jdbc/Jfr4JdbcDataSource.class', 55) +testMajorVersion(multiReleaseJar, 'META-INF/versions/11/dev/jfr4jdbc/Jfr4JdbcDataSource43.class', 55) +testFileNotExist(multiReleaseJar, 'META-INF/versions/11/dev/jfr4jdbc/Jfr4JdbcDataSource42.class') + +void testFileExist(JarFile jarFile, String classFilePath){ + assert jarFile.getEntry(classFilePath) != null +} + +void testFileNotExist(JarFile jarFile, String classFilePath){ + assert jarFile.getEntry(classFilePath) == null +} + + +void testMajorVersion(JarFile jarFile, String classFilePath, int expectedVersion){ + assert (classFile = jarFile.getEntry(classFilePath)) != null + assert expectedVersion == getMajor(jarFile.getInputStream(classFile)) +} + +int getMajor(InputStream is) { + def dis = new DataInputStream(is) + final String firstFourBytes = Integer.toHexString(dis.readUnsignedShort()) + Integer.toHexString(dis.readUnsignedShort()) + if (!firstFourBytes.equalsIgnoreCase("cafebabe")) { + throw new IllegalArgumentException(dataSourceName + " is NOT a Java .class file.") + } + final int minorVersion = dis.readUnsignedShort() + final int majorVersion = dis.readUnsignedShort() + + is.close(); + return majorVersion; +}