Search in sources :

Example 36 with DBConnection

use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.

the class BatchExecutionWithNullTest method testSetup.

@BeforeEach
public void testSetup() throws TestAbortedException, Exception {
    assumeTrue(13 <= new DBConnection(connectionString).getServerVersion(), "Aborting test case as SQL Server version is not compatible with Always encrypted ");
    connection = DriverManager.getConnection(connectionString);
    SQLServerStatement stmt = (SQLServerStatement) connection.createStatement();
    Utils.dropTableIfExists("esimple", stmt);
    String sql1 = "create table esimple (id integer not null, name varchar(255), constraint pk_esimple primary key (id))";
    stmt.execute(sql1);
    stmt.close();
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) SQLServerStatement(com.microsoft.sqlserver.jdbc.SQLServerStatement) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 37 with DBConnection

use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.

the class BatchExecutionTest method testSetup.

@BeforeAll
public static void testSetup() throws TestAbortedException, Exception {
    assumeTrue(13 <= new DBConnection(connectionString).getServerVersion(), "Aborting test case as SQL Server version is not compatible with Always encrypted ");
    connection = DriverManager.getConnection(connectionString + ";columnEncryptionSetting=Enabled;");
    stmt = (SQLServerStatement) connection.createStatement();
    dropTable();
    createTable();
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 38 with DBConnection

use of com.microsoft.sqlserver.testframework.DBConnection in project mssql-jdbc by Microsoft.

the class MergeTest method runTest.

/**
 * Merge test
 *
 * @throws Exception
 */
@Test
@DisplayName("Merge Test")
public void runTest() throws Exception {
    try (DBConnection conn = new DBConnection(connectionString)) {
        if (conn.getServerVersion() >= 10) {
            try (DBStatement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {
                stmt.executeUpdate(setupTables);
                stmt.executeUpdate(mergeCmd2);
                int updateCount = stmt.getUpdateCount();
                assertEquals(updateCount, 3, "Received the wrong update count!");
            }
        }
    }
}
Also used : DBConnection(com.microsoft.sqlserver.testframework.DBConnection) DBStatement(com.microsoft.sqlserver.testframework.DBStatement) Test(org.junit.jupiter.api.Test) AbstractTest(com.microsoft.sqlserver.testframework.AbstractTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

DBConnection (com.microsoft.sqlserver.testframework.DBConnection)38 DBStatement (com.microsoft.sqlserver.testframework.DBStatement)25 Test (org.junit.jupiter.api.Test)16 DBResultSet (com.microsoft.sqlserver.testframework.DBResultSet)14 SQLException (java.sql.SQLException)8 DBTable (com.microsoft.sqlserver.testframework.DBTable)6 BeforeAll (org.junit.jupiter.api.BeforeAll)6 Connection (java.sql.Connection)5 Statement (java.sql.Statement)5 ResultSet (java.sql.ResultSet)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 SQLServerBulkCopy (com.microsoft.sqlserver.jdbc.SQLServerBulkCopy)3 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)3 SQLServerCallableStatement (com.microsoft.sqlserver.jdbc.SQLServerCallableStatement)2 SQLServerPreparedStatement (com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement)2 SQLServerStatement (com.microsoft.sqlserver.jdbc.SQLServerStatement)2 DBColumn (com.microsoft.sqlserver.testframework.DBColumn)2 DBPreparedStatement (com.microsoft.sqlserver.testframework.DBPreparedStatement)2 DisplayName (org.junit.jupiter.api.DisplayName)2 SQLServerColumnEncryptionJavaKeyStoreProvider (com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionJavaKeyStoreProvider)1