From 435c9256b73f25561034f4dd2176f48c2c7077aa Mon Sep 17 00:00:00 2001 From: Suraiya Hameed Date: Mon, 9 Jan 2017 14:05:13 -0800 Subject: [PATCH] more javadocs --- .../jdbc/bulkCopy/BulkCopyConnectionTest.java | 67 ++++--- .../jdbc/bulkCopy/BulkCopyTestSetUp.java | 40 ++-- .../jdbc/bulkCopy/BulkCopyTestUtil.java | 181 ++++++++++++++++++ .../jdbc/bulkCopy/BulkCopyTestWrapper.java | 177 +---------------- .../jdbc/bulkCopy/BulkCopyTimeoutTest.java | 38 ++-- 5 files changed, 256 insertions(+), 247 deletions(-) create mode 100644 src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestUtil.java diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyConnectionTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyConnectionTest.java index ce6c4d321..473ebd696 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyConnectionTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyConnectionTest.java @@ -1,27 +1,10 @@ -// --------------------------------------------------------------------------------------------------------------------------------- -// File: BulkCopyTestConnection.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files(the "Software"), -// to deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// --------------------------------------------------------------------------------------------------------------------------------- +/* + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) 2016 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.bulkCopy; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -47,6 +30,9 @@ import com.microsoft.sqlserver.jdbc.SQLServerConnection; import com.microsoft.sqlserver.jdbc.SQLServerException; +/** + * Test BulkCopy Connection Constructor and BulkCopyOption + */ @RunWith(JUnitPlatform.class) @DisplayName("BulkCopy Connection Test") public class BulkCopyConnectionTest extends BulkCopyTestSetUp { @@ -66,7 +52,7 @@ public DynamicTest apply(final BulkCopyTestWrapper datum) { return DynamicTest.dynamicTest("Testing " + datum.testName, new org.junit.jupiter.api.function.Executable() { @Override public void execute() { - BulkCopyTestUtil.performBulkCopy(datum,sourceTable); + BulkCopyTestUtil.performBulkCopy(datum, sourceTable); } }); } @@ -87,13 +73,16 @@ public DynamicTest apply(final BulkCopyTestWrapper datum) { return DynamicTest.dynamicTest("Testing " + datum.testName, new org.junit.jupiter.api.function.Executable() { @Override public void execute() { - BulkCopyTestUtil.performBulkCopy(datum,sourceTable); + BulkCopyTestUtil.performBulkCopy(datum, sourceTable); } }); } }); } + /** + * BulkCopy:test uninitialized Connection + */ @Test @DisplayName("BulkCopy:test uninitialized Connection") void testInvalidConnection_1() { @@ -106,6 +95,9 @@ public void execute() throws SQLServerException { }); } + /** + * BulkCopy:test uninitialized SQLServerConnection + */ @Test @DisplayName("BulkCopy:test uninitialized SQLServerConnection") void testInvalidConnection_2() { @@ -118,6 +110,9 @@ public void execute() throws SQLServerException { }); } + /** + * BulkCopy:test empty connenction string + */ @Test @DisplayName("BulkCopy:test empty connenction string") void testInvalidConnection_3() { @@ -130,6 +125,9 @@ public void execute() throws SQLServerException { }); } + /** + * BulkCopy:test null connenction string + */ @Test @DisplayName("BulkCopy:test null connenction string") void testInvalidConnection_4() { @@ -142,6 +140,9 @@ public void execute() throws SQLServerException { }); } + /** + * BulkCopy:test null SQLServerBulkCopyOptions + */ @Test @DisplayName("BulkCopy:test null SQLServerBulkCopyOptions") void testEmptyBulkCopyOptions() { @@ -150,9 +151,14 @@ void testEmptyBulkCopyOptions() { SQLServerBulkCopyOptions option = null; bulkWrapper.useBulkCopyOptions(true); bulkWrapper.setBulkOptions(option); - BulkCopyTestUtil.performBulkCopy(bulkWrapper,sourceTable); + BulkCopyTestUtil.performBulkCopy(bulkWrapper, sourceTable); } - + + /** + * Generate BulkCopyTestWrapper objects with data for testing BulkCopyConstructor + * + * @return + */ List createTestData_testBulkCopyConstructor() { String testCaseName = "BulkCopyConstructor "; List testData = new ArrayList(); @@ -169,6 +175,11 @@ List createTestData_testBulkCopyConstructor() { return testData; } + /** + * Generate BulkCopyTestWrapper objects with data for testing BulkCopyOption + * + * @return + */ private List createTestData_testBulkCopyOption() { String testCaseName = "BulkCopyOption "; List testData = new ArrayList(); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestSetUp.java b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestSetUp.java index 52f11bc0c..79770bccf 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestSetUp.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestSetUp.java @@ -1,27 +1,10 @@ -// --------------------------------------------------------------------------------------------------------------------------------- -// File: BulkCopyTestSetUp.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files(the "Software"), -// to deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// --------------------------------------------------------------------------------------------------------------------------------- +/* + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) 2016 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.bulkCopy; import org.junit.jupiter.api.AfterAll; @@ -34,11 +17,17 @@ import com.microsoft.sqlserver.testframework.DBStatement; import com.microsoft.sqlserver.testframework.DBTable;; +/** + * Create and drop source table needed for testing bulk copy + */ @RunWith(JUnitPlatform.class) public class BulkCopyTestSetUp extends AbstractTest { static DBTable sourceTable; + /** + * Create source table needed for testing bulk copy + */ @BeforeAll static void setUpSourceTable() { DBConnection con = null; @@ -55,6 +44,9 @@ static void setUpSourceTable() { } } + /** + * drop source table after testing bulk copy + */ @AfterAll static void dropSourceTable() { DBConnection con = null; diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestUtil.java b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestUtil.java new file mode 100644 index 000000000..9e00697de --- /dev/null +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestUtil.java @@ -0,0 +1,181 @@ +/* + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) 2016 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.bulkCopy; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.Date; +import java.sql.JDBCType; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Time; +import java.sql.Timestamp; + +import com.microsoft.sqlserver.jdbc.SQLServerBulkCopy; +import com.microsoft.sqlserver.testframework.DBConnection; +import com.microsoft.sqlserver.testframework.DBResultSet; +import com.microsoft.sqlserver.testframework.DBStatement; +import com.microsoft.sqlserver.testframework.DBTable; + +/** + * Utility class + */ +class BulkCopyTestUtil { + + /** + * perform bulk copy using source table and validate bulkcopy + * + * @param wrapper + * @param sourceTable + */ + static void performBulkCopy(BulkCopyTestWrapper wrapper, DBTable sourceTable) { + performBulkCopy(wrapper, sourceTable, false); + } + + /** + * perform bulk copy using source table + * + * @param wrapper + * @param sourceTable + * @param validateResult + */ + static void performBulkCopy(BulkCopyTestWrapper wrapper, DBTable sourceTable, boolean validateResult) { + DBConnection con = null; + DBStatement stmt = null; + DBTable destinationTable = null; + try { + con = new DBConnection(wrapper.getConnectionString()); + stmt = con.createStatement(); + + destinationTable = sourceTable.cloneSchema(); + stmt.createTable(destinationTable); + DBResultSet srcResultSet = stmt.executeQuery("SELECT * FROM " + sourceTable.getEscapedTableName() + ";"); + SQLServerBulkCopy bulkCopy; + if (wrapper.isUsingConnection()) { + bulkCopy = new SQLServerBulkCopy((Connection) con.product()); + } + else { + bulkCopy = new SQLServerBulkCopy(wrapper.getConnectionString()); + } + if (wrapper.isUsingBulkCopyOptions()) { + bulkCopy.setBulkCopyOptions(wrapper.getBulkOptions()); + } + bulkCopy.setDestinationTableName(destinationTable.getEscapedTableName()); + bulkCopy.writeToServer((ResultSet) srcResultSet.product()); + bulkCopy.close(); + if (validateResult) { + validateValues(con, sourceTable, destinationTable); + } + } + catch (SQLException ex) { + fail(ex.getMessage()); + } + finally { + stmt.dropTable(destinationTable); + con.close(); + } + } + + /** + * validate if same values are in both source and destination table + * + * @param con + * @param sourceTable + * @param destinationTable + * @throws SQLException + */ + static void validateValues(DBConnection con, DBTable sourceTable, DBTable destinationTable) throws SQLException { + DBStatement srcStmt = con.createStatement(); + DBStatement dstStmt = con.createStatement(); + DBResultSet srcResultSet = srcStmt.executeQuery("SELECT * FROM " + sourceTable.getEscapedTableName() + ";"); + DBResultSet dstResultSet = dstStmt.executeQuery("SELECT * FROM " + destinationTable.getEscapedTableName() + ";"); + ResultSetMetaData destMeta = ((ResultSet) dstResultSet.product()).getMetaData(); + int totalColumns = destMeta.getColumnCount(); + + // verify data from sourceType and resultSet + while (srcResultSet.next() && dstResultSet.next()) + for (int i = 1; i <= totalColumns; i++) { + // TODO: check row and column count in both the tables + + Object srcValue, dstValue; + srcValue = srcResultSet.getObject(i); + dstValue = dstResultSet.getObject(i); + // Bulkcopy doesn't guarantee order of insertion - + // if we need to test several rows either use primary key or + // validate result based on sql JOIN + switch (destMeta.getColumnType(i)) { + case java.sql.Types.BIGINT: + assertTrue((((Long) srcValue).longValue() == ((Long) dstValue).longValue()), "Unexpected bigint value"); + break; + + case java.sql.Types.INTEGER: + assertTrue((((Integer) srcValue).intValue() == ((Integer) dstValue).intValue()), "Unexpected int value"); + break; + + case java.sql.Types.SMALLINT: + case java.sql.Types.TINYINT: + assertTrue((((Short) srcValue).shortValue() == ((Short) dstValue).shortValue()), "Unexpected smallint/tinyint value"); + break; + + case java.sql.Types.BIT: + assertTrue((((Boolean) srcValue).booleanValue() == ((Boolean) dstValue).booleanValue()), "Unexpected bit value"); + break; + + case java.sql.Types.DECIMAL: + case java.sql.Types.NUMERIC: + assertTrue(0 == (((BigDecimal) srcValue).compareTo((BigDecimal) dstValue)), + "Unexpected decimal/numeric/money/smallmoney value"); + break; + + case java.sql.Types.DOUBLE: + assertTrue((((Double) srcValue).doubleValue() == ((Double) dstValue).doubleValue()), "Unexpected float value"); + break; + + case java.sql.Types.REAL: + assertTrue((((Float) srcValue).floatValue() == ((Float) dstValue).floatValue()), "Unexpected real value"); + break; + + case java.sql.Types.VARCHAR: + case java.sql.Types.NVARCHAR: + assertTrue((((String) srcValue).equals((String) dstValue)), "Unexpected varchar/nvarchar value "); + break; + + case java.sql.Types.CHAR: + case java.sql.Types.NCHAR: + assertTrue((((String) srcValue).equals((String) dstValue)), "Unexpected char/nchar value "); + break; + + case java.sql.Types.TIMESTAMP: + assertTrue((((Timestamp) srcValue).getTime() == (((Timestamp) dstValue).getTime())), + "Unexpected datetime/smalldatetime/datetime2 value"); + break; + + case java.sql.Types.DATE: + assertTrue((((Date) srcValue).getTime() == (((Date) dstValue).getTime())), "Unexpected datetime value"); + break; + + case java.sql.Types.TIME: + assertTrue(((Time) srcValue).getTime() == ((Time) dstValue).getTime(), "Unexpected time value "); + break; + + case microsoft.sql.Types.DATETIMEOFFSET: + assertTrue(0 == ((microsoft.sql.DateTimeOffset) srcValue).compareTo((microsoft.sql.DateTimeOffset) dstValue), + "Unexpected time value "); + break; + + default: + fail("Unhandled JDBCType " + JDBCType.valueOf(destMeta.getColumnType(i))); + break; + } + } + } +} \ No newline at end of file diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestWrapper.java b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestWrapper.java index 9a19a102d..354f2fe06 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestWrapper.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTestWrapper.java @@ -1,48 +1,13 @@ -// --------------------------------------------------------------------------------------------------------------------------------- -// File: BulkCopyTestWrapper.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files(the "Software"), -// to deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// --------------------------------------------------------------------------------------------------------------------------------- +/* + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) 2016 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.bulkCopy; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -import java.math.BigDecimal; -import java.sql.Connection; -import java.sql.Date; -import java.sql.JDBCType; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Time; -import java.sql.Timestamp; - -import com.microsoft.sqlserver.jdbc.SQLServerBulkCopy; import com.microsoft.sqlserver.jdbc.SQLServerBulkCopyOptions; -import com.microsoft.sqlserver.testframework.DBConnection; -import com.microsoft.sqlserver.testframework.DBResultSet; -import com.microsoft.sqlserver.testframework.DBStatement; -import com.microsoft.sqlserver.testframework.DBTable; /** * Wrapper class that has all the data/values needed to execute BulkCopy test case @@ -117,132 +82,4 @@ public void setConnectionString(String connectionString) { } -class BulkCopyTestUtil { - - static void performBulkCopy(BulkCopyTestWrapper wrapper, DBTable sourceTable) { - performBulkCopy(wrapper, sourceTable, false); - } - static void performBulkCopy(BulkCopyTestWrapper wrapper, DBTable sourceTable, boolean validateResult) { - DBConnection con = null; - DBStatement stmt = null; - DBTable destinationTable = null; - try { - con = new DBConnection(wrapper.getConnectionString()); - stmt = con.createStatement(); - - destinationTable = sourceTable.cloneSchema(); - stmt.createTable(destinationTable); - DBResultSet srcResultSet = stmt.executeQuery("SELECT * FROM " + sourceTable.getEscapedTableName() + ";"); - SQLServerBulkCopy bulkCopy; - if (wrapper.isUsingConnection()) { - bulkCopy = new SQLServerBulkCopy((Connection) con.product()); - } - else { - bulkCopy = new SQLServerBulkCopy(wrapper.getConnectionString()); - } - if (wrapper.isUsingBulkCopyOptions()) { - bulkCopy.setBulkCopyOptions(wrapper.getBulkOptions()); - } - bulkCopy.setDestinationTableName(destinationTable.getEscapedTableName()); - bulkCopy.writeToServer((ResultSet) srcResultSet.product()); - bulkCopy.close(); - if (validateResult) { - validateValues(con, sourceTable, destinationTable); - } - } - catch (SQLException ex) { - fail(ex.getMessage()); - } - finally { - stmt.dropTable(destinationTable); - con.close(); - } - } - - static void validateValues(DBConnection con, DBTable sourceTable, DBTable destinationTable) throws SQLException { - DBStatement srcStmt = con.createStatement(); - DBStatement dstStmt = con.createStatement(); - DBResultSet srcResultSet = srcStmt.executeQuery("SELECT * FROM " + sourceTable.getEscapedTableName() + ";"); - DBResultSet dstResultSet = dstStmt.executeQuery("SELECT * FROM " + destinationTable.getEscapedTableName() + ";"); - ResultSetMetaData destMeta = ((ResultSet) dstResultSet.product()).getMetaData(); - int totalColumns = destMeta.getColumnCount(); - - // verify data from sourceType and resultSet - while (srcResultSet.next() && dstResultSet.next()) - for (int i = 1; i <= totalColumns; i++) { - // TODO: check row and column count in both the tables - - Object srcValue, dstValue; - srcValue = srcResultSet.getObject(i); - dstValue = dstResultSet.getObject(i); - // Bulkcopy doesn't guarantee order of insertion - - // if we need to test several rows either use primary key or - // validate result based on sql JOIN - switch (destMeta.getColumnType(i)) { - case java.sql.Types.BIGINT: - assertTrue((((Long) srcValue).longValue() == ((Long) dstValue).longValue()), "Unexpected bigint value"); - break; - - case java.sql.Types.INTEGER: - assertTrue((((Integer) srcValue).intValue() == ((Integer) dstValue).intValue()), "Unexpected int value"); - break; - - case java.sql.Types.SMALLINT: - case java.sql.Types.TINYINT: - assertTrue((((Short) srcValue).shortValue() == ((Short) dstValue).shortValue()), "Unexpected smallint/tinyint value"); - break; - - case java.sql.Types.BIT: - assertTrue((((Boolean) srcValue).booleanValue() == ((Boolean) dstValue).booleanValue()), "Unexpected bit value"); - break; - - case java.sql.Types.DECIMAL: - case java.sql.Types.NUMERIC: - assertTrue(0 == (((BigDecimal) srcValue).compareTo((BigDecimal) dstValue)), - "Unexpected decimal/numeric/money/smallmoney value"); - break; - - case java.sql.Types.DOUBLE: - assertTrue((((Double) srcValue).doubleValue() == ((Double) dstValue).doubleValue()), "Unexpected float value"); - break; - - case java.sql.Types.REAL: - assertTrue((((Float) srcValue).floatValue() == ((Float) dstValue).floatValue()), "Unexpected real value"); - break; - - case java.sql.Types.VARCHAR: - case java.sql.Types.NVARCHAR: - assertTrue((((String) srcValue).equals((String) dstValue)), "Unexpected varchar/nvarchar value "); - break; - - case java.sql.Types.CHAR: - case java.sql.Types.NCHAR: - assertTrue((((String) srcValue).equals((String) dstValue)), "Unexpected char/nchar value "); - break; - - case java.sql.Types.TIMESTAMP: - assertTrue((((Timestamp) srcValue).getTime() == (((Timestamp) dstValue).getTime())), - "Unexpected datetime/smalldatetime/datetime2 value"); - break; - - case java.sql.Types.DATE: - assertTrue((((Date) srcValue).getTime() == (((Date) dstValue).getTime())), "Unexpected datetime value"); - break; - - case java.sql.Types.TIME: - assertTrue(((Time) srcValue).getTime() == ((Time) dstValue).getTime(), "Unexpected time value "); - break; - - case microsoft.sql.Types.DATETIMEOFFSET: - assertTrue(0 == ((microsoft.sql.DateTimeOffset) srcValue).compareTo((microsoft.sql.DateTimeOffset) dstValue), - "Unexpected time value "); - break; - - default: - fail("Unhandled JDBCType " + JDBCType.valueOf(destMeta.getColumnType(i))); - break; - } - } - } -} diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTimeoutTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTimeoutTest.java index 121e96989..8735b2c64 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTimeoutTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyTimeoutTest.java @@ -1,33 +1,17 @@ -// --------------------------------------------------------------------------------------------------------------------------------- -// File: BulkCopyTimeoutTest.java -// -// -// Microsoft JDBC Driver for SQL Server -// Copyright(c) Microsoft Corporation -// All rights reserved. -// MIT License -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files(the "Software"), -// to deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, -// and / or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions : -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// --------------------------------------------------------------------------------------------------------------------------------- +/* + * Microsoft JDBC Driver for SQL Server + * + * Copyright(c) 2016 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.bulkCopy; import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.concurrent.ThreadLocalRandom; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.platform.runner.JUnitPlatform; import org.junit.runner.RunWith; @@ -39,18 +23,20 @@ * Test the timeout in SQLServerBulkCopyOptions. Source table is created with large row count so skip data validation. */ @RunWith(JUnitPlatform.class) +@DisplayName("BulkCopy Timeout Test") public class BulkCopyTimeoutTest extends BulkCopyTestSetUp { /** * TODO: add support for small timeout value once test framework has support to add more than 10K rows, to check for Timeout Exception */ - /** + * BulkCopy:test zero timeout * * @throws SQLServerException */ @Test + @DisplayName("BulkCopy:test zero timeout") void testZeroTimeOut() throws SQLServerException { BulkCopyTestWrapper bulkWrapper = new BulkCopyTestWrapper(connectionString); bulkWrapper.setUsingConnection((0 == ThreadLocalRandom.current().nextInt(2)) ? true : false); @@ -63,9 +49,11 @@ void testZeroTimeOut() throws SQLServerException { /** * To verify SQLServerException: The timeout argument cannot be negative. + * * @throws SQLServerException */ @Test + @DisplayName("BulkCopy:test negative timeout") void testNegativeTimeOut() throws SQLServerException { assertThrows(SQLServerException.class, new org.junit.jupiter.api.function.Executable() { @Override