@Test public void testApplyOAuthParameters() throws Exception { OAuthParametersApplier app = new QueryParameterApplier(); Map<String, Object> params = new HashMap<String, Object>(); params.put(OAuth.OAUTH_EXPIRES_IN, 3600l); params.put(OAuth.OAUTH_ACCESS_TOKEN, "token_authz"); params.put(OAuth.OAUTH_CODE, "code_"); params.put(OAuth.OAUTH_SCOPE, "read"); params.put(OAuth.OAUTH_STATE, "state"); params.put("empty_param", ""); params.put("null_param", null); OAuthMessage message = new DummyOAuthMessage("http: app.applyOAuthParameters(message, params); String locationURI = message.getLocationUri(); Assert.assertTrue(locationURI.contains("3600")); Assert.assertTrue(locationURI.contains("token_authz")); Assert.assertTrue(locationURI.contains("code_")); Assert.assertTrue(locationURI.contains("read")); Assert.assertTrue(locationURI.contains("state")); Assert.assertTrue(!locationURI.contains("empty_param")); Assert.assertTrue(!locationURI.contains("null_param")); }
public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) { String messageUrl = message.getLocationUri(); if (messageUrl != null) { boolean containsQuestionMark = messageUrl.contains("?"); StringBuffer url = new StringBuffer(messageUrl); StringBuffer query = new StringBuffer(OAuthUtils.format(params.entrySet(), "UTF-8")); if (!OAuthUtils.isEmpty(query.toString())) { if (containsQuestionMark) { url.append("&").append(query); } else { url.append("?").append(query); } } message.setLocationUri(url.toString()); } return message; }
QueryParameterApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) { String messageUrl = message.getLocationUri(); if (messageUrl != null) { boolean containsQuestionMark = messageUrl.contains("?"); StringBuffer url = new StringBuffer(messageUrl); StringBuffer query = new StringBuffer(OAuthUtils.format(params.entrySet(), "UTF-8")); if (!OAuthUtils.isEmpty(query.toString())) { if (containsQuestionMark) { url.append("&").append(query); } else { url.append("?").append(query); } } message.setLocationUri(url.toString()); } return message; } }
QueryParameterApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) { String messageUrl = message.getLocationUri(); if (messageUrl != null) { boolean containsQuestionMark = messageUrl.contains("?"); StringBuffer url = new StringBuffer(messageUrl); StringBuffer query = new StringBuffer(OAuthUtils.format(params.entrySet(), "UTF-8")); if (!OAuthUtils.isEmpty(query.toString())) { if (containsQuestionMark) { url.append("&").append(query); } else { url.append("?").append(query); } } message.setLocationUri(url.toString()); } return message; }  }
QueryParameterApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) { String messageUrl = message.getLocationUri(); if (messageUrl != null) { boolean containsQuestionMark = messageUrl.contains("?"); StringBuffer url = new StringBuffer(messageUrl); StringBuffer query = new StringBuffer(OAuthUtils.format(params.entrySet(), "UTF-8")); if (!OAuthUtils.isEmpty(query.toString())) { if (containsQuestionMark) { url.append("&").append(query); } else { url.append("?").append(query); } } message.setLocationUri(url.toString()); } return message; }  OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params); }
QueryParameterApplier implements OAuthParametersApplier { public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) { String messageUrl = message.getLocationUri(); if (messageUrl != null) { boolean containsQuestionMark = messageUrl.contains("?"); StringBuffer url = new StringBuffer(messageUrl); StringBuffer query = new StringBuffer(OAuthUtils.format(params.entrySet(), "UTF-8")); if (!OAuthUtils.isEmpty(query.toString())) { if (containsQuestionMark) { url.append("&").append(query); } else { url.append("?").append(query); } } message.setLocationUri(url.toString()); } return message; }  OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params);  }