|
13 | 13 | import com.github.tomakehurst.wiremock.client.WireMock;
|
14 | 14 | import com.github.tomakehurst.wiremock.common.ConsoleNotifier;
|
15 | 15 | import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
|
| 16 | + |
16 | 17 | import org.testng.Assert;
|
17 | 18 | import org.testng.annotations.DataProvider;
|
18 | 19 | import org.testng.annotations.Test;
|
|
34 | 35 | import static org.testng.Assert.assertThrows;
|
35 | 36 | import static org.testng.Assert.fail;
|
36 | 37 |
|
37 |
| - |
38 | 38 | public class ConnectionTest extends JdbcIntegrationTest {
|
39 | 39 |
|
40 | 40 | @Test(groups = { "integration" }, enabled = false)
|
@@ -569,8 +569,32 @@ public void testConnectionWithValidDatabaseName(String dbName) throws Exception
|
569 | 569 | connCheck.close();
|
570 | 570 | }
|
571 | 571 |
|
| 572 | + @Test(groups = { "integration" }) |
| 573 | + public void closedConnectionIsInvalid() throws Exception { |
| 574 | + if (isCloud()) { |
| 575 | + return; |
| 576 | + } |
| 577 | + Connection connection = this.getJdbcConnection(); |
| 578 | + Assert.assertTrue(connection.isValid(3)); |
| 579 | + connection.close(); |
| 580 | + Assert.assertFalse(connection.isValid(3)); |
| 581 | + } |
| 582 | + |
| 583 | + @Test(groups = { "integration" }) |
| 584 | + public void connectionWithWrongCredentialsIsInvalid() throws Exception { |
| 585 | + if (isCloud()) { |
| 586 | + return; |
| 587 | + } |
| 588 | + Connection connection = this.getJdbcConnection(); |
| 589 | + Assert.assertTrue(connection.isValid(3)); |
| 590 | + Properties properties = new Properties(); |
| 591 | + properties.put("password", "invalid"); |
| 592 | + connection = this.getJdbcConnection(properties); |
| 593 | + Assert.assertFalse(connection.isValid(3)); |
| 594 | + } |
| 595 | + |
572 | 596 | @DataProvider(name = "validDatabaseNames")
|
573 |
| - public Object[][] createValidDatabaseNames() { |
| 597 | + private static Object[][] createValidDatabaseNames() { |
574 | 598 | return new Object[][] {
|
575 | 599 | { "foo" },
|
576 | 600 | { "with-dashes" },
|
|
0 commit comments