jaroslav@1202
|
1 |
package ${package};
|
jaroslav@1202
|
2 |
|
jaroslav@1202
|
3 |
import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
|
jaroslav@1202
|
4 |
import org.apidesign.bck2brwsr.vmtest.Http;
|
jaroslav@1202
|
5 |
import org.apidesign.bck2brwsr.vmtest.VMTest;
|
jaroslav@1202
|
6 |
import org.testng.annotations.Factory;
|
jaroslav@1202
|
7 |
|
jaroslav@1202
|
8 |
public class TwitterProtocolTest {
|
jaroslav@1202
|
9 |
private TwitterModel page;
|
jaroslav@1202
|
10 |
@Http(@Http.Resource(
|
jaroslav@1202
|
11 |
path = "/search.json",
|
jaroslav@1202
|
12 |
mimeType = "application/json",
|
jaroslav@1202
|
13 |
parameters = {"callback"},
|
jaroslav@1202
|
14 |
content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\""
|
jaroslav@1202
|
15 |
+ ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":"
|
jaroslav@1202
|
16 |
+ "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\","
|
jaroslav@1202
|
17 |
+ "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\","
|
jaroslav@1202
|
18 |
+ "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
|
jaroslav@1202
|
19 |
+ "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344,"
|
jaroslav@1202
|
20 |
+ "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
|
jaroslav@1202
|
21 |
+ "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
22 |
+ "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
23 |
+ "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
|
jaroslav@1202
|
24 |
+ "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + "
|
jaroslav@1202
|
25 |
+ "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747,"
|
jaroslav@1202
|
26 |
+ "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872,"
|
jaroslav@1202
|
27 |
+ "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\","
|
jaroslav@1202
|
28 |
+ "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
|
jaroslav@1202
|
29 |
+ "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913,"
|
jaroslav@1202
|
30 |
+ "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
|
jaroslav@1202
|
31 |
+ "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
32 |
+ "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
33 |
+ "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
|
jaroslav@1202
|
34 |
+ "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"},"
|
jaroslav@1202
|
35 |
+ "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\","
|
jaroslav@1202
|
36 |
+ "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\","
|
jaroslav@1202
|
37 |
+ "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\","
|
jaroslav@1202
|
38 |
+ "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":"
|
jaroslav@1202
|
39 |
+ "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
40 |
+ "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
41 |
+ "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
|
jaroslav@1202
|
42 |
+ "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"},"
|
jaroslav@1202
|
43 |
+ "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,"
|
jaroslav@1202
|
44 |
+ "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,"
|
jaroslav@1202
|
45 |
+ "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":"
|
jaroslav@1202
|
46 |
+ "{\"result_type\":\"recent\"},\"profile_image_url\":"
|
jaroslav@1202
|
47 |
+ "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
48 |
+ "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
|
jaroslav@1202
|
49 |
+ "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
|
jaroslav@1202
|
50 |
+ "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100,"
|
jaroslav@1202
|
51 |
+ "\"since_id\":0,\"since_id_str\":\"0\"})"
|
jaroslav@1202
|
52 |
))
|
jaroslav@1202
|
53 |
@BrwsrTest public void readFromTwttr() throws InterruptedException {
|
jaroslav@1202
|
54 |
if (page == null) {
|
jaroslav@1222
|
55 |
page = new TwitterModel();
|
jaroslav@1202
|
56 |
page.applyBindings();
|
jaroslav@1202
|
57 |
page.queryTweets("", "q=xyz");
|
jaroslav@1202
|
58 |
}
|
jaroslav@1202
|
59 |
|
jaroslav@1202
|
60 |
if (page.getCurrentTweets().isEmpty()) {
|
jaroslav@1202
|
61 |
throw new InterruptedException();
|
jaroslav@1202
|
62 |
}
|
jaroslav@1202
|
63 |
|
jaroslav@1202
|
64 |
assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets();
|
jaroslav@1202
|
65 |
|
jaroslav@1202
|
66 |
String firstDate = page.getCurrentTweets().get(0).getCreated_at();
|
jaroslav@1202
|
67 |
assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate;
|
jaroslav@1202
|
68 |
}
|
jaroslav@1202
|
69 |
|
jaroslav@1202
|
70 |
@Factory public static Object[] create() {
|
jaroslav@1202
|
71 |
return VMTest.create(TwitterProtocolTest.class);
|
jaroslav@1202
|
72 |
}
|
jaroslav@1202
|
73 |
}
|