package org.scribe.model; import static org.junit.Assert.*; import org.junit.Assume; import org.junit.Test; public class TestOAuthRequest { @Test public void testAddOAuthParameterValid() { String url = ""; Verb verb = Verb.GET; OAuthRequest req = new OAuthRequest(verb, url); String key = "oauth_" + "testValue"; // OAUTH_PREFIX String value = ""; try { req.addOAuthParameter(key, value); } catch (IllegalArgumentException e) { Assume.assumeNoException(e); } assertTrue(req.getOauthParameters().containsKey(key)); } @Test public void testAddOAuthParameterValid2() { String url = ""; Verb verb = Verb.POST; // little variation here ... OAuthRequest req = new OAuthRequest(verb, url); String key = OAuthConstants.SCOPE; String value = ""; try { req.addOAuthParameter(key, value); } catch (IllegalArgumentException e) { Assume.assumeNoException(e); } assertTrue(req.getOauthParameters().containsKey(key)); } @Test public void testAddOAuthParameterInvalid() { String url = ""; Verb verb = Verb.PUT; // little variation here ... OAuthRequest req = new OAuthRequest(verb, url); String key = "Hans"; // should not be valid String value = ""; try { req.addOAuthParameter(key, value); fail("Must not allow key with invalid prefix."); } catch (IllegalArgumentException e) { // this is expected behavior } assertFalse(req.getOauthParameters().containsKey(key)); } }