You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/01/12 11:02:14 UTC

[james-project] 15/20: JAMES-2543 Junit 4 -> 5 migration for JWT helpers

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit d3927090c41521f096e2bcf7be93c83836de8d74
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Dec 31 09:06:22 2020 +0700

    JAMES-2543 Junit 4 -> 5 migration for JWT helpers
---
 .../java/org/apache/james/jwt/JwtConfigurationTest.java     | 12 ++++++------
 .../java/org/apache/james/jwt/JwtTokenVerifierTest.java     | 13 +++++--------
 .../java/org/apache/james/jwt/PublicKeyProviderTest.java    |  6 +++---
 .../test/java/org/apache/james/jwt/PublicKeyReaderTest.java |  6 +++---
 4 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtConfigurationTest.java b/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtConfigurationTest.java
index 34436a9..7941c29 100644
--- a/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtConfigurationTest.java
+++ b/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtConfigurationTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Optional;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class JwtConfigurationTest {
     private static final String INVALID_PUBLIC_KEY = "invalidPublicKey";
@@ -39,32 +39,32 @@ public class JwtConfigurationTest {
         "-----END PUBLIC KEY-----";
 
     @Test
-    public void getJwtPublicKeyPemShouldReturnEmptyWhenEmptyPublicKey() throws Exception {
+    public void getJwtPublicKeyPemShouldReturnEmptyWhenEmptyPublicKey() {
         JwtConfiguration jwtConfiguration = new JwtConfiguration(Optional.empty());
 
         assertThat(jwtConfiguration.getJwtPublicKeyPem()).isNotPresent();
     }
 
     @Test
-    public void constructorShouldThrowWhenNullPublicKey() throws Exception {
+    public void constructorShouldThrowWhenNullPublicKey() {
         assertThatThrownBy(() -> new JwtConfiguration(null))
             .isInstanceOf(NullPointerException.class);
     }
 
     @Test
-    public void constructorShouldThrowWhenNonePublicKey() throws Exception {
+    public void constructorShouldThrowWhenNonePublicKey() {
         assertThatThrownBy(() -> new JwtConfiguration(Optional.of("")))
             .isInstanceOf(IllegalStateException.class);
     }
 
     @Test
-    public void constructorShouldThrowWhenInvalidPublicKey() throws Exception {
+    public void constructorShouldThrowWhenInvalidPublicKey() {
         assertThatThrownBy(() -> new JwtConfiguration(Optional.of(INVALID_PUBLIC_KEY)))
             .isInstanceOf(IllegalStateException.class);
     }
 
     @Test
-    public void getJwtPublicKeyPemShouldReturnWhenValidPublicKey() throws Exception {
+    public void getJwtPublicKeyPemShouldReturnWhenValidPublicKey() {
         JwtConfiguration jwtConfiguration = new JwtConfiguration(Optional.of(VALID_PUBLIC_KEY));
 
         assertThat(jwtConfiguration.getJwtPublicKeyPem()).isPresent();
diff --git a/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtTokenVerifierTest.java b/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtTokenVerifierTest.java
index ae77048..c464a6b 100644
--- a/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtTokenVerifierTest.java
+++ b/server/protocols/jwt/src/test/java/org/apache/james/jwt/JwtTokenVerifierTest.java
@@ -26,9 +26,9 @@ import java.util.Optional;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class JwtTokenVerifierTest {
 
@@ -65,15 +65,12 @@ public class JwtTokenVerifierTest {
         "bmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.";
     private JwtTokenVerifier sut;
 
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @BeforeClass
+    @BeforeAll
     public static void init() {
         Security.addProvider(new BouncyCastleProvider());
     }
 
-    @Before
+    @BeforeEach
     public void setup() {
         PublicKeyProvider pubKeyProvider = new PublicKeyProvider(getJWTConfiguration(), new PublicKeyReader());
         sut = new JwtTokenVerifier(pubKeyProvider);
diff --git a/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java b/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java
index 92dcf77..ce07dce 100644
--- a/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java
+++ b/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyProviderTest.java
@@ -26,8 +26,8 @@ import java.security.interfaces.RSAPublicKey;
 import java.util.Optional;
 
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 public class PublicKeyProviderTest {
 
@@ -41,7 +41,7 @@ public class PublicKeyProviderTest {
             "kwIDAQAB\n" +
             "-----END PUBLIC KEY-----";
 
-    @BeforeClass
+    @BeforeAll
     public static void init() {
         Security.addProvider(new BouncyCastleProvider());
     }
diff --git a/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyReaderTest.java b/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyReaderTest.java
index 1b850d0..57a100e 100644
--- a/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyReaderTest.java
+++ b/server/protocols/jwt/src/test/java/org/apache/james/jwt/PublicKeyReaderTest.java
@@ -25,8 +25,8 @@ import java.security.Security;
 import java.util.Optional;
 
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 public class PublicKeyReaderTest {
 
@@ -40,7 +40,7 @@ public class PublicKeyReaderTest {
             "kwIDAQAB\n" +
             "-----END PUBLIC KEY-----";
 
-    @BeforeClass
+    @BeforeAll
     public static void init() {
         Security.addProvider(new BouncyCastleProvider());
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org