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 all 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 All @@ -21,6 +22,7 @@

import com.microsoft.sqlserver.jdbc.ComparisonUtil;
import com.microsoft.sqlserver.jdbc.TestResource;
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.DBConnection;
import com.microsoft.sqlserver.testframework.DBResultSet;
import com.microsoft.sqlserver.testframework.DBStatement;
Expand Down Expand Up @@ -385,10 +387,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 +405,11 @@ private void validateValuesRepetitiveCM(DBConnection con, DBTable sourceTable,
}
}
}

// verify number of rows and columns
assertTrue(((ResultSet) dstResultSet.product()).getMetaData().getColumnCount() == totalColumns + 1);
assertTrue(sourceTable.getTotalRows() == numRows);
assertTrue(destinationTable.getTotalRows() == numRows);
}
}

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,25 @@ 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);

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 @@ -430,9 +428,7 @@ public void testGetFunctionsWithWrongParams() throws SQLException {
try (Connection conn = DriverManager.getConnection(connectionString)) {
conn.getMetaData().getFunctions("", null, "xp_%");
assertTrue(false, TestResource.getResource("R_noSchemaShouldFail"));
} catch (Exception ae) {

}
} catch (Exception ae) {}
}

/**
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