@@ -100,7 +100,7 @@ public static Collection<Object[]> data() {
100100 private final String standardResultString ;
101101
102102 public HmacAlgorithmsTest (HmacAlgorithms hmacAlgorithm , byte [] standardResultBytes , String standardResultString ) {
103- Assume .assumeTrue (hmacAlgorithm .isAvailable ());
103+ Assume .assumeTrue (HmacUtils .isAvailable (hmacAlgorithm ));
104104 this .hmacAlgorithm = hmacAlgorithm ;
105105 this .standardResultBytes = standardResultBytes ;
106106 this .standardResultString = standardResultString ;
@@ -123,48 +123,48 @@ public void testAlgorithm() throws IOException, NoSuchAlgorithmException {
123123 final String algorithm = hmacAlgorithm .getName ();
124124 Assert .assertNotNull (algorithm );
125125 Assert .assertFalse (algorithm .isEmpty ());
126- Assume .assumeTrue (hmacAlgorithm .isAvailable ());
126+ Assume .assumeTrue (HmacUtils .isAvailable (hmacAlgorithm ));
127127 Mac .getInstance (algorithm );
128128 }
129129
130130 @ Test (expected = IllegalArgumentException .class )
131131 public void testGetHmacEmptyKey () {
132- hmacAlgorithm . getHmac ( EMPTY_BYTE_ARRAY );
132+ HmacUtils . getInitializedMac ( hmacAlgorithm , EMPTY_BYTE_ARRAY );
133133 }
134134
135135 @ Test (expected = IllegalArgumentException .class )
136136 public void testGetHmacNullKey () {
137- hmacAlgorithm . getHmac ( null );
137+ HmacUtils . getInitializedMac ( hmacAlgorithm , null );
138138 }
139139
140140 @ Test (expected = IllegalArgumentException .class )
141141 public void testHmacFailByteArray () throws IOException {
142- hmacAlgorithm . hmac (( byte []) null , STANDARD_PHRASE_BYTES );
142+ new HmacUtils ( hmacAlgorithm , ( byte []) null ). hmac ( STANDARD_PHRASE_BYTES );
143143 }
144144
145145 @ Test (expected = IllegalArgumentException .class )
146146 public void testHmacFailInputStream () throws IOException {
147- hmacAlgorithm . hmac (( byte []) null , new ByteArrayInputStream (STANDARD_PHRASE_BYTES ));
147+ new HmacUtils ( hmacAlgorithm , ( byte []) null ). hmac ( new ByteArrayInputStream (STANDARD_PHRASE_BYTES ));
148148 }
149149
150150 @ Test (expected = IllegalArgumentException .class )
151151 public void testHmacFailString () throws IOException {
152- hmacAlgorithm . hmac (( String ) null , STANDARD_PHRASE_STRING );
152+ new HmacUtils ( hmacAlgorithm , ( String ) null ). hmac ( STANDARD_PHRASE_STRING );
153153 }
154154
155155 @ Test (expected = IllegalArgumentException .class )
156156 public void testHmacHexFailByteArray () throws IOException {
157- hmacAlgorithm . hmacHex (( byte []) null , STANDARD_PHRASE_BYTES );
157+ new HmacUtils ( hmacAlgorithm , ( byte []) null ). hmac ( STANDARD_PHRASE_BYTES );
158158 }
159159
160160 @ Test (expected = IllegalArgumentException .class )
161161 public void testHmacHexFailInputStream () throws IOException {
162- hmacAlgorithm . hmacHex (( byte []) null , new ByteArrayInputStream (STANDARD_PHRASE_BYTES ));
162+ new HmacUtils ( hmacAlgorithm , ( byte []) null ). hmac ( new ByteArrayInputStream (STANDARD_PHRASE_BYTES ));
163163 }
164164
165165 @ Test (expected = IllegalArgumentException .class )
166166 public void testHmacHexFailString () throws IOException {
167- hmacAlgorithm . hmacHex (( String ) null , STANDARD_PHRASE_STRING );
167+ new HmacUtils ( hmacAlgorithm , ( String ) null ). hmac ( STANDARD_PHRASE_STRING );
168168 }
169169
170170 @ Test
@@ -177,34 +177,34 @@ public void testInitializedMac() throws IOException {
177177
178178 @ Test
179179 public void testMacByteArary () throws IOException {
180- Assert .assertArrayEquals (standardResultBytes , hmacAlgorithm .hmac (STANDARD_KEY_BYTES , STANDARD_PHRASE_BYTES ));
180+ Assert .assertArrayEquals (standardResultBytes , new HmacUtils ( hmacAlgorithm , STANDARD_KEY_BYTES ) .hmac (STANDARD_PHRASE_BYTES ));
181181 }
182182
183183 @ Test
184184 public void testMacHexByteArray () throws IOException {
185- Assert .assertEquals (standardResultString , hmacAlgorithm .hmacHex (STANDARD_KEY_BYTES , STANDARD_PHRASE_BYTES ));
185+ Assert .assertEquals (standardResultString , new HmacUtils ( hmacAlgorithm , STANDARD_KEY_BYTES ) .hmacHex (STANDARD_PHRASE_BYTES ));
186186 }
187187
188188 @ Test
189189 public void testMacHexInputStream () throws IOException {
190190 Assert .assertEquals (standardResultString ,
191- hmacAlgorithm .hmacHex (STANDARD_KEY_BYTES , new ByteArrayInputStream (STANDARD_PHRASE_BYTES )));
191+ new HmacUtils ( hmacAlgorithm , STANDARD_KEY_BYTES ) .hmacHex (new ByteArrayInputStream (STANDARD_PHRASE_BYTES )));
192192 }
193193
194194 @ Test
195195 public void testMacHexString () throws IOException {
196- Assert .assertEquals (standardResultString , hmacAlgorithm .hmacHex (STANDARD_KEY_STRING , STANDARD_PHRASE_STRING ));
196+ Assert .assertEquals (standardResultString , new HmacUtils ( hmacAlgorithm , STANDARD_KEY_BYTES ) .hmacHex (STANDARD_PHRASE_STRING ));
197197 }
198198
199199 @ Test
200200 public void testMacInputStream () throws IOException {
201201 Assert .assertArrayEquals (standardResultBytes ,
202- hmacAlgorithm .hmac (STANDARD_KEY_BYTES , new ByteArrayInputStream (STANDARD_PHRASE_BYTES )));
202+ new HmacUtils ( hmacAlgorithm , STANDARD_KEY_BYTES ) .hmac (new ByteArrayInputStream (STANDARD_PHRASE_BYTES )));
203203 }
204204
205205 @ Test
206206 public void testMacString () throws IOException {
207- Assert .assertArrayEquals (standardResultBytes , hmacAlgorithm .hmac (STANDARD_KEY_STRING , STANDARD_PHRASE_STRING ));
207+ Assert .assertArrayEquals (standardResultBytes , new HmacUtils ( hmacAlgorithm , STANDARD_KEY_BYTES ) .hmac (STANDARD_PHRASE_STRING ));
208208 }
209209
210210}
0 commit comments