Skip to content

Commit

Permalink
Remove deprecated ExpectedException.none() in Tests (#1041)
Browse files Browse the repository at this point in the history
* Remove deprecated Rule in KeyStoreUtilTest

Signed-off-by: hsteinmueller <harald.steinmueller@gmail.com>

* Remove more deprecated Rule usages in Tests

Signed-off-by: hsteinmueller <harald.steinmueller@gmail.com>

* Revert changes to all Tests except KeyStoreUtilTest

Signed-off-by: hsteinmueller <harald.steinmueller@gmail.com>
  • Loading branch information
hsteinmueller authored Oct 28, 2021
1 parent 8de2d21 commit ffb9b75
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@
import java.security.GeneralSecurityException;
import java.security.KeyStore;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.assertj.core.api.Assertions.assertThat;

/**
* @author Stas Sukhanov
* @since 08.03.2017
*/
public class KeyStoreUtilTest {

@Rule
public ExpectedException exception = ExpectedException.none();

@Test
public void createKeyStore() throws Exception {
KeyStore keyStore = KeyStoreUtil.createDockerKeyStore(getFile("certpath"));
Expand All @@ -45,10 +42,9 @@ public void createKeyStore() throws Exception {
}

@Test
public void loadInvalidPrivateKey() throws Exception {
exception.expect(GeneralSecurityException.class);
exception.expectMessage("Cannot generate private key");
KeyStoreUtil.loadPrivateKey(getFile("keys/invalid.pem"));
public void loadInvalidPrivateKey() {
GeneralSecurityException exception = assertThrows(GeneralSecurityException.class, () -> KeyStoreUtil.loadPrivateKey(getFile("keys/invalid.pem")));
assertThat(exception).hasMessageContaining("Cannot generate private key");
}

static String getFile(String path) throws FileNotFoundException {
Expand Down

0 comments on commit ffb9b75

Please sign in to comment.