- @Test
- public void testMD5Hash() throws Exception {
- // empty string
- createAndAssertHash("", "d41d8cd98f00b204e9800998ecf8427e");
-
- // non-empty string
- createAndAssertHash("The Guardian", "69b929ae473ed732d5fb8e0a55a8dc8d");
-
- // the same hash for the same string
- createAndAssertHash("The Independent", "db793706d70c37dcc16454fa8eb21b1c");
- createAndAssertHash("The Independent", "db793706d70c37dcc16454fa8eb21b1c"); // one more time
-
- // different strings must have different hashes
- createAndAssertHash("orange", "fe01d67a002dfa0f3ac084298142eccd");
- createAndAssertHash("yellow", "d487dd0b55dfcacdd920ccbdaeafa351");
- }
-
- //TODO: IllegalArgumentException would be better
- @Test(expected = RuntimeException.class)
- public void testMD5HashInvalidInput() throws Exception {
- Util.md5String(null);
- }
-