1.1 --- a/mojo/src/main/resources/META-INF/maven/archetype-metadata.xml Tue Jan 22 22:11:52 2013 +0100
1.2 +++ b/mojo/src/main/resources/META-INF/maven/archetype-metadata.xml Tue Jan 22 22:42:39 2013 +0100
1.3 @@ -35,7 +35,7 @@
1.4 <fileSet filtered="true" packaged="true">
1.5 <directory>src/test/java</directory>
1.6 <includes>
1.7 - <include>**/AppTest.java</include>
1.8 + <include>**/*Test.java</include>
1.9 </includes>
1.10 </fileSet>
1.11 <fileSet filtered="false" packaged="false">
2.1 --- a/mojo/src/main/resources/archetype-resources/pom.xml Tue Jan 22 22:11:52 2013 +0100
2.2 +++ b/mojo/src/main/resources/archetype-resources/pom.xml Tue Jan 22 22:42:39 2013 +0100
2.3 @@ -59,5 +59,11 @@
2.4 <version>6.5.2</version>
2.5 <scope>test</scope>
2.6 </dependency>
2.7 + <dependency>
2.8 + <groupId>${project.groupId}</groupId>
2.9 + <artifactId>vmtest</artifactId>
2.10 + <version>0.3-SNAPSHOT</version>
2.11 + <scope>test</scope>
2.12 + </dependency>
2.13 </dependencies>
2.14 </project>
3.1 --- a/mojo/src/main/resources/archetype-resources/src/main/resources/index.xhtml Tue Jan 22 22:11:52 2013 +0100
3.2 +++ b/mojo/src/main/resources/archetype-resources/src/main/resources/index.xhtml Tue Jan 22 22:42:39 2013 +0100
3.3 @@ -6,7 +6,7 @@
3.4 </head>
3.5 <body>
3.6 <h1 data-bind="text: helloMessage">Loading Bck2Brwsr's Hello World...</h1>
3.7 - Your name: <input data-bind="value: name, valueUpdate: 'afterkeydown'"></input>
3.8 + Your name: <input id='input' data-bind="value: name, valueUpdate: 'afterkeydown'"></input>
3.9 <button id="hello">Say Hello!</button>
3.10 <p>
3.11 <canvas id="canvas" width="300" height="50">
4.1 --- a/mojo/src/main/resources/archetype-resources/src/test/java/AppTest.java Tue Jan 22 22:11:52 2013 +0100
4.2 +++ b/mojo/src/main/resources/archetype-resources/src/test/java/AppTest.java Tue Jan 22 22:42:39 2013 +0100
4.3 @@ -4,7 +4,9 @@
4.4 import org.testng.annotations.BeforeMethod;
4.5 import org.testng.annotations.Test;
4.6
4.7 -/** Demonstrating POJO testing of HTML page model.
4.8 +/** Demonstrating POJO testing of HTML page model. Runs in good old HotSpot
4.9 + * as it does not reference any HTML elements or browser functionality. Just
4.10 + * operates on the page model.
4.11 *
4.12 * @author Jaroslav Tulach <jtulach@netbeans.org>
4.13 */
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/mojo/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Tue Jan 22 22:42:39 2013 +0100
5.3 @@ -0,0 +1,40 @@
5.4 +package ${package};
5.5 +
5.6 +import org.apidesign.bck2brwsr.vmtest.Compare;
5.7 +import org.apidesign.bck2brwsr.vmtest.VMTest;
5.8 +import org.testng.annotations.Factory;
5.9 +
5.10 +/** Bck2brwsr cares about compatibility with real Java. Whatever API is
5.11 + * supported by bck2brwsr, it needs to behave the same way as when running
5.12 + * in HotSpot VM.
5.13 + * <p>
5.14 + * There can be bugs, however. To help us fix them, we kindly ask you to
5.15 + * write an "inconsistency" test. A test that compares behavior of the API
5.16 + * between real VM and bck2brwsr VM. This class is skeleton of such test.
5.17 + *
5.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
5.19 + */
5.20 +public class InconsistencyTest {
5.21 + /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
5.22 + * Make calls to an API that behaves strangely, return some result at
5.23 + * the end. No need to use any <code>assert</code>.
5.24 + *
5.25 + * @return value to compare between HotSpot and bck2brwsr
5.26 + */
5.27 + @Compare
5.28 + public int checkStringHashCode() throws Exception {
5.29 + return "Is string hashCode the same?".hashCode();
5.30 + }
5.31 +
5.32 + /** Factory method that creates a three tests for each method annotated with
5.33 + * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
5.34 + * HotSpot, one in Rhino and the last one compares the results.
5.35 + *
5.36 + * @see org.apidesign.bck2brwsr.vmtest.VMTest
5.37 + */
5.38 + @Factory
5.39 + public static Object[] create() {
5.40 + return VMTest.create(InconsistencyTest.class);
5.41 + }
5.42 +
5.43 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/mojo/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java Tue Jan 22 22:42:39 2013 +0100
6.3 @@ -0,0 +1,46 @@
6.4 +package ${package};
6.5 +
6.6 +import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
6.7 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
6.8 +import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
6.9 +import org.apidesign.bck2brwsr.vmtest.VMTest;
6.10 +import org.testng.annotations.Factory;
6.11 +
6.12 +/** Sometimes it is useful to run tests inside of the real browser.
6.13 + * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
6.14 + * and that is it. If your code references elements on the HTML page,
6.15 + * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
6.16 + * will be made available on the page before your test starts.
6.17 + *
6.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
6.19 + */
6.20 +public class IntegrationTest {
6.21 +
6.22 + /** Write to testing code here. Use <code>assert</code> (but not TestNG's
6.23 + * Assert, as TestNG is not compiled with target 1.6 yet).
6.24 + */
6.25 + @HtmlFragment(
6.26 + "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
6.27 + "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
6.28 + "<button id=\"hello\">Say Hello!</button>\n" +
6.29 + "<p>\n" +
6.30 + " <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
6.31 + "</p>\n"
6.32 + )
6.33 + @BrwsrTest
6.34 + public void modifyValueAssertChangeInModel() {
6.35 + Index m = new Index();
6.36 + m.setName("Joe Hacker");
6.37 + m.applyBindings();
6.38 + assert "Joe Hacker".equals(m.INPUT.getValue()) : "Value is really Joe Hacker: " + m.INPUT.getValue();
6.39 + m.INPUT.setValue("Happy Joe");
6.40 + m.triggerEvent(m.INPUT, OnEvent.CHANGE);
6.41 + assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
6.42 + }
6.43 +
6.44 + @Factory
6.45 + public static Object[] create() {
6.46 + return VMTest.create(IntegrationTest.class);
6.47 + }
6.48 +
6.49 +}