Skip to content

Commit aad48ef

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

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
<artifactId>junit</artifactId>
2222
<version>4.8.1</version>
2323
</dependency>
24+
<dependency>
25+
<groupId>junit</groupId>
26+
<artifactId>junit</artifactId>
27+
<version>4.12</version>
28+
<scope>test</scope>
29+
</dependency>
2430
</dependencies>
2531
<build>
2632
<plugins>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
Assert.assertArrayEquals(new byte[] {}, ComputeTransHashSHA2.hexStringToByteArray(""));
44+
}
45+
46+
@Test
47+
public void hexStringToByteArrayInputNotNullOutputStringIndexOutOfBoundsException() {
48+
thrown.expect(StringIndexOutOfBoundsException.class);
49+
ComputeTransHashSHA2.hexStringToByteArray("/");
50+
}
51+
52+
@Test
53+
public void hexStringToByteArrayInputNotNullOutputStringIndexOutOfBoundsException2() {
54+
thrown.expect(StringIndexOutOfBoundsException.class);
55+
ComputeTransHashSHA2.hexStringToByteArray("#\uff77\u0002");
56+
}
57+
}

0 commit comments

Comments
 (0)