From 501f2b850f511410621f0d8ad43668ff0a6d93c8 Mon Sep 17 00:00:00 2001 From: rene-ye Date: Fri, 6 Apr 2018 11:00:19 -0700 Subject: [PATCH] Removed Exception Test (#669) * Added more information to error messages To help debug an irreproducable/random mismatch error if it occurs in the future. * Fix for the issue when using setMaxRows() with SHOWPLAN ON (#666) * Dont throw exception for colmetadata token * Adding a comment * Update comment * Adding a warning message * remove ignoreLengthPrefixedToken * Fix for uncaught/unhandled exception (#664) * Added more information to error messages To help debug an irreproducable/random mismatch error if it occurs in the future. * Revert "Added information to error message" This reverts commit 25301e6fa042661d4ee1c9dbc8d9cd23ebff8eb7. * Fix for #659 Added error handling logic for special cases. * Read message length Read the message length instead of reading until terminating character * Unsigned byte update Message length is an unsigned byte, converting before using. * Removed clunky hex conversions convert the byte straight to an int and use existing constants instead of making new ones * Narrowed trigger conditions fixed an issue where column names who had the hex token 'AA' would cause an error to be thrown. * Spacing fixes * Added test case * spacing adjustment * Edited test drop procedures Changed IF EXISTS DROP commands to be compatible with sql server 2008 * github spacing misalignment fixes * Changed test condition now only runs on compatible database or higher * Removed error check Removed a previous implementation in favor of one that changes the TDS parser * tdsreader change * removing test for now * enabled tests * github spacing fix * removed array import * removed "arrays" instead of "array" * spacing changes * Use Socket instead of SocketChannel when multiSubnetFailover=true (#662) * Upped SQL Server requirement to 2017 * Removing Exception Test Implement a more generic and compatible test in the future * Removed imports Used in removed test --- .../jdbc/exception/ExceptionTest.java | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/exception/ExceptionTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/exception/ExceptionTest.java index 69245d7ed..422a30d25 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/exception/ExceptionTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/exception/ExceptionTest.java @@ -7,16 +7,12 @@ */ package com.microsoft.sqlserver.jdbc.exception; -import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.UnsupportedEncodingException; import java.net.SocketTimeoutException; -import java.sql.Connection; import java.sql.DriverManager; -import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Statement; import org.junit.jupiter.api.Test; import org.junit.platform.runner.JUnitPlatform; @@ -24,7 +20,6 @@ import com.microsoft.sqlserver.jdbc.SQLServerBulkCSVFileRecord; import com.microsoft.sqlserver.jdbc.SQLServerConnection; -import com.microsoft.sqlserver.jdbc.SQLServerDataSource; import com.microsoft.sqlserver.testframework.AbstractTest; import com.microsoft.sqlserver.testframework.Utils; @@ -98,56 +93,4 @@ private void createWaitForDelayPreocedure(SQLServerConnection conn) throws SQLEx String sql = "CREATE PROCEDURE " + waitForDelaySPName + " AS" + " BEGIN" + " WAITFOR DELAY '00:00:" + waitForDelaySeconds + "';" + " END"; conn.createStatement().execute(sql); } - - @Test - public void testResultSetErrorSearch() throws Exception { - SQLServerDataSource ds = new SQLServerDataSource(); - ds.setURL(connectionString); - - String dropTable_sql = "DROP TABLE IF EXISTS TEST659;"; - String dropProc_sql = "DROP PROCEDURE IF EXISTS proc_insert_masse_TEST;"; - String createTable_sql = "CREATE TABLE TEST659 (ID INT IDENTITY NOT NULL," + - "FIELD1 VARCHAR (255) NOT NULL," + - "FIELD2 VARCHAR (255) NOT NULL);"; - String createProc_sql = "CREATE PROCEDURE proc_insert_masse_TEST @json NVARCHAR(MAX) " - + "AS " - + "BEGIN TRANSACTION " - + "BEGIN TRY " - + "SET NOCOUNT ON; " - + "MERGE INTO TEST659 AS target " - + "USING " - + "(SELECT * FROM OPENJSON(@json) " - + "WITH (FIELD1 VARCHAR(255) 'strict $.FIELD1')) " - + "AS src " - + "ON (1 = 0) " - + "WHEN NOT MATCHED THEN " - + "INSERT (FIELD1) VALUES (src.FIELD1) " - + "OUTPUT inserted.ID; " - + "COMMIT TRANSACTION; " - + "END TRY " - + "BEGIN CATCH " - + "DECLARE @errorMessage NVARCHAR(4000) = ERROR_MESSAGE(); " - + "ROLLBACK TRANSACTION; " - + "RAISERROR('Error occured during the insert: %s', 16, 1, @errorMessage); " - + "END CATCH;"; - String proc_sql = "EXECUTE [dbo].proc_insert_masse_TEST N'[{\"FIELD1\" : \"TEST\"}]';"; - - Connection conn = ds.getConnection(); - if (conn.getMetaData().getDatabaseMajorVersion() >= 13) - { - Statement stmt = conn.createStatement(); - stmt.execute(dropTable_sql); - stmt.execute(createTable_sql); - stmt.execute(dropProc_sql); - stmt.execute(createProc_sql); - stmt.execute(proc_sql); - ResultSet rs = stmt.getResultSet(); - try { - rs.next(); - fail("No exceptions caught."); - } catch (SQLException e) { - assertTrue(e.getMessage().contains("Error occured during the insert:"), "Unexpected Error Message: " + e.getMessage()); - } - } - } }