HttpUtil { public static String encodeIncludingSpecialCharacters(String toEncode) { String encoded = urlencode(toEncode, "Unable to urlencode " + toEncode); for (Map.Entry<String, String> s : specialChars.entrySet()) { encoded = encoded.replace(s.getKey(), s.getValue()); } return encoded; }  static String encodeParameters(RequestConfig config, Heroku.RequestKey... keys); static String encodeIncludingSpecialCharacters(String toEncode); static String urlencode(String toEncode, String messageIfFails); static UnsupportedOperationException noBody(); static URL toURL(String url); static RequestFailedException insufficientPrivileges(int code, byte[] bytes); static byte[] getBytes(InputStream in); static String getUTF8String(byte[] in);  }
@Test public void encodeParametersIncludingSpecialCharactersShouldEncodePeriodDashAsteriskAndUnderscore() { assertEquals("%2e%2d%2a%5f", encodeIncludingSpecialCharacters(".-*_")); }
@Test public void encodeSpecialCharsInEmailAddressShouldNotLeaveAPeriodOrAtsign() { assertEquals("j%40heroku%2djar%2ecom", encodeIncludingSpecialCharacters("j@heroku-jar.com")); }