Skip to content

Commit

Permalink
Test | Improvements in LobsTest exception and failure handling (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Mar 28, 2019
1 parent 98b1097 commit a89a909
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/test/java/com/microsoft/sqlserver/jdbc/unit/lobs/LobsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package com.microsoft.sqlserver.jdbc.unit.lobs;

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

Expand Down Expand Up @@ -156,6 +157,7 @@ private void testInvalidLobs(Class<?> lobClass, boolean isResultSet) throws SQLE
}
try {
this.updateLob(lob, updater, 1);
fail(TestResource.getResource("R_expectedFailPassed"));
} catch (SQLException e) {
boolean verified = false;

Expand Down Expand Up @@ -199,7 +201,7 @@ else if (lobClass == Blob.class)
}
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
dropTables(table, stmt1);
if (null != updater) {
Expand Down Expand Up @@ -245,17 +247,20 @@ private void testFreedBlobs(Class<?> lobClass, boolean isResultSet) throws SQLEx
stream.read();
blob.free();
}
try (InputStream stream = blob.getBinaryStream()) {} catch (SQLException e) {
System.err.println(e.getMessage());
try (InputStream stream = blob.getBinaryStream()) {
fail(TestResource.getResource("R_expectedFailPassed"));
} catch (SQLException e) {
assertTrue(e.getMessage().contains(TestResource.getResource("R_blobFreed")));
}
}
}
try (InputStream stream = blob.getBinaryStream()) {} catch (SQLException e) {
try (InputStream stream = blob.getBinaryStream()) {
fail(TestResource.getResource("R_expectedFailPassed"));
} catch (SQLException e) {
assertTrue(e.getMessage().contains(TestResource.getResource("R_blobFreed")));
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
dropTables(table, stmt);
}
Expand Down

0 comments on commit a89a909

Please sign in to comment.