Skip to content

Commit

Permalink
updated junit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyc committed Jan 12, 2022
1 parent b65190a commit d4fabdb
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.sql.Statement;
import java.util.Arrays;

import microsoft.sql.DateTimeOffset;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
Expand Down Expand Up @@ -1026,22 +1027,18 @@ public void readVarcharInteger() throws SQLException {
}

/**
* Tests unsupported type
* Tests returning class of base type datetimeoffset in sql_variant is correct
*
* @throws SQLException
*/
@Test
public void testUnsupportedDatatype() throws SQLException {
public void testDateTimeOffsetAsSqlVariant() throws SQLException {
try (Connection con = getConnection(); Statement stmt = con.createStatement();
SQLServerResultSet rs = (SQLServerResultSet) stmt.executeQuery(
"select cast(cast('2017-08-16 17:31:09.995 +07:00' as datetimeoffset) as sql_variant)")) {
rs.next();
try {
rs.getObject(1);
fail(TestResource.getResource("R_expectedExceptionNotThrown"));
} catch (Exception e) {
assertTrue(e.getMessage().equalsIgnoreCase("Unexpected TDS type DATETIMEOFFSETN in SQL_VARIANT."));
}
Object object = rs.getObject(1);
assertEquals(object.getClass(), DateTimeOffset.class);
}
}

Expand Down

0 comments on commit d4fabdb

Please sign in to comment.