rt/mojo/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 26 Feb 2013 16:54:16 +0100
changeset 772 d382dacfd73f
parent 534 mojo/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java@3cefccd50bd5
permissions -rw-r--r--
Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
     1 package ${package};
     2 
     3 import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
     4 import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
     5 import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
     6 import org.apidesign.bck2brwsr.vmtest.VMTest;
     7 import org.testng.annotations.Factory;
     8 
     9 /** Sometimes it is useful to run tests inside of the real browser. 
    10  * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
    11  * and that is it. If your code references elements on the HTML page,
    12  * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
    13  * will be made available on the page before your test starts.
    14  *
    15  * @author Jaroslav Tulach <jtulach@netbeans.org>
    16  */
    17 public class IntegrationTest {
    18     
    19     /** Write to testing code here. Use <code>assert</code> (but not TestNG's
    20      * Assert, as TestNG is not compiled with target 1.6 yet).
    21      */
    22     @HtmlFragment(
    23         "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
    24         "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
    25         "<button id=\"hello\">Say Hello!</button>\n" +
    26         "<p>\n" +
    27         "    <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
    28         "</p>\n"
    29     )
    30     @BrwsrTest
    31     public void modifyValueAssertChangeInModel() {
    32         Index m = new Index();
    33         m.setName("Joe Hacker");
    34         m.applyBindings();
    35         assert "Joe Hacker".equals(m.INPUT.getValue()) : "Value is really Joe Hacker: " + m.INPUT.getValue();
    36         m.INPUT.setValue("Happy Joe");
    37         m.triggerEvent(m.INPUT, OnEvent.CHANGE);
    38         assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
    39     }
    40 
    41     @Factory
    42     public static Object[] create() {
    43         return VMTest.create(IntegrationTest.class);
    44     }
    45     
    46 }