@Test public void testInvalidString() { String foobar = "clearly-bad-md5string"; try { MD5Digest md5Digest = MD5Digest.fromString(foobar); Assert.fail("Should have thrown an exception"); } catch (Exception e) { log.info("Found expected exception", e.getMessage()); } }
schemaKey = headers[0].getValue().substring(SCHEMA_ID_HEADER_PREFIX.length()); MD5Digest schemaId = MD5Digest.fromString(schemaKey); return schemaId; } catch (Throwable t) {
@Test public void testValidString() throws NoSuchAlgorithmException, UnsupportedEncodingException { String message = "3432rdaesdfdsf2443223 234 324324 23423 e23e 23d"; byte[] md5digest = MessageDigest.getInstance("MD5").digest(message.getBytes("UTF-8")); String md5String = DigestUtils.md5Hex(message); Assert.assertNotNull(md5digest); MD5Digest md5 = MD5Digest.fromBytes(md5digest); Assert.assertEquals(md5.asString(), md5String); Assert.assertEquals(md5.asBytes(), md5digest); MD5Digest otherMd5 = MD5Digest.fromString(md5String); Assert.assertEquals(otherMd5.asBytes(), md5.asBytes()); }
schemaKey = headers[0].getValue().substring(SCHEMA_ID_HEADER_PREFIX.length()); MD5Digest schemaId = MD5Digest.fromString(schemaKey); return schemaId; } catch (Throwable t) {