Mercurial > hg > release > icedtea-web-1.6
changeset 956:b4631fce293a
Clenaup in PolicyEditor tests and MVC
line wrap: on
line diff
--- 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@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@redhat.com> Fix JOptionPane modality problems after making PolicyEditor itself modal
--- 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
--- 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 {
--- 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 {
--- 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 {
--- 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 {
--- 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. */ - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +package net.sourceforge.jnlp.security.policyeditor; 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 static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test;
--- 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 {
--- 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;
--- 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); }