OAuth { public static HttpParameters decodeForm(String form) { HttpParameters params = new HttpParameters(); if (isEmpty(form)) { return params; } for (String nvp : form.split("\\&")) { int equals = nvp.indexOf('='); String name; String value; if (equals < 0) { name = percentDecode(nvp); value = null; } else { name = percentDecode(nvp.substring(0, equals)); value = percentDecode(nvp.substring(equals + 1)); } params.put(name, value); } return params; }  static String percentEncode(String s); static String percentDecode(String s); static void formEncode(Collection<T> parameters,
            OutputStream into); static String formEncode(Collection<T> parameters); static HttpParameters decodeForm(String form); static HttpParameters decodeForm(InputStream content); static Map<String, String> toMap(Collection<T> from); static final String safeToString(Object from); static boolean isEmpty(String str); static String addQueryParameters(String url, String... kvPairs); static String addQueryParameters(String url, Map<String, String> params); static String addQueryString(String url, String queryString); static String prepareOAuthHeader(String... kvPairs); static HttpParameters oauthHeaderToParamsMap(String oauthHeader); static String toHeaderElement(String name, String value); static void debugOut(String key, String value); static final String VERSION_1_0; static final String ENCODING; static final String FORM_ENCODED; static final String HTTP_AUTHORIZATION_HEADER; static final String OAUTH_CONSUMER_KEY; static final String OAUTH_TOKEN; static final String OAUTH_TOKEN_SECRET; static final String OAUTH_SIGNATURE_METHOD; static final String OAUTH_SIGNATURE; static final String OAUTH_TIMESTAMP; static final String OAUTH_NONCE; static final String OAUTH_VERSION; static final String OAUTH_CALLBACK; static final String OAUTH_CALLBACK_CONFIRMED; static final String OAUTH_VERIFIER; static final String OUT_OF_BAND; }
@Test public void shouldCorrectlyFormDecodeParameters() { HttpParameters params = OAuth.decodeForm("one=" + reservedCharactersEncoded + "&" + "one=another&" + reservedCharactersEncoded + "=" + rfc3986UnreservedCharacters); assertTrue(params.size() == 3); Iterator<String> iter1 = params.get("one").iterator(); assertEquals(rfc3986ReservedCharacters, iter1.next()); assertEquals("another", iter1.next()); Iterator<String> iter2 = params.get(rfc3986ReservedCharacters).iterator(); assertEquals(rfc3986UnreservedCharacters, iter2.next()); }