1
1
package org .simplejavamail .utils .mail .dkim ;
2
2
3
- import static org .junit .Assert .assertArrayEquals ;
4
- import static org .junit .Assert .assertEquals ;
5
- import static org .junit .Assert .assertNotNull ;
6
-
7
3
import java .io .ByteArrayOutputStream ;
8
4
import java .util .Base64 ;
9
5
import java .util .HashMap ;
16
12
import jakarta .mail .Session ;
17
13
import jakarta .mail .internet .InternetAddress ;
18
14
import jakarta .mail .internet .MimeMessage ;
15
+ import org .junit .jupiter .api .Test ;
19
16
20
- import org .junit .Test ;
17
+ import static org .assertj .core .api .Assertions .assertThat ;
18
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
21
19
22
20
public class DomainKeyTest {
23
21
@@ -35,16 +33,13 @@ public void checkDomainKeyRecognizesPublicKey() throws Exception {
35
33
36
34
DomainKey domainKey = new DomainKey (tags );
37
35
38
- assertNotNull (domainKey );
36
+ assertThat (domainKey ). isNotNull ( );
39
37
assertArrayEquals (Base64 .getDecoder ().decode (EXAMPLE_DOMAIN_KEY ), domainKey .getPublicKey ().getEncoded ());
40
-
41
38
}
42
39
43
40
@ Test
44
41
public void checkHashWithEmptyBody () throws Exception {
45
-
46
42
checkBodyHash ("" , "empty body" );
47
-
48
43
}
49
44
50
45
private void checkBodyHash (String body , String description ) throws Exception {
@@ -56,15 +51,12 @@ private void checkBodyHash(String body, String description) throws Exception {
56
51
}
57
52
}
58
53
59
- private void checkBodyHash (Canonicalization canonicalization , SigningAlgorithm algorithm , String body ,
60
- String description ) throws Exception {
61
-
54
+ private void checkBodyHash (Canonicalization canonicalization , SigningAlgorithm algorithm , String body , String description ) throws Exception {
62
55
String configuration = canonicalization .name () + " " + algorithm .getHashNotation ().toUpperCase ();
63
56
String expected = Utils .digest (canonicalization .canonicalizeBody (body ), algorithm .getHashNotation ());
64
57
String actual = calculateBodyHashWithSigner (Utils .getSigner (canonicalization , algorithm ));
65
58
66
- assertEquals (configuration + " / " + description , expected , actual );
67
-
59
+ assertThat (actual ).as (configuration + " / " + description ).isEqualTo (expected );
68
60
}
69
61
70
62
private String calculateBodyHashWithSigner (DkimSigner dkimSigner ) throws Exception {
0 commit comments