use of twitter4j.conf.ConfigurationBuilder in project twitter4j by yusuke.
the class DAOTest method getJSONArrayFromGetURL.
private JSONArray getJSONArrayFromGetURL(String url) throws Exception {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setUser(id1.screenName);
builder.setPassword(id1.password);
return getJSONArrayFromGetURL(url, builder.build());
}
use of twitter4j.conf.ConfigurationBuilder in project twitter4j by yusuke.
the class ApplicationOnlyAuthTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
builder = new ConfigurationBuilder();
builder.setApplicationOnlyAuthEnabled(true);
}
use of twitter4j.conf.ConfigurationBuilder in project twitter4j by yusuke.
the class ApplicationOnlyAuthTest method testSettingAccessToken1.
public void testSettingAccessToken1() throws TwitterException {
// setup
builder.setOAuthConsumerKey(browserConsumerKey).setOAuthConsumerSecret(browserConsumerSecret);
OAuth2Token token = new TwitterFactory(builder.build()).getInstance().getOAuth2Token();
// exercise & verify
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setApplicationOnlyAuthEnabled(true);
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
twitter.setOAuthConsumer(browserConsumerKey, browserConsumerSecret);
twitter.setOAuth2Token(token);
Map<String, RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus("search");
RateLimitStatus searchTweetsRateLimit = rateLimitStatus.get("/search/tweets");
assertNotNull(searchTweetsRateLimit);
assertEquals(searchTweetsRateLimit.getLimit(), 450);
}
use of twitter4j.conf.ConfigurationBuilder 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);
}
use of twitter4j.conf.ConfigurationBuilder in project twitter4j by yusuke.
the class ApplicationOnlyAuthTest method testAuthWithPropertyFile.
public void testAuthWithPropertyFile() throws Exception {
String filename = "./twitter4j.properties";
try {
// setup
writeFile(filename, "enableApplicationOnlyAuth=true", "http.useSSL=true", "oauth.consumerKey=" + browserConsumerKey, "oauth.consumerSecret=" + browserConsumerSecret);
// exercise
Twitter twitter = new TwitterFactory(new ConfigurationBuilder().build()).getInstance();
OAuth2Token token = twitter.getOAuth2Token();
assertEquals("bearer", token.getTokenType());
// verify
Map<String, RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus("search");
RateLimitStatus searchTweetsRateLimit = rateLimitStatus.get("/search/tweets");
assertNotNull(searchTweetsRateLimit);
assertEquals(searchTweetsRateLimit.getLimit(), 450);
} finally {
deleteFile(filename);
}
}
Aggregations