Skip to content

Commit 2844e45

Browse files
committed
add unit test for clear()
1 parent 79e256e commit 2844e45

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcMdcTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,13 @@ public void testThreadIsolation() throws InterruptedException {
149149
assertEquals("JdbcConnection-B", threadBIdAfterRegister.get());
150150
assertEquals("JdbcConnection-A", threadAIdAfterB.get());
151151
}
152+
153+
@Test
154+
public void testMdcCloseableClearsContext() {
155+
try (BigQueryJdbcMdc.MdcCloseable mdc =
156+
BigQueryJdbcMdc.registerInstance(mockConnection1, "789")) {
157+
assertEquals("JdbcConnection-789", BigQueryJdbcMdc.getConnectionId());
158+
}
159+
assertNull(BigQueryJdbcMdc.getConnectionId());
160+
}
152161
}

0 commit comments

Comments
 (0)