@Test public void testGenerateCode() throws Exception { for (String algorithm : algs) { for (String key : keys) { for (int i = 0; i < testStrings.length; ++i) { InputStream in = IOUtils.toInputStream(testStrings[i]); InputStream keyStream = IOUtils.toInputStream(key); PipedInputStream result = new PipedInputStream(); OutputStream out = new PipedOutputStream(result); MessageAuthenticator.generateCode(algorithm, in, keyStream, out); out.close(); String actual = new String(Hex.encodeHex(IOUtils.toByteArray(result))); assertEquals(codes.get(algorithm).get(key)[i].toLowerCase(), actual.toLowerCase()); } } } }