Skip to content

Commit 3dc4b50

Browse files
committed
Adding unit tests for net.authorize.sample.Sha512.ComputeTransHashSHA2.java
These tests were written using Diffblue Cover
1 parent 63f849e commit 3dc4b50

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
<artifactId>junit</artifactId>
2222
<version>4.8.1</version>
2323
</dependency>
24+
</dependency>
25+
<dependency>
26+
<groupId>junit</groupId>
27+
<artifactId>junit</artifactId>
28+
<version>4.12</version>
29+
<scope>test</scope>
30+
</dependency>
2431
</dependencies>
2532
<build>
2633
<plugins>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package net.authorize.sample.Sha512;
2+
3+
import org.junit.Assert;
4+
import org.junit.Rule;
5+
import org.junit.Test;
6+
import org.junit.rules.ExpectedException;
7+
8+
public class ComputeTransHashSHA2Test {
9+
10+
@Rule public final ExpectedException thrown = ExpectedException.none();
11+
12+
@Test
13+
public void getHMACSHA512InputNotNullNotNullOutputIllegalArgumentException() throws Exception {
14+
thrown.expect(IllegalArgumentException.class);
15+
ComputeTransHashSHA2.getHMACSHA512("/", "/");
16+
}
17+
18+
@Test
19+
public void getHMACSHA512InputNotNullNotNullOutputIllegalArgumentException2() throws Exception {
20+
thrown.expect(IllegalArgumentException.class);
21+
ComputeTransHashSHA2.getHMACSHA512(
22+
"\u0003\u0001\u0001 \u0010\u0000 0 ",
23+
"\u0000\u0000\u0000?????????????????????????????????????");
24+
}
25+
26+
@Test
27+
public void getHMACSHA512InputNotNullNullOutputIllegalArgumentException() throws Exception {
28+
thrown.expect(IllegalArgumentException.class);
29+
ComputeTransHashSHA2.getHMACSHA512(
30+
"\u8003\u0001\u0000\u0000>\u0000\ubffe\ubffe\ubffe\u0003",
31+
null);
32+
}
33+
34+
@Test
35+
public void getHMACSHA512InputNullNotNullOutputIllegalArgumentException() throws Exception {
36+
thrown.expect(IllegalArgumentException.class);
37+
ComputeTransHashSHA2.getHMACSHA512(
38+
null, "\u0000\u0000\u0000??????????????????????");
39+
}
40+
41+
@Test
42+
public void hexStringToByteArrayInputNotNullOutput0() {
43+
44+
Assert.assertArrayEquals(new byte[] {}, ComputeTransHashSHA2.hexStringToByteArray(""));
45+
}
46+
47+
@Test
48+
public void hexStringToByteArrayInputNotNullOutputStringIndexOutOfBoundsException() {
49+
50+
thrown.expect(StringIndexOutOfBoundsException.class);
51+
ComputeTransHashSHA2.hexStringToByteArray("/");
52+
}
53+
54+
@Test
55+
public void hexStringToByteArrayInputNotNullOutputStringIndexOutOfBoundsException2() {
56+
thrown.expect(StringIndexOutOfBoundsException.class);
57+
ComputeTransHashSHA2.hexStringToByteArray("#\uff77\u0002");
58+
}
59+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy