You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jt...@apache.org on 2020/12/07 14:27:16 UTC

[netbeans-html4j] 02/02: Documenting KnockoutTCK

This is an automated email from the ASF dual-hosted git repository.

jtulach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans-html4j.git

commit f28cd08f58e2511be9b20dcab5e68fc9d0ffe4b2
Author: Jaroslav Tulach <ja...@apidesign.org>
AuthorDate: Mon Dec 7 15:04:27 2020 +0100

    Documenting KnockoutTCK
---
 .../java/org/netbeans/html/json/tck/KOTest.java    | 10 ++++-
 .../org/netbeans/html/json/tck/KnockoutTCK.java    | 51 ++++++++++++++--------
 .../src/test/java/org/netbeans/html/ko4j/KOFx.java |  2 +
 .../org/netbeans/html/ko4j/KnockoutFXTest.java     |  5 ++-
 pom.xml                                            |  1 +
 5 files changed, 48 insertions(+), 21 deletions(-)

diff --git a/json-tck/src/main/java/org/netbeans/html/json/tck/KOTest.java b/json-tck/src/main/java/org/netbeans/html/json/tck/KOTest.java
index 4458ed2..9ca07c9 100644
--- a/json-tck/src/main/java/org/netbeans/html/json/tck/KOTest.java
+++ b/json-tck/src/main/java/org/netbeans/html/json/tck/KOTest.java
@@ -23,10 +23,16 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-/** Annotates method that is part of {@link KnockoutTCK test compatibility kit} 
+/** Annotates method that is part of {@link KnockoutTCK visual test compatibility kit}
+ * or {@link JavaScriptTCK headless test compatibility kit}
  * and should be executed in appropriate environment. The method annotated by
  * this annotation will be public instance method of its class 
- * with no arguments.
+ * with no arguments. A typical way to enumerate such methods is:
+ * <p>
+ * {@codesnippet net.java.html.boot.script.ScriptEngineJavaScriptTCK}
+ * and then one can execute such methods as
+ * <p>
+ * {@codesnippet net.java.html.boot.script.ScriptEngineCase#run}
  *
  * @author Jaroslav Tulach
  */
diff --git a/json-tck/src/main/java/org/netbeans/html/json/tck/KnockoutTCK.java b/json-tck/src/main/java/org/netbeans/html/json/tck/KnockoutTCK.java
index 369c418..59b1774 100644
--- a/json-tck/src/main/java/org/netbeans/html/json/tck/KnockoutTCK.java
+++ b/json-tck/src/main/java/org/netbeans/html/json/tck/KnockoutTCK.java
@@ -31,26 +31,41 @@ import net.java.html.json.tests.OperationsTest;
 import net.java.html.json.tests.Utils;
 import net.java.html.json.tests.WebSocketTest;
 import org.netbeans.html.context.spi.Contexts.Builder;
-import org.openide.util.lookup.ServiceProvider;
 
