Mercurial > hg > release > icedtea-web-1.7
changeset 1480:4abd0f089773
Added test for javafx
author | Jiri Vanek <jvanek@redhat.com> |
---|---|
date | Fri, 02 Mar 2018 10:41:29 +0100 |
parents | 6b237a5f396c |
children | bcbef8d7bbd6 |
files | .hgignore ChangeLog netx/net/sourceforge/jnlp/util/FileUtils.java tests/netx/unit/net/sourceforge/jnlp/util/FileUtilsTest.java tests/reproducers/custom/JavaFx/resources/JavaFx.jar tests/reproducers/custom/JavaFx/resources/JavaFx.jnlp tests/reproducers/custom/JavaFx/srcs/Controller.java tests/reproducers/custom/JavaFx/srcs/Main.java tests/reproducers/custom/JavaFx/srcs/Makefile tests/reproducers/custom/JavaFx/srcs/helloworld.fxml tests/reproducers/custom/JavaFx/testcases/JavaFxTest.java tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java |
diffstat | 13 files changed, 237 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Fri Mar 02 10:34:07 2018 +0100 +++ b/.hgignore Fri Mar 02 10:41:29 2018 +0100 @@ -12,3 +12,6 @@ netx/net/sourceforge/jnlp/resources/ChangeLog\.html netx/net/sourceforge/jnlp/resources/NEWS\.html netx-dist-tests-whitelist +rust-launcher/target +rust-launcher/Cargo.lock +
--- a/ChangeLog Fri Mar 02 10:34:07 2018 +0100 +++ b/ChangeLog Fri Mar 02 10:41:29 2018 +0100 @@ -1,3 +1,16 @@ +2018-02-06 Jiri Vanek <jvanek@redhat.com> + + Added test for javafx-desc + * tests/reproducers/custom/JavaFx/resources/JavaFx.jar + * tests/reproducers/custom/JavaFx/resources/JavaFx.jnlp + * tests/reproducers/custom/JavaFx/srcs/Controller.class + * tests/reproducers/custom/JavaFx/srcs/Controller.java + * tests/reproducers/custom/JavaFx/srcs/Main.class + * tests/reproducers/custom/JavaFx/srcs/Main.java + * tests/reproducers/custom/JavaFx/srcs/Makefile + * tests/reproducers/custom/JavaFx/srcs/helloworld.fxml + * tests/reproducers/custom/JavaFx/testcases/JavaFxTest.java + 2018-02-05 Jiri Vanek <jvanek@redhat.com> Added basic support for javafx desc
--- a/netx/net/sourceforge/jnlp/util/FileUtils.java Fri Mar 02 10:34:07 2018 +0100 +++ b/netx/net/sourceforge/jnlp/util/FileUtils.java Fri Mar 02 10:41:29 2018 +0100 @@ -33,12 +33,12 @@ import java.io.Writer; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; +import java.nio.file.Files; +import java.nio.file.attribute.*; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; import javax.swing.JFrame; import javax.swing.JOptionPane; @@ -307,7 +307,6 @@ throw new IOException(R("RCantRename", tempFile, file)); } } - } /**
--- a/tests/netx/unit/net/sourceforge/jnlp/util/FileUtilsTest.java Fri Mar 02 10:34:07 2018 +0100 +++ b/tests/netx/unit/net/sourceforge/jnlp/util/FileUtilsTest.java Fri Mar 02 10:41:29 2018 +0100 @@ -37,6 +37,9 @@ package net.sourceforge.jnlp.util; import java.io.File; +import java.nio.file.Files; +import java.nio.file.attribute.AclEntry; +import java.nio.file.attribute.AclFileAttributeView; import java.util.ArrayList; import java.util.Arrays; import java.util.List;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/JavaFx/resources/JavaFx.jnlp Fri Mar 02 10:41:29 2018 +0100 @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<jnlp spec="1.0" xmlns:jfx="http://javafx.com" > + <information> + <title>JavaFx</title> + <vendor>ITW</vendor> + <description>JavaFx</description> + <offline-allowed/> + </information> + <resources> + <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/> + <jar href="JavaFx.jar" size="2102" download="eager" /> + </resources> + <jfx:javafx-desc width="600" height="400" main-class="Main" name="JavaFXApp" /> + <update check="background"/> +</jnlp>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/JavaFx/srcs/Controller.java Fri Mar 02 10:41:29 2018 +0100 @@ -0,0 +1,11 @@ +import javafx.fxml.FXML; +import javafx.scene.text.Text; + +public class Controller { + @FXML private Text text; + + @FXML + public void onPressButton() { + text.setVisible(true); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/JavaFx/srcs/Main.java Fri Mar 02 10:41:29 2018 +0100 @@ -0,0 +1,23 @@ +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) throws Exception { + Parent root = FXMLLoader.load(getClass().getResource("helloworld.fxml")); + primaryStage.setTitle("Hello World"); + primaryStage.setScene(new Scene(root, 500, 200)); + primaryStage.show(); + System.out.println("jnlp-javafx started"); + System.out.println("jnlp-javafx can be terminated"); + } + + + public static void main(String[] args) { + launch(args); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/JavaFx/srcs/Makefile Fri Mar 02 10:41:29 2018 +0100 @@ -0,0 +1,25 @@ +TESTNAME=JavaFx + +JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar +JAVAC=$(EXPORTED_JAVAC) +JAR=$(EXPORTED_JAR) +JARSIGNER=$(EXPORTED_JARSIGNER) + +TMPDIR:=$(shell mktemp -d) + +prepare-reproducer: + echo PREPARING REPRODUCER $(TESTNAME) + #this test contains prebuild binary, as javafx, when installed on computer, preven ITW from building + #due to JSObject differennt implementation + #$(JAVAC) -d $(TMPDIR) -classpath $(JAVAC_CLASSPATH) Controller.java Main.java; \ + #cp helloworld.fxml $(TMPDIR) ; \ + #pushd $(TMPDIR); \ + #$(JAR) cf $(TESTNAME).jar *.class *.fxml; \ + #popd + #cp $(TMPDIR)/$(TESTNAME).jar $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \ + cp ../resources/* $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \ + rm -rf $(TMPDIR); \ + echo PREPARED REPRODUCER $(TESTNAME); \ + +clean-reproducer: + echo NOTHING TO CLEAN FOR $(TESTNAME)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/JavaFx/srcs/helloworld.fxml Fri Mar 02 10:41:29 2018 +0100 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.layout.GridPane?> +<?import javafx.scene.text.Text?> +<?import javafx.scene.control.Button?> +<GridPane fx:controller="Controller" + xmlns:fx="http://javafx.com/fxml" + alignment="CENTER"> + <Text text="Hello" + GridPane.columnIndex="0" GridPane.rowIndex="0" GridPane.halignment="CENTER"/> + <Button fx:id="button" text="press if you're brave enough" + GridPane.columnIndex="0" GridPane.rowIndex="1" GridPane.halignment="CENTER" + onAction="#onPressButton"/> + <Text fx:id="text" text="BAF!" style="-fx-text-fill: red; -fx-font-size: 50; -fx-fill: red;" + GridPane.rowIndex="2" GridPane.columnIndex="0" GridPane.halignment="CENTER" + visible="false"/> +</GridPane> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/custom/JavaFx/testcases/JavaFxTest.java Fri Mar 02 10:41:29 2018 +0100 @@ -0,0 +1,81 @@ +/* +Copyright (C) 2014 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + +import java.util.Arrays; +import net.sourceforge.jnlp.OptionsDefinitions; +import org.junit.Assert; +import org.junit.Test; + +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.annotations.NeedsDisplay; +import net.sourceforge.jnlp.closinglisteners.StringBasedClosingListener; + +public class JavaFxTest { + + private static final String correct = "jnlp-javafx started"; + private static final String done = "jnlp-javafx can be terminated"; + public static final ServerAccess server = new ServerAccess(); + + /* + * Randomly seeing: + * +(javaws:13906): Gdk-ERROR **: The program 'javaws' received an X Window System error. +This probably reflects a bug in the program. +The error was 'RenderBadPicture (invalid Picture parameter)'. + (Details: serial 7754 error_code 141 request_code 138 minor_code 7) + (Note to programmers: normally, X errors are reported asynchronously; + that is, you will receive the error a while after causing it. + To debug your program, run it with the --sync command line + option to change this behavior. You can then get a meaningful + backtrace from your debugger if you break on the gdk_x_error() function.) + + * Suprsing is, that awt splasshcreen is visible, and after it also itw error dialogue is visible + */ + @Test + @NeedsDisplay + public void testJavawsJNLP() throws Exception { + ProcessResult pr = server.executeJavaws( + Arrays.asList(new String[]{OptionsDefinitions.OPTIONS.NOSEC.option, OptionsDefinitions.OPTIONS.HEADLESS.option}), + "/JavaFx.jnlp", + new StringBasedClosingListener(done), + new StringBasedClosingListener("xceptionxception")); + System.out.println(pr.stdout); + System.out.println(pr.stderr); + Assert.assertTrue("stdout should contain " + correct + ", but it didnt.", pr.stdout.contains(correct)); + } +}
--- a/tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java Fri Mar 02 10:34:07 2018 +0100 +++ b/tests/reproducers/simple/simpletest1/testcases/XDGspecificationTests.java Fri Mar 02 10:41:29 2018 +0100 @@ -327,7 +327,7 @@ ProcessWrapper pw1 = new ProcessWrapper(); pw1.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath() + server.getItwebSettingsFile().getAbsolutePath() })); pw1.setVars(setXdgVAlues(tmp, tmp)); ProcessResult pr1 = pw1.execute(); @@ -335,7 +335,7 @@ ProcessWrapper pw2 = new ProcessWrapper(); pw2.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "oldBaf", "differentOldBaf" })); @@ -796,7 +796,7 @@ ProcessWrapper pw = new ProcessWrapper(); pw.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath() + server.getItwebSettingsFile().getAbsolutePath() })); pw.setVars(removeXdgVAlues()); ProcessResult pr = pw.execute(); @@ -819,7 +819,7 @@ ProcessWrapper pw = new ProcessWrapper(); pw.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath() + server.getItwebSettingsFile().getAbsolutePath() })); pw.setVars(setXdgVAlues(f)); ProcessResult pr = pw.execute(); @@ -846,7 +846,7 @@ ProcessWrapper pw1 = new ProcessWrapper(); pw1.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath() + server.getItwebSettingsFile().getAbsolutePath() })); pw1.setVars(removeXdgVAlues()); ProcessResult pr1 = pw1.execute(); @@ -857,7 +857,7 @@ ProcessWrapper pw2 = new ProcessWrapper(); pw2.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath() + server.getItwebSettingsFile().getAbsolutePath() })); pw2.setVars(removeXdgVAlues()); ProcessResult pr2 = pw2.execute(); @@ -882,7 +882,7 @@ ProcessWrapper pw1 = new ProcessWrapper(); pw1.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath() + server.getItwebSettingsFile().getAbsolutePath() })); pw1.setVars(setXdgVAlues(f)); ProcessResult pr = pw1.execute(); @@ -892,7 +892,7 @@ ProcessWrapper pw2 = new ProcessWrapper(); pw2.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath() + server.getItwebSettingsFile().getAbsolutePath() })); pw2.setVars(removeXdgVAlues()); ProcessResult pr2 = pw2.execute(); @@ -918,7 +918,7 @@ ProcessWrapper pw = new ProcessWrapper(); pw.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "blah", "differentBlah" })); @@ -944,7 +944,7 @@ ProcessWrapper pw = new ProcessWrapper(); pw.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "blah", "differentBlah" })); @@ -974,7 +974,7 @@ ProcessWrapper pw1 = new ProcessWrapper(); pw1.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "blah", "differentBlah" })); @@ -988,7 +988,7 @@ ProcessWrapper pw2 = new ProcessWrapper(); pw2.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "baf", "differentBaf" })); @@ -1016,7 +1016,7 @@ ProcessWrapper pw1 = new ProcessWrapper(); pw1.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "blah", "differentBlah" })); @@ -1029,7 +1029,7 @@ ProcessWrapper pw2 = new ProcessWrapper(); pw2.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "baf", "differentBaf" })); @@ -1197,7 +1197,7 @@ ProcessWrapper pw = new ProcessWrapper(); pw.setArgs(Arrays.asList( new String[]{ - new File(server.getJavawsFile().getParentFile(), "itweb-settings").getAbsolutePath(), + server.getItwebSettingsFile().getAbsolutePath(), //one impl of new parser was unable to handle duplicates "set", "blah", "blah" }));
--- a/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java Fri Mar 02 10:34:07 2018 +0100 +++ b/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java Fri Mar 02 10:41:29 2018 +0100 @@ -325,6 +325,34 @@ public File getJavawsFile() { return new File(System.getProperty(JAVAWS_BUILD_BIN)); } + + /** + * + * @return - file pointing to itweb-settings deducted from passed inside + * javaws binary location (JAVAWS_BUILD_BIN) + */ + public File getItwebSettingsFile() { + String itwebSettings = "itweb-settings"; + return getFileInJavawsDir(itwebSettings); + } + + /** + * + * @return - file pointing to itweb-settings deducted from passed inside + * javaws binary location (JAVAWS_BUILD_BIN) + */ + public File getIPolicyEditorFile() { + String policyeditor = "policyeditor"; + return getFileInJavawsDir(policyeditor); + } + + private File getFileInJavawsDir(String file) { + String javawsNameRoot = "javaws"; + File dir = getJavawsFile().getParentFile(); + String name = getJavawsFile().getName(); + String nwName = name.replace(javawsNameRoot, file); + return new File(dir, nwName); + } /** *