jaroslav@947: /** jaroslav@947: * Back 2 Browser Bytecode Translator jaroslav@947: * Copyright (C) 2012 Jaroslav Tulach jaroslav@947: * jaroslav@947: * This program is free software: you can redistribute it and/or modify jaroslav@947: * it under the terms of the GNU General Public License as published by jaroslav@947: * the Free Software Foundation, version 2 of the License. jaroslav@947: * jaroslav@947: * This program is distributed in the hope that it will be useful, jaroslav@947: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@947: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@947: * GNU General Public License for more details. jaroslav@947: * jaroslav@947: * You should have received a copy of the GNU General Public License jaroslav@947: * along with this program. Look for COPYING file in the top folder. jaroslav@947: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@947: */ jaroslav@947: package org.apidesign.bck2brwsr.demo.twitter; jaroslav@947: jaroslav@1024: import net.java.html.json.Context; jaroslav@947: import org.apidesign.bck2brwsr.vmtest.BrwsrTest; jaroslav@947: import org.apidesign.bck2brwsr.vmtest.Http; jaroslav@947: import org.apidesign.bck2brwsr.vmtest.VMTest; jaroslav@947: import org.testng.annotations.Factory; jaroslav@947: jaroslav@947: /** jaroslav@947: * jaroslav@947: * @author Jaroslav Tulach jaroslav@947: */ jaroslav@947: public class TwitterProtocolTest { jaroslav@947: private TwitterModel page; jaroslav@947: @Http(@Http.Resource( jaroslav@954: path = "/search.json", jaroslav@947: mimeType = "application/json", jaroslav@954: parameters = {"callback"}, jaroslav@954: content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\"" jaroslav@947: + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":" jaroslav@947: + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\"," jaroslav@947: + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\"," jaroslav@947: + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":" jaroslav@947: + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344," jaroslav@947: + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":" jaroslav@947: + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" jaroslav@947: + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + " jaroslav@947: + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747," jaroslav@947: + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872," jaroslav@947: + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\"," jaroslav@947: + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":" jaroslav@947: + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913," jaroslav@947: + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":" jaroslav@947: + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" jaroslav@947: + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"}," jaroslav@947: + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\"," jaroslav@947: + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\"," jaroslav@947: + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\"," jaroslav@947: + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":" jaroslav@947: + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" jaroslav@947: + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"}," jaroslav@947: + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648," jaroslav@947: + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null," jaroslav@947: + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":" jaroslav@947: + "{\"result_type\":\"recent\"},\"profile_image_url\":" jaroslav@947: + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," jaroslav@947: + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" jaroslav@947: + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100," jaroslav@954: + "\"since_id\":0,\"since_id_str\":\"0\"})" jaroslav@947: )) jaroslav@947: @BrwsrTest public void readFromTwttr() throws InterruptedException { jaroslav@947: if (page == null) { jaroslav@1024: page = new TwitterModel(Context.findDefault(TwitterProtocolTest.class)); jaroslav@947: page.applyBindings(); jaroslav@954: page.queryTweets("", "q=xyz"); jaroslav@947: } jaroslav@947: jaroslav@947: if (page.getCurrentTweets().isEmpty()) { jaroslav@947: throw new InterruptedException(); jaroslav@947: } jaroslav@947: jaroslav@947: assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets(); jaroslav@948: jaroslav@948: String firstDate = page.getCurrentTweets().get(0).getCreated_at(); jaroslav@948: assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate; jaroslav@947: } jaroslav@947: jaroslav@947: @Factory public static Object[] create() { jaroslav@947: return VMTest.create(TwitterProtocolTest.class); jaroslav@947: } jaroslav@947: }