1.1 --- a/javaquery/demo-twitter/bck2brwsr-assembly.xml Mon Apr 15 18:30:30 2013 +0200
1.2 +++ b/javaquery/demo-twitter/bck2brwsr-assembly.xml Mon Apr 15 20:47:42 2013 +0200
1.3 @@ -54,9 +54,5 @@
1.4 <source>${project.build.directory}/${project.build.finalName}.jar</source>
1.5 <outputDirectory>/</outputDirectory>
1.6 </file>
1.7 - <file>
1.8 - <source>${project.build.directory}/bck2brwsr.js</source>
1.9 - <outputDirectory>/</outputDirectory>
1.10 - </file>
1.11 </files>
1.12 </assembly>
1.13 \ No newline at end of file
2.1 --- a/javaquery/demo-twitter/nbactions.xml Mon Apr 15 18:30:30 2013 +0200
2.2 +++ b/javaquery/demo-twitter/nbactions.xml Mon Apr 15 20:47:42 2013 +0200
2.3 @@ -17,13 +17,34 @@
2.4 along with this program. Look for COPYING file in the top folder.
2.5 If not, see http://opensource.org/licenses/GPL-2.0.
2.6
2.7 --->
2.8 -<actions>
2.9 - <action>
2.10 - <actionName>run</actionName>
2.11 - <goals>
2.12 - <goal>process-classes</goal>
2.13 - <goal>org.apidesign.bck2brwsr:mojo:0.6-SNAPSHOT:brwsr</goal>
2.14 - </goals>
2.15 - </action>
2.16 +--><actions>
2.17 + <action>
2.18 + <actionName>run</actionName>
2.19 + <packagings>
2.20 + <packaging>jar</packaging>
2.21 + </packagings>
2.22 + <goals>
2.23 + <goal>process-classes</goal>
2.24 + <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
2.25 + </goals>
2.26 + <properties>
2.27 + <exec.args>-classpath %classpath org.apidesign.bck2brwsr.demo.twitter.Main</exec.args>
2.28 + <exec.executable>java</exec.executable>
2.29 + </properties>
2.30 + </action>
2.31 + <action>
2.32 + <actionName>debug</actionName>
2.33 + <packagings>
2.34 + <packaging>jar</packaging>
2.35 + </packagings>
2.36 + <goals>
2.37 + <goal>process-classes</goal>
2.38 + <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
2.39 + </goals>
2.40 + <properties>
2.41 + <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.apidesign.bck2brwsr.demo.twitter.Main</exec.args>
2.42 + <exec.executable>java</exec.executable>
2.43 + <jpda.listen>true</jpda.listen>
2.44 + </properties>
2.45 + </action>
2.46 </actions>
3.1 --- a/javaquery/demo-twitter/pom.xml Mon Apr 15 18:30:30 2013 +0200
3.2 +++ b/javaquery/demo-twitter/pom.xml Mon Apr 15 20:47:42 2013 +0200
3.3 @@ -48,24 +48,6 @@
3.4 </properties>
3.5 <build>
3.6 <plugins>
3.7 - <plugin>
3.8 - <groupId>org.apidesign.bck2brwsr</groupId>
3.9 - <artifactId>mojo</artifactId>
3.10 - <version>0.6-SNAPSHOT</version>
3.11 - <executions>
3.12 - <execution>
3.13 - <goals>
3.14 - <goal>brwsr</goal>
3.15 - <goal>j2js</goal>
3.16 - </goals>
3.17 - </execution>
3.18 - </executions>
3.19 - <configuration>
3.20 - <startpage>org/apidesign/bck2brwsr/demo/twitter/index.html</startpage>
3.21 - <javascript>${project.build.directory}/bck2brwsr.js</javascript>
3.22 - <obfuscation>${bck2brwsr.obfuscationlevel}</obfuscation>
3.23 - </configuration>
3.24 - </plugin>
3.25 <plugin>
3.26 <groupId>org.apache.maven.plugins</groupId>
3.27 <artifactId>maven-compiler-plugin</artifactId>
3.28 @@ -133,5 +115,10 @@
3.29 <version>0.6-SNAPSHOT</version>
3.30 <scope>test</scope>
3.31 </dependency>
3.32 + <dependency>
3.33 + <groupId>org.apidesign.bck2brwsr</groupId>
3.34 + <artifactId>launcher</artifactId>
3.35 + <version>0.6-SNAPSHOT</version>
3.36 + </dependency>
3.37 </dependencies>
3.38 </project>
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/Main.java Mon Apr 15 20:47:42 2013 +0200
4.3 @@ -0,0 +1,33 @@
4.4 +/**
4.5 + * Back 2 Browser Bytecode Translator
4.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
4.7 + *
4.8 + * This program is free software: you can redistribute it and/or modify
4.9 + * it under the terms of the GNU General Public License as published by
4.10 + * the Free Software Foundation, version 2 of the License.
4.11 + *
4.12 + * This program is distributed in the hope that it will be useful,
4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.15 + * GNU General Public License for more details.
4.16 + *
4.17 + * You should have received a copy of the GNU General Public License
4.18 + * along with this program. Look for COPYING file in the top folder.
4.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
4.20 + */
4.21 +
4.22 +package org.apidesign.bck2brwsr.demo.twitter;
4.23 +
4.24 +import java.io.IOException;
4.25 +import org.apidesign.bck2brwsr.launcher.Launcher;
4.26 +
4.27 +/**
4.28 + *
4.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
4.30 + */
4.31 +class Main {
4.32 + public static void main(String... args) throws IOException {
4.33 + Launcher.showURL(ClassLoader.getSystemClassLoader(), "org/apidesign/bck2brwsr/demo/twitter/index.html");
4.34 + }
4.35 +
4.36 +}
5.1 --- a/javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClientTest.java Mon Apr 15 18:30:30 2013 +0200
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,67 +0,0 @@
5.4 -/**
5.5 - * Back 2 Browser Bytecode Translator
5.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5.7 - *
5.8 - * This program is free software: you can redistribute it and/or modify
5.9 - * it under the terms of the GNU General Public License as published by
5.10 - * the Free Software Foundation, version 2 of the License.
5.11 - *
5.12 - * This program is distributed in the hope that it will be useful,
5.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.15 - * GNU General Public License for more details.
5.16 - *
5.17 - * You should have received a copy of the GNU General Public License
5.18 - * along with this program. Look for COPYING file in the top folder.
5.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
5.20 - */
5.21 -package org.apidesign.bck2brwsr.demo.twitter;
5.22 -
5.23 -import java.util.List;
5.24 -import static org.testng.Assert.*;
5.25 -import org.testng.annotations.BeforeMethod;
5.26 -import org.testng.annotations.Test;
5.27 -
5.28 -/** We can unit test the TwitterModel smoothly.
5.29 - *
5.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
5.31 - */
5.32 -public class TwitterClientTest {
5.33 - private TwitterModel model;
5.34 -
5.35 -
5.36 - @BeforeMethod
5.37 - public void initModel() {
5.38 - model = new TwitterModel().applyBindings();
5.39 - }
5.40 -
5.41 - @Test public void testIsValidToAdd() {
5.42 - model.setUserNameToAdd("Joe");
5.43 - Tweeters t = new Tweeters();
5.44 - t.setName("test");
5.45 - model.getSavedLists().add(t);
5.46 - model.setActiveTweetersName("test");
5.47 -
5.48 - assertTrue(model.isUserNameToAddIsValid(), "Joe is OK");
5.49 - TwitterClient.addUser(model);
5.50 - assertFalse(model.isUserNameToAddIsValid(), "Can't add Joe for the 2nd time");
5.51 - assertEquals(t.getUserNames().size(), 0, "Original tweeters list remains empty");
5.52 -
5.53 - List<String> mod = model.getActiveTweeters();
5.54 - assertTrue(model.isHasUnsavedChanges(), "We have modifications");
5.55 - assertEquals(mod.size(), 1, "One element in the list");
5.56 - assertEquals(mod.get(0), "Joe", "Its name is Joe");
5.57 -
5.58 - assertSame(model.getActiveTweeters(), mod, "Editing list is the modified one");
5.59 -
5.60 - TwitterClient.saveChanges(model);
5.61 - assertFalse(model.isHasUnsavedChanges(), "Does not have anything to save");
5.62 -
5.63 - assertSame(model.getActiveTweeters(), mod, "Still editing the old modified one");
5.64 - }
5.65 -
5.66 - @Test public void httpAtTheEnd() {
5.67 - String res = TwitterClient.Twt.html("Ahoj http://kuk");
5.68 - assertEquals(res, "Ahoj <a href='http://kuk'>http://kuk</a>");
5.69 - }
5.70 -}
6.1 --- a/javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterProtocolTest.java Mon Apr 15 18:30:30 2013 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,94 +0,0 @@
6.4 -/**
6.5 - * Back 2 Browser Bytecode Translator
6.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
6.7 - *
6.8 - * This program is free software: you can redistribute it and/or modify
6.9 - * it under the terms of the GNU General Public License as published by
6.10 - * the Free Software Foundation, version 2 of the License.
6.11 - *
6.12 - * This program is distributed in the hope that it will be useful,
6.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.15 - * GNU General Public License for more details.
6.16 - *
6.17 - * You should have received a copy of the GNU General Public License
6.18 - * along with this program. Look for COPYING file in the top folder.
6.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
6.20 - */
6.21 -package org.apidesign.bck2brwsr.demo.twitter;
6.22 -
6.23 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
6.24 -import org.apidesign.bck2brwsr.vmtest.Http;
6.25 -import org.apidesign.bck2brwsr.vmtest.VMTest;
6.26 -import org.testng.annotations.Factory;
6.27 -
6.28 -/**
6.29 - *
6.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
6.31 - */
6.32 -public class TwitterProtocolTest {
6.33 - private TwitterModel page;
6.34 - @Http(@Http.Resource(
6.35 - path = "/search.json",
6.36 - mimeType = "application/json",
6.37 - parameters = {"callback"},
6.38 - content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\""
6.39 - + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":"
6.40 - + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\","
6.41 - + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\","
6.42 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
6.43 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344,"
6.44 - + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
6.45 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.46 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.47 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
6.48 - + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + "
6.49 - + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747,"
6.50 - + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872,"
6.51 - + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\","
6.52 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
6.53 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913,"
6.54 - + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
6.55 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.56 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.57 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
6.58 - + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"},"
6.59 - + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\","
6.60 - + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\","
6.61 - + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\","
6.62 - + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":"
6.63 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.64 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.65 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
6.66 - + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"},"
6.67 - + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,"
6.68 - + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,"
6.69 - + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":"
6.70 - + "{\"result_type\":\"recent\"},\"profile_image_url\":"
6.71 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.72 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
6.73 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
6.74 - + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100,"
6.75 - + "\"since_id\":0,\"since_id_str\":\"0\"})"
6.76 - ))
6.77 - @BrwsrTest public void readFromTwttr() throws InterruptedException {
6.78 - if (page == null) {
6.79 - page = new TwitterModel();
6.80 - page.applyBindings();
6.81 - page.queryTweets("", "q=xyz");
6.82 - }
6.83 -
6.84 - if (page.getCurrentTweets().isEmpty()) {
6.85 - throw new InterruptedException();
6.86 - }
6.87 -
6.88 - assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets();
6.89 -
6.90 - String firstDate = page.getCurrentTweets().get(0).getCreated_at();
6.91 - assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate;
6.92 - }
6.93 -
6.94 - @Factory public static Object[] create() {
6.95 - return VMTest.create(TwitterProtocolTest.class);
6.96 - }
6.97 -}