Separating the archetype into its own module - to give it better name among archetypes
1.1 --- a/pom.xml Thu Mar 21 15:53:55 2013 +0100
1.2 +++ b/pom.xml Fri Mar 22 00:02:21 2013 +0100
1.3 @@ -80,7 +80,7 @@
1.4 <exclude>.*/**</exclude>
1.5 <exclude>rt/emul/*/src/main/**</exclude>
1.6 <exclude>rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java</exclude>
1.7 - <exclude>rt/mojo/src/main/resources/archetype-resources/**</exclude>
1.8 + <exclude>rt/archetype/src/main/resources/archetype-resources/**</exclude>
1.9 <exclude>rt/vmtest/src/test/resources/**</exclude>
1.10 <exclude>dew/src/main/resources/org/apidesign/bck2brwsr/dew/**</exclude>
1.11 <exclude>javaquery/api/src/main/resources/org/apidesign/bck2brwsr/htmlpage/knockout*.js</exclude>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/rt/archetype/pom.xml Fri Mar 22 00:02:21 2013 +0100
2.3 @@ -0,0 +1,62 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.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">
2.6 + <modelVersion>4.0.0</modelVersion>
2.7 + <parent>
2.8 + <artifactId>rt</artifactId>
2.9 + <groupId>org.apidesign.bck2brwsr</groupId>
2.10 + <version>0.5-SNAPSHOT</version>
2.11 + </parent>
2.12 + <groupId>org.apidesign.bck2brwsr</groupId>
2.13 + <artifactId>bck2brwsr-archetype-html-sample</artifactId>
2.14 + <version>0.5-SNAPSHOT</version>
2.15 + <packaging>jar</packaging>
2.16 + <name>Bck2Brwsr Maven Archetype</name>
2.17 + <description>
2.18 + Creates a skeletal HTML page and associated Java controller class.
2.19 + Runs in any browser (even without Java plugin) with the help of Bck2Brwsr
2.20 + virtual machine.
2.21 + </description>
2.22 + <build>
2.23 + <plugins>
2.24 + <plugin>
2.25 + <groupId>org.apache.maven.plugins</groupId>
2.26 + <artifactId>maven-compiler-plugin</artifactId>
2.27 + <version>2.3.2</version>
2.28 + <configuration>
2.29 + <source>1.6</source>
2.30 + <target>1.6</target>
2.31 + </configuration>
2.32 + </plugin>
2.33 + <plugin>
2.34 + <groupId>org.apache.maven.plugins</groupId>
2.35 + <artifactId>maven-surefire-plugin</artifactId>
2.36 + <configuration>
2.37 + <skipTests>true</skipTests>
2.38 + </configuration>
2.39 + <executions>
2.40 + <execution>
2.41 + <id>test</id>
2.42 + <goals>
2.43 + <goal>test</goal>
2.44 + </goals>
2.45 + <phase>integration-test</phase>
2.46 + <configuration>
2.47 + <additionalClasspathElements>
2.48 + <additionalClasspathElement>${project.build.directory}/bck2brwsr-archetype-html-sample-${project.version}.jar</additionalClasspathElement>
2.49 + </additionalClasspathElements>
2.50 + <skipTests>false</skipTests>
2.51 + </configuration>
2.52 + </execution>
2.53 +
2.54 + </executions>
2.55 + </plugin>
2.56 + </plugins>
2.57 + </build>
2.58 + <dependencies>
2.59 + <dependency>
2.60 + <groupId>org.testng</groupId>
2.61 + <artifactId>testng</artifactId>
2.62 + <scope>test</scope>
2.63 + </dependency>
2.64 + </dependencies>
2.65 +</project>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/rt/archetype/src/main/java/org/apidesign/bck2brwsr/archetype/package-info.java Fri Mar 22 00:02:21 2013 +0100
3.3 @@ -0,0 +1,18 @@
3.4 +/**
3.5 + * Back 2 Browser Bytecode Translator
3.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
3.7 + *
3.8 + * This program is free software: you can redistribute it and/or modify
3.9 + * it under the terms of the GNU General Public License as published by
3.10 + * the Free Software Foundation, version 2 of the License.
3.11 + *
3.12 + * This program is distributed in the hope that it will be useful,
3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.15 + * GNU General Public License for more details.
3.16 + *
3.17 + * You should have received a copy of the GNU General Public License
3.18 + * along with this program. Look for COPYING file in the top folder.
3.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
3.20 + */
3.21 +package org.apidesign.bck2brwsr.archetype;
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/rt/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Fri Mar 22 00:02:21 2013 +0100
4.3 @@ -0,0 +1,55 @@
4.4 +<?xml version="1.0" encoding="UTF-8"?>
4.5 +<!--
4.6 +
4.7 + Back 2 Browser Bytecode Translator
4.8 + Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
4.9 +
4.10 + This program is free software: you can redistribute it and/or modify
4.11 + it under the terms of the GNU General Public License as published by
4.12 + the Free Software Foundation, version 2 of the License.
4.13 +
4.14 + This program is distributed in the hope that it will be useful,
4.15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4.16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.17 + GNU General Public License for more details.
4.18 +
4.19 + You should have received a copy of the GNU General Public License
4.20 + along with this program. Look for COPYING file in the top folder.
4.21 + If not, see http://opensource.org/licenses/GPL-2.0.
4.22 +
4.23 +-->
4.24 +<archetype-descriptor name="Get Java Bck2Brwsr!">
4.25 + <fileSets>
4.26 + <fileSet filtered="true" packaged="true">
4.27 + <directory>src/main/java</directory>
4.28 + <includes>
4.29 + <include>**/App.java</include>
4.30 + </includes>
4.31 + </fileSet>
4.32 + <fileSet filtered="true" packaged="true">
4.33 + <directory>src/main/resources</directory>
4.34 + <includes>
4.35 + <include>**/*.xhtml</include>
4.36 + <include>**/*.html</include>
4.37 + </includes>
4.38 + </fileSet>
4.39 + <fileSet filtered="true" packaged="true">
4.40 + <directory>src/test/java</directory>
4.41 + <includes>
4.42 + <include>**/*Test.java</include>
4.43 + </includes>
4.44 + </fileSet>
4.45 + <fileSet filtered="false" packaged="false">
4.46 + <directory></directory>
4.47 + <includes>
4.48 + <include>nbactions.xml</include>
4.49 + </includes>
4.50 + </fileSet>
4.51 + <fileSet filtered="true" packaged="false">
4.52 + <directory></directory>
4.53 + <includes>
4.54 + <include>bck2brwsr-assembly.xml</include>
4.55 + </includes>
4.56 + </fileSet>
4.57 + </fileSets>
4.58 +</archetype-descriptor>
4.59 \ No newline at end of file
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/rt/archetype/src/main/resources/archetype-resources/bck2brwsr-assembly.xml Fri Mar 22 00:02:21 2013 +0100
5.3 @@ -0,0 +1,61 @@
5.4 +<?xml version="1.0"?>
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 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5.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">
5.26 +
5.27 + <id>bck2brwsr</id>
5.28 + <formats>
5.29 + <format>zip</format>
5.30 + </formats>
5.31 + <baseDirectory>public_html</baseDirectory>
5.32 + <dependencySets>
5.33 + <dependencySet>
5.34 + <useProjectArtifact>false</useProjectArtifact>
5.35 + <scope>runtime</scope>
5.36 + <outputDirectory>lib</outputDirectory>
5.37 + <includes>
5.38 + <include>*:jar</include>
5.39 + <include>*:rt</include>
5.40 + </includes>
5.41 + </dependencySet>
5.42 + <dependencySet>
5.43 + <useProjectArtifact>false</useProjectArtifact>
5.44 + <scope>provided</scope>
5.45 + <includes>
5.46 + <include>*:js</include>
5.47 + </includes>
5.48 + <unpack>true</unpack>
5.49 + <outputDirectory>/</outputDirectory>
5.50 + </dependencySet>
5.51 + </dependencySets>
5.52 + <files>
5.53 + <file>
5.54 + <source>${project.build.directory}/${project.build.finalName}.jar</source>
5.55 + <outputDirectory>/</outputDirectory>
5.56 + </file>
5.57 + <file>
5.58 + <source>${project.build.directory}/classes/${package.replace('.','/')}/index.html</source>
5.59 + <outputDirectory>/</outputDirectory>
5.60 + <destName>index.html</destName>
5.61 + </file>
5.62 + </files>
5.63 +
5.64 +</assembly>
5.65 \ No newline at end of file
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/rt/archetype/src/main/resources/archetype-resources/nbactions.xml Fri Mar 22 00:02:21 2013 +0100
6.3 @@ -0,0 +1,10 @@
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>org.apidesign.bck2brwsr:mojo:0.5-SNAPSHOT:brwsr</goal>
6.11 + </goals>
6.12 + </action>
6.13 +</actions>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/rt/archetype/src/main/resources/archetype-resources/pom.xml Fri Mar 22 00:02:21 2013 +0100
7.3 @@ -0,0 +1,135 @@
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 + </properties>
7.45 + <build>
7.46 + <plugins>
7.47 + <plugin>
7.48 + <groupId>org.apidesign.bck2brwsr</groupId>
7.49 + <artifactId>mojo</artifactId>
7.50 + <version>0.5-SNAPSHOT</version>
7.51 + <executions>
7.52 + <execution>
7.53 + <goals>
7.54 + <goal>brwsr</goal>
7.55 + </goals>
7.56 + </execution>
7.57 + </executions>
7.58 + <configuration>
7.59 + <startpage>${package.replace('.','/')}/index.html</startpage>
7.60 + </configuration>
7.61 + </plugin>
7.62 + <plugin>
7.63 + <groupId>org.apache.maven.plugins</groupId>
7.64 + <artifactId>maven-compiler-plugin</artifactId>
7.65 + <version>2.3.2</version>
7.66 + <configuration>
7.67 + <source>1.7</source>
7.68 + <target>1.7</target>
7.69 + </configuration>
7.70 + </plugin>
7.71 + <plugin>
7.72 + <groupId>org.apache.maven.plugins</groupId>
7.73 + <artifactId>maven-jar-plugin</artifactId>
7.74 + <version>2.4</version>
7.75 + <configuration>
7.76 + <archive>
7.77 + <manifest>
7.78 + <addClasspath>true</addClasspath>
7.79 + <classpathPrefix>lib/</classpathPrefix>
7.80 + </manifest>
7.81 + </archive>
7.82 + </configuration>
7.83 + </plugin>
7.84 + <plugin>
7.85 + <artifactId>maven-assembly-plugin</artifactId>
7.86 + <version>2.4</version>
7.87 + <executions>
7.88 + <execution>
7.89 + <id>distro-assembly</id>
7.90 + <phase>package</phase>
7.91 + <goals>
7.92 + <goal>single</goal>
7.93 + </goals>
7.94 + <configuration>
7.95 + <descriptors>
7.96 + <descriptor>bck2brwsr-assembly.xml</descriptor>
7.97 + </descriptors>
7.98 + </configuration>
7.99 + </execution>
7.100 + </executions>
7.101 + </plugin>
7.102 + </plugins>
7.103 + </build>
7.104 +
7.105 + <dependencies>
7.106 + <dependency>
7.107 + <groupId>org.apidesign.bck2brwsr</groupId>
7.108 + <artifactId>emul</artifactId>
7.109 + <version>0.5-SNAPSHOT</version>
7.110 + <classifier>rt</classifier>
7.111 + </dependency>
7.112 + <dependency>
7.113 + <groupId>org.apidesign.bck2brwsr</groupId>
7.114 + <artifactId>javaquery.api</artifactId>
7.115 + <version>0.5-SNAPSHOT</version>
7.116 + </dependency>
7.117 + <dependency>
7.118 + <groupId>org.testng</groupId>
7.119 + <artifactId>testng</artifactId>
7.120 + <version>6.5.2</version>
7.121 + <scope>test</scope>
7.122 + </dependency>
7.123 + <dependency>
7.124 + <groupId>org.apidesign.bck2brwsr</groupId>
7.125 + <artifactId>vm4brwsr</artifactId>
7.126 + <classifier>js</classifier>
7.127 + <type>zip</type>
7.128 + <version>0.5-SNAPSHOT</version>
7.129 + <scope>provided</scope>
7.130 + </dependency>
7.131 + <dependency>
7.132 + <groupId>org.apidesign.bck2brwsr</groupId>
7.133 + <artifactId>vmtest</artifactId>
7.134 + <version>0.5-SNAPSHOT</version>
7.135 + <scope>test</scope>
7.136 + </dependency>
7.137 + </dependencies>
7.138 +</project>
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/rt/archetype/src/main/resources/archetype-resources/src/main/java/App.java Fri Mar 22 00:02:21 2013 +0100
8.3 @@ -0,0 +1,34 @@
8.4 +package ${package};
8.5 +
8.6 +import org.apidesign.bck2brwsr.htmlpage.api.*;
8.7 +import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;
8.8 +import org.apidesign.bck2brwsr.htmlpage.api.Page;
8.9 +import org.apidesign.bck2brwsr.htmlpage.api.Property;
8.10 +import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
8.11 +
8.12 +/** Edit the index.xhtml file. Use 'id' to name certain HTML elements.
8.13 + * Use this class to define behavior of the elements.
8.14 + */
8.15 +@Page(xhtml="index.html", className="Index", properties={
8.16 + @Property(name="name", type=String.class)
8.17 +})
8.18 +public class App {
8.19 + static {
8.20 + Index model = new Index();
8.21 + model.setName("World");
8.22 + model.applyBindings();
8.23 + }
8.24 +
8.25 + @On(event = CLICK, id="hello")
8.26 + static void hello(Index m) {
8.27 + GraphicsContext g = m.CANVAS.getContext();
8.28 + g.clearRect(0, 0, 1000, 1000);
8.29 + g.setFont("italic 40px Calibri");
8.30 + g.fillText(m.getHelloMessage(), 10, 40);
8.31 + }
8.32 +
8.33 + @ComputedProperty
8.34 + static String helloMessage(String name) {
8.35 + return "Hello " + name + "!";
8.36 + }
8.37 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/rt/archetype/src/main/resources/archetype-resources/src/main/resources/index.html Fri Mar 22 00:02:21 2013 +0100
9.3 @@ -0,0 +1,22 @@
9.4 +<?xml version="1.0" encoding="UTF-8"?>
9.5 +<!DOCTYPE html>
9.6 +<html xmlns="http://www.w3.org/1999/xhtml">
9.7 + <head>
9.8 + <title>Bck2Brwsr's Hello World</title>
9.9 + </head>
9.10 + <body>
9.11 + <h1 data-bind="text: helloMessage">Loading Bck2Brwsr's Hello World...</h1>
9.12 + Your name: <input id='input' data-bind="value: name, valueUpdate: 'afterkeydown'"></input>
9.13 + <button id="hello">Say Hello!</button>
9.14 + <p>
9.15 + <canvas id="canvas" width="300" height="50">
9.16 + </canvas>
9.17 + </p>
9.18 +
9.19 + <script src="bck2brwsr.js"></script>
9.20 + <script type="text/javascript">
9.21 + var vm = bck2brwsr('${artifactId}-${version}.jar');
9.22 + vm.loadClass('${package}.App');
9.23 + </script>
9.24 + </body>
9.25 +</html>
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/rt/archetype/src/main/resources/archetype-resources/src/test/java/AppTest.java Fri Mar 22 00:02:21 2013 +0100
10.3 @@ -0,0 +1,26 @@
10.4 +package ${package};
10.5 +
10.6 +import static org.testng.Assert.*;
10.7 +import org.testng.annotations.BeforeMethod;
10.8 +import org.testng.annotations.Test;
10.9 +
10.10 +/** Demonstrating POJO testing of HTML page model. Runs in good old HotSpot
10.11 + * as it does not reference any HTML elements or browser functionality. Just
10.12 + * operates on the page model.
10.13 + *
10.14 + * @author Jaroslav Tulach <jtulach@netbeans.org>
10.15 + */
10.16 +public class AppTest {
10.17 + private Index model;
10.18 +
10.19 +
10.20 + @BeforeMethod
10.21 + public void initModel() {
10.22 + model = new Index().applyBindings();
10.23 + }
10.24 +
10.25 + @Test public void testHelloMessage() {
10.26 + model.setName("Joe");
10.27 + assertEquals(model.getHelloMessage(), "Hello Joe!", "Cleared after pressing +");
10.28 + }
10.29 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/rt/archetype/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Fri Mar 22 00:02:21 2013 +0100
11.3 @@ -0,0 +1,40 @@
11.4 +package ${package};
11.5 +
11.6 +import org.apidesign.bck2brwsr.vmtest.Compare;
11.7 +import org.apidesign.bck2brwsr.vmtest.VMTest;
11.8 +import org.testng.annotations.Factory;
11.9 +
11.10 +/** Bck2brwsr cares about compatibility with real Java. Whatever API is
11.11 + * supported by bck2brwsr, it needs to behave the same way as when running
11.12 + * in HotSpot VM.
11.13 + * <p>
11.14 + * There can be bugs, however. To help us fix them, we kindly ask you to
11.15 + * write an "inconsistency" test. A test that compares behavior of the API
11.16 + * between real VM and bck2brwsr VM. This class is skeleton of such test.
11.17 + *
11.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
11.19 + */
11.20 +public class InconsistencyTest {
11.21 + /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
11.22 + * Make calls to an API that behaves strangely, return some result at
11.23 + * the end. No need to use any <code>assert</code>.
11.24 + *
11.25 + * @return value to compare between HotSpot and bck2brwsr
11.26 + */
11.27 + @Compare
11.28 + public int checkStringHashCode() throws Exception {
11.29 + return "Is string hashCode the same?".hashCode();
11.30 + }
11.31 +
11.32 + /** Factory method that creates a three tests for each method annotated with
11.33 + * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
11.34 + * HotSpot, one in Rhino and the last one compares the results.
11.35 + *
11.36 + * @see org.apidesign.bck2brwsr.vmtest.VMTest
11.37 + */
11.38 + @Factory
11.39 + public static Object[] create() {
11.40 + return VMTest.create(InconsistencyTest.class);
11.41 + }
11.42 +
11.43 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/rt/archetype/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java Fri Mar 22 00:02:21 2013 +0100
12.3 @@ -0,0 +1,46 @@
12.4 +package ${package};
12.5 +
12.6 +import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
12.7 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
12.8 +import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
12.9 +import org.apidesign.bck2brwsr.vmtest.VMTest;
12.10 +import org.testng.annotations.Factory;
12.11 +
12.12 +/** Sometimes it is useful to run tests inside of the real browser.
12.13 + * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
12.14 + * and that is it. If your code references elements on the HTML page,
12.15 + * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
12.16 + * will be made available on the page before your test starts.
12.17 + *
12.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
12.19 + */
12.20 +public class IntegrationTest {
12.21 +
12.22 + /** Write to testing code here. Use <code>assert</code> (but not TestNG's
12.23 + * Assert, as TestNG is not compiled with target 1.6 yet).
12.24 + */
12.25 + @HtmlFragment(
12.26 + "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
12.27 + "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
12.28 + "<button id=\"hello\">Say Hello!</button>\n" +
12.29 + "<p>\n" +
12.30 + " <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
12.31 + "</p>\n"
12.32 + )
12.33 + @BrwsrTest
12.34 + public void modifyValueAssertChangeInModel() {
12.35 + Index m = new Index();
12.36 + m.setName("Joe Hacker");
12.37 + m.applyBindings();
12.38 + assert "Joe Hacker".equals(m.INPUT.getValue()) : "Value is really Joe Hacker: " + m.INPUT.getValue();
12.39 + m.INPUT.setValue("Happy Joe");
12.40 + m.triggerEvent(m.INPUT, OnEvent.CHANGE);
12.41 + assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
12.42 + }
12.43 +
12.44 + @Factory
12.45 + public static Object[] create() {
12.46 + return VMTest.create(IntegrationTest.class);
12.47 + }
12.48 +
12.49 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/rt/archetype/src/test/java/org/apidesign/bck2brwsr/archetype/ArchetypeVersionTest.java Fri Mar 22 00:02:21 2013 +0100
13.3 @@ -0,0 +1,104 @@
13.4 +/**
13.5 + * Back 2 Browser Bytecode Translator
13.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
13.7 + *
13.8 + * This program is free software: you can redistribute it and/or modify
13.9 + * it under the terms of the GNU General Public License as published by
13.10 + * the Free Software Foundation, version 2 of the License.
13.11 + *
13.12 + * This program is distributed in the hope that it will be useful,
13.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.15 + * GNU General Public License for more details.
13.16 + *
13.17 + * You should have received a copy of the GNU General Public License
13.18 + * along with this program. Look for COPYING file in the top folder.
13.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
13.20 + */
13.21 +package org.apidesign.bck2brwsr.archetype;
13.22 +
13.23 +import java.net.URL;
13.24 +import javax.xml.XMLConstants;
13.25 +import javax.xml.parsers.DocumentBuilderFactory;
13.26 +import javax.xml.xpath.XPathConstants;
13.27 +import javax.xml.xpath.XPathExpression;
13.28 +import javax.xml.xpath.XPathFactory;
13.29 +import org.testng.annotations.Test;
13.30 +import org.xml.sax.InputSource;
13.31 +import static org.testng.Assert.*;
13.32 +import org.testng.annotations.BeforeClass;
13.33 +import org.w3c.dom.Document;
13.34 +import org.w3c.dom.NodeList;
13.35 +
13.36 +/**
13.37 + *
13.38 + * @author Jaroslav Tulach <jtulach@netbeans.org>
13.39 + */
13.40 +public class ArchetypeVersionTest {
13.41 + private String version;
13.42 +
13.43 + public ArchetypeVersionTest() {
13.44 + }
13.45 +
13.46 + @BeforeClass public void readCurrentVersion() throws Exception {
13.47 + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
13.48 + URL u = l.getResource("META-INF/maven/org.apidesign.bck2brwsr/bck2brwsr-archetype-html-sample/pom.xml");
13.49 + assertNotNull(u, "Own pom found: " + System.getProperty("java.class.path"));
13.50 +
13.51 + final XPathFactory fact = XPathFactory.newInstance();
13.52 + fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
13.53 +
13.54 + XPathExpression xp = fact.newXPath().compile("project/version/text()");
13.55 +
13.56 + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(u.openStream());
13.57 + version = xp.evaluate(dom);
13.58 +
13.59 + assertFalse(version.isEmpty(), "There should be some version string");
13.60 + }
13.61 +
13.62 +
13.63 + @Test public void testComparePomDepsVersions() throws Exception {
13.64 + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
13.65 + URL r = l.getResource("archetype-resources/pom.xml");
13.66 + assertNotNull(r, "Archetype pom found");
13.67 +
13.68 + final XPathFactory fact = XPathFactory.newInstance();
13.69 + XPathExpression xp2 = fact.newXPath().compile(
13.70 + "//version[../groupId/text() = 'org.apidesign.bck2brwsr']/text()"
13.71 + );
13.72 +
13.73 + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
13.74 + NodeList arch = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
13.75 +
13.76 + if (arch.getLength() < 3) {
13.77 + fail("There should be at least three dependencies to bck2brwsr APIs: " + arch.getLength());
13.78 + }
13.79 +
13.80 + for (int i = 0; i < arch.getLength(); i++) {
13.81 + assertEquals(arch.item(i).getTextContent(), version, i + "th dependency needs to be on latest version of bck2brwsr");
13.82 + }
13.83 + }
13.84 +
13.85 + @Test public void testNbActions() throws Exception {
13.86 + final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
13.87 + URL r = l.getResource("archetype-resources/nbactions.xml");
13.88 + assertNotNull(r, "Archetype nb file found");
13.89 +
13.90 + final XPathFactory fact = XPathFactory.newInstance();
13.91 + XPathExpression xp2 = fact.newXPath().compile(
13.92 + "//goal/text()"
13.93 + );
13.94 +
13.95 + Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
13.96 + NodeList goals = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
13.97 +
13.98 + for (int i = 0; i < goals.getLength(); i++) {
13.99 + String s = goals.item(i).getTextContent();
13.100 + if (s.contains("bck2brwsr")) {
13.101 + String[] arr = s.split(":");
13.102 + assertEquals(arr.length, 4, "Three :");
13.103 + assertEquals(arr[2], version, "Proper version is used");
13.104 + }
13.105 + }
13.106 + }
13.107 +}
14.1 --- a/rt/mojo/pom.xml Thu Mar 21 15:53:55 2013 +0100
14.2 +++ b/rt/mojo/pom.xml Fri Mar 22 00:02:21 2013 +0100
14.3 @@ -10,7 +10,7 @@
14.4 <artifactId>mojo</artifactId>
14.5 <version>0.5-SNAPSHOT</version>
14.6 <packaging>maven-plugin</packaging>
14.7 - <name>Bck2Brwsr Maven Project</name>
14.8 + <name>Bck2Brwsr Maven Plugins</name>
14.9 <url>http://maven.apache.org</url>
14.10 <build>
14.11 <plugins>
14.12 @@ -62,7 +62,7 @@
14.13 <dependency>
14.14 <groupId>${project.groupId}</groupId>
14.15 <artifactId>vm4brwsr</artifactId>
14.16 - <version>0.5-SNAPSHOT</version>
14.17 + <version>${project.version}</version>
14.18 <exclusions>
14.19 <exclusion>
14.20 <artifactId>emul.mini</artifactId>
14.21 @@ -81,11 +81,5 @@
14.22 <artifactId>launcher</artifactId>
14.23 <version>${project.version}</version>
14.24 </dependency>
14.25 - <dependency>
14.26 - <groupId>org.testng</groupId>
14.27 - <artifactId>testng</artifactId>
14.28 - <version>6.5.2</version>
14.29 - <scope>test</scope>
14.30 - </dependency>
14.31 </dependencies>
14.32 </project>
15.1 --- a/rt/mojo/src/main/resources/META-INF/maven/archetype-metadata.xml Thu Mar 21 15:53:55 2013 +0100
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,55 +0,0 @@
15.4 -<?xml version="1.0" encoding="UTF-8"?>
15.5 -<!--
15.6 -
15.7 - Back 2 Browser Bytecode Translator
15.8 - Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
15.9 -
15.10 - This program is free software: you can redistribute it and/or modify
15.11 - it under the terms of the GNU General Public License as published by
15.12 - the Free Software Foundation, version 2 of the License.
15.13 -
15.14 - This program is distributed in the hope that it will be useful,
15.15 - but WITHOUT ANY WARRANTY; without even the implied warranty of
15.16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.17 - GNU General Public License for more details.
15.18 -
15.19 - You should have received a copy of the GNU General Public License
15.20 - along with this program. Look for COPYING file in the top folder.
15.21 - If not, see http://opensource.org/licenses/GPL-2.0.
15.22 -
15.23 --->
15.24 -<archetype-descriptor name="Get Java Bck2Brwsr!">
15.25 - <fileSets>
15.26 - <fileSet filtered="true" packaged="true">
15.27 - <directory>src/main/java</directory>
15.28 - <includes>
15.29 - <include>**/App.java</include>
15.30 - </includes>
15.31 - </fileSet>
15.32 - <fileSet filtered="true" packaged="true">
15.33 - <directory>src/main/resources</directory>
15.34 - <includes>
15.35 - <include>**/*.xhtml</include>
15.36 - <include>**/*.html</include>
15.37 - </includes>
15.38 - </fileSet>
15.39 - <fileSet filtered="true" packaged="true">
15.40 - <directory>src/test/java</directory>
15.41 - <includes>
15.42 - <include>**/*Test.java</include>
15.43 - </includes>
15.44 - </fileSet>
15.45 - <fileSet filtered="false" packaged="false">
15.46 - <directory></directory>
15.47 - <includes>
15.48 - <include>nbactions.xml</include>
15.49 - </includes>
15.50 - </fileSet>
15.51 - <fileSet filtered="true" packaged="false">
15.52 - <directory></directory>
15.53 - <includes>
15.54 - <include>bck2brwsr-assembly.xml</include>
15.55 - </includes>
15.56 - </fileSet>
15.57 - </fileSets>
15.58 -</archetype-descriptor>
15.59 \ No newline at end of file
16.1 --- a/rt/mojo/src/main/resources/archetype-resources/bck2brwsr-assembly.xml Thu Mar 21 15:53:55 2013 +0100
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,61 +0,0 @@
16.4 -<?xml version="1.0"?>
16.5 -<!--
16.6 -
16.7 - Back 2 Browser Bytecode Translator
16.8 - Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
16.9 -
16.10 - This program is free software: you can redistribute it and/or modify
16.11 - it under the terms of the GNU General Public License as published by
16.12 - the Free Software Foundation, version 2 of the License.
16.13 -
16.14 - This program is distributed in the hope that it will be useful,
16.15 - but WITHOUT ANY WARRANTY; without even the implied warranty of
16.16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.17 - GNU General Public License for more details.
16.18 -
16.19 - You should have received a copy of the GNU General Public License
16.20 - along with this program. Look for COPYING file in the top folder.
16.21 - If not, see http://opensource.org/licenses/GPL-2.0.
16.22 -
16.23 --->
16.24 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16.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">
16.26 -
16.27 - <id>bck2brwsr</id>
16.28 - <formats>
16.29 - <format>zip</format>
16.30 - </formats>
16.31 - <baseDirectory>public_html</baseDirectory>
16.32 - <dependencySets>
16.33 - <dependencySet>
16.34 - <useProjectArtifact>false</useProjectArtifact>
16.35 - <scope>runtime</scope>
16.36 - <outputDirectory>lib</outputDirectory>
16.37 - <includes>
16.38 - <include>*:jar</include>
16.39 - <include>*:rt</include>
16.40 - </includes>
16.41 - </dependencySet>
16.42 - <dependencySet>
16.43 - <useProjectArtifact>false</useProjectArtifact>
16.44 - <scope>provided</scope>
16.45 - <includes>
16.46 - <include>*:js</include>
16.47 - </includes>
16.48 - <unpack>true</unpack>
16.49 - <outputDirectory>/</outputDirectory>
16.50 - </dependencySet>
16.51 - </dependencySets>
16.52 - <files>
16.53 - <file>
16.54 - <source>${project.build.directory}/${project.build.finalName}.jar</source>
16.55 - <outputDirectory>/</outputDirectory>
16.56 - </file>
16.57 - <file>
16.58 - <source>${project.build.directory}/classes/${package.replace('.','/')}/index.html</source>
16.59 - <outputDirectory>/</outputDirectory>
16.60 - <destName>index.html</destName>
16.61 - </file>
16.62 - </files>
16.63 -
16.64 -</assembly>
16.65 \ No newline at end of file
17.1 --- a/rt/mojo/src/main/resources/archetype-resources/nbactions.xml Thu Mar 21 15:53:55 2013 +0100
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,10 +0,0 @@
17.4 -<?xml version="1.0" encoding="UTF-8"?>
17.5 -<actions>
17.6 - <action>
17.7 - <actionName>run</actionName>
17.8 - <goals>
17.9 - <goal>process-classes</goal>
17.10 - <goal>org.apidesign.bck2brwsr:mojo:0.5-SNAPSHOT:brwsr</goal>
17.11 - </goals>
17.12 - </action>
17.13 -</actions>
18.1 --- a/rt/mojo/src/main/resources/archetype-resources/pom.xml Thu Mar 21 15:53:55 2013 +0100
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,135 +0,0 @@
18.4 -<?xml version="1.0"?>
18.5 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18.6 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18.7 - <modelVersion>4.0.0</modelVersion>
18.8 -
18.9 - <groupId>${groupId}</groupId>
18.10 - <artifactId>${artifactId}</artifactId>
18.11 - <version>${version}</version>
18.12 - <packaging>jar</packaging>
18.13 -
18.14 - <name>${artifactId}</name>
18.15 -
18.16 - <repositories>
18.17 - <repository>
18.18 - <id>java.net</id>
18.19 - <name>Java.net</name>
18.20 - <url>https://maven.java.net/content/repositories/releases/</url>
18.21 - <snapshots>
18.22 - <enabled>true</enabled>
18.23 - </snapshots>
18.24 - </repository>
18.25 - <repository>
18.26 - <id>netbeans</id>
18.27 - <name>NetBeans</name>
18.28 - <url>http://bits.netbeans.org/maven2/</url>
18.29 - </repository>
18.30 - </repositories>
18.31 - <pluginRepositories>
18.32 - <pluginRepository>
18.33 - <id>java.net</id>
18.34 - <name>Java.net</name>
18.35 - <url>https://maven.java.net/content/repositories/releases/</url>
18.36 - <snapshots>
18.37 - <enabled>true</enabled>
18.38 - </snapshots>
18.39 - </pluginRepository>
18.40 - </pluginRepositories>
18.41 -
18.42 - <properties>
18.43 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18.44 - </properties>
18.45 - <build>
18.46 - <plugins>
18.47 - <plugin>
18.48 - <groupId>org.apidesign.bck2brwsr</groupId>
18.49 - <artifactId>mojo</artifactId>
18.50 - <version>0.5-SNAPSHOT</version>
18.51 - <executions>
18.52 - <execution>
18.53 - <goals>
18.54 - <goal>brwsr</goal>
18.55 - </goals>
18.56 - </execution>
18.57 - </executions>
18.58 - <configuration>
18.59 - <startpage>${package.replace('.','/')}/index.html</startpage>
18.60 - </configuration>
18.61 - </plugin>
18.62 - <plugin>
18.63 - <groupId>org.apache.maven.plugins</groupId>
18.64 - <artifactId>maven-compiler-plugin</artifactId>
18.65 - <version>2.3.2</version>
18.66 - <configuration>
18.67 - <source>1.7</source>
18.68 - <target>1.7</target>
18.69 - </configuration>
18.70 - </plugin>
18.71 - <plugin>
18.72 - <groupId>org.apache.maven.plugins</groupId>
18.73 - <artifactId>maven-jar-plugin</artifactId>
18.74 - <version>2.4</version>
18.75 - <configuration>
18.76 - <archive>
18.77 - <manifest>
18.78 - <addClasspath>true</addClasspath>
18.79 - <classpathPrefix>lib/</classpathPrefix>
18.80 - </manifest>
18.81 - </archive>
18.82 - </configuration>
18.83 - </plugin>
18.84 - <plugin>
18.85 - <artifactId>maven-assembly-plugin</artifactId>
18.86 - <version>2.4</version>
18.87 - <executions>
18.88 - <execution>
18.89 - <id>distro-assembly</id>
18.90 - <phase>package</phase>
18.91 - <goals>
18.92 - <goal>single</goal>
18.93 - </goals>
18.94 - <configuration>
18.95 - <descriptors>
18.96 - <descriptor>bck2brwsr-assembly.xml</descriptor>
18.97 - </descriptors>
18.98 - </configuration>
18.99 - </execution>
18.100 - </executions>
18.101 - </plugin>
18.102 - </plugins>
18.103 - </build>
18.104 -
18.105 - <dependencies>
18.106 - <dependency>
18.107 - <groupId>org.apidesign.bck2brwsr</groupId>
18.108 - <artifactId>emul</artifactId>
18.109 - <version>0.5-SNAPSHOT</version>
18.110 - <classifier>rt</classifier>
18.111 - </dependency>
18.112 - <dependency>
18.113 - <groupId>org.apidesign.bck2brwsr</groupId>
18.114 - <artifactId>javaquery.api</artifactId>
18.115 - <version>0.5-SNAPSHOT</version>
18.116 - </dependency>
18.117 - <dependency>
18.118 - <groupId>org.testng</groupId>
18.119 - <artifactId>testng</artifactId>
18.120 - <version>6.5.2</version>
18.121 - <scope>test</scope>
18.122 - </dependency>
18.123 - <dependency>
18.124 - <groupId>org.apidesign.bck2brwsr</groupId>
18.125 - <artifactId>vm4brwsr</artifactId>
18.126 - <classifier>js</classifier>
18.127 - <type>zip</type>
18.128 - <version>0.5-SNAPSHOT</version>
18.129 - <scope>provided</scope>
18.130 - </dependency>
18.131 - <dependency>
18.132 - <groupId>org.apidesign.bck2brwsr</groupId>
18.133 - <artifactId>vmtest</artifactId>
18.134 - <version>0.5-SNAPSHOT</version>
18.135 - <scope>test</scope>
18.136 - </dependency>
18.137 - </dependencies>
18.138 -</project>
19.1 --- a/rt/mojo/src/main/resources/archetype-resources/src/main/java/App.java Thu Mar 21 15:53:55 2013 +0100
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,34 +0,0 @@
19.4 -package ${package};
19.5 -
19.6 -import org.apidesign.bck2brwsr.htmlpage.api.*;
19.7 -import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;
19.8 -import org.apidesign.bck2brwsr.htmlpage.api.Page;
19.9 -import org.apidesign.bck2brwsr.htmlpage.api.Property;
19.10 -import org.apidesign.bck2brwsr.htmlpage.api.ComputedProperty;
19.11 -
19.12 -/** Edit the index.xhtml file. Use 'id' to name certain HTML elements.
19.13 - * Use this class to define behavior of the elements.
19.14 - */
19.15 -@Page(xhtml="index.html", className="Index", properties={
19.16 - @Property(name="name", type=String.class)
19.17 -})
19.18 -public class App {
19.19 - static {
19.20 - Index model = new Index();
19.21 - model.setName("World");
19.22 - model.applyBindings();
19.23 - }
19.24 -
19.25 - @On(event = CLICK, id="hello")
19.26 - static void hello(Index m) {
19.27 - GraphicsContext g = m.CANVAS.getContext();
19.28 - g.clearRect(0, 0, 1000, 1000);
19.29 - g.setFont("italic 40px Calibri");
19.30 - g.fillText(m.getHelloMessage(), 10, 40);
19.31 - }
19.32 -
19.33 - @ComputedProperty
19.34 - static String helloMessage(String name) {
19.35 - return "Hello " + name + "!";
19.36 - }
19.37 -}
20.1 --- a/rt/mojo/src/main/resources/archetype-resources/src/main/resources/index.html Thu Mar 21 15:53:55 2013 +0100
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,22 +0,0 @@
20.4 -<?xml version="1.0" encoding="UTF-8"?>
20.5 -<!DOCTYPE html>
20.6 -<html xmlns="http://www.w3.org/1999/xhtml">
20.7 - <head>
20.8 - <title>Bck2Brwsr's Hello World</title>
20.9 - </head>
20.10 - <body>
20.11 - <h1 data-bind="text: helloMessage">Loading Bck2Brwsr's Hello World...</h1>
20.12 - Your name: <input id='input' data-bind="value: name, valueUpdate: 'afterkeydown'"></input>
20.13 - <button id="hello">Say Hello!</button>
20.14 - <p>
20.15 - <canvas id="canvas" width="300" height="50">
20.16 - </canvas>
20.17 - </p>
20.18 -
20.19 - <script src="bck2brwsr.js"></script>
20.20 - <script type="text/javascript">
20.21 - var vm = bck2brwsr('${artifactId}-${version}.jar');
20.22 - vm.loadClass('${package}.App');
20.23 - </script>
20.24 - </body>
20.25 -</html>
21.1 --- a/rt/mojo/src/main/resources/archetype-resources/src/test/java/AppTest.java Thu Mar 21 15:53:55 2013 +0100
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,26 +0,0 @@
21.4 -package ${package};
21.5 -
21.6 -import static org.testng.Assert.*;
21.7 -import org.testng.annotations.BeforeMethod;
21.8 -import org.testng.annotations.Test;
21.9 -
21.10 -/** Demonstrating POJO testing of HTML page model. Runs in good old HotSpot
21.11 - * as it does not reference any HTML elements or browser functionality. Just
21.12 - * operates on the page model.
21.13 - *
21.14 - * @author Jaroslav Tulach <jtulach@netbeans.org>
21.15 - */
21.16 -public class AppTest {
21.17 - private Index model;
21.18 -
21.19 -
21.20 - @BeforeMethod
21.21 - public void initModel() {
21.22 - model = new Index().applyBindings();
21.23 - }
21.24 -
21.25 - @Test public void testHelloMessage() {
21.26 - model.setName("Joe");
21.27 - assertEquals(model.getHelloMessage(), "Hello Joe!", "Cleared after pressing +");
21.28 - }
21.29 -}
22.1 --- a/rt/mojo/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Thu Mar 21 15:53:55 2013 +0100
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,40 +0,0 @@
22.4 -package ${package};
22.5 -
22.6 -import org.apidesign.bck2brwsr.vmtest.Compare;
22.7 -import org.apidesign.bck2brwsr.vmtest.VMTest;
22.8 -import org.testng.annotations.Factory;
22.9 -
22.10 -/** Bck2brwsr cares about compatibility with real Java. Whatever API is
22.11 - * supported by bck2brwsr, it needs to behave the same way as when running
22.12 - * in HotSpot VM.
22.13 - * <p>
22.14 - * There can be bugs, however. To help us fix them, we kindly ask you to
22.15 - * write an "inconsistency" test. A test that compares behavior of the API
22.16 - * between real VM and bck2brwsr VM. This class is skeleton of such test.
22.17 - *
22.18 - * @author Jaroslav Tulach <jtulach@netbeans.org>
22.19 - */
22.20 -public class InconsistencyTest {
22.21 - /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
22.22 - * Make calls to an API that behaves strangely, return some result at
22.23 - * the end. No need to use any <code>assert</code>.
22.24 - *
22.25 - * @return value to compare between HotSpot and bck2brwsr
22.26 - */
22.27 - @Compare
22.28 - public int checkStringHashCode() throws Exception {
22.29 - return "Is string hashCode the same?".hashCode();
22.30 - }
22.31 -
22.32 - /** Factory method that creates a three tests for each method annotated with
22.33 - * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
22.34 - * HotSpot, one in Rhino and the last one compares the results.
22.35 - *
22.36 - * @see org.apidesign.bck2brwsr.vmtest.VMTest
22.37 - */
22.38 - @Factory
22.39 - public static Object[] create() {
22.40 - return VMTest.create(InconsistencyTest.class);
22.41 - }
22.42 -
22.43 -}
23.1 --- a/rt/mojo/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java Thu Mar 21 15:53:55 2013 +0100
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,46 +0,0 @@
23.4 -package ${package};
23.5 -
23.6 -import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
23.7 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
23.8 -import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
23.9 -import org.apidesign.bck2brwsr.vmtest.VMTest;
23.10 -import org.testng.annotations.Factory;
23.11 -
23.12 -/** Sometimes it is useful to run tests inside of the real browser.
23.13 - * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
23.14 - * and that is it. If your code references elements on the HTML page,
23.15 - * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
23.16 - * will be made available on the page before your test starts.
23.17 - *
23.18 - * @author Jaroslav Tulach <jtulach@netbeans.org>
23.19 - */
23.20 -public class IntegrationTest {
23.21 -
23.22 - /** Write to testing code here. Use <code>assert</code> (but not TestNG's
23.23 - * Assert, as TestNG is not compiled with target 1.6 yet).
23.24 - */
23.25 - @HtmlFragment(
23.26 - "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
23.27 - "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
23.28 - "<button id=\"hello\">Say Hello!</button>\n" +
23.29 - "<p>\n" +
23.30 - " <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
23.31 - "</p>\n"
23.32 - )
23.33 - @BrwsrTest
23.34 - public void modifyValueAssertChangeInModel() {
23.35 - Index m = new Index();
23.36 - m.setName("Joe Hacker");
23.37 - m.applyBindings();
23.38 - assert "Joe Hacker".equals(m.INPUT.getValue()) : "Value is really Joe Hacker: " + m.INPUT.getValue();
23.39 - m.INPUT.setValue("Happy Joe");
23.40 - m.triggerEvent(m.INPUT, OnEvent.CHANGE);
23.41 - assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
23.42 - }
23.43 -
23.44 - @Factory
23.45 - public static Object[] create() {
23.46 - return VMTest.create(IntegrationTest.class);
23.47 - }
23.48 -
23.49 -}
24.1 --- a/rt/mojo/src/test/java/org/apidesign/bck2brwsr/mojo/ArchetypeVersionTest.java Thu Mar 21 15:53:55 2013 +0100
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,102 +0,0 @@
24.4 -/**
24.5 - * Back 2 Browser Bytecode Translator
24.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
24.7 - *
24.8 - * This program is free software: you can redistribute it and/or modify
24.9 - * it under the terms of the GNU General Public License as published by
24.10 - * the Free Software Foundation, version 2 of the License.
24.11 - *
24.12 - * This program is distributed in the hope that it will be useful,
24.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
24.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24.15 - * GNU General Public License for more details.
24.16 - *
24.17 - * You should have received a copy of the GNU General Public License
24.18 - * along with this program. Look for COPYING file in the top folder.
24.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
24.20 - */
24.21 -package org.apidesign.bck2brwsr.mojo;
24.22 -
24.23 -import java.net.URL;
24.24 -import javax.xml.XMLConstants;
24.25 -import javax.xml.parsers.DocumentBuilderFactory;
24.26 -import javax.xml.xpath.XPathConstants;
24.27 -import javax.xml.xpath.XPathExpression;
24.28 -import javax.xml.xpath.XPathFactory;
24.29 -import org.testng.annotations.Test;
24.30 -import org.xml.sax.InputSource;
24.31 -import static org.testng.Assert.*;
24.32 -import org.testng.annotations.BeforeClass;
24.33 -import org.w3c.dom.Document;
24.34 -import org.w3c.dom.NodeList;
24.35 -
24.36 -/**
24.37 - *
24.38 - * @author Jaroslav Tulach <jtulach@netbeans.org>
24.39 - */
24.40 -public class ArchetypeVersionTest {
24.41 - private String version;
24.42 -
24.43 - public ArchetypeVersionTest() {
24.44 - }
24.45 -
24.46 - @BeforeClass public void readCurrentVersion() throws Exception {
24.47 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
24.48 - URL u = l.getResource("META-INF/maven/org.apidesign.bck2brwsr/mojo/plugin-help.xml");
24.49 - assertNotNull(u, "Own pom found");
24.50 -
24.51 - final XPathFactory fact = XPathFactory.newInstance();
24.52 - fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
24.53 -
24.54 - XPathExpression xp = fact.newXPath().compile("plugin/version/text()");
24.55 - version = xp.evaluate(new InputSource(u.openStream()));
24.56 -
24.57 - assertFalse(version.isEmpty(), "There should be some version string");
24.58 - }
24.59 -
24.60 -
24.61 - @Test public void testComparePomDepsVersions() throws Exception {
24.62 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
24.63 - URL r = l.getResource("archetype-resources/pom.xml");
24.64 - assertNotNull(r, "Archetype pom found");
24.65 -
24.66 - final XPathFactory fact = XPathFactory.newInstance();
24.67 - XPathExpression xp2 = fact.newXPath().compile(
24.68 - "//version[../groupId/text() = 'org.apidesign.bck2brwsr']/text()"
24.69 - );
24.70 -
24.71 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
24.72 - NodeList arch = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
24.73 -
24.74 - if (arch.getLength() < 3) {
24.75 - fail("There should be at least three dependencies to bck2brwsr APIs: " + arch.getLength());
24.76 - }
24.77 -
24.78 - for (int i = 0; i < arch.getLength(); i++) {
24.79 - assertEquals(arch.item(i).getTextContent(), version, i + "th dependency needs to be on latest version of bck2brwsr");
24.80 - }
24.81 - }
24.82 -
24.83 - @Test public void testNbActions() throws Exception {
24.84 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
24.85 - URL r = l.getResource("archetype-resources/nbactions.xml");
24.86 - assertNotNull(r, "Archetype nb file found");
24.87 -
24.88 - final XPathFactory fact = XPathFactory.newInstance();
24.89 - XPathExpression xp2 = fact.newXPath().compile(
24.90 - "//goal/text()"
24.91 - );
24.92 -
24.93 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
24.94 - NodeList goals = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
24.95 -
24.96 - for (int i = 0; i < goals.getLength(); i++) {
24.97 - String s = goals.item(i).getTextContent();
24.98 - if (s.contains("bck2brwsr")) {
24.99 - String[] arr = s.split(":");
24.100 - assertEquals(arr.length, 4, "Three :");
24.101 - assertEquals(arr[2], version, "Proper version is used");
24.102 - }
24.103 - }
24.104 - }
24.105 -}
25.1 --- a/rt/pom.xml Thu Mar 21 15:53:55 2013 +0100
25.2 +++ b/rt/pom.xml Fri Mar 22 00:02:21 2013 +0100
25.3 @@ -15,6 +15,7 @@
25.4 <module>core</module>
25.5 <module>emul</module>
25.6 <module>launcher</module>
25.7 + <module>archetype</module>
25.8 <module>mojo</module>
25.9 <module>vm</module>
25.10 <module>vmtest</module>