|
| 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