Search in sources :

Example 1 with BrowserBuilder

use of net.java.html.boot.BrowserBuilder in project dukescript-presenters by dukescript.

the class GtkKnockoutTest method compatibilityTests.

@Factory
public static Object[] compatibilityTests() throws Exception {
    Class[] arr = testClasses();
    for (int i = 0; i < arr.length; i++) {
        assertEquals(arr[i].getClassLoader(), GtkKnockoutTest.class.getClassLoader(), "All classes loaded by the same classloader");
    }
    URI uri = DynamicHTTP.initServer();
    final BrowserBuilder bb = BrowserBuilder.newBrowser(new WebKitPresenter(true)).loadClass(GtkKnockoutTest.class).loadPage(uri.toString()).invoke("initialized");
    Executors.newSingleThreadExecutor().submit(new Runnable() {

        @Override
        public void run() {
            bb.showAndWait();
        }
    });
    ClassLoader l = getClassLoader();
    List<Object> res = new ArrayList<>();
    for (Class oldC : arr) {
        Class<?> c = Class.forName(oldC.getName(), true, l);
        seekKOTests(c, res);
    }
    return res.toArray();
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) BrowserBuilder(net.java.html.boot.BrowserBuilder) Factory(org.testng.annotations.Factory)

Example 2 with BrowserBuilder

use of net.java.html.boot.BrowserBuilder in project dukescript-presenters by dukescript.

the class KoBrowserTest method compatibilityTests.

@Factory
public static Object[] compatibilityTests() throws Exception {
    Browser.LOG.setLevel(Level.FINE);
    Browser.LOG.addHandler(new ConsoleHandler());
    final BrowserBuilder bb = BrowserBuilder.newBrowser(new Browser("KoBrowserTest")).loadClass(KoBrowserTest.class).loadPage("empty.html").invoke("initialized");
    Executors.newSingleThreadExecutor().submit(new Runnable() {

        @Override
        public void run() {
            bb.showAndWait();
        }
    });
    List<Object> res = new ArrayList<Object>();
    Class<? extends Annotation> test = loadClass().getClassLoader().loadClass(KOTest.class.getName()).asSubclass(Annotation.class);
    Class[] arr = (Class[]) loadClass().getDeclaredMethod("tests").invoke(null);
    final HttpServer s = Browser.findServer(browserPresenter);
    ServerConfiguration conf = s.getServerConfiguration();
    conf.addHttpHandler(new DynamicHTTP(s), "/dynamic");
    for (Class c : arr) {
        for (Method m : c.getMethods()) {
            if (m.getAnnotation(test) != null) {
                res.add(new KOScript(browserPresenter, m));
            }
        }
    }
    return res.toArray();
}
Also used : ServerConfiguration(org.glassfish.grizzly.http.server.ServerConfiguration) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) ConsoleHandler(java.util.logging.ConsoleHandler) BrowserBuilder(net.java.html.boot.BrowserBuilder) HttpServer(org.glassfish.grizzly.http.server.HttpServer) Factory(org.testng.annotations.Factory)

Example 3 with BrowserBuilder

use of net.java.html.boot.BrowserBuilder in project dukescript-presenters by dukescript.

the class BrowserTest method compatibilityTests.

@Factory
public static Object[] compatibilityTests() throws Exception {
    final BrowserBuilder bb = BrowserBuilder.newBrowser(new Browser("BrowserTest")).loadClass(BrowserTest.class).loadPage("empty.html").invoke("initialized");
    Executors.newSingleThreadExecutor().submit(new Runnable() {

        @Override
        public void run() {
            bb.showAndWait();
        }
    });
    List<Object> res = new ArrayList<Object>();
    Class<? extends Annotation> test = loadClass().getClassLoader().loadClass(KOTest.class.getName()).asSubclass(Annotation.class);
    Class[] arr = (Class[]) loadClass().getDeclaredMethod("tests").invoke(null);
    for (Class c : arr) {
        for (Method m : c.getMethods()) {
            if (m.getAnnotation(test) != null) {
                res.add(new KOScript(browserPresenter, m));
            }
        }
    }
    return res.toArray();
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) BrowserBuilder(net.java.html.boot.BrowserBuilder) Factory(org.testng.annotations.Factory)

Example 4 with BrowserBuilder

use of net.java.html.boot.BrowserBuilder in project dukescript-presenters by dukescript.

the class GtkJavaScriptTest method compatibilityTests.

@Factory
public static Object[] compatibilityTests() throws Exception {
    final BrowserBuilder bb = BrowserBuilder.newBrowser(new WebKitPresenter(true)).loadClass(GtkJavaScriptTest.class).loadPage("empty.html").invoke("initialized");
    Executors.newSingleThreadExecutor().submit(new Runnable() {

        @Override
        public void run() {
            bb.showAndWait();
        }
    });
    List<Object> res = new ArrayList<>();
    Class<? extends Annotation> test = loadClass().getClassLoader().loadClass(KOTest.class.getName()).asSubclass(Annotation.class);
    Class[] arr = (Class[]) loadClass().getDeclaredMethod("tests").invoke(null);
    for (Class c : arr) {
        for (Method m : c.getMethods()) {
            if (m.getAnnotation(test) != null) {
                res.add(new Case(browserPresenter, m));
            }
        }
    }
    return res.toArray();
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) BrowserBuilder(net.java.html.boot.BrowserBuilder) Factory(org.testng.annotations.Factory)

Example 5 with BrowserBuilder

use of net.java.html.boot.BrowserBuilder in project dukescript-presenters by dukescript.

the class GenericTest method createTests.

static Object[] createTests(Testing p) throws Exception {
    final BrowserBuilder bb = BrowserBuilder.newBrowser(p).loadClass(GenericTest.class).loadPage("empty.html").invoke("initialized");
    Executors.newSingleThreadExecutor().submit(new Runnable() {

        @Override
        public void run() {
            bb.showAndWait();
        }
    });
    List<Object> res = new ArrayList<Object>();
    Class<? extends Annotation> test = loadClass().getClassLoader().loadClass(KOTest.class.getName()).asSubclass(Annotation.class);
    Class[] arr = (Class[]) loadClass().getDeclaredMethod("tests").invoke(null);
    for (Class c : arr) {
        for (Method m : c.getMethods()) {
            if (m.getAnnotation(test) != null) {
                res.add(new Case(p, m));
            }
        }
    }
    return res.toArray();
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) BrowserBuilder(net.java.html.boot.BrowserBuilder)

Aggregations

ArrayList (java.util.ArrayList)5 BrowserBuilder (net.java.html.boot.BrowserBuilder)5 Method (java.lang.reflect.Method)4 Factory (org.testng.annotations.Factory)4 URI (java.net.URI)1 ConsoleHandler (java.util.logging.ConsoleHandler)1 HttpServer (org.glassfish.grizzly.http.server.HttpServer)1 ServerConfiguration (org.glassfish.grizzly.http.server.ServerConfiguration)1