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