diff --git a/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java b/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java index a1e9d740df213..ce43bd3034907 100644 --- a/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java +++ b/test/jdk/sun/security/ec/ECDHKeyAgreementParamValidation.java @@ -87,11 +87,10 @@ public void testDoPhaseWithInvalidKey() throws Exception { KeyAgreement ka = KeyAgreement.getInstance("ECDH"); ka.init(kpP256.getPrivate()); - try { - ka.doPhase(kpP384.getPublic(), true); - } catch (InvalidKeyException e) { - // Do nothing - } + + Assertions.assertThrows( + InvalidKeyException.class, + () -> ka.doPhase(kpP384.getPublic(), true)); // Should not generate share key with SECP256R1 private key and SECP384R1 public key Assertions.assertThrows(IllegalStateException.class, ka::generateSecret);