/hg/release/icedtea-web-1.6: Fixed issue, when desktop/menu shor...
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Tue Jun 9 15:53:02 UTC 2015
changeset 7b9e3303f691 in /hg/release/icedtea-web-1.6
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.6?cmd=changeset;node=7b9e3303f691
author: Jiri Vanek <jvanek at redhat.com>
date: Tue Jun 09 17:52:42 2015 +0200
Fixed issue, when desktop/menu shortcut created during -html mode, was not created like it
diffstat:
ChangeLog | 61 +++--
netx/net/sourceforge/jnlp/runtime/Boot.java | 3 +
netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java | 11 +
netx/net/sourceforge/jnlp/util/FileUtils.java | 12 +-
netx/net/sourceforge/jnlp/util/XDesktopEntry.java | 9 +-
tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java | 111 +++++++++-
6 files changed, 174 insertions(+), 33 deletions(-)
diffs (385 lines):
diff -r 4e3281c63564 -r 7b9e3303f691 ChangeLog
--- a/ChangeLog Tue Jun 09 14:36:37 2015 +0200
+++ b/ChangeLog Tue Jun 09 17:52:42 2015 +0200
@@ -1,3 +1,16 @@
+2015-06-09 Jiri Vanek <jvanek at redhat.com>
+
+ Fixed issue, when desktop/menu shortcut created during -html mode, was not created like it
+ * netx/net/sourceforge/jnlp/runtime/Boot.java: setHtml(true) used when
+ commandline contains html switch
+ * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: added html field and setter and getter
+ * netx/net/sourceforge/jnlp/util/XDesktopEntry.java: (getContentsAsReader) now
+ add -html if jnlpruntime.isHtml.
+ * tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java: added tests for new
+ functionality
+ * Changelog: occurence of tab asterix slash replaced by tab asterix space in file
+ declarations
+
2015-06-09 Jiri Vanek <jvanek at redhat.com>
Fixed bug when generated desktop icon was not matched and user was asked for recreation
@@ -242,25 +255,25 @@
2015-04-13 Jiri Vanek <jvanek at redhat.com>
set single place for keystore operations
- */netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: usage of keystore moved
+ * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: usage of keystore moved
to utility method
- */netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
- */netx/net/sourceforge/jnlp/security/KeyStores.java: same
- */netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
- */netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
- */netx/net/sourceforge/jnlp/security/SecurityUtil.java: added five new methods
+ * netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
+ * netx/net/sourceforge/jnlp/security/KeyStores.java: same
+ * netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
+ * netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
+ * netx/net/sourceforge/jnlp/security/SecurityUtil.java: added five new methods
wrapping work on keystores
2015-04-13 Jiri Vanek <jvanek at redhat.com>
Removed redundant occurrence of default keystore password
- */netx/net/sourceforge/jnlp/security/KeyStores.java: removed redundant DEFAULT_PASSWORD
- */netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: call to KeyStores.getPassword
+ * netx/net/sourceforge/jnlp/security/KeyStores.java: removed redundant DEFAULT_PASSWORD
+ * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: call to KeyStores.getPassword
replaced by SecurityUtil.getTrustedCertsPassword
- */netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
- */netx/net/sourceforge/jnlp/security/SecurityUtil.java: same
- */netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
- */netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
+ * netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
+ * netx/net/sourceforge/jnlp/security/SecurityUtil.java: same
+ * netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
+ * netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
2015-04-13 Jiri Vanek <jvanek at redhat.com>
@@ -1076,34 +1089,34 @@
2014-12-05 Jiri Vanek <jvanek at redhat.com>
Added support for menu shortcuts.
- */netx/net/sourceforge/jnlp/Parser.java: used setMenu instead of addMenu
- */netx/net/sourceforge/jnlp/ShortcutDesc.java: removed isOnline support,
+ * netx/net/sourceforge/jnlp/Parser.java: used setMenu instead of addMenu
+ * netx/net/sourceforge/jnlp/ShortcutDesc.java: removed isOnline support,
added onDesktop and toMenu support. addMenu renamed to setMenu.
Added deploymentJavawsShortcutToString, just for comfortableness.
- */netx/net/sourceforge/jnlp/config/PathsAndFiles.java: Added support for
+ * netx/net/sourceforge/jnlp/config/PathsAndFiles.java: Added support for
XDG_DATA_HOME, declared ICONS_DIR and MENUS_DIR
- */netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java: removed
+ * netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java: removed
duplicated logic of deploymentJavawsShortcutToString/comboboxItem and
hardcoded calls to depolyment.
- */netx/net/sourceforge/jnlp/resources/Messages.properties: added
+ * netx/net/sourceforge/jnlp/resources/Messages.properties: added
CPTabMenuShortcuts, FILEicons, FILEmenus. adapted SDesktopShortcut
- */netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java:
+ * netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java:
removed retired fixme, now it do not ask for shortcut creation if menu or
desktop entry exists. Added menu support and removed not-implemented call.
Added temporary IconsCreationDescriptor qiockfix for dialog->logic information
rtransfer. Used where needed.
- */netx/net/sourceforge/jnlp/security/SecurityDialogs.java: Added boolean
+ * netx/net/sourceforge/jnlp/security/SecurityDialogs.java: Added boolean
and integer workarounds around showAccessWarningDialog
- */netx/net/sourceforge/jnlp/security/dialogs/AccessWarningPane.java: Added
+ * netx/net/sourceforge/jnlp/security/dialogs/AccessWarningPane.java: Added
menu support.
Is now coding more sophisticated return value if are about desktop creations.
- */netx/net/sourceforge/jnlp/services/ServiceUtil.java: Adapted to
+ * netx/net/sourceforge/jnlp/services/ServiceUtil.java: Adapted to
showAccessWarningDialog changes
- */netx/net/sourceforge/jnlp/util/FileUtils.java: INVALID_CHARS extended
+ * netx/net/sourceforge/jnlp/util/FileUtils.java: INVALID_CHARS extended
for more linux one and most windows ones.
- */netx/net/sourceforge/jnlp/util/XDesktopEntry.java: added logic to place
+ * netx/net/sourceforge/jnlp/util/XDesktopEntry.java: added logic to place
menu shortcut.
- */tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java: Is now testing only
+ * tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java: Is now testing only
presence of isOnline instead if it is used.
diff -r 4e3281c63564 -r 7b9e3303f691 netx/net/sourceforge/jnlp/runtime/Boot.java
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java Tue Jun 09 14:36:37 2015 +0200
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java Tue Jun 09 17:52:42 2015 +0200
@@ -177,6 +177,9 @@
if (optionParser.hasOption(OptionsDefinitions.OPTIONS.TRUSTALL)) {
JNLPRuntime.setTrustAll(true);
}
+ if (optionParser.hasOption(OptionsDefinitions.OPTIONS.HTML)) {
+ JNLPRuntime.setHtml(true);
+ }
if (optionParser.hasOption(OptionsDefinitions.OPTIONS.TRUSTNONE)) {
JNLPRuntime.setTrustNone(true);
}
diff -r 4e3281c63564 -r 7b9e3303f691 netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Tue Jun 09 14:36:37 2015 +0200
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Tue Jun 09 17:52:42 2015 +0200
@@ -151,6 +151,9 @@
/** all security dialogs will be consumed and pretented as being verified by user and allowed.*/
private static boolean trustAll=false;
+
+ /** flag keeping rest of jnlpruntime live that javaws was lunched as -html */
+ private static boolean html=false;
/** all security dialogs will be consumed and we will pretend the Sandbox option was chosen */
private static boolean trustNone = false;
@@ -830,6 +833,14 @@
}
}
+ public static void setHtml(boolean html) {
+ JNLPRuntime.html = html;
+ }
+
+ public static boolean isHtml() {
+ return html;
+ }
+
static void setTrustAll(boolean b) {
trustAll=b;
}
diff -r 4e3281c63564 -r 7b9e3303f691 netx/net/sourceforge/jnlp/util/FileUtils.java
--- a/netx/net/sourceforge/jnlp/util/FileUtils.java Tue Jun 09 14:36:37 2015 +0200
+++ b/netx/net/sourceforge/jnlp/util/FileUtils.java Tue Jun 09 17:52:42 2015 +0200
@@ -30,6 +30,7 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
+import java.io.Reader;
import java.io.Writer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
@@ -575,8 +576,15 @@
* @throws IOException if connection can't be established or resource does not exist
*/
public static String getContentOfStream(InputStream is, String encoding) throws IOException {
+ try {
+ return getContentOfReader(new InputStreamReader(is, encoding));
+ } finally {
+ is.close();
+ }
+ }
+ public static String getContentOfReader(Reader r) throws IOException {
try {
- BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding));
+ BufferedReader br = new BufferedReader(r);
StringBuilder sb = new StringBuilder();
while (true) {
String s = br.readLine();
@@ -588,7 +596,7 @@
}
return sb.toString();
} finally {
- is.close();
+ r.close();
}
}
diff -r 4e3281c63564 -r 7b9e3303f691 netx/net/sourceforge/jnlp/util/XDesktopEntry.java
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java Tue Jun 09 14:36:37 2015 +0200
+++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java Tue Jun 09 17:52:42 2015 +0200
@@ -40,6 +40,7 @@
import net.sourceforge.jnlp.IconDesc;
import net.sourceforge.jnlp.JNLPFile;
+import net.sourceforge.jnlp.OptionsDefinitions;
import net.sourceforge.jnlp.PluginBridge;
import net.sourceforge.jnlp.StreamEater;
import net.sourceforge.jnlp.cache.CacheUtil;
@@ -151,9 +152,13 @@
}
if (JNLPRuntime.isWebstartApplication()) {
+ String htmlSwitch = "";
+ if (JNLPRuntime.isHtml()){
+ htmlSwitch = " "+OptionsDefinitions.OPTIONS.HTML.option;
+ }
fileContents += "Exec="
- + getJavaWsBin() + " \"" + file.getSourceLocation() + "\"\n";
- OutputController.getLogger().log("Using " + getJavaWsBin() + " as binary for " + file.getSourceLocation());
+ + getJavaWsBin() + htmlSwitch + " \"" + file.getSourceLocation() + "\"\n";
+ OutputController.getLogger().log("Using " + getJavaWsBin() + htmlSwitch + " as binary for " + file.getSourceLocation());
} else {
if (info.getShortcutType() == AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.BROWSER) {
String browser = info.getBrowser();
diff -r 4e3281c63564 -r 7b9e3303f691 tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java Tue Jun 09 14:36:37 2015 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java Tue Jun 09 17:52:42 2015 +0200
@@ -37,15 +37,25 @@
package net.sourceforge.jnlp.util;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
+import java.io.Reader;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import net.sourceforge.jnlp.InformationDesc;
+import net.sourceforge.jnlp.JNLPFile;
+import net.sourceforge.jnlp.PluginBridgeTest;
import net.sourceforge.jnlp.ServerAccess;
import net.sourceforge.jnlp.annotations.KnownToFail;
+import net.sourceforge.jnlp.mock.DummyJNLPFileWithJar;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.security.dialogs.AccessWarningPaneComplexReturn;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -74,6 +84,32 @@
private static final String src8 = XDesktopEntry.XDG_DESKTOP_DIR + " = " + des8;
private static final String src9 = XDesktopEntry.XDG_DESKTOP_DIR + " = " + des9;
private static Map<String, String> backupedEnv;
+ private static boolean wasHtml;
+ private static boolean wasJavaws;
+
+ @BeforeClass
+ public static void saveJnlpRuntimeHtml() {
+ wasHtml = JNLPRuntime.isHtml();
+ wasJavaws = JNLPRuntime.isWebstartApplication();
+ }
+
+ private static void setIsWebstart(boolean value) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
+ Field field = JNLPRuntime.class.getDeclaredField("isWebstartApplication");
+ field.setAccessible(true);
+ field.set(null, value);
+ }
+
+ @After
+ public void restoreJnlpRuntimeHtml() throws Exception {
+ JNLPRuntime.setHtml(wasHtml);
+ setIsWebstart(wasJavaws);
+ }
+
+ @AfterClass
+ public static void restoreJnlpRuntimeHtmlFinally() throws Exception {
+ JNLPRuntime.setHtml(wasHtml);
+ setIsWebstart(wasJavaws);
+ }
@BeforeClass
public static void ensureHomeVaribale() throws NoSuchFieldException, IllegalAccessException, IllegalArgumentException, ClassNotFoundException {
@@ -84,7 +120,7 @@
backupedEnv = null;
} else {
backupedEnv = env;
- Map<String,String> m = new HashMap<String,String>(env);
+ Map<String, String> m = new HashMap<String, String>(env);
m.put(HOME, System.getProperty("user.home"));
fakeEnvironment(m);
ServerAccess.logOutputReprint("Hacked environment");
@@ -102,7 +138,7 @@
}
}
- private static void fakeEnvironment(Map<String,String> m) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
+ private static void fakeEnvironment(Map<String, String> m) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
Class<?> processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment");
Field env = processEnvironmentClass.getDeclaredField("theUnmodifiableEnvironment");
env.setAccessible(true);
@@ -123,13 +159,13 @@
@Test
public void getFreedesktopOrgDesktopPathFromtestSimple() throws IOException {
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src1)));
- Assert.assertEquals(s, des1);
+ Assert.assertEquals(des1, s);
}
@Test
public void getFreedesktopOrgDesktopPathFromtestSpaced() throws IOException {
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src2)));
- Assert.assertEquals(s, des1);
+ Assert.assertEquals(des1, s);
}
@Test(expected = IOException.class)
@@ -160,6 +196,7 @@
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src8)));
Assert.assertEquals(s, des8res);
}
+
@Test
public void getFreedesktopOrgDesktopPathFromtestSpacedWithHomeAndMixedQuotes() throws IOException {
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src9)));
@@ -181,4 +218,68 @@
ServerAccess.logOutputReprint(entry.getKey() + " = " + entry.getValue());
}
}
-}
\ No newline at end of file
+
+ @Test
+ public void allFilesHaveSameName() throws IOException {
+ JNLPFile jnlpf = new DummyJnlpWithTitle();
+ XDesktopEntry xde = new XDesktopEntry(jnlpf);
+ File f1 = xde.getShortcutTmpFile();
+ File f2 = xde.getLinuxDesktopIconFile();
+ File f3 = xde.getLinuxMenuIconFile();
+ Assert.assertEquals(f1.getName(), f2.getName());
+ Assert.assertEquals(f2.getName(), f3.getName());
+ }
+
+ private void testHtmlOccurences(boolean html, boolean javaws, boolean menu, AccessWarningPaneComplexReturn.ShortcutResult.Shortcut type, int occurences) throws Exception {
+ JNLPRuntime.setHtml(html);
+ setIsWebstart(javaws);
+ JNLPFile jnlpf = new DummyJnlpWithTitle();
+ XDesktopEntry xde = new XDesktopEntry(jnlpf);
+ AccessWarningPaneComplexReturn.ShortcutResult a = new AccessWarningPaneComplexReturn.ShortcutResult(true);
+ a.setBrowser("blah");
+ a.setFixHref(false);
+ a.setShortcutType(type);
+ Reader r = xde.getContentsAsReader(menu, a, true);
+ String s = FileUtils.getContentOfReader(r);
+ Assert.assertEquals(occurences, PluginBridgeTest.countOccurences(s, "-html"));
+ }
+
+ @Test
+ public void htmlSwitchCorrectAccordingToJnlpRuntimeAndShortcutType() throws Exception {
+ AccessWarningPaneComplexReturn.ShortcutResult.Shortcut[] v = AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.values();
+ for (AccessWarningPaneComplexReturn.ShortcutResult.Shortcut w : v) {
+ int var1 = 0;
+ if (w == AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.JAVAWS_HTML) {
+ var1 = 1;
+ }
+ testHtmlOccurences(true, true, true, w, 1);
+ testHtmlOccurences(true, false, false, w, var1);
+ testHtmlOccurences(true, false, true, w, var1);
+ testHtmlOccurences(true, true, false, w, 1);
+ testHtmlOccurences(false, true, true, w, 0);
+ testHtmlOccurences(false, false, false, w, var1);
+ testHtmlOccurences(false, true, false, w, 0);
+ testHtmlOccurences(false, false, true, w, var1);
+ }
+ }
+
+ private static class DummyJnlpWithTitle extends DummyJNLPFileWithJar {
+
+ public DummyJnlpWithTitle() throws MalformedURLException {
+ super(new File("/some/path/blah.jar"));
+ }
+
+ @Override
+ public InformationDesc getInformation() {
+ return new InformationDesc(null, false) {
+
+ @Override
+ public String getTitle() {
+ return "Demo App";
+ }
+
+ };
+ }
+
+ };
+}
More information about the distro-pkg-dev
mailing list