Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address TODOs in tests #873

Merged
merged 6 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package com.microsoft.sqlserver.jdbc.bulkCopy;

import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
Expand Down Expand Up @@ -385,10 +386,10 @@ private void validateValuesRepetitiveCM(DBConnection con, DBTable sourceTable,
int totalColumns = sourceMeta.getColumnCount();

// verify data from sourceType and resultSet
int numRows = 0;
while (srcResultSet.next() && dstResultSet.next()) {
numRows++;
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);
Expand All @@ -403,6 +404,13 @@ private void validateValuesRepetitiveCM(DBConnection con, DBTable sourceTable,
}
}
}

// verify number of rows and columns
assertTrue(((ResultSet) dstResultSet.product()).getMetaData().getColumnCount() == totalColumns + 1);
if (numRows > 0) {
lilgreenbird marked this conversation as resolved.
Show resolved Hide resolved
assertTrue(sourceTable.getTotalRows() == numRows);
assertTrue(destinationTable.getTotalRows() == numRows);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ private class ColumnMetadata {
SqlType sqlType = dstTable.getSqlType(i);
int precision = sqlType.getPrecision();
if (JDBCType.TIMESTAMP == sqlType.getJdbctype()) {
// TODO: update the test to use correct precision once bulkCopy is fixed
precision = 50;
}
columnMetadata.put(i + 1, new ColumnMetadata(sqlType.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package com.microsoft.sqlserver.jdbc.bulkCopy;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.sql.Connection;
Expand Down Expand Up @@ -280,17 +281,26 @@ static void validateValues(DBConnection con, DBTable sourceTable, DBTable destin
int totalColumns = destMeta.getColumnCount();

// verify data from sourceType and resultSet
int numRows = 0;
while (srcResultSet.next() && dstResultSet.next()) {
numRows++;
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);

ComparisonUtil.compareExpectedAndActual(destMeta.getColumnType(i), srcValue, dstValue);
}
}

// verify number of rows and columns
assertTrue(((ResultSet) srcResultSet.product()).getMetaData().getColumnCount() == totalColumns);
assertTrue(((ResultSet) dstResultSet.product()).getMetaData().getColumnCount() == totalColumns);
lilgreenbird marked this conversation as resolved.
Show resolved Hide resolved

if (numRows > 0) {
lilgreenbird marked this conversation as resolved.
Show resolved Hide resolved
assertTrue(sourceTable.getTotalRows() == numRows);
assertTrue(destinationTable.getTotalRows() == numRows);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,7 @@ public void testGetColumnPrivileges() throws SQLException {
}

/**
* TODO: Check JDBC Specs: Can we have any tables/functions without category?
*
* Testing {@link SQLServerDatabaseMetaData#getFunctions(String, String, String)} with sending wrong category.
* Testing {@link SQLServerDatabaseMetaData#getFunctions(String, String, String)} with sending wrong catalog.
*
* @throws SQLException
*/
Expand All @@ -431,7 +429,7 @@ public void testGetFunctionsWithWrongParams() throws SQLException {
conn.getMetaData().getFunctions("", null, "xp_%");
assertTrue(false, TestResource.getResource("R_noSchemaShouldFail"));
} catch (Exception ae) {

assertTrue(ae.getMessage().startsWith("The argument catalog is not valid"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public void bulkCopyTestVarbinary8000() throws SQLException {
*
* @throws SQLException
*/
@Test // TODO: check bitnull
@Test
public void bulkCopyTestBitNull() throws SQLException {
try (Connection con = DriverManager.getConnection(connectionString); Statement stmt = con.createStatement()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,10 @@ public void testDateTime() throws SQLException {
*
* @throws SQLException
* @throws SQLTimeoutException
* https://msdn.microsoft.com/en-ca/library/dd303302.aspx?f=255&MSPPError=-2147217396
* Data types cannot be NULL when inside a sql_variant
*/
@Test // TODO We need to check this later. Right now sending null with TVP is not supported
lilgreenbird marked this conversation as resolved.
Show resolved Hide resolved
@Test
public void testNull() throws SQLException {
tvp = new SQLServerDataTable();
tvp.addColumnMetadata("c1", microsoft.sql.Types.SQL_VARIANT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,13 @@ public static void populateProperties() {
currentJVM = IBM_JVM;
}

// TODO: Need to check this.
if (p.getProperty("java.vendor").startsWith("SAP")) {
currentJVM = SAP_JVM;
}
}

/**
* After stabilizing parameterized test case TODO: Enable FIPS can be done in two ways.
* <LI>JVM Level - Done.
* <LI>Program Level - Not Done. We need to test both on different environments.
* Test FIPS in Oracle Env.
*
* @since 6.1.2
*/
Expand All @@ -91,7 +88,7 @@ public void testFIPSOnOracle() throws Exception {
}

/**
* It will test FIPS on IBM Env. If JVM is not IBM test will not fail. It will simply skipped.
* Test FIPS in IBM Env. If JVM is not IBM test will not fail. It will simply skipped.
*
* @since 6.1.2
*/
Expand Down