Skip to content

Commit

Permalink
Address TODOs in tests (#873)
Browse files Browse the repository at this point in the history
* address TODOs

* rename var

* rename var

* comments only

* review udpates

* more review updates
  • Loading branch information
lilgreenbird authored Nov 28, 2018
1 parent 25028fb commit 195ea92
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
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) {
assertTrue(sourceTable.getTotalRows() == numRows);
assertTrue(destinationTable.getTotalRows() == numRows);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,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 @@ -429,9 +427,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
@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

0 comments on commit 195ea92

Please sign in to comment.