OAuthTokenDeserializer extends TypeDeserializer<OAuthToken> { @Override protected OAuthToken deserialize(InputStream stream, Charset charset) throws Exception { Map<String, String> tokens = parseQueryString(IOs.toString(stream, charset, true)); return new OAuthToken( tokens.get("oauth_token"), tokens.get("oauth_token_secret"), filter(tokens, "oauth_token", "oauth_token_secret") ); }    }
@Test public void shouldDeserializeUrlFormEncodedToken() throws Exception { OAuthToken actual = toTest.deserialize(DATA, Charset.defaultCharset()); assertEquals("oauthToken", actual.getToken()); assertEquals("oauthTokenSecret", actual.getSecret()); assertEquals("extra1", actual.getAttribute("extra1").getName()); assertEquals("extra1Val", actual.getAttribute("extra1").getValue()); assertEquals("extra2", actual.getAttribute("extra2").getName()); assertEquals("extra2Val", actual.getAttribute("extra2").getValue()); }