-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
145 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/test/java/com/microsoft/sqlserver/jdbc/connection/ConnectionWrapper43Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
|
||
} |