-/** Entry point for providers of different HTML binding technologies (like
- * Knockout.js in JavaFX's WebView). Sample usage:
+/**
+ * An enhanced, visual <em>Test Compatibility Kit</em> for people providing their own
+ * implementation of {@link org.netbeans.html.boot.spi.Fn.Presenter} or any other system that understands
+ * {@link net.java.html.js.JavaScriptBody} annotation. The {@link KnockoutTCK}
+ * is an extension over {@link JavaScriptTCK} - the <em>headless</em> test
+ * compatibility kit. Once the <em>headless</em> functionality works fine,
+ * it is time to test the visual aspects - at the end the goal is to run visual
+ * <b>Java</b> applications in browser, right?
+ * <p>
+ * The {@link KnockoutTCK} shall be subclassesed and {@code abstract} methods
+ * of the class implemented to provide the necessary environment for execution.
+ * A typical way to obtain all the methods to be tested for each of {@link #testClasses} is:
+ * <p>
+ * {@codesnippet org.netbeans.html.ko4j.KnockoutFXTest}
+ * <p>
+ * The visual tests interact with browser environment and perform asynchronous
+ * network calls. That has two consequences:
+ * <ul>
+ *  <li>the test may ask you to set a server up via {@link KnockoutTCK#prepareWebResource(java.lang.String, java.lang.String, java.lang.String[])} call -
+ *    return URL which the test later connects to
+ *  <li>the test may need to wait - in such case it throws {@link InterruptedException} - wait a while
+ *    and call the test method again (while keeping the instance and its internal state)
+ * </ul>
+ * <p>
+ * The typical way to execute the visual tests requires one to perform something like:
+ * <p>
+ * {@codesnippet org.netbeans.html.ko4j.KOFx}
+ * e.g. initialize the test instance, run the test method. If it yields an
+ * {@link InterruptedException}, run the test again. Should there be no success
+ * in a fixed time, give up and fail the test. Succeed otherwise.
+ * This is more complicated than running headless {@link JavaScriptTCK} tests,
+ * but so is the behavior of typical applications in the browser with access to
+ * network.
  * 
-<pre>
-{@link ServiceProvider @ServiceProvider}(service = KnockoutTCK.class)
-public final class MyKnockoutBindingTest extends KnockoutTCK {
-    {@link Override @Override}
-    protected BrwsrCtx createContext() {
-        // use {@link Builder}.{@link Builder#build() build}();
-    }
-
-    {@code @org.testng.annotations.Factory}
-    public static Object[] create() {
-        return VMTest.newTests().withClasses({@link KnockoutTCK#testClasses}()).build();
-    }
-}
- * </pre>
- *
  * @author Jaroslav Tulach
  */
 public abstract class KnockoutTCK {
diff --git a/ko4j/src/test/java/org/netbeans/html/ko4j/KOFx.java b/ko4j/src/test/java/org/netbeans/html/ko4j/KOFx.java
index 1e34b1c..989705f 100644
--- a/ko4j/src/test/java/org/netbeans/html/ko4j/KOFx.java
+++ b/ko4j/src/test/java/org/netbeans/html/ko4j/KOFx.java
@@ -62,6 +62,7 @@ public final class KOFx implements ITest, Runnable {
         }
     }
 
+    // BEGIN: org.netbeans.html.ko4j.KOFx
     @Override
     public synchronized void run() {
         boolean notify = true;
@@ -102,5 +103,6 @@ public final class KOFx implements ITest, Runnable {
             }
         }
     }
+    // END: org.netbeans.html.ko4j.KOFx
     
 }
diff --git a/ko4j/src/test/java/org/netbeans/html/ko4j/KnockoutFXTest.java b/ko4j/src/test/java/org/netbeans/html/ko4j/KnockoutFXTest.java
index 42dac5b..4c86b00 100644
--- a/ko4j/src/test/java/org/netbeans/html/ko4j/KnockoutFXTest.java
+++ b/ko4j/src/test/java/org/netbeans/html/ko4j/KnockoutFXTest.java
@@ -95,7 +95,9 @@ public final class KnockoutFXTest extends KnockoutTCK {
         return res.toArray();
     }
 
-    private static void seekKOTests(Class<?> c, List<Object> res) throws SecurityException, ClassNotFoundException {
+    // BEGIN: org.netbeans.html.ko4j.KnockoutFXTest
+    private static void seekKOTests(Class<?> c, List<Object> res)
+    throws ClassNotFoundException {
         Class<? extends Annotation> koTest =
             c.getClassLoader().loadClass(KOTest.class.getName()).
             asSubclass(Annotation.class);
@@ -108,6 +110,7 @@ public final class KnockoutFXTest extends KnockoutTCK {
             }
         }
     }
+    // END: org.netbeans.html.ko4j.KnockoutFXTest
 
     private static boolean skipUnsupported(Method m) {
         String version = System.getProperty("java.version"); // NOI18N
diff --git a/pom.xml b/pom.xml
index ed859f3..a5bbba2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -156,6 +156,7 @@ org.netbeans.html.boot.impl:org.netbeans.html.boot.fx:org.netbeans.html.context.
                 <additionalOptions>
                     -snippetpath boot-fx/src/test
                     -snippetpath boot-script/src/test
+                    -snippetpath ko4j/src/test
                     -snippetpath json/src/test
                     -snippetpath webkit/src/test
                     ${javadoc.allowjs}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists