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

Enable verify data #724

Merged
merged 6 commits into from
Jun 20, 2018
Merged
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 @@ -17,10 +17,7 @@
import java.sql.JDBCType;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.Calendar;
import java.util.logging.Level;
Expand Down Expand Up @@ -212,8 +209,7 @@ public void verifydata(int ordinal,
Object retrieved = this.getXXX(ordinal + 1, coercion);

// Verify
// TODO: Check the intermittent verification error
// verifydata(ordinal, coercion, expectedData, retrieved);
verifydata(ordinal, coercion, expectedData, retrieved);
}

/**
Expand Down Expand Up @@ -268,7 +264,10 @@ public void verifydata(int ordinal,
break;

case java.sql.Types.REAL:
assertTrue((((Float) expectedData).floatValue() == ((Float) retrieved).floatValue()),
if (expectedData instanceof Double) {
expectedData = (Float) (((Double) expectedData).floatValue());
}
assertTrue(((Float) expectedData).floatValue() == ((Float) retrieved).floatValue(),
"Unexpected real value, expected: " + (Float) expectedData + " received: " + (Float) retrieved);
break;

Expand Down Expand Up @@ -297,19 +296,25 @@ else if (metaData.getColumnTypeName(ordinal + 1).equalsIgnoreCase("smalldatetime
+ " ,received: " + (((Timestamp) retrieved).getTime()));
break;
}
else
assertTrue(("" + Timestamp.valueOf((LocalDateTime) expectedData)).equalsIgnoreCase("" + retrieved), "Unexpected datetime2 value, "
+ "expected: " + Timestamp.valueOf((LocalDateTime) expectedData) + " ,received: " + retrieved);
break;
else {
String retrievedTimestamp = retrieved.toString();
String expectedTimestamp = expectedData.toString().substring(0,retrievedTimestamp.length());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

assertTrue(expectedTimestamp.equalsIgnoreCase(retrievedTimestamp), "Unexpected datetime2 value, " + "expected: "
+ expectedTimestamp + " ,received: " + retrievedTimestamp);
break;
}


case java.sql.Types.DATE:
assertTrue((("" + expectedData).equalsIgnoreCase("" + retrieved)),
"Unexpected date value, expected: " + expectedData + " ,received: " + retrieved);
break;

case java.sql.Types.TIME:
assertTrue(("" + Time.valueOf((LocalTime) expectedData)).equalsIgnoreCase("" + retrieved),
"Unexpected time value, exptected: " + Time.valueOf((LocalTime) expectedData) + " ,received: " + retrieved);
String retrievedTime = retrieved.toString();
String expectedTime = expectedData.toString().substring(0,retrievedTime.length());
assertTrue(expectedTime.equalsIgnoreCase(retrievedTime),
"Unexpected time value, expected: " + expectedTime + " ,received: " + retrievedTime);
break;

case microsoft.sql.Types.DATETIMEOFFSET:
Expand Down Expand Up @@ -446,7 +451,7 @@ private static Object roundSmallDateTimeValue(Object value) {
cal = (Calendar) value;
}
else {
ts = (java.sql.Timestamp) value;
ts = Timestamp.valueOf((String) value);
cal = Calendar.getInstance();
cal.setTimeInMillis(ts.getTime());
nanos = ts.getNanos();
Expand Down Expand Up @@ -546,4 +551,4 @@ public DBStatement statement() {
return (null);
}

}
}