Assert.assertEquals(null, result);
}
@Test
public void testStoreToken_1() throws Exception {
OAuth2Token token = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
token.setGadgetUri("xxx");
token.setServiceName("yyy");
token.setExpiresAt(2);
token.setIssuedAt(1);
token.setMacAlgorithm(OAuth2Message.HMAC_SHA_1);
token.setMacSecret("shh, it's a secret".getBytes("UTF-8"));
token.setScope("mac_scope");
token.setSecret("i'll never tell".getBytes("UTF-8"));
token.setTokenType(OAuth2Message.MAC_TOKEN_TYPE);
token.setType(OAuth2Token.Type.ACCESS);
token.setUser("zzz");
final Integer result = this.cache.storeToken(token);
Assert.assertEquals(460203885, result.intValue());
token = this.cache.getToken(result);
Assert.assertNotNull(token);
Assert.assertEquals("xxx", token.getGadgetUri());
Assert.assertEquals("yyy", token.getServiceName());
Assert.assertEquals(2, token.getExpiresAt());
Assert.assertEquals(1, token.getIssuedAt());
Assert.assertEquals(OAuth2Message.HMAC_SHA_1, token.getMacAlgorithm());
Assert.assertEquals("shh, it's a secret", new String(token.getMacSecret(), "UTF-8"));
Assert.assertEquals("mac_scope", token.getScope());
Assert.assertEquals("i'll never tell", new String(token.getSecret(), "UTF-8"));
Assert.assertEquals(OAuth2Message.MAC_TOKEN_TYPE, token.getTokenType());
Assert.assertEquals(OAuth2Token.Type.ACCESS, token.getType());
Assert.assertEquals("zzz", token.getUser());
}