### Question:
MD5Util { public static String generateMD5(String baseValue) { return generateMD5(baseValue, "UTF-8", "MD5"); }  static String generateMD5(String baseValue);  }### Answer:
@Test public void shouldGenerateForString() throws Exception { String hash = MD5Util.generateMD5("<items><itemtypes/></items>"); assertEquals("5b4422df25563a6e8cd98a6a1327aaa4", hash); }
@Test(expected = UnsupportedEncodingException.class) public void shouldHandleUnsupportedEncodingException() throws Throwable { try { MD5Util.generateMD5("someValue", "myEncoding", "MD5"); } catch (RuntimeException e) { unwrapException(e); } }
@Test(expected = NoSuchAlgorithmException.class) public void shouldHandleNoSuchAlgorithmException() throws Throwable { try { MD5Util.generateMD5("someValue", "UTF-8", "myAlgorithm"); } catch (RuntimeException e) { unwrapException(e); } }