/hg/icedtea-web: Clenaup in PolicyEditor tests and MVC

jvanek at icedtea.classpath.org jvanek at icedtea.classpath.org
Thu Mar 27 13:09:25 UTC 2014


changeset b4631fce293a in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=b4631fce293a
author: Jiri Vanek <jvanek at redhat.com>
date: Thu Mar 27 14:08:54 2014 +0100

	Clenaup in PolicyEditor tests and MVC


diffstat:

 ChangeLog                                                                                   |  10 +++
 netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java                           |  29 ++++++++-
 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java        |   2 -
 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionActionsTest.java       |   3 +-
 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTargetTest.java        |   1 -
 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTypeTest.java          |   1 -
 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorParsingTest.java     |  14 +---
 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorPermissionsTest.java |   6 +-
 tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java            |   6 +-
 tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java                          |   4 +
 10 files changed, 47 insertions(+), 29 deletions(-)

diffs (201 lines):

diff -r f975d5db4fbd -r b4631fce293a ChangeLog
--- a/ChangeLog	Wed Mar 26 13:56:55 2014 -0400
+++ b/ChangeLog	Thu Mar 27 14:08:54 2014 +0100
@@ -1,3 +1,13 @@
+2014-03-27  Jiri Vanek  <jvanek at redhat.com>
+
+	Clenaup in PolicyEditor tests and MVC
+	* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java: MVC
+	mixing method (updatecheckboxes) splited to invokelater and plain impls.
+	* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/* : removed
+	warnings and fixed wrong package declaration.
+	* tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java: when
+	filelaks are negative, take it as success.
+
 2014-03-26  Andrew Azores  <aazores at redhat.com>
 
 	Fix JOptionPane modality problems after making PolicyEditor itself modal
diff -r f975d5db4fbd -r b4631fce293a netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Thu Mar 27 14:08:54 2014 +0100
@@ -55,6 +55,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationTargetException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.channels.FileLock;
@@ -793,10 +794,31 @@
      * @param codebase whose permissions to display
      */
     private void updateCheckboxes(final String codebase) {
-        SwingUtilities.invokeLater(new Runnable() {
+        try {
+            if (SwingUtilities.isEventDispatchThread()){
+             updateCheckboxesImpl(codebase);   
+            } else {
+            updateCheckboxesInvokeAndWait(codebase);
+            }
+        } catch (InterruptedException ex) {
+            OutputController.getLogger().log(ex);
+        } catch (InvocationTargetException ex) {
+            OutputController.getLogger().log(ex);
+        }
+    }
+    
+    private void updateCheckboxesInvokeAndWait(final String codebase) throws InterruptedException, InvocationTargetException {
+        SwingUtilities.invokeAndWait(new Runnable() {
             @Override
             public void run() {
-                for (final PolicyEditorPermissions perm : PolicyEditorPermissions.values()) {
+               updateCheckboxesImpl(codebase);
+            }
+        });
+
+    }
+    
+     private void updateCheckboxesImpl(String codebase) {
+                 for (final PolicyEditorPermissions perm : PolicyEditorPermissions.values()) {
                     final JCheckBox box = checkboxMap.get(perm);
                     for (final ActionListener l : box.getActionListeners()) {
                         box.removeActionListener(l);
@@ -830,9 +852,6 @@
                     });
                 }
             }
-        });
-
-    }
 
     /**
      * Set a mnemonic key for a menu item or button
diff -r f975d5db4fbd -r b4631fce293a tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java	Thu Mar 27 14:08:54 2014 +0100
@@ -37,8 +37,6 @@
 package net.sourceforge.jnlp.security.policyeditor;
 
 import static org.junit.Assert.assertTrue;
-import net.sourceforge.jnlp.security.policyeditor.CustomPermission;
-
 import org.junit.Test;
 
 public class CustomPermissionTest {
diff -r f975d5db4fbd -r b4631fce293a tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionActionsTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionActionsTest.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionActionsTest.java	Thu Mar 27 14:08:54 2014 +0100
@@ -36,10 +36,9 @@
 
 package net.sourceforge.jnlp.security.policyeditor;
 
-import static org.junit.Assert.assertTrue;
-
 import java.util.HashSet;
 import java.util.Set;
+import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 
 public class PermissionActionsTest {
diff -r f975d5db4fbd -r b4631fce293a tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTargetTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTargetTest.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTargetTest.java	Thu Mar 27 14:08:54 2014 +0100
@@ -37,7 +37,6 @@
 package net.sourceforge.jnlp.security.policyeditor;
 
 import static org.junit.Assert.assertTrue;
-
 import org.junit.Test;
 
 public class PermissionTargetTest {
diff -r f975d5db4fbd -r b4631fce293a tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTypeTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTypeTest.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PermissionTypeTest.java	Thu Mar 27 14:08:54 2014 +0100
@@ -37,7 +37,6 @@
 package net.sourceforge.jnlp.security.policyeditor;
 
 import static org.junit.Assert.assertTrue;
-
 import org.junit.Test;
 
 public class PermissionTypeTest {
diff -r f975d5db4fbd -r b4631fce293a tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorParsingTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorParsingTest.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorParsingTest.java	Thu Mar 27 14:08:54 2014 +0100
@@ -33,18 +33,14 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version.
  */
+package net.sourceforge.jnlp.security.policyeditor;
 
+import java.io.File;
+import java.util.Map;
+import net.sourceforge.jnlp.annotations.KnownToFail;
+import net.sourceforge.jnlp.util.FileUtils;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.Map;
-import net.sourceforge.jnlp.annotations.KnownToFail;
-import net.sourceforge.jnlp.security.policyeditor.PolicyEditor;
-import net.sourceforge.jnlp.security.policyeditor.PolicyEditorPermissions;
-import net.sourceforge.jnlp.util.FileUtils;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
diff -r f975d5db4fbd -r b4631fce293a tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorPermissionsTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorPermissionsTest.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorPermissionsTest.java	Thu Mar 27 14:08:54 2014 +0100
@@ -36,13 +36,9 @@
 
 package net.sourceforge.jnlp.security.policyeditor;
 
+import java.util.regex.Pattern;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
-import java.util.regex.Pattern;
-
-import net.sourceforge.jnlp.security.policyeditor.PolicyEditorPermissions;
-
 import org.junit.Test;
 
 public class PolicyEditorPermissionsTest {
diff -r f975d5db4fbd -r b4631fce293a tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/PolicyEditorTest.java	Thu Mar 27 14:08:54 2014 +0100
@@ -36,15 +36,13 @@
 
 package net.sourceforge.jnlp.security.policyeditor;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import java.io.File;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import org.junit.Before;
 import org.junit.Test;
 
diff -r f975d5db4fbd -r b4631fce293a tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java
--- a/tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java	Wed Mar 26 13:56:55 2014 -0400
+++ b/tests/test-extensions/net/sourceforge/jnlp/util/FileTestUtils.java	Thu Mar 27 14:08:54 2014 +0100
@@ -79,6 +79,10 @@
         runnable.run();
         Thread.sleep(10);
         long filesLeaked = getOpenFileDescriptorCount() - filesOpenBefore;
+        //how come? Appearently can...
+        if (filesLeaked<0){
+            return;
+        }
         assertEquals(0, filesLeaked);
     }
 


More information about the distro-pkg-dev mailing list