From ae8d4a133259f48b3411fc9103bc74ada531f656 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 31 May 2018 13:20:37 -0700 Subject: [PATCH] Add support for JDK 10 in both Maven and Gradle (#691) * Feature | Added support for JDK 10 in both Maven and Gradle - builds jre10 jars for the driver, replacing jre9 * JDK 10 | Merge 42 classes to base classes to reduce class redundancy. * JDK 10 | Attempt to run JDK 10 with Appveyor * Remove unwanted space * Updating Travis script to use JDK 10 * Testing without addons * Update script for Jacoco report to build 43 profile * Revert driver changes for 42 compliance - to be added in a separate PR * Revert Test class changes for 42 compliance - to be done in a separate PR * Reformatted code * Add ID to jacoco plugin execution task --- .travis.yml | 9 +- appveyor.yml | 5 +- build.gradle | 6 +- pom.xml | 122 +++++++++--------- .../connection/ConnectionWrapper43Test.java | 76 +++++++++++ 5 files changed, 145 insertions(+), 73 deletions(-) create mode 100644 src/test/java/com/microsoft/sqlserver/jdbc/connection/ConnectionWrapper43Test.java diff --git a/.travis.yml b/.travis.yml index a9a2d8f11..1a4299131 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,8 @@ language: java jdk: - - oraclejdk9 + - oraclejdk10 -addons: - apt: - packages: - - oracle-java9-installer - services: - docker @@ -45,5 +40,5 @@ script: - docker ps -a ##Test for JDBC Specification 43 & 42 and submit coverage report. - - mvn test -B -Pbuild41 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC43 + - mvn test -B -Pbuild43 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC43 - mvn test -B -Pbuild42 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC42 diff --git a/appveyor.yml b/appveyor.yml index cc473aded..6ab08769c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,12 +4,11 @@ init: - cmd: net start MSSQL$%SQL_Instance% environment: - JAVA_HOME: C:\Program Files\Java\jdk9 + JAVA_HOME: C:\Program Files\Java\jdk10 mssql_jdbc_test_connection_properties: jdbc:sqlserver://localhost:1433;instanceName=%SQL_Instance%;databaseName=master;username=sa;password=Password12!; - matrix: - SQL_Instance: SQL2008R2SP2 - - SQL_Instance: SQL2016 + - SQL_Instance: SQL2017 install: - ps: Write-Host 'Installing JCE with powershell' diff --git a/build.gradle b/build.gradle index b4cfce4a7..bdd3c1090 100644 --- a/build.gradle +++ b/build.gradle @@ -27,11 +27,11 @@ allprojects { if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile == "build43")){ - jreVersion = "jre9" + jreVersion = "jre10" excludedFile = 'com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java' - sourceCompatibility = 9 - targetCompatibility = 9 + sourceCompatibility = 10 + targetCompatibility = 10 } if((hasProperty('buildProfile') && buildProfile == "build42")) { diff --git a/pom.xml b/pom.xml index f1f5dd160..2696fc391 100644 --- a/pom.xml +++ b/pom.xml @@ -1,37 +1,38 @@ - 4.0.0 - + com.microsoft.sqlserver mssql-jdbc 6.5.3-SNAPSHOT jar - + Microsoft JDBC Driver for SQL Server Microsoft JDBC Driver for SQL Server. https://github.com/Microsoft/mssql-jdbc - + MIT License http://www.opensource.org/licenses/mit-license.php - + Microsoft Corporation - + Microsoft http://www.microsoft.com - + https://github.com/Microsoft/mssql-jdbc @@ -41,7 +42,7 @@ 1.2.0 5.2.0 - + com.microsoft.azure @@ -49,14 +50,14 @@ 1.0.0 true - + com.microsoft.azure adal4j 1.5.0 true - + junit @@ -157,14 +158,14 @@ - + build43 true - + - ${project.artifactId}-${project.version}.jre9-preview + ${project.artifactId}-${project.version}.jre10-preview maven-compiler-plugin @@ -173,8 +174,8 @@ **/com/microsoft/sqlserver/jdbc/SQLServerJdbc42.java - 9 - 9 + 10 + 10 @@ -219,7 +220,7 @@ - + @@ -235,13 +236,14 @@ - + org.jacoco jacoco-maven-plugin - 0.7.8 + 0.8.1 + pre-test prepare-agent @@ -256,46 +258,46 @@ - - org.apache.felix - maven-bundle-plugin - 3.4.0 - true - - - com.microsoft.sqlserver.jdbc,microsoft.sql - !microsoft.sql,* - - - - - bundle-manifest - process-classes - - manifest - - - - - + + org.apache.felix + maven-bundle-plugin + 3.4.0 + true + + + com.microsoft.sqlserver.jdbc,microsoft.sql + !microsoft.sql,* + + + + + bundle-manifest + process-classes + + manifest + + + + + org.apache.maven.plugins - maven-javadoc-plugin - 3.0.0 - - - true - - - - - attach-javadocs - - jar - - - - + maven-javadoc-plugin + 3.0.0 + + + true + + + + + attach-javadocs + + jar + + + + org.apache.maven.plugins @@ -307,7 +309,7 @@ ${skipTestTag} - + org.junit.platform @@ -326,9 +328,9 @@ outdated-dependencies.txt file:///${session.executionRootDirectory}/maven-version-rules.xml - - + + - + diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/connection/ConnectionWrapper43Test.java b/src/test/java/com/microsoft/sqlserver/jdbc/connection/ConnectionWrapper43Test.java new file mode 100644 index 000000000..204673991 --- /dev/null +++ b/src/test/java/com/microsoft/sqlserver/jdbc/connection/ConnectionWrapper43Test.java @@ -0,0 +1,76 @@ +/* + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) Microsoft Corporation All rights reserved. + * + * This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information. + */ +package com.microsoft.sqlserver.jdbc.connection; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.SQLException; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.platform.runner.JUnitPlatform; +import org.junit.runner.RunWith; + +import com.microsoft.sqlserver.jdbc.SQLServerConnection; +import com.microsoft.sqlserver.jdbc.SQLServerConnection43; +import com.microsoft.sqlserver.testframework.AbstractTest; + +/** + * Test ConnectionWrapper43Test class + * + */ +@RunWith(JUnitPlatform.class) +public class ConnectionWrapper43Test extends AbstractTest { + static Connection connection = null; + double javaVersion = Double.parseDouble(System.getProperty("java.specification.version")); + static int major; + static int minor; + + /** + * Tests creation of SQLServerConnection43Test object + * + * @throws SQLException + */ + @Test + public void SQLServerConnection43Test() throws SQLException { + try { + if (1.8d <= javaVersion && 4 == major && 2 == minor) { + assertTrue(connection instanceof SQLServerConnection); + } + else { + assertTrue(connection instanceof SQLServerConnection43); + } + } + finally { + if (null != connection) { + connection.close(); + } + } + } + + @BeforeAll + private static void setupConnection() throws SQLException { + connection = DriverManager.getConnection(connectionString); + + DatabaseMetaData metadata = connection.getMetaData(); + major = metadata.getJDBCMajorVersion(); + minor = metadata.getJDBCMinorVersion(); + } + + @AfterAll + private static void terminateVariation() throws SQLException { + if (null != connection) { + connection.close(); + } + } + +}