1.1 --- a/twitter/nbactions-bck2brwsr.xml Tue Aug 13 17:00:13 2013 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,35 +0,0 @@
1.4 -<?xml version="1.0" encoding="UTF-8"?>
1.5 -<!--
1.6 -
1.7 - The MIT License (MIT)
1.8 -
1.9 - Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.10 -
1.11 - Permission is hereby granted, free of charge, to any person obtaining a copy
1.12 - of this software and associated documentation files (the "Software"), to deal
1.13 - in the Software without restriction, including without limitation the rights
1.14 - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1.15 - copies of the Software, and to permit persons to whom the Software is
1.16 - furnished to do so, subject to the following conditions:
1.17 -
1.18 - The above copyright notice and this permission notice shall be included in
1.19 - all copies or substantial portions of the Software.
1.20 -
1.21 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1.22 - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1.23 - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1.24 - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1.25 - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1.26 - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1.27 - THE SOFTWARE.
1.28 -
1.29 --->
1.30 -<actions>
1.31 - <action>
1.32 - <actionName>run</actionName>
1.33 - <goals>
1.34 - <goal>process-classes</goal>
1.35 - <goal>bck2brwsr:brwsr</goal>
1.36 - </goals>
1.37 - </action>
1.38 -</actions>
2.1 --- a/twitter/nbactions-fxbrwsr.xml Tue Aug 13 17:00:13 2013 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,45 +0,0 @@
2.4 -<?xml version="1.0" encoding="UTF-8"?>
2.5 -<!--
2.6 -
2.7 - The MIT License (MIT)
2.8 -
2.9 - Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
2.10 -
2.11 - Permission is hereby granted, free of charge, to any person obtaining a copy
2.12 - of this software and associated documentation files (the "Software"), to deal
2.13 - in the Software without restriction, including without limitation the rights
2.14 - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2.15 - copies of the Software, and to permit persons to whom the Software is
2.16 - furnished to do so, subject to the following conditions:
2.17 -
2.18 - The above copyright notice and this permission notice shall be included in
2.19 - all copies or substantial portions of the Software.
2.20 -
2.21 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2.22 - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2.23 - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2.24 - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2.25 - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2.26 - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2.27 - THE SOFTWARE.
2.28 -
2.29 --->
2.30 -<actions>
2.31 - <action>
2.32 - <actionName>run</actionName>
2.33 - <goals>
2.34 - <goal>process-classes</goal>
2.35 - <goal>bck2brwsr:brwsr</goal>
2.36 - </goals>
2.37 - </action>
2.38 - <action>
2.39 - <actionName>debug</actionName>
2.40 - <goals>
2.41 - <goal>process-classes</goal>
2.42 - <goal>bck2brwsr:brwsr</goal>
2.43 - </goals>
2.44 - <properties>
2.45 - <jpda.listen>maven</jpda.listen>
2.46 - </properties>
2.47 - </action>
2.48 -</actions>
3.1 --- a/twitter/nbactions.xml Tue Aug 13 17:00:13 2013 +0200
3.2 +++ b/twitter/nbactions.xml Tue Aug 13 21:11:28 2013 +0200
3.3 @@ -28,15 +28,15 @@
3.4 <action>
3.5 <actionName>run</actionName>
3.6 <goals>
3.7 - <goal>process-classes</goal>
3.8 - <goal>bck2brwsr:brwsr</goal>
3.9 + <goal>package</goal>
3.10 + <goal>exec:java</goal>
3.11 </goals>
3.12 </action>
3.13 <action>
3.14 <actionName>debug</actionName>
3.15 <goals>
3.16 - <goal>process-classes</goal>
3.17 - <goal>bck2brwsr:brwsr</goal>
3.18 + <goal>package</goal>
3.19 + <goal>exec:java</goal>
3.20 </goals>
3.21 <properties>
3.22 <jpda.listen>maven</jpda.listen>
4.1 --- a/twitter/pom.xml Tue Aug 13 17:00:13 2013 +0200
4.2 +++ b/twitter/pom.xml Tue Aug 13 21:11:28 2013 +0200
4.3 @@ -2,8 +2,8 @@
4.4 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.5 <modelVersion>4.0.0</modelVersion>
4.6
4.7 - <groupId>org.apidesign.bck2brwsr</groupId>
4.8 - <artifactId>demo-twitter</artifactId>
4.9 + <groupId>org.apidesign.html.demo</groupId>
4.10 + <artifactId>twitter</artifactId>
4.11 <version>1.0-SNAPSHOT</version>
4.12 <packaging>jar</packaging>
4.13 <parent>
4.14 @@ -12,27 +12,18 @@
4.15 <version>1.0-SNAPSHOT</version>
4.16 </parent>
4.17
4.18 - <name>Fx/Bck2Brwsr's Twttr</name>
4.19 + <name>KO4Java's Twttr</name>
4.20 <description>
4.21 - Rewrite of knockout.js example to use model written in Java and
4.22 - execute using FxBrwsr or Bck2Brwsr.
4.23 + Rewrite of knockout.js example to use model written in Java displayed
4.24 + by HTML.
4.25 </description>
4.26
4.27 <properties>
4.28 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4.29 - <net.java.html.version>0.1</net.java.html.version>
4.30 - <bck2brwsr.version>0.7</bck2brwsr.version>
4.31 - <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
4.32 - <brwsr.startpage>org/apidesign/html/demo/twitter/index.html</brwsr.startpage>
4.33 + <net.java.html.version>0.4</net.java.html.version>
4.34 + <project.mainclass>org.apidesign.html.demo.twitter.TwitterMain</project.mainclass>
4.35 </properties>
4.36
4.37 - <repositories>
4.38 - <repository>
4.39 - <id>java.net</id>
4.40 - <name>Java.net</name>
4.41 - <url>https://maven.java.net/content/repositories/releases/</url>
4.42 - </repository>
4.43 - </repositories>
4.44 <pluginRepositories>
4.45 <pluginRepository>
4.46 <id>java.net</id>
4.47 @@ -44,22 +35,6 @@
4.48 <build>
4.49 <plugins>
4.50 <plugin>
4.51 - <groupId>org.apidesign.bck2brwsr</groupId>
4.52 - <artifactId>bck2brwsr-maven-plugin</artifactId>
4.53 - <version>${bck2brwsr.version}</version>
4.54 - <executions>
4.55 - <execution>
4.56 - <goals>
4.57 - <goal>brwsr</goal>
4.58 - </goals>
4.59 - </execution>
4.60 - </executions>
4.61 - <configuration>
4.62 - <startpage>${brwsr.startpage}</startpage>
4.63 - <launcher>${brwsr}</launcher>
4.64 - </configuration>
4.65 - </plugin>
4.66 - <plugin>
4.67 <groupId>org.apache.maven.plugins</groupId>
4.68 <artifactId>maven-compiler-plugin</artifactId>
4.69 <version>2.3.2</version>
4.70 @@ -79,6 +54,20 @@
4.71 </configuration>
4.72 </plugin>
4.73 <plugin>
4.74 + <groupId>org.codehaus.mojo</groupId>
4.75 + <artifactId>exec-maven-plugin</artifactId>
4.76 + <version>1.2.1</version>
4.77 + <configuration>
4.78 + <systemProperties>
4.79 + <systemProperty>
4.80 + <key>browser.rootdir</key>
4.81 + <value>${basedir}/src/main/webapp/</value>
4.82 + </systemProperty>
4.83 + </systemProperties>
4.84 + <mainClass>${project.mainclass}</mainClass>
4.85 + </configuration>
4.86 + </plugin>
4.87 + <plugin>
4.88 <groupId>org.apache.maven.plugins</groupId>
4.89 <artifactId>maven-jar-plugin</artifactId>
4.90 <version>2.4</version>
4.91 @@ -110,154 +99,28 @@
4.92 <scope>test</scope>
4.93 </dependency>
4.94 <dependency>
4.95 - <groupId>org.apidesign.bck2brwsr</groupId>
4.96 - <artifactId>vmtest</artifactId>
4.97 - <version>${bck2brwsr.version}</version>
4.98 - <scope>test</scope>
4.99 - </dependency>
4.100 - <dependency>
4.101 <groupId>org.apidesign.html</groupId>
4.102 <artifactId>net.java.html.json</artifactId>
4.103 <version>${net.java.html.version}</version>
4.104 <type>jar</type>
4.105 </dependency>
4.106 + <dependency>
4.107 + <groupId>org.apidesign.html</groupId>
4.108 + <artifactId>net.java.html.boot</artifactId>
4.109 + <version>${net.java.html.version}</version>
4.110 + <type>jar</type>
4.111 + </dependency>
4.112 + <dependency>
4.113 + <groupId>org.apidesign.html</groupId>
4.114 + <artifactId>boot-fx</artifactId>
4.115 + <version>${net.java.html.version}</version>
4.116 + <scope>runtime</scope>
4.117 + </dependency>
4.118 + <dependency>
4.119 + <groupId>org.apidesign.html</groupId>
4.120 + <artifactId>ko-fx</artifactId>
4.121 + <version>${net.java.html.version}</version>
4.122 + <scope>runtime</scope>
4.123 + </dependency>
4.124 </dependencies>
4.125 - <profiles>
4.126 - <profile>
4.127 - <id>fxbrwsr</id>
4.128 - <activation>
4.129 - <activeByDefault>true</activeByDefault>
4.130 - </activation>
4.131 - <properties>
4.132 - <brwsr>fxbrwsr</brwsr>
4.133 - </properties>
4.134 - <build>
4.135 - <plugins>
4.136 - <plugin>
4.137 - <groupId>org.apache.maven.plugins</groupId>
4.138 - <artifactId>maven-jar-plugin</artifactId>
4.139 - <version>2.4</version>
4.140 - <configuration>
4.141 - <archive>
4.142 - <manifest>
4.143 - <mainClass>org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher</mainClass>
4.144 - <addClasspath>true</addClasspath>
4.145 - <classpathPrefix>lib/</classpathPrefix>
4.146 - </manifest>
4.147 - <manifestEntries>
4.148 - <StartPage>${brwsr.startpage}</StartPage>
4.149 - </manifestEntries>
4.150 - </archive>
4.151 - </configuration>
4.152 - </plugin>
4.153 - <plugin>
4.154 - <artifactId>maven-assembly-plugin</artifactId>
4.155 - <version>2.4</version>
4.156 - <executions>
4.157 - <execution>
4.158 - <id>distro-assembly</id>
4.159 - <phase>package</phase>
4.160 - <goals>
4.161 - <goal>single</goal>
4.162 - </goals>
4.163 - <configuration>
4.164 - <descriptors>
4.165 - <descriptor>src/main/assembly/fxbrwsr.xml</descriptor>
4.166 - </descriptors>
4.167 - </configuration>
4.168 - </execution>
4.169 - </executions>
4.170 - </plugin>
4.171 - </plugins>
4.172 - </build>
4.173 - <dependencies>
4.174 - <dependency>
4.175 - <groupId>org.apidesign.html</groupId>
4.176 - <artifactId>ko-fx</artifactId>
4.177 - <version>${net.java.html.version}</version>
4.178 - </dependency>
4.179 - <dependency>
4.180 - <groupId>org.apidesign.bck2brwsr</groupId>
4.181 - <artifactId>launcher.fx</artifactId>
4.182 - <version>${bck2brwsr.version}</version>
4.183 - <scope>runtime</scope>
4.184 - </dependency>
4.185 - </dependencies>
4.186 - </profile>
4.187 - <profile>
4.188 - <id>bck2brwsr</id>
4.189 - <activation>
4.190 - <property>
4.191 - <name>brwsr</name>
4.192 - <value>bck2brwsr</value>
4.193 - </property>
4.194 - </activation>
4.195 - <build>
4.196 - <plugins>
4.197 - <plugin>
4.198 - <groupId>org.apidesign.bck2brwsr</groupId>
4.199 - <artifactId>bck2brwsr-maven-plugin</artifactId>
4.200 - <executions>
4.201 - <execution>
4.202 - <goals>
4.203 - <goal>j2js</goal>
4.204 - </goals>
4.205 - </execution>
4.206 - </executions>
4.207 - <configuration>
4.208 - <javascript>${project.build.directory}/bck2brwsr.js</javascript>
4.209 - <obfuscation>${bck2brwsr.obfuscationlevel}</obfuscation>
4.210 - </configuration>
4.211 - </plugin>
4.212 - <plugin>
4.213 - <groupId>org.apache.maven.plugins</groupId>
4.214 - <artifactId>maven-compiler-plugin</artifactId>
4.215 - <configuration>
4.216 - <compilerArguments>
4.217 - <bootclasspath>netbeans.ignore.jdk.bootclasspath</bootclasspath>
4.218 - </compilerArguments>
4.219 - </configuration>
4.220 - </plugin>
4.221 - <plugin>
4.222 - <artifactId>maven-assembly-plugin</artifactId>
4.223 - <version>2.4</version>
4.224 - <executions>
4.225 - <execution>
4.226 - <id>distro-assembly</id>
4.227 - <phase>package</phase>
4.228 - <goals>
4.229 - <goal>single</goal>
4.230 - </goals>
4.231 - <configuration>
4.232 - <descriptors>
4.233 - <descriptor>src/main/assembly/bck2brwsr.xml</descriptor>
4.234 - </descriptors>
4.235 - </configuration>
4.236 - </execution>
4.237 - </executions>
4.238 - </plugin>
4.239 - </plugins>
4.240 - </build>
4.241 - <dependencies>
4.242 - <dependency>
4.243 - <groupId>org.apidesign.bck2brwsr</groupId>
4.244 - <artifactId>emul</artifactId>
4.245 - <version>${bck2brwsr.version}</version>
4.246 - <classifier>rt</classifier>
4.247 - </dependency>
4.248 - <dependency>
4.249 - <groupId>org.apidesign.html</groupId>
4.250 - <artifactId>ko-bck2brwsr</artifactId>
4.251 - <version>${net.java.html.version}</version>
4.252 - <scope>runtime</scope>
4.253 - </dependency>
4.254 - <dependency>
4.255 - <groupId>org.apidesign.bck2brwsr</groupId>
4.256 - <artifactId>launcher.http</artifactId>
4.257 - <version>${bck2brwsr.version}</version>
4.258 - <scope>test</scope>
4.259 - </dependency>
4.260 - </dependencies>
4.261 - </profile>
4.262 - </profiles>
4.263 </project>
5.1 --- a/twitter/src/main/assembly/bck2brwsr.xml Tue Aug 13 17:00:13 2013 +0200
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,68 +0,0 @@
5.4 -<?xml version="1.0"?>
5.5 -<!--
5.6 -
5.7 - The MIT License (MIT)
5.8 -
5.9 - Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5.10 -
5.11 - Permission is hereby granted, free of charge, to any person obtaining a copy
5.12 - of this software and associated documentation files (the "Software"), to deal
5.13 - in the Software without restriction, including without limitation the rights
5.14 - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5.15 - copies of the Software, and to permit persons to whom the Software is
5.16 - furnished to do so, subject to the following conditions:
5.17 -
5.18 - The above copyright notice and this permission notice shall be included in
5.19 - all copies or substantial portions of the Software.
5.20 -
5.21 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5.22 - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5.23 - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5.24 - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5.25 - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5.26 - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
5.27 - THE SOFTWARE.
5.28 -
5.29 --->
5.30 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5.31 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
5.32 -
5.33 - <id>bck2brwsr</id>
5.34 - <formats>
5.35 - <format>zip</format>
5.36 - </formats>
5.37 - <baseDirectory>public_html</baseDirectory>
5.38 - <dependencySets>
5.39 - <dependencySet>
5.40 - <useProjectArtifact>false</useProjectArtifact>
5.41 - <scope>runtime</scope>
5.42 - <outputDirectory>lib</outputDirectory>
5.43 - <includes>
5.44 - <include>*:jar</include>
5.45 - <include>*:rt</include>
5.46 - </includes>
5.47 - </dependencySet>
5.48 - </dependencySets>
5.49 - <fileSets>
5.50 - <fileSet>
5.51 - <directory>${project.build.directory}/classes/org/apidesign/html/demo/twitter/</directory>
5.52 - <includes>
5.53 - <include>**/*</include>
5.54 - </includes>
5.55 - <excludes>
5.56 - <exclude>**/*.class</exclude>
5.57 - </excludes>
5.58 - <outputDirectory>/</outputDirectory>
5.59 - </fileSet>
5.60 - </fileSets>
5.61 - <files>
5.62 - <file>
5.63 - <source>${project.build.directory}/${project.build.finalName}.jar</source>
5.64 - <outputDirectory>/</outputDirectory>
5.65 - </file>
5.66 - <file>
5.67 - <source>${project.build.directory}/bck2brwsr.js</source>
5.68 - <outputDirectory>/</outputDirectory>
5.69 - </file>
5.70 - </files>
5.71 -</assembly>
5.72 \ No newline at end of file
6.1 --- a/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java Tue Aug 13 17:00:13 2013 +0200
6.2 +++ b/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterClient.java Tue Aug 13 21:11:28 2013 +0200
6.3 @@ -26,7 +26,6 @@
6.4 import java.util.Arrays;
6.5 import java.util.List;
6.6 import net.java.html.json.ComputedProperty;
6.7 -import net.java.html.json.Context;
6.8 import net.java.html.json.Function;
6.9 import net.java.html.json.Model;
6.10 import net.java.html.json.OnPropertyChange;
6.11 @@ -45,7 +44,7 @@
6.12 @Property(name="currentTweets", type=Tweet.class, array = true),
6.13 @Property(name="loading", type=boolean.class)
6.14 })
6.15 -public class TwitterClient {
6.16 +final class TwitterClient {
6.17 @Model(className = "Tweeters", properties = {
6.18 @Property(name="name", type = String.class),
6.19 @Property(name="userNames", type = String.class, array = true)
6.20 @@ -118,9 +117,8 @@
6.21 model.queryTweets("http://search.twitter.com", sb.toString());
6.22 }
6.23
6.24 - private static final Context DEFAULT = Context.findDefault(TwitterClient.class);
6.25 - static {
6.26 - final TwitterModel model = new TwitterModel(DEFAULT);
6.27 + static void init() {
6.28 + final TwitterModel model = new TwitterModel();
6.29 final List<Tweeters> svdLst = model.getSavedLists();
6.30 svdLst.add(newTweeters("API Design", "JaroslavTulach"));
6.31 svdLst.add(newTweeters("Celebrities", "JohnCleese", "MCHammer", "StephenFry", "algore", "StevenSanderson"));
6.32 @@ -161,7 +159,7 @@
6.33 final List<Tweeters> sl = model.getSavedLists();
6.34 sl.remove(findByName(sl, model.getActiveTweetersName()));
6.35 if (sl.isEmpty()) {
6.36 - final Tweeters t = new Tweeters(DEFAULT);
6.37 + final Tweeters t = new Tweeters();
6.38 t.setName("New");
6.39 sl.add(t);
6.40 }
6.41 @@ -195,11 +193,11 @@
6.42 return l;
6.43 }
6.44 }
6.45 - return list.isEmpty() ? new Tweeters(DEFAULT) : list.get(0);
6.46 + return list.isEmpty() ? new Tweeters() : list.get(0);
6.47 }
6.48
6.49 private static Tweeters newTweeters(String listName, String... userNames) {
6.50 - Tweeters t = new Tweeters(DEFAULT);
6.51 + Tweeters t = new Tweeters();
6.52 t.setName(listName);
6.53 t.getUserNames().addAll(Arrays.asList(userNames));
6.54 return t;
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/twitter/src/main/java/org/apidesign/html/demo/twitter/TwitterMain.java Tue Aug 13 21:11:28 2013 +0200
7.3 @@ -0,0 +1,47 @@
7.4 +/**
7.5 + * The MIT License (MIT)
7.6 + *
7.7 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
7.8 + *
7.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
7.10 + * of this software and associated documentation files (the "Software"), to deal
7.11 + * in the Software without restriction, including without limitation the rights
7.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7.13 + * copies of the Software, and to permit persons to whom the Software is
7.14 + * furnished to do so, subject to the following conditions:
7.15 + *
7.16 + * The above copyright notice and this permission notice shall be included in
7.17 + * all copies or substantial portions of the Software.
7.18 + *
7.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
7.25 + * THE SOFTWARE.
7.26 + */
7.27 +package org.apidesign.html.demo.twitter;
7.28 +
7.29 +import net.java.html.boot.BrowserBuilder;
7.30 +
7.31 +/** Boots browser and then performs initialization when the HTML page
7.32 + * is ready.
7.33 + *
7.34 + * @author Jaroslav Tulach <jtulach@netbeans.org>
7.35 + */
7.36 +public class TwitterMain {
7.37 + private TwitterMain() {
7.38 + }
7.39 +
7.40 + public static void main(String... args) {
7.41 + BrowserBuilder.newBrowser().loadPage("pages/index.html")
7.42 + .invoke("onPageLoad", args).loadClass(TwitterMain.class)
7.43 + .showAndWait();
7.44 + System.exit(0);
7.45 + }
7.46 +
7.47 + public static void onPageLoad(String... args) {
7.48 + TwitterClient.init();
7.49 + }
7.50 +}
8.1 --- a/twitter/src/main/resources/org/apidesign/html/demo/twitter/index.html Tue Aug 13 17:00:13 2013 +0200
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,105 +0,0 @@
8.4 -<?xml version="1.0" encoding="UTF-8"?>
8.5 -<!--
8.6 -
8.7 - The MIT License (MIT)
8.8 -
8.9 - Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
8.10 -
8.11 - Permission is hereby granted, free of charge, to any person obtaining a copy
8.12 - of this software and associated documentation files (the "Software"), to deal
8.13 - in the Software without restriction, including without limitation the rights
8.14 - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8.15 - copies of the Software, and to permit persons to whom the Software is
8.16 - furnished to do so, subject to the following conditions:
8.17 -
8.18 - The above copyright notice and this permission notice shall be included in
8.19 - all copies or substantial portions of the Software.
8.20 -
8.21 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8.22 - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8.23 - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8.24 - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8.25 - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8.26 - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
8.27 - THE SOFTWARE.
8.28 -
8.29 --->
8.30 -
8.31 -<!--
8.32 - Copied from knockout.js Twitter example:
8.33 - http://knockoutjs.com/examples/twitter.html
8.34 --->
8.35 -
8.36 -<!DOCTYPE html>
8.37 -<html xmlns="http://www.w3.org/1999/xhtml">
8.38 - <head>
8.39 - <title>Bck2Brwsr's Twitter</title>
8.40 - </head>
8.41 - <body>
8.42 - <link href='twitterExample.css' rel='Stylesheet' ></link>
8.43 -
8.44 - <style type='text/css'>
8.45 - .liveExample select { height: 1.7em; }
8.46 - .liveExample button { height: 2em; }
8.47 - </style>
8.48 -
8.49 -
8.50 - <h2>Bck2Brwsr's Twitter</h2>
8.51 -
8.52 - <p>
8.53 - This code is based on original <a href="http://knockoutjs.com/examples/twitter.html">knockout.js Twitter example</a> and
8.54 - uses almost unmodified HTML page. It just changes the model. It
8.55 - is written in Java language and it is executed using <a href="http://bck2brwsr.apidesign.org">Bck2Brwsr</a>
8.56 - virtual machine. The Java source code has about 190 lines and is available
8.57 - <a href="http://source.apidesign.org/hg/bck2brwsr/file/7fc6b7e9c982/javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClient.java">here</a>
8.58 - - in fact it may even be more dense than the original JavaScript model.
8.59 - </p>
8.60 -
8.61 - <div class='liveExample'>
8.62 - <div class='configuration'>
8.63 - <div class='listChooser'>
8.64 - <button data-bind='click: deleteList, enable: activeTweetersName'>Delete</button>
8.65 - <button data-bind='click: saveChanges, enable: hasUnsavedChanges'>Save</button>
8.66 - <select data-bind='options: savedLists, optionsValue: "name", value: activeTweetersName'> </select>
8.67 - </div>
8.68 -
8.69 - <p>Currently viewing <span data-bind='text: activeTweetersCount'> </span> user(s):</p>
8.70 - <div class='currentUsers' >
8.71 - <ul data-bind='foreach: activeTweeters'>
8.72 - <li>
8.73 - <button data-bind='click: $root.removeUser'>Remove</button>
8.74 - <div data-bind='text: $data'> </div>
8.75 - </li>
8.76 - </ul>
8.77 - </div>
8.78 -
8.79 - <form data-bind='submit: addUser'>
8.80 - <label>Add user:</label>
8.81 - <input data-bind='value: userNameToAdd, valueUpdate: "keyup", css: { invalid: !userNameToAddIsValid() }' />
8.82 - <button data-bind='enable: userNameToAddIsValid' type='submit'>Add</button>
8.83 - </form>
8.84 - </div>
8.85 - <div class='tweets'>
8.86 - <div class='loadingIndicator' data-bind="visible: loading">Loading...</div>
8.87 - <table data-bind='foreach: currentTweets' width='100%'>
8.88 - <tr>
8.89 - <td><img data-bind='attr: { src: profile_image_url }' /></td>
8.90 - <td>
8.91 - <a class='twitterUser' data-bind='attr: { href: userUrl }, text: from_user'> </a>
8.92 - <span data-bind='html: html'> </span>
8.93 - <div class='tweetInfo' data-bind='text: created_at'> </div>
8.94 - </td>
8.95 - </tr>
8.96 - </table>
8.97 - </div>
8.98 - </div>
8.99 -
8.100 - <script src="bck2brwsr.js"></script>
8.101 - <script type="text/javascript">
8.102 - var vm = bck2brwsr('demo-twitter-1.0-SNAPSHOT.jar');
8.103 - vm.loadClass('org.apidesign.html.demo.twitter.TwitterClient');
8.104 - </script>
8.105 -
8.106 -
8.107 - </body>
8.108 -</html>
9.1 --- a/twitter/src/main/resources/org/apidesign/html/demo/twitter/twitterExample.css Tue Aug 13 17:00:13 2013 +0200
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,58 +0,0 @@
9.4 -/**
9.5 - * The MIT License (MIT)
9.6 - *
9.7 - * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
9.8 - *
9.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
9.10 - * of this software and associated documentation files (the "Software"), to deal
9.11 - * in the Software without restriction, including without limitation the rights
9.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9.13 - * copies of the Software, and to permit persons to whom the Software is
9.14 - * furnished to do so, subject to the following conditions:
9.15 - *
9.16 - * The above copyright notice and this permission notice shall be included in
9.17 - * all copies or substantial portions of the Software.
9.18 - *
9.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
9.22 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
9.25 - * THE SOFTWARE.
9.26 - */
9.27 -
9.28 -
9.29 -
9.30 -/*
9.31 - Copied from knockout.js Twitter example:
9.32 - http://knockoutjs.com/examples/twitter.html
9.33 -*/
9.34 -
9.35 -.configuration, .tweets, .tweets td { font-family: Verdana; font-size: 13px; }
9.36 -.configuration { background-color: #DEDEDE; border: 2px solid gray; float:left; height: 40em; width: 40%; padding: 0.5em; border-right-width:0; }
9.37 -.tweets { width: 55%; border: 2px solid gray; height: 40em; overflow: scroll; overflow-x: hidden; background-color: Black; color: White; padding: 0.5em; position: relative; }
9.38 -.tweets table { border-width: 0;}
9.39 -.tweets tr { vertical-align: top; }
9.40 -.tweets td { padding: 0.4em 0.3em 1em 0.4em; border-width: 0; }
9.41 -.tweets img { width: 4em; }
9.42 -.tweetInfo { color: Gray; font-size: 0.9em; }
9.43 -.twitterUser { color: #77AAFF; text-decoration: none; font-size: 1.1em; font-weight: bold; }
9.44 -input.invalid { border: 1px solid red !important; background-color: #FFAAAA !important; }
9.45 -
9.46 -.listChooser select, .listChooser button { vertical-align:top; }
9.47 -.listChooser select { width: 60%; font-size:1.2em; height:1.4em; }
9.48 -.listChooser button { width: 19%; height:1.68em; float:right; }
9.49 -
9.50 -.currentUsers { height: 28em; overflow-y: auto; overflow-x: hidden; }
9.51 -.currentUsers button { float: right; height: 2.5em; margin: 0.1em; padding-left: 1em; padding-right: 1em; }
9.52 -.currentUsers ul, .configuration li { list-style: none; margin: 0; padding: 0 }
9.53 -.currentUsers li { height: 2.4em; font-size: 1.2em; background-color: #A7D0E3; border: 1px solid gray; margin-bottom: 0.3em; -webkit-border-radius: 5px; -moz-border-radius: 5px; -webkit-box-shadow: 0 0.2em 0.5em gray; -moz-box-shadow: 0 0.2em 0.5em gray; }
9.54 -.currentUsers li div { padding: 0.6em; }
9.55 -.currentUsers li:hover { background-color: #EEC; }
9.56 -
9.57 -.configuration form label { width: 25%; display: inline-block; text-align:right; overflow: hidden; }
9.58 -.configuration form input { width:40%; font-size: 1.3em; border:1px solid silver; background-color: White; padding: 0.1em; }
9.59 -.configuration form button { width: 20%; margin-left: 0.3em; height: 2em; }
9.60 -
9.61 -.loadingIndicator { position: absolute; top: 0.1em; left: 0.1em; font: 0.8em Arial; background-color: #229; color: White; padding: 0.2em 0.5em 0.2em 0.5em; }
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/twitter/src/main/webapp/pages/index.html Tue Aug 13 21:11:28 2013 +0200
10.3 @@ -0,0 +1,97 @@
10.4 +<?xml version="1.0" encoding="UTF-8"?>
10.5 +<!--
10.6 +
10.7 + The MIT License (MIT)
10.8 +
10.9 + Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
10.10 +
10.11 + Permission is hereby granted, free of charge, to any person obtaining a copy
10.12 + of this software and associated documentation files (the "Software"), to deal
10.13 + in the Software without restriction, including without limitation the rights
10.14 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10.15 + copies of the Software, and to permit persons to whom the Software is
10.16 + furnished to do so, subject to the following conditions:
10.17 +
10.18 + The above copyright notice and this permission notice shall be included in
10.19 + all copies or substantial portions of the Software.
10.20 +
10.21 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10.22 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10.23 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10.24 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10.25 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10.26 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
10.27 + THE SOFTWARE.
10.28 +
10.29 +-->
10.30 +
10.31 +<!--
10.32 + Copied from knockout.js Twitter example:
10.33 + http://knockoutjs.com/examples/twitter.html
10.34 +-->
10.35 +
10.36 +<!DOCTYPE html>
10.37 +<html xmlns="http://www.w3.org/1999/xhtml">
10.38 + <head>
10.39 + <title>Html and Java Twitter</title>
10.40 + </head>
10.41 + <body>
10.42 + <link href='twitterExample.css' rel='Stylesheet' ></link>
10.43 +
10.44 + <style type='text/css'>
10.45 + .liveExample select { height: 1.7em; }
10.46 + .liveExample button { height: 2em; }
10.47 + </style>
10.48 +
10.49 +
10.50 + <h2>Bck2Brwsr's Twitter</h2>
10.51 +
10.52 + <p>
10.53 + This code is based on original <a href="http://knockoutjs.com/examples/twitter.html">knockout.js Twitter example</a> and
10.54 + uses almost unmodified HTML page. It just changes the model. It
10.55 + is written in Java language and it is executed using the HotSpot
10.56 + virtual machine. The Java source code has about 190 lines and is available
10.57 + <a href="http://source.apidesign.org/hg/bck2brwsr/file/7fc6b7e9c982/javaquery/demo-twitter/src/main/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClient.java">here</a>
10.58 + - in fact it may even be more dense than the original JavaScript model.
10.59 + </p>
10.60 +
10.61 + <div class='liveExample'>
10.62 + <div class='configuration'>
10.63 + <div class='listChooser'>
10.64 + <button data-bind='click: deleteList, enable: activeTweetersName'>Delete</button>
10.65 + <button data-bind='click: saveChanges, enable: hasUnsavedChanges'>Save</button>
10.66 + <select data-bind='options: savedLists, optionsValue: "name", value: activeTweetersName'> </select>
10.67 + </div>
10.68 +
10.69 + <p>Currently viewing <span data-bind='text: activeTweetersCount'> </span> user(s):</p>
10.70 + <div class='currentUsers' >
10.71 + <ul data-bind='foreach: activeTweeters'>
10.72 + <li>
10.73 + <button data-bind='click: $root.removeUser'>Remove</button>
10.74 + <div data-bind='text: $data'> </div>
10.75 + </li>
10.76 + </ul>
10.77 + </div>
10.78 +
10.79 + <form data-bind='submit: addUser'>
10.80 + <label>Add user:</label>
10.81 + <input data-bind='value: userNameToAdd, valueUpdate: "keyup", css: { invalid: !userNameToAddIsValid() }' />
10.82 + <button data-bind='enable: userNameToAddIsValid' type='submit'>Add</button>
10.83 + </form>
10.84 + </div>
10.85 + <div class='tweets'>
10.86 + <div class='loadingIndicator' data-bind="visible: loading">Loading...</div>
10.87 + <table data-bind='foreach: currentTweets' width='100%'>
10.88 + <tr>
10.89 + <td><img data-bind='attr: { src: profile_image_url }' /></td>
10.90 + <td>
10.91 + <a class='twitterUser' data-bind='attr: { href: userUrl }, text: from_user'> </a>
10.92 + <span data-bind='html: html'> </span>
10.93 + <div class='tweetInfo' data-bind='text: created_at'> </div>
10.94 + </td>
10.95 + </tr>
10.96 + </table>
10.97 + </div>
10.98 + </div>
10.99 + </body>
10.100 +</html>
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/twitter/src/main/webapp/pages/twitterExample.css Tue Aug 13 21:11:28 2013 +0200
11.3 @@ -0,0 +1,58 @@
11.4 +/**
11.5 + * The MIT License (MIT)
11.6 + *
11.7 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
11.8 + *
11.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
11.10 + * of this software and associated documentation files (the "Software"), to deal
11.11 + * in the Software without restriction, including without limitation the rights
11.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11.13 + * copies of the Software, and to permit persons to whom the Software is
11.14 + * furnished to do so, subject to the following conditions:
11.15 + *
11.16 + * The above copyright notice and this permission notice shall be included in
11.17 + * all copies or substantial portions of the Software.
11.18 + *
11.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
11.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
11.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
11.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11.25 + * THE SOFTWARE.
11.26 + */
11.27 +
11.28 +
11.29 +
11.30 +/*
11.31 + Copied from knockout.js Twitter example:
11.32 + http://knockoutjs.com/examples/twitter.html
11.33 +*/
11.34 +
11.35 +.configuration, .tweets, .tweets td { font-family: Verdana; font-size: 13px; }
11.36 +.configuration { background-color: #DEDEDE; border: 2px solid gray; float:left; height: 40em; width: 40%; padding: 0.5em; border-right-width:0; }
11.37 +.tweets { width: 55%; border: 2px solid gray; height: 40em; overflow: scroll; overflow-x: hidden; background-color: Black; color: White; padding: 0.5em; position: relative; }
11.38 +.tweets table { border-width: 0;}
11.39 +.tweets tr { vertical-align: top; }
11.40 +.tweets td { padding: 0.4em 0.3em 1em 0.4em; border-width: 0; }
11.41 +.tweets img { width: 4em; }
11.42 +.tweetInfo { color: Gray; font-size: 0.9em; }
11.43 +.twitterUser { color: #77AAFF; text-decoration: none; font-size: 1.1em; font-weight: bold; }
11.44 +input.invalid { border: 1px solid red !important; background-color: #FFAAAA !important; }
11.45 +
11.46 +.listChooser select, .listChooser button { vertical-align:top; }
11.47 +.listChooser select { width: 60%; font-size:1.2em; height:1.4em; }
11.48 +.listChooser button { width: 19%; height:1.68em; float:right; }
11.49 +
11.50 +.currentUsers { height: 28em; overflow-y: auto; overflow-x: hidden; }
11.51 +.currentUsers button { float: right; height: 2.5em; margin: 0.1em; padding-left: 1em; padding-right: 1em; }
11.52 +.currentUsers ul, .configuration li { list-style: none; margin: 0; padding: 0 }
11.53 +.currentUsers li { height: 2.4em; font-size: 1.2em; background-color: #A7D0E3; border: 1px solid gray; margin-bottom: 0.3em; -webkit-border-radius: 5px; -moz-border-radius: 5px; -webkit-box-shadow: 0 0.2em 0.5em gray; -moz-box-shadow: 0 0.2em 0.5em gray; }
11.54 +.currentUsers li div { padding: 0.6em; }
11.55 +.currentUsers li:hover { background-color: #EEC; }
11.56 +
11.57 +.configuration form label { width: 25%; display: inline-block; text-align:right; overflow: hidden; }
11.58 +.configuration form input { width:40%; font-size: 1.3em; border:1px solid silver; background-color: White; padding: 0.1em; }
11.59 +.configuration form button { width: 20%; margin-left: 0.3em; height: 2em; }
11.60 +
11.61 +.loadingIndicator { position: absolute; top: 0.1em; left: 0.1em; font: 0.8em Arial; background-color: #229; color: White; padding: 0.2em 0.5em 0.2em 0.5em; }
12.1 --- a/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java Tue Aug 13 17:00:13 2013 +0200
12.2 +++ b/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java Tue Aug 13 21:11:28 2013 +0200
12.3 @@ -23,9 +23,7 @@
12.4 */
12.5 package org.apidesign.html.demo.twitter;
12.6
12.7 -import org.apidesign.html.demo.twitter.TwitterClient;
12.8 import java.util.List;
12.9 -import net.java.html.json.Context;
12.10 import static org.testng.Assert.*;
12.11 import org.testng.annotations.BeforeMethod;
12.12 import org.testng.annotations.Test;
12.13 @@ -40,12 +38,12 @@
12.14
12.15 @BeforeMethod
12.16 public void initModel() {
12.17 - model = new TwitterModel(Context.EMPTY);
12.18 + model = new TwitterModel();
12.19 }
12.20
12.21 @Test public void testIsValidToAdd() {
12.22 model.setUserNameToAdd("Joe");
12.23 - Tweeters t = new Tweeters(Context.EMPTY);
12.24 + Tweeters t = new Tweeters();
12.25 t.setName("test");
12.26 model.getSavedLists().add(t);
12.27 model.setActiveTweetersName("test");
13.1 --- a/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterProtocolTest.java Tue Aug 13 17:00:13 2013 +0200
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,101 +0,0 @@
13.4 -/**
13.5 - * The MIT License (MIT)
13.6 - *
13.7 - * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
13.8 - *
13.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
13.10 - * of this software and associated documentation files (the "Software"), to deal
13.11 - * in the Software without restriction, including without limitation the rights
13.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13.13 - * copies of the Software, and to permit persons to whom the Software is
13.14 - * furnished to do so, subject to the following conditions:
13.15 - *
13.16 - * The above copyright notice and this permission notice shall be included in
13.17 - * all copies or substantial portions of the Software.
13.18 - *
13.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13.22 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
13.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
13.25 - * THE SOFTWARE.
13.26 - */
13.27 -package org.apidesign.html.demo.twitter;
13.28 -
13.29 -import net.java.html.json.Context;
13.30 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
13.31 -import org.apidesign.bck2brwsr.vmtest.Http;
13.32 -import org.apidesign.bck2brwsr.vmtest.VMTest;
13.33 -import org.testng.annotations.Factory;
13.34 -
13.35 -/**
13.36 - *
13.37 - * @author Jaroslav Tulach <jtulach@netbeans.org>
13.38 - */
13.39 -public class TwitterProtocolTest {
13.40 - private TwitterModel page;
13.41 - @Http(@Http.Resource(
13.42 - path = "/search.json",
13.43 - mimeType = "application/json",
13.44 - parameters = {"callback"},
13.45 - content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\""
13.46 - + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":"
13.47 - + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\","
13.48 - + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\","
13.49 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
13.50 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344,"
13.51 - + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
13.52 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.53 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.54 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
13.55 - + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + "
13.56 - + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747,"
13.57 - + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872,"
13.58 - + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\","
13.59 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
13.60 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913,"
13.61 - + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
13.62 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.63 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.64 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
13.65 - + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"},"
13.66 - + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\","
13.67 - + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\","
13.68 - + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\","
13.69 - + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":"
13.70 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.71 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.72 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
13.73 - + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"},"
13.74 - + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,"
13.75 - + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,"
13.76 - + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":"
13.77 - + "{\"result_type\":\"recent\"},\"profile_image_url\":"
13.78 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.79 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
13.80 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
13.81 - + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100,"
13.82 - + "\"since_id\":0,\"since_id_str\":\"0\"})"
13.83 - ))
13.84 - @BrwsrTest public void readFromTwttr() throws InterruptedException {
13.85 - if (page == null) {
13.86 - page = new TwitterModel(Context.findDefault(TwitterProtocolTest.class));
13.87 - page.applyBindings();
13.88 - page.queryTweets("", "q=xyz");
13.89 - }
13.90 -
13.91 - if (page.getCurrentTweets().isEmpty()) {
13.92 - throw new InterruptedException();
13.93 - }
13.94 -
13.95 - assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets();
13.96 -
13.97 - String firstDate = page.getCurrentTweets().get(0).getCreated_at();
13.98 - assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate;
13.99 - }
13.100 -
13.101 - @Factory public static Object[] create() {
13.102 - return VMTest.create(TwitterProtocolTest.class);
13.103 - }
13.104 -}