use of twitter4j.auth.Authorization in project twitter4j by yusuke.
the class AuthorizationTest method testOAuthInstance.
public void testOAuthInstance() throws Exception {
String consumerSecret;
String consumerKey;
consumerSecret = p.getProperty("browser.oauth.consumerSecret");
consumerKey = p.getProperty("browser.oauth.consumerSecret");
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecret);
try {
twitter.setOAuthConsumer(consumerSecret, consumerKey);
fail("should throw IllegalStateException");
} catch (IllegalStateException ignore) {
}
Authorization auth = twitter.getAuthorization();
assertTrue(auth instanceof OAuthAuthorization);
}
use of twitter4j.auth.Authorization in project twitter4j by yusuke.
the class AuthorizationTest method testAnonymousInstance.
public void testAnonymousInstance() throws Exception {
Twitter twitter = new TwitterFactory().getInstance();
Authorization auth = twitter.getAuthorization();
assertTrue(auth instanceof NullAuthorization);
}
use of twitter4j.auth.Authorization in project twitter4j by yusuke.
the class AuthorizationTest method testOAuth2Instance.
public void testOAuth2Instance() throws Exception {
String consumerSecret = p.getProperty("browser.oauth.consumerSecret");
String consumerKey = p.getProperty("browser.oauth.consumerSecret");
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setApplicationOnlyAuthEnabled(true);
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
twitter.setOAuthConsumer(consumerKey, consumerSecret);
try {
twitter.setOAuthConsumer(consumerSecret, consumerKey);
fail("should throw IllegalStateException");
} catch (IllegalStateException ignore) {
}
Authorization auth = twitter.getAuthorization();
assertTrue(auth instanceof OAuth2Authorization);
}
Aggregations