test: use assertInstanceOf() where applicable

This commit is contained in:
Stefan Kalscheuer 2024-04-13 13:39:40 +02:00
parent 2f5b25d847
commit c35760d0ab
Signed by: stefan
GPG Key ID: 3887EC2A53B55430
3 changed files with 3 additions and 3 deletions

View File

@ -136,7 +136,7 @@ class HTTPVaultConnectorBuilderTest {
() -> HTTPVaultConnector.builder().fromEnv(), () -> HTTPVaultConnector.builder().fromEnv(),
"Creation with unknown cert path failed" "Creation with unknown cert path failed"
); );
assertTrue(e.getCause() instanceof NoSuchFileException); assertInstanceOf(NoSuchFileException.class, e.getCause());
assertEquals(VAULT_CACERT, ((NoSuchFileException) e.getCause()).getFile()); assertEquals(VAULT_CACERT, ((NoSuchFileException) e.getCause()).getFile());
return null; return null;

View File

@ -909,7 +909,7 @@ class HTTPVaultConnectorIT {
assertFalse(res.getAuth().isRenewable(), "Root token should not be renewable"); assertFalse(res.getAuth().isRenewable(), "Root token should not be renewable");
assertFalse(res.getAuth().isOrphan(), "Root token should not be orphan"); assertFalse(res.getAuth().isOrphan(), "Root token should not be orphan");
// Starting with Vault 1.0 a warning "custom ID uses weaker SHA1.." is given. // Starting with Vault 1.0 a warning "custom ID uses weaker SHA1..." is given.
// Starting with Vault 1.11 a second warning "Endpoint ignored unrecognized parameters" is given. // Starting with Vault 1.11 a second warning "Endpoint ignored unrecognized parameters" is given.
assertFalse(res.getWarnings().isEmpty(), "Token creation did not return expected warning"); assertFalse(res.getWarnings().isEmpty(), "Token creation did not return expected warning");

View File

@ -91,7 +91,7 @@ class HTTPVaultConnectorTest {
"Querying health status succeeded on invalid instance" "Querying health status succeeded on invalid instance"
); );
assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message"); assertEquals("Unable to connect to Vault server", e.getMessage(), "Unexpected exception message");
assertTrue(e.getCause() instanceof IOException, "Unexpected cause"); assertInstanceOf(IOException.class, e.getCause(), "Unexpected cause");
// Now simulate a failing request that succeeds on second try. // Now simulate a failing request that succeeds on second try.
connector = HTTPVaultConnector.builder(wireMock.url("/")).withNumberOfRetries(1).withTimeout(250).build(); connector = HTTPVaultConnector.builder(wireMock.url("/")).withNumberOfRetries(1).withTimeout(250).build();