# HG changeset patch # User Jaroslav Tulach # Date 1366051662 -7200 # Node ID a28d8ee85ba95e33d196c24041ea03da1ad84730 # Parent 9ddce13e8ff9bb497ce964fc9fbf493bf27da264 Modifying the Twitter example to run in FX Web View diff -r 9ddce13e8ff9 -r a28d8ee85ba9 javaquery/demo-twitter/bck2brwsr-assembly.xml --- a/javaquery/demo-twitter/bck2brwsr-assembly.xml Mon Apr 15 18:30:30 2013 +0200 +++ b/javaquery/demo-twitter/bck2brwsr-assembly.xml Mon Apr 15 20:47:42 2013 +0200 @@ -54,9 +54,5 @@ ${project.build.directory}/${project.build.finalName}.jar / - - ${project.build.directory}/bck2brwsr.js - / - \ No newline at end of file diff -r 9ddce13e8ff9 -r a28d8ee85ba9 javaquery/demo-twitter/nbactions.xml --- a/javaquery/demo-twitter/nbactions.xml Mon Apr 15 18:30:30 2013 +0200 +++ b/javaquery/demo-twitter/nbactions.xml Mon Apr 15 20:47:42 2013 +0200 @@ -17,13 +17,34 @@ along with this program. Look for COPYING file in the top folder. If not, see http://opensource.org/licenses/GPL-2.0. ---> - - - run - - process-classes - org.apidesign.bck2brwsr:mojo:0.6-SNAPSHOT:brwsr - - +--> + + run + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -classpath %classpath org.apidesign.bck2brwsr.demo.twitter.Main + java + + + + debug + + jar + + + process-classes + org.codehaus.mojo:exec-maven-plugin:1.2.1:exec + + + -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.apidesign.bck2brwsr.demo.twitter.Main + java + true + + diff -r 9ddce13e8ff9 -r a28d8ee85ba9 javaquery/demo-twitter/pom.xml --- a/javaquery/demo-twitter/pom.xml Mon Apr 15 18:30:30 2013 +0200 +++ b/javaquery/demo-twitter/pom.xml Mon Apr 15 20:47:42 2013 +0200 @@ -48,24 +48,6 @@ - - org.apidesign.bck2brwsr - mojo - 0.6-SNAPSHOT - - - - brwsr - j2js - - - - - org/apidesign/bck2brwsr/demo/twitter/index.html - ${project.build.directory}/bck2brwsr.js - ${bck2brwsr.obfuscationlevel} - - org.apache.maven.plugins maven-compiler-plugin @@ -133,5 +115,10 @@ 0.6-SNAPSHOT test + + org.apidesign.bck2brwsr + launcher + 0.6-SNAPSHOT + diff -r 9ddce13e8ff9 -r a28d8ee85ba9 javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/Main.java Mon Apr 15 20:47:42 2013 +0200 @@ -0,0 +1,33 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ + +package org.apidesign.bck2brwsr.demo.twitter; + +import java.io.IOException; +import org.apidesign.bck2brwsr.launcher.Launcher; + +/** + * + * @author Jaroslav Tulach + */ +class Main { + public static void main(String... args) throws IOException { + Launcher.showURL(ClassLoader.getSystemClassLoader(), "org/apidesign/bck2brwsr/demo/twitter/index.html"); + } + +} diff -r 9ddce13e8ff9 -r a28d8ee85ba9 javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClientTest.java --- a/javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClientTest.java Mon Apr 15 18:30:30 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.demo.twitter; - -import java.util.List; -import static org.testng.Assert.*; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -/** We can unit test the TwitterModel smoothly. - * - * @author Jaroslav Tulach - */ -public class TwitterClientTest { - private TwitterModel model; - - - @BeforeMethod - public void initModel() { - model = new TwitterModel().applyBindings(); - } - - @Test public void testIsValidToAdd() { - model.setUserNameToAdd("Joe"); - Tweeters t = new Tweeters(); - t.setName("test"); - model.getSavedLists().add(t); - model.setActiveTweetersName("test"); - - assertTrue(model.isUserNameToAddIsValid(), "Joe is OK"); - TwitterClient.addUser(model); - assertFalse(model.isUserNameToAddIsValid(), "Can't add Joe for the 2nd time"); - assertEquals(t.getUserNames().size(), 0, "Original tweeters list remains empty"); - - List mod = model.getActiveTweeters(); - assertTrue(model.isHasUnsavedChanges(), "We have modifications"); - assertEquals(mod.size(), 1, "One element in the list"); - assertEquals(mod.get(0), "Joe", "Its name is Joe"); - - assertSame(model.getActiveTweeters(), mod, "Editing list is the modified one"); - - TwitterClient.saveChanges(model); - assertFalse(model.isHasUnsavedChanges(), "Does not have anything to save"); - - assertSame(model.getActiveTweeters(), mod, "Still editing the old modified one"); - } - - @Test public void httpAtTheEnd() { - String res = TwitterClient.Twt.html("Ahoj http://kuk"); - assertEquals(res, "Ahoj http://kuk"); - } -} diff -r 9ddce13e8ff9 -r a28d8ee85ba9 javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterProtocolTest.java --- a/javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterProtocolTest.java Mon Apr 15 18:30:30 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. - */ -package org.apidesign.bck2brwsr.demo.twitter; - -import org.apidesign.bck2brwsr.vmtest.BrwsrTest; -import org.apidesign.bck2brwsr.vmtest.Http; -import org.apidesign.bck2brwsr.vmtest.VMTest; -import org.testng.annotations.Factory; - -/** - * - * @author Jaroslav Tulach - */ -public class TwitterProtocolTest { - private TwitterModel page; - @Http(@Http.Resource( - path = "/search.json", - mimeType = "application/json", - parameters = {"callback"}, - content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\"" - + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":" - + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\"," - + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\"," - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":" - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344," - + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":" - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + " - + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747," - + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872," - + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\"," - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":" - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913," - + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":" - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"}," - + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\"," - + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\"," - + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\"," - + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":" - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"}," - + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648," - + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null," - + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":" - + "{\"result_type\":\"recent\"},\"profile_image_url\":" - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\"," - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":" - + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100," - + "\"since_id\":0,\"since_id_str\":\"0\"})" - )) - @BrwsrTest public void readFromTwttr() throws InterruptedException { - if (page == null) { - page = new TwitterModel(); - page.applyBindings(); - page.queryTweets("", "q=xyz"); - } - - if (page.getCurrentTweets().isEmpty()) { - throw new InterruptedException(); - } - - assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets(); - - String firstDate = page.getCurrentTweets().get(0).getCreated_at(); - assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate; - } - - @Factory public static Object[] create() { - return VMTest.create(TwitterProtocolTest.class); - } -}