1.1 --- a/ko/archetype/src/main/resources/archetype-resources/pom.xml Mon Sep 09 17:34:30 2013 +0200
1.2 +++ b/ko/archetype/src/main/resources/archetype-resources/pom.xml Mon Sep 09 19:35:12 2013 +0200
1.3 @@ -114,6 +114,12 @@
1.4 <scope>test</scope>
1.5 </dependency>
1.6 <dependency>
1.7 + <groupId>org.apidesign.bck2brwsr</groupId>
1.8 + <artifactId>launcher.http</artifactId>
1.9 + <version>\${bck2brwsr.launcher.version}</version>
1.10 + <scope>test</scope>
1.11 + </dependency>
1.12 + <dependency>
1.13 <groupId>org.apidesign.bck2brwsr</groupId>
1.14 <artifactId>vmtest</artifactId>
1.15 <version>\${bck2brwsr.version}</version>
1.16 @@ -255,12 +261,6 @@
1.17 <version>\${bck2brwsr.version}</version>
1.18 <scope>runtime</scope>
1.19 </dependency>
1.20 - <dependency>
1.21 - <groupId>org.apidesign.bck2brwsr</groupId>
1.22 - <artifactId>launcher.http</artifactId>
1.23 - <version>\${bck2brwsr.launcher.version}</version>
1.24 - <scope>test</scope>
1.25 - </dependency>
1.26 </dependencies>
1.27 </profile>
1.28 </profiles>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Mon Sep 09 19:35:12 2013 +0200
2.3 @@ -0,0 +1,38 @@
2.4 +package ${package};
2.5 +
2.6 +import org.apidesign.bck2brwsr.vmtest.Compare;
2.7 +import org.apidesign.bck2brwsr.vmtest.VMTest;
2.8 +import org.testng.annotations.Factory;
2.9 +
2.10 +/** Bck2brwsr cares about compatibility with real Java. Whatever API is
2.11 + * supported by bck2brwsr, it needs to behave the same way as when running
2.12 + * in HotSpot VM.
2.13 + * <p>
2.14 + * There can be bugs, however. To help us fix them, we kindly ask you to
2.15 + * write an "inconsistency" test. A test that compares behavior of the API
2.16 + * between real VM and bck2brwsr VM. This class is skeleton of such test.
2.17 + */
2.18 +public class InconsistencyTest {
2.19 + /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
2.20 + * Make calls to an API that behaves strangely, return some result at
2.21 + * the end. No need to use any <code>assert</code>.
2.22 + *
2.23 + * @return value to compare between HotSpot and bck2brwsr
2.24 + */
2.25 + @Compare
2.26 + public int checkStringHashCode() throws Exception {
2.27 + return "Is string hashCode the same?".hashCode();
2.28 + }
2.29 +
2.30 + /** Factory method that creates a three tests for each method annotated with
2.31 + * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
2.32 + * HotSpot, one in Rhino and the last one compares the results.
2.33 + *
2.34 + * @see org.apidesign.bck2brwsr.vmtest.VMTest
2.35 + */
2.36 + @Factory
2.37 + public static Object[] create() {
2.38 + return VMTest.create(InconsistencyTest.class);
2.39 + }
2.40 +
2.41 +}
3.1 --- a/rt/archetype/pom.xml Mon Sep 09 17:34:30 2013 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,87 +0,0 @@
3.4 -<?xml version="1.0" encoding="UTF-8"?>
3.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">
3.6 - <modelVersion>4.0.0</modelVersion>
3.7 - <parent>
3.8 - <artifactId>rt</artifactId>
3.9 - <groupId>org.apidesign.bck2brwsr</groupId>
3.10 - <version>0.8-SNAPSHOT</version>
3.11 - </parent>
3.12 - <groupId>org.apidesign.bck2brwsr</groupId>
3.13 - <artifactId>bck2brwsr-archetype-html-sample</artifactId>
3.14 - <version>0.8-SNAPSHOT</version>
3.15 - <packaging>jar</packaging>
3.16 - <name>Bck2Brwsr Maven Archetype</name>
3.17 - <description>
3.18 - Creates a skeletal HTML page and associated Java controller class.
3.19 - Runs in any browser (even without Java plugin) with the help of Bck2Brwsr
3.20 - virtual machine.
3.21 - </description>
3.22 - <build>
3.23 - <resources>
3.24 - <resource>
3.25 - <directory>src/main/resources</directory>
3.26 - <filtering>true</filtering>
3.27 - <includes>
3.28 - <include>**/pom.xml</include>
3.29 - </includes>
3.30 - </resource>
3.31 - <resource>
3.32 - <directory>src/main/resources</directory>
3.33 - <filtering>false</filtering>
3.34 - <excludes>
3.35 - <exclude>**/pom.xml</exclude>
3.36 - </excludes>
3.37 - </resource>
3.38 - </resources>
3.39 - <plugins>
3.40 - <plugin>
3.41 - <groupId>org.apache.maven.plugins</groupId>
3.42 - <artifactId>maven-compiler-plugin</artifactId>
3.43 - <version>2.3.2</version>
3.44 - <configuration>
3.45 - <source>1.6</source>
3.46 - <target>1.6</target>
3.47 - </configuration>
3.48 - </plugin>
3.49 - <plugin>
3.50 - <groupId>org.apache.maven.plugins</groupId>
3.51 - <artifactId>maven-resources-plugin</artifactId>
3.52 - <version>2.6</version>
3.53 - <configuration>
3.54 - <escapeString>\</escapeString>
3.55 - <target>1.6</target>
3.56 - </configuration>
3.57 - </plugin>
3.58 - <plugin>
3.59 - <groupId>org.apache.maven.plugins</groupId>
3.60 - <artifactId>maven-surefire-plugin</artifactId>
3.61 - <configuration>
3.62 - <skipTests>true</skipTests>
3.63 - </configuration>
3.64 - <executions>
3.65 - <execution>
3.66 - <id>test</id>
3.67 - <goals>
3.68 - <goal>test</goal>
3.69 - </goals>
3.70 - <phase>integration-test</phase>
3.71 - <configuration>
3.72 - <additionalClasspathElements>
3.73 - <additionalClasspathElement>${project.build.directory}/bck2brwsr-archetype-html-sample-${project.version}.jar</additionalClasspathElement>
3.74 - </additionalClasspathElements>
3.75 - <skipTests>false</skipTests>
3.76 - </configuration>
3.77 - </execution>
3.78 -
3.79 - </executions>
3.80 - </plugin>
3.81 - </plugins>
3.82 - </build>
3.83 - <dependencies>
3.84 - <dependency>
3.85 - <groupId>org.testng</groupId>
3.86 - <artifactId>testng</artifactId>
3.87 - <scope>test</scope>
3.88 - </dependency>
3.89 - </dependencies>
3.90 -</project>
4.1 --- a/rt/archetype/src/main/java/org/apidesign/bck2brwsr/archetype/package-info.java Mon Sep 09 17:34:30 2013 +0200
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,18 +0,0 @@
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 -package org.apidesign.bck2brwsr.archetype;
5.1 --- a/rt/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Mon Sep 09 17:34:30 2013 +0200
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,55 +0,0 @@
5.4 -<?xml version="1.0" encoding="UTF-8"?>
5.5 -<!--
5.6 -
5.7 - Back 2 Browser Bytecode Translator
5.8 - Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5.9 -
5.10 - This program is free software: you can redistribute it and/or modify
5.11 - it under the terms of the GNU General Public License as published by
5.12 - the Free Software Foundation, version 2 of the License.
5.13 -
5.14 - This program is distributed in the hope that it will be useful,
5.15 - but WITHOUT ANY WARRANTY; without even the implied warranty of
5.16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.17 - GNU General Public License for more details.
5.18 -
5.19 - You should have received a copy of the GNU General Public License
5.20 - along with this program. Look for COPYING file in the top folder.
5.21 - If not, see http://opensource.org/licenses/GPL-2.0.
5.22 -
5.23 --->
5.24 -<archetype-descriptor name="Get Java Bck2Brwsr!">
5.25 - <fileSets>
5.26 - <fileSet filtered="true" packaged="true">
5.27 - <directory>src/main/java</directory>
5.28 - <includes>
5.29 - <include>**/App.java</include>
5.30 - </includes>
5.31 - </fileSet>
5.32 - <fileSet filtered="true" packaged="true">
5.33 - <directory>src/main/resources</directory>
5.34 - <includes>
5.35 - <include>**/*.xhtml</include>
5.36 - <include>**/*.html</include>
5.37 - </includes>
5.38 - </fileSet>
5.39 - <fileSet filtered="true" packaged="true">
5.40 - <directory>src/test/java</directory>
5.41 - <includes>
5.42 - <include>**/*Test.java</include>
5.43 - </includes>
5.44 - </fileSet>
5.45 - <fileSet filtered="false" packaged="false">
5.46 - <directory></directory>
5.47 - <includes>
5.48 - <include>nbactions.xml</include>
5.49 - </includes>
5.50 - </fileSet>
5.51 - <fileSet filtered="true" packaged="false">
5.52 - <directory></directory>
5.53 - <includes>
5.54 - <include>bck2brwsr-assembly.xml</include>
5.55 - </includes>
5.56 - </fileSet>
5.57 - </fileSets>
5.58 -</archetype-descriptor>
5.59 \ No newline at end of file
6.1 --- a/rt/archetype/src/main/resources/archetype-resources/bck2brwsr-assembly.xml Mon Sep 09 17:34:30 2013 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,61 +0,0 @@
6.4 -<?xml version="1.0"?>
6.5 -<!--
6.6 -
6.7 - Back 2 Browser Bytecode Translator
6.8 - Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
6.9 -
6.10 - This program is free software: you can redistribute it and/or modify
6.11 - it under the terms of the GNU General Public License as published by
6.12 - the Free Software Foundation, version 2 of the License.
6.13 -
6.14 - This program is distributed in the hope that it will be useful,
6.15 - but WITHOUT ANY WARRANTY; without even the implied warranty of
6.16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.17 - GNU General Public License for more details.
6.18 -
6.19 - You should have received a copy of the GNU General Public License
6.20 - along with this program. Look for COPYING file in the top folder.
6.21 - If not, see http://opensource.org/licenses/GPL-2.0.
6.22 -
6.23 --->
6.24 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6.25 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
6.26 -
6.27 - <id>bck2brwsr</id>
6.28 - <formats>
6.29 - <format>zip</format>
6.30 - </formats>
6.31 - <baseDirectory>public_html</baseDirectory>
6.32 - <dependencySets>
6.33 - <dependencySet>
6.34 - <useProjectArtifact>false</useProjectArtifact>
6.35 - <scope>runtime</scope>
6.36 - <outputDirectory>lib</outputDirectory>
6.37 - <includes>
6.38 - <include>*:jar</include>
6.39 - <include>*:rt</include>
6.40 - </includes>
6.41 - </dependencySet>
6.42 - <dependencySet>
6.43 - <useProjectArtifact>false</useProjectArtifact>
6.44 - <scope>provided</scope>
6.45 - <includes>
6.46 - <include>*:js</include>
6.47 - </includes>
6.48 - <unpack>true</unpack>
6.49 - <outputDirectory>/</outputDirectory>
6.50 - </dependencySet>
6.51 - </dependencySets>
6.52 - <files>
6.53 - <file>
6.54 - <source>${project.build.directory}/${project.build.finalName}.jar</source>
6.55 - <outputDirectory>/</outputDirectory>
6.56 - </file>
6.57 - <file>
6.58 - <source>${project.build.directory}/classes/${package.replace('.','/')}/index.html</source>
6.59 - <outputDirectory>/</outputDirectory>
6.60 - <destName>index.html</destName>
6.61 - </file>
6.62 - </files>
6.63 -
6.64 -</assembly>
6.65 \ No newline at end of file
7.1 --- a/rt/archetype/src/main/resources/archetype-resources/nbactions.xml Mon Sep 09 17:34:30 2013 +0200
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,10 +0,0 @@
7.4 -<?xml version="1.0" encoding="UTF-8"?>
7.5 -<actions>
7.6 - <action>
7.7 - <actionName>run</actionName>
7.8 - <goals>
7.9 - <goal>process-classes</goal>
7.10 - <goal>bck2brwsr:brwsr</goal>
7.11 - </goals>
7.12 - </action>
7.13 -</actions>
8.1 --- a/rt/archetype/src/main/resources/archetype-resources/pom.xml Mon Sep 09 17:34:30 2013 +0200
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,135 +0,0 @@
8.4 -<?xml version="1.0"?>
8.5 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8.6 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
8.7 - <modelVersion>4.0.0</modelVersion>
8.8 -
8.9 - <groupId>\${groupId}</groupId>
8.10 - <artifactId>\${artifactId}</artifactId>
8.11 - <version>\${version}</version>
8.12 - <packaging>jar</packaging>
8.13 -
8.14 - <name>\${artifactId}</name>
8.15 -
8.16 - <repositories>
8.17 - <repository>
8.18 - <id>java.net</id>
8.19 - <name>Java.net</name>
8.20 - <url>https://maven.java.net/content/repositories/releases/</url>
8.21 - <snapshots>
8.22 - <enabled>true</enabled>
8.23 - </snapshots>
8.24 - </repository>
8.25 - <repository>
8.26 - <id>netbeans</id>
8.27 - <name>NetBeans</name>
8.28 - <url>http://bits.netbeans.org/maven2/</url>
8.29 - </repository>
8.30 - </repositories>
8.31 - <pluginRepositories>
8.32 - <pluginRepository>
8.33 - <id>java.net</id>
8.34 - <name>Java.net</name>
8.35 - <url>https://maven.java.net/content/repositories/releases/</url>
8.36 - <snapshots>
8.37 - <enabled>true</enabled>
8.38 - </snapshots>
8.39 - </pluginRepository>
8.40 - </pluginRepositories>
8.41 -
8.42 - <properties>
8.43 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
8.44 - </properties>
8.45 - <build>
8.46 - <plugins>
8.47 - <plugin>
8.48 - <groupId>org.apidesign.bck2brwsr</groupId>
8.49 - <artifactId>bck2brwsr-maven-plugin</artifactId>
8.50 - <version>${project.version}</version>
8.51 - <executions>
8.52 - <execution>
8.53 - <goals>
8.54 - <goal>brwsr</goal>
8.55 - </goals>
8.56 - </execution>
8.57 - </executions>
8.58 - <configuration>
8.59 - <startpage>\${package.replace('.','/')}/index.html</startpage>
8.60 - </configuration>
8.61 - </plugin>
8.62 - <plugin>
8.63 - <groupId>org.apache.maven.plugins</groupId>
8.64 - <artifactId>maven-compiler-plugin</artifactId>
8.65 - <version>2.3.2</version>
8.66 - <configuration>
8.67 - <source>1.7</source>
8.68 - <target>1.7</target>
8.69 - </configuration>
8.70 - </plugin>
8.71 - <plugin>
8.72 - <groupId>org.apache.maven.plugins</groupId>
8.73 - <artifactId>maven-jar-plugin</artifactId>
8.74 - <version>2.4</version>
8.75 - <configuration>
8.76 - <archive>
8.77 - <manifest>
8.78 - <addClasspath>true</addClasspath>
8.79 - <classpathPrefix>lib/</classpathPrefix>
8.80 - </manifest>
8.81 - </archive>
8.82 - </configuration>
8.83 - </plugin>
8.84 - <plugin>
8.85 - <artifactId>maven-assembly-plugin</artifactId>
8.86 - <version>2.4</version>
8.87 - <executions>
8.88 - <execution>
8.89 - <id>distro-assembly</id>
8.90 - <phase>package</phase>
8.91 - <goals>
8.92 - <goal>single</goal>
8.93 - </goals>
8.94 - <configuration>
8.95 - <descriptors>
8.96 - <descriptor>bck2brwsr-assembly.xml</descriptor>
8.97 - </descriptors>
8.98 - </configuration>
8.99 - </execution>
8.100 - </executions>
8.101 - </plugin>
8.102 - </plugins>
8.103 - </build>
8.104 -
8.105 - <dependencies>
8.106 - <dependency>
8.107 - <groupId>org.apidesign.bck2brwsr</groupId>
8.108 - <artifactId>emul</artifactId>
8.109 - <version>${project.version}</version>
8.110 - <classifier>rt</classifier>
8.111 - </dependency>
8.112 - <dependency>
8.113 - <groupId>org.apidesign.bck2brwsr</groupId>
8.114 - <artifactId>javaquery.api</artifactId>
8.115 - <version>${project.version}</version>
8.116 - </dependency>
8.117 - <dependency>
8.118 - <groupId>org.testng</groupId>
8.119 - <artifactId>testng</artifactId>
8.120 - <version>6.5.2</version>
8.121 - <scope>test</scope>
8.122 - </dependency>
8.123 - <dependency>
8.124 - <groupId>org.apidesign.bck2brwsr</groupId>
8.125 - <artifactId>vm4brwsr</artifactId>
8.126 - <classifier>js</classifier>
8.127 - <type>zip</type>
8.128 - <version>${project.version}</version>
8.129 - <scope>provided</scope>
8.130 - </dependency>
8.131 - <dependency>
8.132 - <groupId>org.apidesign.bck2brwsr</groupId>
8.133 - <artifactId>vmtest</artifactId>
8.134 - <version>${project.version}</version>
8.135 - <scope>test</scope>
8.136 - </dependency>
8.137 - </dependencies>
8.138 -</project>
9.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/main/java/App.java Mon Sep 09 17:34:30 2013 +0200
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,88 +0,0 @@
9.4 -package ${package};
9.5 -
9.6 -import java.util.List;
9.7 -import org.apidesign.bck2brwsr.htmlpage.api.*;
9.8 -import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;
9.9 -import org.apidesign.bck2brwsr.htmlpage.api.Page;
9.10 -import org.apidesign.bck2brwsr.htmlpage.api.Property;
9.11 -import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
9.12 -
9.13 -/** This is the controller class for associated index.html page. The <code>Index</code>
9.14 - * is autogenerated by parsing the index.html page. It fields represent individual
9.15 - * elements annotated by "id" in the page.
9.16 - */
9.17 -@Page(xhtml="index.html", className="Index", properties={
9.18 - @Property(name="name", type=String.class),
9.19 - @Property(name="messages", type=String.class, array=true),
9.20 -})
9.21 -public class App {
9.22 - static {
9.23 - Index model = new Index();
9.24 - model.setName("World");
9.25 - model.applyBindings();
9.26 - }
9.27 -
9.28 - /**
9.29 - * @param m the model of the index page creates in static initializer
9.30 - */
9.31 - @On(event = CLICK, id="hello")
9.32 - static void hello(Index m) {
9.33 - display(m.getHelloMessage(), m);
9.34 - m.getMessages().add(m.getHelloMessage());
9.35 - }
9.36 -
9.37 - /** Reacts when mouse moves over the canvas.
9.38 - *
9.39 - * @param m the model of the page
9.40 - * @param x property "x" extracted from the event generated by the browser
9.41 - * @param y property "y" from the mouse event
9.42 - */
9.43 - @On(event = MOUSE_MOVE, id="canvas")
9.44 - static void clearPoint(Index m, int x, int y) {
9.45 - GraphicsContext g = m.canvas.getContext();
9.46 - boolean even = (x + y) % 2 == 0;
9.47 - if (even) {
9.48 - g.setFillStyle("blue");
9.49 - } else {
9.50 - g.setFillStyle("red");
9.51 - }
9.52 - g.clearRect(0, 0, 1000, 1000);
9.53 - g.setFont("italic 40px Calibri");
9.54 - g.fillText(m.getHelloMessage(), 10, 40);
9.55 - }
9.56 -
9.57 - /** Callback function called by the KnockOut/Java binding on elements
9.58 - * representing href's with individual messages being their data.
9.59 - *
9.60 - * @param data the data associated with the element
9.61 - * @param m the model of the page
9.62 - */
9.63 - @OnFunction
9.64 - static void display(String data, Index m) {
9.65 - GraphicsContext g = m.canvas.getContext();
9.66 - g.clearRect(0, 0, 1000, 1000);
9.67 - g.setFillStyle("black");
9.68 - g.setFont("italic 40px Calibri");
9.69 - g.fillText(data, 10, 40);
9.70 - }
9.71 -
9.72 - /** Callback function.
9.73 - *
9.74 - * @param data data associated with the actual element on the page
9.75 - * @param m the model of the page
9.76 - */
9.77 - @OnFunction
9.78 - static void remove(String data, Index m) {
9.79 - m.getMessages().remove(data);
9.80 - }
9.81 -
9.82 - @ComputedProperty
9.83 - static String helloMessage(String name) {
9.84 - return "Hello " + name + "!";
9.85 - }
9.86 -
9.87 - @ComputedProperty
9.88 - static boolean noMessages(List<String> messages) {
9.89 - return messages.isEmpty();
9.90 - }
9.91 -}
10.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/main/resources/index.html Mon Sep 09 17:34:30 2013 +0200
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,31 +0,0 @@
10.4 -<?xml version="1.0" encoding="UTF-8"?>
10.5 -<!DOCTYPE html>
10.6 -<html xmlns="http://www.w3.org/1999/xhtml">
10.7 - <head>
10.8 - <title>Bck2Brwsr's Hello World</title>
10.9 - </head>
10.10 - <body>
10.11 - <h1 data-bind="text: helloMessage">Loading Bck2Brwsr's Hello World...</h1>
10.12 - Your name: <input id='input' data-bind="value: name, valueUpdate: 'afterkeydown'"></input>
10.13 - <button id="hello">Say Hello!</button>
10.14 - <p>
10.15 - <canvas id="canvas" width="300" height="50">
10.16 - </canvas>
10.17 - </p>
10.18 -
10.19 -
10.20 - <div data-bind="if: noMessages">No message displayed yet.</div>
10.21 - <ul data-bind="foreach: messages">
10.22 - <li>
10.23 - <a href="#" data-bind="text: $data, click: $root.display"></a>
10.24 - (<a href="#" data-bind="click: $root.remove">delete</a>)
10.25 - </li>
10.26 - </ul>
10.27 -
10.28 - <script src="bck2brwsr.js"></script>
10.29 - <script type="text/javascript">
10.30 - var vm = bck2brwsr('${artifactId}-${version}.jar');
10.31 - vm.loadClass('${package}.App');
10.32 - </script>
10.33 - </body>
10.34 -</html>
11.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/test/java/AppTest.java Mon Sep 09 17:34:30 2013 +0200
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,26 +0,0 @@
11.4 -package ${package};
11.5 -
11.6 -import static org.testng.Assert.*;
11.7 -import org.testng.annotations.BeforeMethod;
11.8 -import org.testng.annotations.Test;
11.9 -
11.10 -/** Demonstrating POJO testing of HTML page model. Runs in good old HotSpot
11.11 - * as it does not reference any HTML elements or browser functionality. Just
11.12 - * operates on the page model.
11.13 - *
11.14 - * @author Jaroslav Tulach <jtulach@netbeans.org>
11.15 - */
11.16 -public class AppTest {
11.17 - private Index model;
11.18 -
11.19 -
11.20 - @BeforeMethod
11.21 - public void initModel() {
11.22 - model = new Index().applyBindings();
11.23 - }
11.24 -
11.25 - @Test public void testHelloMessage() {
11.26 - model.setName("Joe");
11.27 - assertEquals(model.getHelloMessage(), "Hello Joe!", "Cleared after pressing +");
11.28 - }
11.29 -}
12.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Mon Sep 09 17:34:30 2013 +0200
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,40 +0,0 @@
12.4 -package ${package};
12.5 -
12.6 -import org.apidesign.bck2brwsr.vmtest.Compare;
12.7 -import org.apidesign.bck2brwsr.vmtest.VMTest;
12.8 -import org.testng.annotations.Factory;
12.9 -
12.10 -/** Bck2brwsr cares about compatibility with real Java. Whatever API is
12.11 - * supported by bck2brwsr, it needs to behave the same way as when running
12.12 - * in HotSpot VM.
12.13 - * <p>
12.14 - * There can be bugs, however. To help us fix them, we kindly ask you to
12.15 - * write an "inconsistency" test. A test that compares behavior of the API
12.16 - * between real VM and bck2brwsr VM. This class is skeleton of such test.
12.17 - *
12.18 - * @author Jaroslav Tulach <jtulach@netbeans.org>
12.19 - */
12.20 -public class InconsistencyTest {
12.21 - /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
12.22 - * Make calls to an API that behaves strangely, return some result at
12.23 - * the end. No need to use any <code>assert</code>.
12.24 - *
12.25 - * @return value to compare between HotSpot and bck2brwsr
12.26 - */
12.27 - @Compare
12.28 - public int checkStringHashCode() throws Exception {
12.29 - return "Is string hashCode the same?".hashCode();
12.30 - }
12.31 -
12.32 - /** Factory method that creates a three tests for each method annotated with
12.33 - * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
12.34 - * HotSpot, one in Rhino and the last one compares the results.
12.35 - *
12.36 - * @see org.apidesign.bck2brwsr.vmtest.VMTest
12.37 - */
12.38 - @Factory
12.39 - public static Object[] create() {
12.40 - return VMTest.create(InconsistencyTest.class);
12.41 - }
12.42 -
12.43 -}
13.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java Mon Sep 09 17:34:30 2013 +0200
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,46 +0,0 @@
13.4 -package ${package};
13.5 -
13.6 -import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
13.7 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
13.8 -import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
13.9 -import org.apidesign.bck2brwsr.vmtest.VMTest;
13.10 -import org.testng.annotations.Factory;
13.11 -
13.12 -/** Sometimes it is useful to run tests inside of the real browser.
13.13 - * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
13.14 - * and that is it. If your code references elements on the HTML page,
13.15 - * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
13.16 - * will be made available on the page before your test starts.
13.17 - *
13.18 - * @author Jaroslav Tulach <jtulach@netbeans.org>
13.19 - */
13.20 -public class IntegrationTest {
13.21 -
13.22 - /** Write to testing code here. Use <code>assert</code> (but not TestNG's
13.23 - * Assert, as TestNG is not compiled with target 1.6 yet).
13.24 - */
13.25 - @HtmlFragment(
13.26 - "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
13.27 - "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
13.28 - "<button id=\"hello\">Say Hello!</button>\n" +
13.29 - "<p>\n" +
13.30 - " <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
13.31 - "</p>\n"
13.32 - )
13.33 - @BrwsrTest
13.34 - public void modifyValueAssertChangeInModel() {
13.35 - Index m = new Index();
13.36 - m.setName("Joe Hacker");
13.37 - m.applyBindings();
13.38 - assert "Joe Hacker".equals(m.input.getValue()) : "Value is really Joe Hacker: " + m.input.getValue();
13.39 - m.input.setValue("Happy Joe");
13.40 - m.triggerEvent(m.input, OnEvent.CHANGE);
13.41 - assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
13.42 - }
13.43 -
13.44 - @Factory
13.45 - public static Object[] create() {
13.46 - return VMTest.create(IntegrationTest.class);
13.47 - }
13.48 -
13.49 -}
14.1 --- a/rt/archetype/src/test/java/org/apidesign/bck2brwsr/archetype/ArchetypeVersionTest.java Mon Sep 09 17:34:30 2013 +0200
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,101 +0,0 @@
14.4 -/**
14.5 - * Back 2 Browser Bytecode Translator
14.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
14.7 - *
14.8 - * This program is free software: you can redistribute it and/or modify
14.9 - * it under the terms of the GNU General Public License as published by
14.10 - * the Free Software Foundation, version 2 of the License.
14.11 - *
14.12 - * This program is distributed in the hope that it will be useful,
14.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
14.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14.15 - * GNU General Public License for more details.
14.16 - *
14.17 - * You should have received a copy of the GNU General Public License
14.18 - * along with this program. Look for COPYING file in the top folder.
14.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
14.20 - */
14.21 -package org.apidesign.bck2brwsr.archetype;
14.22 -
14.23 -import java.net.URL;
14.24 -import javax.xml.XMLConstants;
14.25 -import javax.xml.parsers.DocumentBuilderFactory;
14.26 -import javax.xml.xpath.XPathConstants;
14.27 -import javax.xml.xpath.XPathExpression;
14.28 -import javax.xml.xpath.XPathFactory;
14.29 -import org.testng.annotations.Test;
14.30 -import static org.testng.Assert.*;
14.31 -import org.testng.annotations.BeforeClass;
14.32 -import org.w3c.dom.Document;
14.33 -import org.w3c.dom.NodeList;
14.34 -
14.35 -/**
14.36 - *
14.37 - * @author Jaroslav Tulach <jtulach@netbeans.org>
14.38 - */
14.39 -public class ArchetypeVersionTest {
14.40 - private String version;
14.41 -
14.42 - public ArchetypeVersionTest() {
14.43 - }
14.44 -
14.45 - @BeforeClass public void readCurrentVersion() throws Exception {
14.46 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
14.47 - URL u = l.getResource("META-INF/maven/org.apidesign.bck2brwsr/bck2brwsr-archetype-html-sample/pom.xml");
14.48 - assertNotNull(u, "Own pom found: " + System.getProperty("java.class.path"));
14.49 -
14.50 - final XPathFactory fact = XPathFactory.newInstance();
14.51 - fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
14.52 -
14.53 - XPathExpression xp = fact.newXPath().compile("project/version/text()");
14.54 -
14.55 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(u.openStream());
14.56 - version = xp.evaluate(dom);
14.57 -
14.58 - assertFalse(version.isEmpty(), "There should be some version string");
14.59 - }
14.60 -
14.61 -
14.62 - @Test public void testComparePomDepsVersions() throws Exception {
14.63 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
14.64 - URL r = l.getResource("archetype-resources/pom.xml");
14.65 - assertNotNull(r, "Archetype pom found");
14.66 -
14.67 - final XPathFactory fact = XPathFactory.newInstance();
14.68 - XPathExpression xp2 = fact.newXPath().compile(
14.69 - "//version[../groupId/text() = 'org.apidesign.bck2brwsr']/text()"
14.70 - );
14.71 -
14.72 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
14.73 - NodeList arch = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
14.74 -
14.75 - if (arch.getLength() < 3) {
14.76 - fail("There should be at least three dependencies to bck2brwsr APIs: " + arch.getLength());
14.77 - }
14.78 -
14.79 - for (int i = 0; i < arch.getLength(); i++) {
14.80 - assertEquals(arch.item(i).getTextContent(), version, i + "th dependency needs to be on latest version of bck2brwsr");
14.81 - }
14.82 - }
14.83 -
14.84 - @Test public void testNbActions() throws Exception {
14.85 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
14.86 - URL r = l.getResource("archetype-resources/nbactions.xml");
14.87 - assertNotNull(r, "Archetype nb file found");
14.88 -
14.89 - final XPathFactory fact = XPathFactory.newInstance();
14.90 - XPathExpression xp2 = fact.newXPath().compile(
14.91 - "//goal/text()"
14.92 - );
14.93 -
14.94 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
14.95 - NodeList goals = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
14.96 -
14.97 - for (int i = 0; i < goals.getLength(); i++) {
14.98 - String s = goals.item(i).getTextContent();
14.99 - if (s.contains("bck2brwsr")) {
14.100 - assertFalse(s.matches(".*bck2brwsr.*[0-9].*"), "No numbers: " + s);
14.101 - }
14.102 - }
14.103 - }
14.104 -}
15.1 --- a/rt/pom.xml Mon Sep 09 17:34:30 2013 +0200
15.2 +++ b/rt/pom.xml Mon Sep 09 19:35:12 2013 +0200
15.3 @@ -14,7 +14,6 @@
15.4 <modules>
15.5 <module>core</module>
15.6 <module>emul</module>
15.7 - <module>archetype</module>
15.8 <module>mojo</module>
15.9 <module>vm</module>
15.10 <module>vmtest</module>