1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/ko-archetype/pom.xml Mon May 13 11:39:33 2013 +0200
1.3 @@ -0,0 +1,88 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<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">
1.6 + <modelVersion>4.0.0</modelVersion>
1.7 + <parent>
1.8 + <artifactId>html</artifactId>
1.9 + <groupId>org.apidesign</groupId>
1.10 + <version>0.3-SNAPSHOT</version>
1.11 + </parent>
1.12 + <groupId>org.apidesign.html</groupId>
1.13 + <artifactId>knockout4j-archetype</artifactId>
1.14 + <version>0.3-SNAPSHOT</version>
1.15 + <packaging>jar</packaging>
1.16 + <name>Knockout 4 Java Maven Archetype</name>
1.17 + <description>
1.18 + HTML page with Knockout.js bindings driven by application model
1.19 + written in Java. Use your favorite language to code. Use
1.20 + HTML as a lightweight rendering toolkit. Deploy using JavaFX or
1.21 + bck2brwsr virtual machine.
1.22 + </description>
1.23 + <build>
1.24 + <resources>
1.25 + <resource>
1.26 + <directory>src/main/resources</directory>
1.27 + <filtering>true</filtering>
1.28 + <includes>
1.29 + <include>**/pom.xml</include>
1.30 + </includes>
1.31 + </resource>
1.32 + <resource>
1.33 + <directory>src/main/resources</directory>
1.34 + <filtering>false</filtering>
1.35 + <excludes>
1.36 + <exclude>**/pom.xml</exclude>
1.37 + </excludes>
1.38 + </resource>
1.39 + </resources>
1.40 + <plugins>
1.41 + <plugin>
1.42 + <groupId>org.apache.maven.plugins</groupId>
1.43 + <artifactId>maven-compiler-plugin</artifactId>
1.44 + <version>2.3.2</version>
1.45 + <configuration>
1.46 + <source>1.6</source>
1.47 + <target>1.6</target>
1.48 + </configuration>
1.49 + </plugin>
1.50 + <plugin>
1.51 + <groupId>org.apache.maven.plugins</groupId>
1.52 + <artifactId>maven-resources-plugin</artifactId>
1.53 + <version>2.6</version>
1.54 + <configuration>
1.55 + <escapeString>\</escapeString>
1.56 + <target>1.6</target>
1.57 + </configuration>
1.58 + </plugin>
1.59 + <plugin>
1.60 + <groupId>org.apache.maven.plugins</groupId>
1.61 + <artifactId>maven-surefire-plugin</artifactId>
1.62 + <configuration>
1.63 + <skipTests>true</skipTests>
1.64 + </configuration>
1.65 + <executions>
1.66 + <execution>
1.67 + <id>test</id>
1.68 + <goals>
1.69 + <goal>test</goal>
1.70 + </goals>
1.71 + <phase>integration-test</phase>
1.72 + <configuration>
1.73 + <additionalClasspathElements>
1.74 + <additionalClasspathElement>${project.build.directory}/knockout4j-archetype-${project.version}.jar</additionalClasspathElement>
1.75 + </additionalClasspathElements>
1.76 + <skipTests>false</skipTests>
1.77 + </configuration>
1.78 + </execution>
1.79 +
1.80 + </executions>
1.81 + </plugin>
1.82 + </plugins>
1.83 + </build>
1.84 + <dependencies>
1.85 + <dependency>
1.86 + <groupId>org.testng</groupId>
1.87 + <artifactId>testng</artifactId>
1.88 + <scope>test</scope>
1.89 + </dependency>
1.90 + </dependencies>
1.91 +</project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/ko-archetype/src/main/java/org/apidesign/html/archetype/package-info.java Mon May 13 11:39:33 2013 +0200
2.3 @@ -0,0 +1,21 @@
2.4 +/**
2.5 + * HTML via Java(tm) Language Bindings
2.6 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
2.7 + *
2.8 + * This program is free software: you can redistribute it and/or modify
2.9 + * it under the terms of the GNU General Public License as published by
2.10 + * the Free Software Foundation, version 2 of the License.
2.11 + *
2.12 + * This program is distributed in the hope that it will be useful,
2.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.15 + * GNU General Public License for more details. apidesign.org
2.16 + * designates this particular file as subject to the
2.17 + * "Classpath" exception as provided by apidesign.org
2.18 + * in the License file that accompanied this code.
2.19 + *
2.20 + * You should have received a copy of the GNU General Public License
2.21 + * along with this program. Look for COPYING file in the top folder.
2.22 + * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
2.23 + */
2.24 +package org.apidesign.html.archetype;
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/ko-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Mon May 13 11:39:33 2013 +0200
3.3 @@ -0,0 +1,37 @@
3.4 +<?xml version="1.0" encoding="UTF-8"?>
3.5 +<archetype-descriptor name="FX/Bck2Brwsr Example">
3.6 + <fileSets>
3.7 + <fileSet filtered="true" packaged="true">
3.8 + <directory>src/main/java</directory>
3.9 + <includes>
3.10 + <include>**/App.java</include>
3.11 + </includes>
3.12 + </fileSet>
3.13 + <fileSet filtered="true" packaged="true">
3.14 + <directory>src/main/resources</directory>
3.15 + <includes>
3.16 + <include>**/*.xhtml</include>
3.17 + <include>**/*.html</include>
3.18 + </includes>
3.19 + </fileSet>
3.20 + <fileSet filtered="true" packaged="true">
3.21 + <directory>src/test/java</directory>
3.22 + <includes>
3.23 + <include>**/*Test.java</include>
3.24 + </includes>
3.25 + </fileSet>
3.26 + <fileSet filtered="false" packaged="false">
3.27 + <directory></directory>
3.28 + <includes>
3.29 + <include>nbactions*.xml</include>
3.30 + </includes>
3.31 + </fileSet>
3.32 + <fileSet filtered="true" packaged="false">
3.33 + <directory>assembly</directory>
3.34 + <includes>
3.35 + <include>fxbrwsr-assembly.xml</include>
3.36 + <include>bck2brwsr-assembly.xml</include>
3.37 + </includes>
3.38 + </fileSet>
3.39 + </fileSets>
3.40 +</archetype-descriptor>
3.41 \ No newline at end of file
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/ko-archetype/src/main/resources/archetype-resources/nbactions-bck2brwsr.xml Mon May 13 11:39:33 2013 +0200
4.3 @@ -0,0 +1,10 @@
4.4 +<?xml version="1.0" encoding="UTF-8"?>
4.5 +<actions>
4.6 + <action>
4.7 + <actionName>run</actionName>
4.8 + <goals>
4.9 + <goal>process-classes</goal>
4.10 + <goal>bck2brwsr:brwsr</goal>
4.11 + </goals>
4.12 + </action>
4.13 +</actions>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/ko-archetype/src/main/resources/archetype-resources/nbactions-fxbrwsr.xml Mon May 13 11:39:33 2013 +0200
5.3 @@ -0,0 +1,20 @@
5.4 +<?xml version="1.0" encoding="UTF-8"?>
5.5 +<actions>
5.6 + <action>
5.7 + <actionName>run</actionName>
5.8 + <goals>
5.9 + <goal>process-classes</goal>
5.10 + <goal>bck2brwsr:brwsr</goal>
5.11 + </goals>
5.12 + </action>
5.13 + <action>
5.14 + <actionName>debug</actionName>
5.15 + <goals>
5.16 + <goal>process-classes</goal>
5.17 + <goal>bck2brwsr:brwsr</goal>
5.18 + </goals>
5.19 + <properties>
5.20 + <jpda.listen>maven</jpda.listen>
5.21 + </properties>
5.22 + </action>
5.23 +</actions>
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/ko-archetype/src/main/resources/archetype-resources/nbactions.xml Mon May 13 11:39:33 2013 +0200
6.3 @@ -0,0 +1,20 @@
6.4 +<?xml version="1.0" encoding="UTF-8"?>
6.5 +<actions>
6.6 + <action>
6.7 + <actionName>run</actionName>
6.8 + <goals>
6.9 + <goal>process-classes</goal>
6.10 + <goal>bck2brwsr:brwsr</goal>
6.11 + </goals>
6.12 + </action>
6.13 + <action>
6.14 + <actionName>debug</actionName>
6.15 + <goals>
6.16 + <goal>process-classes</goal>
6.17 + <goal>bck2brwsr:brwsr</goal>
6.18 + </goals>
6.19 + <properties>
6.20 + <jpda.listen>maven</jpda.listen>
6.21 + </properties>
6.22 + </action>
6.23 +</actions>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/ko-archetype/src/main/resources/archetype-resources/pom.xml Mon May 13 11:39:33 2013 +0200
7.3 @@ -0,0 +1,265 @@
7.4 +<?xml version="1.0"?>
7.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7.6 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
7.7 + <modelVersion>4.0.0</modelVersion>
7.8 +
7.9 + <groupId>\${groupId}</groupId>
7.10 + <artifactId>\${artifactId}</artifactId>
7.11 + <version>\${version}</version>
7.12 + <packaging>jar</packaging>
7.13 +
7.14 + <name>\${artifactId}</name>
7.15 +
7.16 + <repositories>
7.17 + <repository>
7.18 + <id>java.net</id>
7.19 + <name>Java.net</name>
7.20 + <url>https://maven.java.net/content/repositories/releases/</url>
7.21 + <snapshots>
7.22 + <enabled>true</enabled>
7.23 + </snapshots>
7.24 + </repository>
7.25 + <repository>
7.26 + <id>netbeans</id>
7.27 + <name>NetBeans</name>
7.28 + <url>http://bits.netbeans.org/maven2/</url>
7.29 + </repository>
7.30 + </repositories>
7.31 + <pluginRepositories>
7.32 + <pluginRepository>
7.33 + <id>java.net</id>
7.34 + <name>Java.net</name>
7.35 + <url>https://maven.java.net/content/repositories/releases/</url>
7.36 + <snapshots>
7.37 + <enabled>true</enabled>
7.38 + </snapshots>
7.39 + </pluginRepository>
7.40 + </pluginRepositories>
7.41 +
7.42 + <properties>
7.43 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
7.44 + <net.java.html.version>${project.version}</net.java.html.version>
7.45 + <bck2brwsr.version>${bck2brwsr.version}</bck2brwsr.version>
7.46 + <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
7.47 + <brwsr.startpage>org/apidesign/html/demo/twitter/index.html</brwsr.startpage>
7.48 + </properties>
7.49 + <build>
7.50 + <plugins>
7.51 + <plugin>
7.52 + <groupId>org.apidesign.bck2brwsr</groupId>
7.53 + <artifactId>bck2brwsr-maven-plugin</artifactId>
7.54 + <version>\${bck2brwsr.version}</version>
7.55 + <executions>
7.56 + <execution>
7.57 + <goals>
7.58 + <goal>brwsr</goal>
7.59 + </goals>
7.60 + </execution>
7.61 + </executions>
7.62 + <configuration>
7.63 + <startpage>\${brwsr.startpage}</startpage>
7.64 + <launcher>\${brwsr}</launcher>
7.65 + </configuration>
7.66 + </plugin>
7.67 + <plugin>
7.68 + <groupId>org.apache.maven.plugins</groupId>
7.69 + <artifactId>maven-compiler-plugin</artifactId>
7.70 + <version>2.3.2</version>
7.71 + <configuration>
7.72 + <source>1.7</source>
7.73 + <target>1.7</target>
7.74 + </configuration>
7.75 + </plugin>
7.76 + <plugin>
7.77 + <groupId>org.apache.maven.plugins</groupId>
7.78 + <artifactId>maven-surefire-plugin</artifactId>
7.79 + <version>2.14.1</version>
7.80 + <configuration>
7.81 + <systemPropertyVariables>
7.82 + <vmtest.brwsrs>\${brwsr}</vmtest.brwsrs>
7.83 + </systemPropertyVariables>
7.84 + </configuration>
7.85 + </plugin>
7.86 + <plugin>
7.87 + <groupId>org.apache.maven.plugins</groupId>
7.88 + <artifactId>maven-jar-plugin</artifactId>
7.89 + <version>2.4</version>
7.90 + <configuration>
7.91 + <archive>
7.92 + <manifest>
7.93 + <addClasspath>true</addClasspath>
7.94 + <classpathPrefix>lib/</classpathPrefix>
7.95 + </manifest>
7.96 + </archive>
7.97 + </configuration>
7.98 + </plugin>
7.99 + <plugin>
7.100 + <groupId>org.apache.maven.plugins</groupId>
7.101 + <artifactId>maven-deploy-plugin</artifactId>
7.102 + <version>2.7</version>
7.103 + <configuration>
7.104 + <skip>true</skip>
7.105 + </configuration>
7.106 + </plugin>
7.107 + </plugins>
7.108 + </build>
7.109 +
7.110 + <dependencies>
7.111 + <dependency>
7.112 + <groupId>org.testng</groupId>
7.113 + <artifactId>testng</artifactId>
7.114 + <version>6.5.2</version>
7.115 + <scope>test</scope>
7.116 + </dependency>
7.117 + <dependency>
7.118 + <groupId>org.apidesign.bck2brwsr</groupId>
7.119 + <artifactId>vmtest</artifactId>
7.120 + <version>\${bck2brwsr.version}</version>
7.121 + <scope>test</scope>
7.122 + </dependency>
7.123 + <dependency>
7.124 + <groupId>org.apidesign.html</groupId>
7.125 + <artifactId>net.java.html.json</artifactId>
7.126 + <version>\${net.java.html.version}</version>
7.127 + <type>jar</type>
7.128 + </dependency>
7.129 + </dependencies>
7.130 + <profiles>
7.131 + <profile>
7.132 + <id>fxbrwsr</id>
7.133 + <activation>
7.134 + <activeByDefault>true</activeByDefault>
7.135 + </activation>
7.136 + <properties>
7.137 + <brwsr>fxbrwsr</brwsr>
7.138 + </properties>
7.139 + <build>
7.140 + <plugins>
7.141 + <plugin>
7.142 + <groupId>org.apache.maven.plugins</groupId>
7.143 + <artifactId>maven-jar-plugin</artifactId>
7.144 + <version>2.4</version>
7.145 + <configuration>
7.146 + <archive>
7.147 + <manifest>
7.148 + <mainClass>org.apidesign.bck2brwsr.launcher.FXBrwsrLauncher</mainClass>
7.149 + <addClasspath>true</addClasspath>
7.150 + <classpathPrefix>lib/</classpathPrefix>
7.151 + </manifest>
7.152 + <manifestEntries>
7.153 + <StartPage>\${brwsr.startpage}</StartPage>
7.154 + </manifestEntries>
7.155 + </archive>
7.156 + </configuration>
7.157 + </plugin>
7.158 + <plugin>
7.159 + <artifactId>maven-assembly-plugin</artifactId>
7.160 + <version>2.4</version>
7.161 + <executions>
7.162 + <execution>
7.163 + <id>distro-assembly</id>
7.164 + <phase>package</phase>
7.165 + <goals>
7.166 + <goal>single</goal>
7.167 + </goals>
7.168 + <configuration>
7.169 + <descriptors>
7.170 + <descriptor>src/main/assembly/fxbrwsr.xml</descriptor>
7.171 + </descriptors>
7.172 + </configuration>
7.173 + </execution>
7.174 + </executions>
7.175 + </plugin>
7.176 + </plugins>
7.177 + </build>
7.178 + <dependencies>
7.179 + <dependency>
7.180 + <groupId>org.apidesign.html</groupId>
7.181 + <artifactId>ko-fx</artifactId>
7.182 + <version>\${net.java.html.version}</version>
7.183 + </dependency>
7.184 + <dependency>
7.185 + <groupId>org.apidesign.bck2brwsr</groupId>
7.186 + <artifactId>launcher.fx</artifactId>
7.187 + <version>\${bck2brwsr.version}</version>
7.188 + <scope>runtime</scope>
7.189 + </dependency>
7.190 + </dependencies>
7.191 + </profile>
7.192 + <profile>
7.193 + <id>bck2brwsr</id>
7.194 + <activation>
7.195 + <property>
7.196 + <name>brwsr</name>
7.197 + <value>bck2brwsr</value>
7.198 + </property>
7.199 + </activation>
7.200 + <build>
7.201 + <plugins>
7.202 + <plugin>
7.203 + <groupId>org.apidesign.bck2brwsr</groupId>
7.204 + <artifactId>bck2brwsr-maven-plugin</artifactId>
7.205 + <executions>
7.206 + <execution>
7.207 + <goals>
7.208 + <goal>j2js</goal>
7.209 + </goals>
7.210 + </execution>
7.211 + </executions>
7.212 + <configuration>
7.213 + <javascript>\${project.build.directory}/bck2brwsr.js</javascript>
7.214 + <obfuscation>\${bck2brwsr.obfuscationlevel}</obfuscation>
7.215 + </configuration>
7.216 + </plugin>
7.217 + <plugin>
7.218 + <groupId>org.apache.maven.plugins</groupId>
7.219 + <artifactId>maven-compiler-plugin</artifactId>
7.220 + <configuration>
7.221 + <compilerArguments>
7.222 + <bootclasspath>netbeans.ignore.jdk.bootclasspath</bootclasspath>
7.223 + </compilerArguments>
7.224 + </configuration>
7.225 + </plugin>
7.226 + <plugin>
7.227 + <artifactId>maven-assembly-plugin</artifactId>
7.228 + <version>2.4</version>
7.229 + <executions>
7.230 + <execution>
7.231 + <id>distro-assembly</id>
7.232 + <phase>package</phase>
7.233 + <goals>
7.234 + <goal>single</goal>
7.235 + </goals>
7.236 + <configuration>
7.237 + <descriptors>
7.238 + <descriptor>src/main/assembly/bck2brwsr.xml</descriptor>
7.239 + </descriptors>
7.240 + </configuration>
7.241 + </execution>
7.242 + </executions>
7.243 + </plugin>
7.244 + </plugins>
7.245 + </build>
7.246 + <dependencies>
7.247 + <dependency>
7.248 + <groupId>org.apidesign.bck2brwsr</groupId>
7.249 + <artifactId>emul</artifactId>
7.250 + <version>\${bck2brwsr.version}</version>
7.251 + <classifier>rt</classifier>
7.252 + </dependency>
7.253 + <dependency>
7.254 + <groupId>org.apidesign.html</groupId>
7.255 + <artifactId>ko-bck2brwsr</artifactId>
7.256 + <version>\${net.java.html.version}</version>
7.257 + <scope>runtime</scope>
7.258 + </dependency>
7.259 + <dependency>
7.260 + <groupId>org.apidesign.bck2brwsr</groupId>
7.261 + <artifactId>launcher.http</artifactId>
7.262 + <version>\${bck2brwsr.version}</version>
7.263 + <scope>test</scope>
7.264 + </dependency>
7.265 + </dependencies>
7.266 + </profile>
7.267 + </profiles>
7.268 +</project>
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/ko-archetype/src/main/resources/archetype-resources/src/main/assembly/bck2brwsr.xml Mon May 13 11:39:33 2013 +0200
8.3 @@ -0,0 +1,43 @@
8.4 +<?xml version="1.0"?>
8.5 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8.6 + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
8.7 +
8.8 + <id>bck2brwsr</id>
8.9 + <formats>
8.10 + <format>zip</format>
8.11 + </formats>
8.12 + <baseDirectory>public_html</baseDirectory>
8.13 + <dependencySets>
8.14 + <dependencySet>
8.15 + <useProjectArtifact>false</useProjectArtifact>
8.16 + <scope>runtime</scope>
8.17 + <outputDirectory>lib</outputDirectory>
8.18 + <includes>
8.19 + <include>*:jar</include>
8.20 + <include>*:rt</include>
8.21 + </includes>
8.22 + </dependencySet>
8.23 + </dependencySets>
8.24 + <fileSets>
8.25 + <fileSet>
8.26 + <directory>${project.build.directory}/classes/org/apidesign/html/demo/twitter/</directory>
8.27 + <includes>
8.28 + <include>**/*</include>
8.29 + </includes>
8.30 + <excludes>
8.31 + <exclude>**/*.class</exclude>
8.32 + </excludes>
8.33 + <outputDirectory>/</outputDirectory>
8.34 + </fileSet>
8.35 + </fileSets>
8.36 + <files>
8.37 + <file>
8.38 + <source>${project.build.directory}/${project.build.finalName}.jar</source>
8.39 + <outputDirectory>/</outputDirectory>
8.40 + </file>
8.41 + <file>
8.42 + <source>${project.build.directory}/bck2brwsr.js</source>
8.43 + <outputDirectory>/</outputDirectory>
8.44 + </file>
8.45 + </files>
8.46 +</assembly>
8.47 \ No newline at end of file
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/ko-archetype/src/main/resources/archetype-resources/src/main/assembly/fxbrwsr.xml Mon May 13 11:39:33 2013 +0200
9.3 @@ -0,0 +1,23 @@
9.4 +<?xml version="1.0"?>
9.5 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9.6 + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
9.7 +
9.8 + <id>fxbrwsr</id>
9.9 + <formats>
9.10 + <format>zip</format>
9.11 + </formats>
9.12 + <baseDirectory>${project.build.finalName}-fxbrwsr</baseDirectory>
9.13 + <dependencySets>
9.14 + <dependencySet>
9.15 + <useProjectArtifact>false</useProjectArtifact>
9.16 + <scope>runtime</scope>
9.17 + <outputDirectory>lib</outputDirectory>
9.18 + </dependencySet>
9.19 + </dependencySets>
9.20 + <files>
9.21 + <file>
9.22 + <source>${project.build.directory}/${project.build.finalName}.jar</source>
9.23 + <outputDirectory>/</outputDirectory>
9.24 + </file>
9.25 + </files>
9.26 +</assembly>
9.27 \ No newline at end of file
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/ko-archetype/src/main/resources/archetype-resources/src/main/java/App.java Mon May 13 11:39:33 2013 +0200
10.3 @@ -0,0 +1,88 @@
10.4 +package ${package};
10.5 +
10.6 +import java.util.List;
10.7 +import org.apidesign.bck2brwsr.htmlpage.api.*;
10.8 +import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;
10.9 +import org.apidesign.bck2brwsr.htmlpage.api.Page;
10.10 +import org.apidesign.bck2brwsr.htmlpage.api.Property;
10.11 +import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
10.12 +
10.13 +/** This is the controller class for associated index.html page. The <code>Index</code>
10.14 + * is autogenerated by parsing the index.html page. It fields represent individual
10.15 + * elements annotated by "id" in the page.
10.16 + */
10.17 +@Page(xhtml="index.html", className="Index", properties={
10.18 + @Property(name="name", type=String.class),
10.19 + @Property(name="messages", type=String.class, array=true),
10.20 +})
10.21 +public class App {
10.22 + static {
10.23 + Index model = new Index();
10.24 + model.setName("World");
10.25 + model.applyBindings();
10.26 + }
10.27 +
10.28 + /**
10.29 + * @param m the model of the index page creates in static initializer
10.30 + */
10.31 + @On(event = CLICK, id="hello")
10.32 + static void hello(Index m) {
10.33 + display(m.getHelloMessage(), m);
10.34 + m.getMessages().add(m.getHelloMessage());
10.35 + }
10.36 +
10.37 + /** Reacts when mouse moves over the canvas.
10.38 + *
10.39 + * @param m the model of the page
10.40 + * @param x property "x" extracted from the event generated by the browser
10.41 + * @param y property "y" from the mouse event
10.42 + */
10.43 + @On(event = MOUSE_MOVE, id="canvas")
10.44 + static void clearPoint(Index m, int x, int y) {
10.45 + GraphicsContext g = m.canvas.getContext();
10.46 + boolean even = (x + y) % 2 == 0;
10.47 + if (even) {
10.48 + g.setFillStyle("blue");
10.49 + } else {
10.50 + g.setFillStyle("red");
10.51 + }
10.52 + g.clearRect(0, 0, 1000, 1000);
10.53 + g.setFont("italic 40px Calibri");
10.54 + g.fillText(m.getHelloMessage(), 10, 40);
10.55 + }
10.56 +
10.57 + /** Callback function called by the KnockOut/Java binding on elements
10.58 + * representing href's with individual messages being their data.
10.59 + *
10.60 + * @param data the data associated with the element
10.61 + * @param m the model of the page
10.62 + */
10.63 + @OnFunction
10.64 + static void display(String data, Index m) {
10.65 + GraphicsContext g = m.canvas.getContext();
10.66 + g.clearRect(0, 0, 1000, 1000);
10.67 + g.setFillStyle("black");
10.68 + g.setFont("italic 40px Calibri");
10.69 + g.fillText(data, 10, 40);
10.70 + }
10.71 +
10.72 + /** Callback function.
10.73 + *
10.74 + * @param data data associated with the actual element on the page
10.75 + * @param m the model of the page
10.76 + */
10.77 + @OnFunction
10.78 + static void remove(String data, Index m) {
10.79 + m.getMessages().remove(data);
10.80 + }
10.81 +
10.82 + @ComputedProperty
10.83 + static String helloMessage(String name) {
10.84 + return "Hello " + name + "!";
10.85 + }
10.86 +
10.87 + @ComputedProperty
10.88 + static boolean noMessages(List<String> messages) {
10.89 + return messages.isEmpty();
10.90 + }
10.91 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/ko-archetype/src/main/resources/archetype-resources/src/main/resources/index.html Mon May 13 11:39:33 2013 +0200
11.3 @@ -0,0 +1,31 @@
11.4 +<?xml version="1.0" encoding="UTF-8"?>
11.5 +<!DOCTYPE html>
11.6 +<html xmlns="http://www.w3.org/1999/xhtml">
11.7 + <head>
11.8 + <title>Bck2Brwsr's Hello World</title>
11.9 + </head>
11.10 + <body>
11.11 + <h1 data-bind="text: helloMessage">Loading Bck2Brwsr's Hello World...</h1>
11.12 + Your name: <input id='input' data-bind="value: name, valueUpdate: 'afterkeydown'"></input>
11.13 + <button id="hello">Say Hello!</button>
11.14 + <p>
11.15 + <canvas id="canvas" width="300" height="50">
11.16 + </canvas>
11.17 + </p>
11.18 +
11.19 +
11.20 + <div data-bind="if: noMessages">No message displayed yet.</div>
11.21 + <ul data-bind="foreach: messages">
11.22 + <li>
11.23 + <a href="#" data-bind="text: $data, click: $root.display"></a>
11.24 + (<a href="#" data-bind="click: $root.remove">delete</a>)
11.25 + </li>
11.26 + </ul>
11.27 +
11.28 + <script src="bck2brwsr.js"></script>
11.29 + <script type="text/javascript">
11.30 + var vm = bck2brwsr('${artifactId}-${version}.jar');
11.31 + vm.loadClass('${package}.App');
11.32 + </script>
11.33 + </body>
11.34 +</html>
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/ko-archetype/src/main/resources/archetype-resources/src/test/java/AppTest.java Mon May 13 11:39:33 2013 +0200
12.3 @@ -0,0 +1,26 @@
12.4 +package ${package};
12.5 +
12.6 +import static org.testng.Assert.*;
12.7 +import org.testng.annotations.BeforeMethod;
12.8 +import org.testng.annotations.Test;
12.9 +
12.10 +/** Demonstrating POJO testing of HTML page model. Runs in good old HotSpot
12.11 + * as it does not reference any HTML elements or browser functionality. Just
12.12 + * operates on the page model.
12.13 + *
12.14 + * @author Jaroslav Tulach <jtulach@netbeans.org>
12.15 + */
12.16 +public class AppTest {
12.17 + private Index model;
12.18 +
12.19 +
12.20 + @BeforeMethod
12.21 + public void initModel() {
12.22 + model = new Index().applyBindings();
12.23 + }
12.24 +
12.25 + @Test public void testHelloMessage() {
12.26 + model.setName("Joe");
12.27 + assertEquals(model.getHelloMessage(), "Hello Joe!", "Cleared after pressing +");
12.28 + }
12.29 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/ko-archetype/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Mon May 13 11:39:33 2013 +0200
13.3 @@ -0,0 +1,40 @@
13.4 +package ${package};
13.5 +
13.6 +import org.apidesign.bck2brwsr.vmtest.Compare;
13.7 +import org.apidesign.bck2brwsr.vmtest.VMTest;
13.8 +import org.testng.annotations.Factory;
13.9 +
13.10 +/** Bck2brwsr cares about compatibility with real Java. Whatever API is
13.11 + * supported by bck2brwsr, it needs to behave the same way as when running
13.12 + * in HotSpot VM.
13.13 + * <p>
13.14 + * There can be bugs, however. To help us fix them, we kindly ask you to
13.15 + * write an "inconsistency" test. A test that compares behavior of the API
13.16 + * between real VM and bck2brwsr VM. This class is skeleton of such test.
13.17 + *
13.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
13.19 + */
13.20 +public class InconsistencyTest {
13.21 + /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
13.22 + * Make calls to an API that behaves strangely, return some result at
13.23 + * the end. No need to use any <code>assert</code>.
13.24 + *
13.25 + * @return value to compare between HotSpot and bck2brwsr
13.26 + */
13.27 + @Compare
13.28 + public int checkStringHashCode() throws Exception {
13.29 + return "Is string hashCode the same?".hashCode();
13.30 + }
13.31 +
13.32 + /** Factory method that creates a three tests for each method annotated with
13.33 + * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
13.34 + * HotSpot, one in Rhino and the last one compares the results.
13.35 + *
13.36 + * @see org.apidesign.bck2brwsr.vmtest.VMTest
13.37 + */
13.38 + @Factory
13.39 + public static Object[] create() {
13.40 + return VMTest.create(InconsistencyTest.class);
13.41 + }
13.42 +
13.43 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/ko-archetype/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java Mon May 13 11:39:33 2013 +0200
14.3 @@ -0,0 +1,46 @@
14.4 +package ${package};
14.5 +
14.6 +import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
14.7 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
14.8 +import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
14.9 +import org.apidesign.bck2brwsr.vmtest.VMTest;
14.10 +import org.testng.annotations.Factory;
14.11 +
14.12 +/** Sometimes it is useful to run tests inside of the real browser.
14.13 + * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
14.14 + * and that is it. If your code references elements on the HTML page,
14.15 + * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
14.16 + * will be made available on the page before your test starts.
14.17 + *
14.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
14.19 + */
14.20 +public class IntegrationTest {
14.21 +
14.22 + /** Write to testing code here. Use <code>assert</code> (but not TestNG's
14.23 + * Assert, as TestNG is not compiled with target 1.6 yet).
14.24 + */
14.25 + @HtmlFragment(
14.26 + "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
14.27 + "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
14.28 + "<button id=\"hello\">Say Hello!</button>\n" +
14.29 + "<p>\n" +
14.30 + " <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
14.31 + "</p>\n"
14.32 + )
14.33 + @BrwsrTest
14.34 + public void modifyValueAssertChangeInModel() {
14.35 + Index m = new Index();
14.36 + m.setName("Joe Hacker");
14.37 + m.applyBindings();
14.38 + assert "Joe Hacker".equals(m.input.getValue()) : "Value is really Joe Hacker: " + m.input.getValue();
14.39 + m.input.setValue("Happy Joe");
14.40 + m.triggerEvent(m.input, OnEvent.CHANGE);
14.41 + assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
14.42 + }
14.43 +
14.44 + @Factory
14.45 + public static Object[] create() {
14.46 + return VMTest.create(IntegrationTest.class);
14.47 + }
14.48 +
14.49 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/ko-archetype/src/test/java/org/apidesign/html/archetype/ArchetypeVersionTest.java Mon May 13 11:39:33 2013 +0200
15.3 @@ -0,0 +1,98 @@
15.4 +/**
15.5 + * HTML via Java(tm) Language Bindings
15.6 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
15.7 + *
15.8 + * This program is free software: you can redistribute it and/or modify
15.9 + * it under the terms of the GNU General Public License as published by
15.10 + * the Free Software Foundation, version 2 of the License.
15.11 + *
15.12 + * This program is distributed in the hope that it will be useful,
15.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.15 + * GNU General Public License for more details. apidesign.org
15.16 + * designates this particular file as subject to the
15.17 + * "Classpath" exception as provided by apidesign.org
15.18 + * in the License file that accompanied this code.
15.19 + *
15.20 + * You should have received a copy of the GNU General Public License
15.21 + * along with this program. Look for COPYING file in the top folder.
15.22 + * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
15.23 + */
15.24 +package org.apidesign.html.archetype;
15.25 +
15.26 +import java.net.URL;
15.27 +import javax.xml.XMLConstants;
15.28 +import javax.xml.parsers.DocumentBuilderFactory;
15.29 +import javax.xml.xpath.XPathConstants;
15.30 +import javax.xml.xpath.XPathExpression;
15.31 +import javax.xml.xpath.XPathFactory;
15.32 +import org.testng.annotations.Test;
15.33 +import static org.testng.Assert.*;
15.34 +import org.testng.annotations.BeforeClass;
15.35 +import org.w3c.dom.Document;
15.36 +import org.w3c.dom.NodeList;
15.37 +
15.38 +/**
15.39 + *
15.40 + * @author Jaroslav Tulach <jtulach@netbeans.org>
15.41 + */
15.42 +public class ArchetypeVersionTest {
15.43 + private String version;
15.44 +
15.45 + public ArchetypeVersionTest() {
15.46 + }
15.47 +
15.48 + @BeforeClass public void readCurrentVersion() throws Exception {
15.49 + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
15.50 + URL u = l.getResource("META-INF/maven/org.apidesign.html/knockout4j-archetype/pom.xml");
15.51 + assertNotNull(u, "Own pom found: " + System.getProperty("java.class.path"));
15.52 +
15.53 + final XPathFactory fact = XPathFactory.newInstance();
15.54 + fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
15.55 +
15.56 + XPathExpression xp = fact.newXPath().compile("project/version/text()");
15.57 +
15.58 + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(u.openStream());
15.59 + version = xp.evaluate(dom);
15.60 +
15.61 + assertFalse(version.isEmpty(), "There should be some version string");
15.62 + }
15.63 +
15.64 +
15.65 + @Test public void testComparePomDepsVersions() throws Exception {
15.66 + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
15.67 + URL r = l.getResource("archetype-resources/pom.xml");
15.68 + assertNotNull(r, "Archetype pom found");
15.69 +
15.70 + final XPathFactory fact = XPathFactory.newInstance();
15.71 + XPathExpression xp2 = fact.newXPath().compile(
15.72 + "//properties/net.java.html.version/text()"
15.73 + );
15.74 +
15.75 + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
15.76 + String arch = (String) xp2.evaluate(dom, XPathConstants.STRING);
15.77 +
15.78 + assertEquals(arch, version, "net.java.html.json dependency needs to be on latest version");
15.79 + }
15.80 +
15.81 + @Test public void testNbActions() throws Exception {
15.82 + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
15.83 + URL r = l.getResource("archetype-resources/nbactions.xml");
15.84 + assertNotNull(r, "Archetype nb file found");
15.85 +
15.86 + final XPathFactory fact = XPathFactory.newInstance();
15.87 + XPathExpression xp2 = fact.newXPath().compile(
15.88 + "//goal/text()"
15.89 + );
15.90 +
15.91 + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
15.92 + NodeList goals = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
15.93 +
15.94 + for (int i = 0; i < goals.getLength(); i++) {
15.95 + String s = goals.item(i).getTextContent();
15.96 + if (s.contains("apidesign")) {
15.97 + assertFalse(s.matches(".*apidesign.*[0-9].*"), "No numbers: " + s);
15.98 + }
15.99 + }
15.100 + }
15.101 +}