### Question:
BasicOAuthStore implements OAuthStore { public ConsumerInfo getConsumerKeyAndSecret( SecurityToken securityToken, String serviceName, OAuthServiceProvider provider) throws GadgetException { ++consumerKeyLookupCount; BasicOAuthStoreConsumerIndex pk = new BasicOAuthStoreConsumerIndex(); pk.setGadgetUri(securityToken.getAppUrl()); pk.setServiceName(serviceName); BasicOAuthStoreConsumerKeyAndSecret cks = consumerInfos.get(pk); if (cks == null) { cks = defaultKey; } if (cks == null) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, "No key for gadget " + securityToken.getAppUrl() + " and service " + serviceName); } OAuthConsumer consumer; final KeyType keyType = cks.getKeyType(); if (keyType == KeyType.RSA_PRIVATE) { consumer = new OAuthConsumer(null, cks.getConsumerKey(), null, provider); consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.RSA_SHA1); consumer.setProperty(RSA_SHA1.PRIVATE_KEY, cks.getConsumerSecret()); } else if (keyType == KeyType.PLAINTEXT) { consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider); consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, "PLAINTEXT"); } else { consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider); consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1); } String callback = (cks.getCallbackUrl() != null ? cks.getCallbackUrl() : defaultCallbackUrl); if (authority != null) { callback = callback.replace("%authority%", authority.getAuthority()); } return new ConsumerInfo(consumer, cks.getKeyName(), callback, cks.isOauthBodyHash()); } BasicOAuthStore(); void initFromConfigString(String oauthConfigStr); static String convertFromOpenSsl(String privateKey); void setDefaultKey(BasicOAuthStoreConsumerKeyAndSecret defaultKey); void setDefaultCallbackUrl(String defaultCallbackUrl); void setConsumerKeyAndSecret(
      BasicOAuthStoreConsumerIndex providerKey, BasicOAuthStoreConsumerKeyAndSecret keyAndSecret); void setAuthority(Authority authority); ConsumerInfo getConsumerKeyAndSecret(
      SecurityToken securityToken, String serviceName, OAuthServiceProvider provider); TokenInfo getTokenInfo(SecurityToken securityToken, ConsumerInfo consumerInfo,
      String serviceName, String tokenName); void setTokenInfo(SecurityToken securityToken, ConsumerInfo consumerInfo,
      String serviceName, String tokenName, TokenInfo tokenInfo); void removeToken(SecurityToken securityToken, ConsumerInfo consumerInfo,
      String serviceName, String tokenName); int getConsumerKeyLookupCount(); int getAccessTokenLookupCount(); int getAccessTokenAddCount(); int getAccessTokenRemoveCount();  }### Answer:
@Test public void testInit() throws Exception { FakeGadgetToken t = new FakeGadgetToken(); t.setAppUrl("http: OAuthServiceProvider provider = new OAuthServiceProvider("req", "authorize", "access"); ConsumerInfo consumerInfo = store.getConsumerKeyAndSecret(t, "", provider); OAuthConsumer consumer = consumerInfo.getConsumer(); assertEquals("gadgetConsumer", consumer.consumerKey); assertEquals("gadgetSecret", consumer.consumerSecret); assertEquals("HMAC-SHA1", consumer.getProperty("oauth_signature_method")); assertEquals(provider, consumer.serviceProvider); assertNull(consumerInfo.getKeyName()); assertEquals("default callback", consumerInfo.getCallbackUrl()); t.setAppUrl("http: consumerInfo = store.getConsumerKeyAndSecret(t, "", provider); consumer = consumerInfo.getConsumer(); assertEquals("rsaconsumer", consumer.consumerKey); assertNull(consumer.consumerSecret); assertEquals("RSA-SHA1", consumer.getProperty("oauth_signature_method")); assertEquals(provider, consumer.serviceProvider); assertEquals("rsaprivate", consumer.getProperty(RSA_SHA1.PRIVATE_KEY)); assertNull(consumerInfo.getKeyName()); assertEquals("callback", consumerInfo.getCallbackUrl()); }