OAuth { public static String addQueryParameters(String url, String... kvPairs) { String queryDelim = url.contains("?") ? "&" : "?"; StringBuilder sb = new StringBuilder(url + queryDelim); for (int i = 0; i < kvPairs.length; i += 2) { if (i > 0) { sb.append("&"); } sb.append(OAuth.percentEncode(kvPairs[i])).append("=").append(OAuth.percentEncode(kvPairs[i + 1])); } return sb.toString(); }  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 shouldCorrectlyAppendQueryParameters() { String url1 = "http: assertEquals("http: OAuth.addQueryParameters(url1, "a", "1", "b", "2")); String url2 = "http: assertEquals("http: OAuth.addQueryParameters(url2, "a", "1", "b", "2")); Map<String, String> params = new LinkedHashMap<String, String>(); params.put("a", "1"); params.put("b", "2"); assertEquals("http: }