1.1 --- a/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterProtocolTest.java Tue Aug 13 17:00:13 2013 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,101 +0,0 @@
1.4 -/**
1.5 - * The MIT License (MIT)
1.6 - *
1.7 - * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.8 - *
1.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
1.10 - * of this software and associated documentation files (the "Software"), to deal
1.11 - * in the Software without restriction, including without limitation the rights
1.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1.13 - * copies of the Software, and to permit persons to whom the Software is
1.14 - * furnished to do so, subject to the following conditions:
1.15 - *
1.16 - * The above copyright notice and this permission notice shall be included in
1.17 - * all copies or substantial portions of the Software.
1.18 - *
1.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1.22 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1.25 - * THE SOFTWARE.
1.26 - */
1.27 -package org.apidesign.html.demo.twitter;
1.28 -
1.29 -import net.java.html.json.Context;
1.30 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
1.31 -import org.apidesign.bck2brwsr.vmtest.Http;
1.32 -import org.apidesign.bck2brwsr.vmtest.VMTest;
1.33 -import org.testng.annotations.Factory;
1.34 -
1.35 -/**
1.36 - *
1.37 - * @author Jaroslav Tulach <jtulach@netbeans.org>
1.38 - */
1.39 -public class TwitterProtocolTest {
1.40 - private TwitterModel page;
1.41 - @Http(@Http.Resource(
1.42 - path = "/search.json",
1.43 - mimeType = "application/json",
1.44 - parameters = {"callback"},
1.45 - content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\""
1.46 - + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":"
1.47 - + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\","
1.48 - + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\","
1.49 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
1.50 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344,"
1.51 - + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
1.52 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.53 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.54 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
1.55 - + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + "
1.56 - + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747,"
1.57 - + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872,"
1.58 - + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\","
1.59 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
1.60 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913,"
1.61 - + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
1.62 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.63 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.64 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
1.65 - + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"},"
1.66 - + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\","
1.67 - + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\","
1.68 - + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\","
1.69 - + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":"
1.70 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.71 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.72 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
1.73 - + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"},"
1.74 - + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,"
1.75 - + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,"
1.76 - + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":"
1.77 - + "{\"result_type\":\"recent\"},\"profile_image_url\":"
1.78 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.79 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
1.80 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
1.81 - + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100,"
1.82 - + "\"since_id\":0,\"since_id_str\":\"0\"})"
1.83 - ))
1.84 - @BrwsrTest public void readFromTwttr() throws InterruptedException {
1.85 - if (page == null) {
1.86 - page = new TwitterModel(Context.findDefault(TwitterProtocolTest.class));
1.87 - page.applyBindings();
1.88 - page.queryTweets("", "q=xyz");
1.89 - }
1.90 -
1.91 - if (page.getCurrentTweets().isEmpty()) {
1.92 - throw new InterruptedException();
1.93 - }
1.94 -
1.95 - assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets();
1.96 -
1.97 - String firstDate = page.getCurrentTweets().get(0).getCreated_at();
1.98 - assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate;
1.99 - }
1.100 -
1.101 - @Factory public static Object[] create() {
1.102 - return VMTest.create(TwitterProtocolTest.class);
1.103 - }
1.104 -}