Skip to content
Browse files

simplified test cases

  • Loading branch information...
1 parent 92d2ddb commit ab332e7eb076ac9427c47758215a300e0416c746 @yusuke committed Sep 7, 2012
View
16 twitter4j-core/src/test/java/twitter4j/MBeansIntegrationTest.java
@@ -15,30 +15,28 @@
*/
package twitter4j;
-import junit.framework.TestCase;
-import twitter4j.conf.ConfigurationBuilder;
-
/**
* Integration tests for APIStatistics ensuring that the integration logic
* in Twitter (API client) works.
*
* @author Nick Dellamaggiore (nick.dellamaggiore <at> gmail.com)
*/
-public class MBeansIntegrationTest extends TestCase {
- private Twitter twitter;
+public class MBeansIntegrationTest extends TwitterTestBase {
+
+ public MBeansIntegrationTest(String name) {
+ super(name);
+ }
@Override
- protected void setUp()
- throws Exception {
+ protected void setUp() throws Exception {
super.setUp();
- twitter = new TwitterFactory(new ConfigurationBuilder().setMBeanEnabled(true).build()).getInstance();
}
public void testMonitoringIntegration() throws Exception {
// monitoring is turned on with mbeanEnabled=true
TwitterAPIMonitor monitor = TwitterAPIMonitor.getInstance();
assertEquals(0, monitor.getStatistics().getCallCount());
- twitter.getDailyTrends();
+ twitter1.getDailyTrends();
assertEquals(1, monitor.getStatistics().getCallCount());
}
}
View
31 twitter4j-core/src/test/java/twitter4j/SearchAPITest.java
@@ -137,32 +137,17 @@ public void testEasyPaging() throws Exception {
public void testTrends() throws Exception {
List<Trends> trendsList;
- trendsList = unauthenticated.getDailyTrends();
- assertTrends(trendsList, 20);
+ trendsList = twitter1.getDailyTrends();
+ assertTrue(trendsList.size() > 0);
- trendsList = unauthenticated.getDailyTrends(new Date(), true);
- assertTrends(trendsList, 20);
+ trendsList = twitter1.getDailyTrends(new Date(), true);
+ assertTrue(trendsList.size() > 0);
- trendsList = unauthenticated.getWeeklyTrends();
- assertTrends(trendsList, 30);
+ trendsList = twitter1.getWeeklyTrends();
+ assertTrue(trendsList.size() > 0);
- trendsList = unauthenticated.getWeeklyTrends(new Date(), true);
- assertTrends(trendsList, 30);
+ trendsList = twitter1.getWeeklyTrends(new Date(), true);
+ assertTrue(trendsList.size() > 0);
}
- private void assertTrends(List<Trends> trendsArray, int expectedSize) throws Exception {
- Date trendAt = null;
- for (Trends singleTrends : trendsArray) {
- assertTrue((expectedSize - 10) < singleTrends.getTrends().length);
- if (trendAt != null) {
- assertTrue(trendAt.before(singleTrends.getTrendAt()));
- }
- trendAt = singleTrends.getTrendAt();
- for (int i = 0; i < singleTrends.getTrends().length; i++) {
- assertNotNull(singleTrends.getTrends()[i].getName());
- assertNull(singleTrends.getTrends()[i].getUrl());
- assertNotNull(singleTrends.getTrends()[i].getQuery());
- }
- }
- }
}

0 comments on commit ab332e7

Please sign in to comment.
Something went wrong with that request. Please try again.