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 2019/10/28 16:51:41 UTC
[netbeans-html4j] branch master updated: Skip the webkit tests if
the libraries cannot be loaded
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
The following commit(s) were added to refs/heads/master by this push:
new 593ead6 Skip the webkit tests if the libraries cannot be loaded
593ead6 is described below
commit 593ead6f77247ec9a9c59d0490d97df239a8d008
Author: Jaroslav Tulach <ja...@apidesign.org>
AuthorDate: Mon Oct 28 17:51:33 2019 +0100
Skip the webkit tests if the libraries cannot be loaded
---
.../html/presenters/webkit/WebKitPresenter.java | 12 +++++-
.../html/presenters/webkit/GtkJavaScriptTest.java | 38 +++++++++++++----
.../html/presenters/webkit/GtkKnockoutTest.java | 28 +++++++++----
.../org/netbeans/html/presenters/webkit/Skip.java | 49 ++++++++++++++++++++++
4 files changed, 109 insertions(+), 18 deletions(-)
diff --git a/webkit/src/main/java/org/netbeans/html/presenters/webkit/WebKitPresenter.java b/webkit/src/main/java/org/netbeans/html/presenters/webkit/WebKitPresenter.java
index 7adf6e2..774b94b 100644
--- a/webkit/src/main/java/org/netbeans/html/presenters/webkit/WebKitPresenter.java
+++ b/webkit/src/main/java/org/netbeans/html/presenters/webkit/WebKitPresenter.java
@@ -126,8 +126,16 @@ public final class WebKitPresenter implements Fn.Presenter, Fn.KeepAlive, Execut
}
shell.show(page.toURI());
- } catch (Throwable t) {
- LOG.log(Level.SEVERE, onPageApp, t);
+ } catch (RuntimeException t) {
+ throw t;
+ } catch (Exception t) {
+ if (t.getCause() instanceof Error) {
+ throw (Error) t.getCause();
+ }
+ if (t.getCause() instanceof RuntimeException) {
+ throw (RuntimeException) t.getCause();
+ }
+ throw new RuntimeException(t);
}
}
diff --git a/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkJavaScriptTest.java b/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkJavaScriptTest.java
index 777d0af..dc42bcd 100644
--- a/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkJavaScriptTest.java
+++ b/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkJavaScriptTest.java
@@ -22,7 +22,10 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import net.java.html.BrwsrCtx;
import net.java.html.boot.BrowserBuilder;
import org.netbeans.html.boot.spi.Fn;
@@ -50,21 +53,38 @@ public class GtkJavaScriptTest extends JavaScriptTCK {
loadPage("empty.html");
// END: org.netbeans.html.presenters.webkit.GtkJavaScriptTest
- Executors.newSingleThreadExecutor().submit(bb::showAndWait);
+ Future<Void> future = Executors.newSingleThreadExecutor().submit(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ bb.showAndWait();
+ return null;
+ }
+ });
List<Object> res = new ArrayList<>();
- Class<? extends Annotation> test =
- loadClass().getClassLoader().loadClass(KOTest.class.getName()).
- asSubclass(Annotation.class);
+ try {
+ future.get();
+ 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));
+ 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));
+ }
}
}
+ } catch (InterruptedException | ExecutionException err) {
+ err.printStackTrace();
+ if (err.getCause() instanceof LinkageError) {
+ res.add(new Skip(err.getCause().getMessage()));
+ } else {
+ res.add(new Skip(err.getMessage()));
+ }
}
+
return res.toArray();
}
diff --git a/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkKnockoutTest.java b/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkKnockoutTest.java
index 9650e8d..946601b 100644
--- a/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkKnockoutTest.java
+++ b/webkit/src/test/java/org/netbeans/html/presenters/webkit/GtkKnockoutTest.java
@@ -30,8 +30,11 @@ import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import net.java.html.BrwsrCtx;
import net.java.html.boot.BrowserBuilder;
import net.java.html.js.JavaScriptBody;
@@ -74,18 +77,29 @@ public final class GtkKnockoutTest extends KnockoutTCK {
loadPage(uri.toString()).
invoke("initialized");
- Executors.newSingleThreadExecutor().submit(new Runnable() {
+ Future<Void> future = Executors.newSingleThreadExecutor().submit(new Callable<Void>() {
@Override
- public void run() {
+ public Void call() {
bb.showAndWait();
+ return null;
}
});
-
- ClassLoader l = getClassLoader();
+
List<Object> res = new ArrayList<>();
- for (Class oldC : arr) {
- Class<?> c = Class.forName(oldC.getName(), true, l);
- seekKOTests(c, res);
+ try {
+ future.get();
+ ClassLoader l = getClassLoader();
+ for (Class oldC : arr) {
+ Class<?> c = Class.forName(oldC.getName(), true, l);
+ seekKOTests(c, res);
+ }
+ } catch (InterruptedException | ExecutionException err) {
+ err.printStackTrace();
+ if (err.getCause() instanceof LinkageError) {
+ res.add(new Skip(err.getCause().getMessage()));
+ } else {
+ res.add(new Skip(err.getMessage()));
+ }
}
return res.toArray();
}
diff --git a/webkit/src/test/java/org/netbeans/html/presenters/webkit/Skip.java b/webkit/src/test/java/org/netbeans/html/presenters/webkit/Skip.java
new file mode 100644
index 0000000..fc3f170
--- /dev/null
+++ b/webkit/src/test/java/org/netbeans/html/presenters/webkit/Skip.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.html.presenters.webkit;
+
+import org.testng.IHookCallBack;
+import org.testng.IHookable;
+import org.testng.ITest;
+import org.testng.ITestResult;
+import org.testng.SkipException;
+import org.testng.annotations.Test;
+
+public final class Skip implements ITest, IHookable {
+ private final String msg;
+
+ Skip(String msg) {
+ this.msg = msg;
+ }
+
+ @Override
+ public String getTestName() {
+ return "Skip";
+ }
+
+ @Test
+ public void executeTest() throws Exception {
+ throw new SkipException(msg);
+ }
+
+ @Override
+ public void run(IHookCallBack ihcb, ITestResult itr) {
+ ihcb.runTestMethod(itr);
+ }
+}
---------------------------------------------------------------------
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