changeset 985:7a6519fee342

CustomPermission properly formats basic permissions 2014-06-06 Andrew Azores <aazores@redhat.com> * netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java (toString): fixed empty actions string appearing on basic permissions, which do not have actions * tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java: (testToStringWithoutActions): new test
author Andrew Azores <aazores@redhat.com>
date Fri, 06 Jun 2014 14:42:02 -0400
parents 476ce40cafc7
children 576b9e693117
files ChangeLog netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java
diffstat 3 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jun 06 09:35:30 2014 -0400
+++ b/ChangeLog	Fri Jun 06 14:42:02 2014 -0400
@@ -1,3 +1,11 @@
+2014-06-06  Andrew Azores  <aazores@redhat.com>
+
+	* netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java
+	(toString): fixed empty actions string appearing on basic permissions, which
+	do not have actions
+	* tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java:
+	(testToStringWithoutActions): new test
+
 2014-06-06  Andrew Azores  <aazores@redhat.com>
 
 	Fixed NullPointerException when closing PolicyEditor with changes made and
--- a/netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java	Fri Jun 06 09:35:30 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/CustomPermission.java	Fri Jun 06 14:42:02 2014 -0400
@@ -107,7 +107,7 @@
         sb.append(target);
         sb.append("\"");
 
-        if (!this.actions.equals(PermissionActions.NONE)) {
+        if (!this.actions.equals(PermissionActions.NONE.rawString())) {
             sb.append(", \"");
             sb.append(actions);
             sb.append("\"");
--- a/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java	Fri Jun 06 09:35:30 2014 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/security/policyeditor/CustomPermissionTest.java	Fri Jun 06 14:42:02 2014 -0400
@@ -36,7 +36,9 @@
 
 package net.sourceforge.jnlp.security.policyeditor;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+
 import org.junit.Test;
 
 public class CustomPermissionTest {
@@ -114,6 +116,13 @@
     }
 
     @Test
+    public void testToStringWithoutActions() throws Exception {
+        final CustomPermission cp = new CustomPermission("java.lang.RuntimePermission", "createClassLoader", "");
+        final String expected = "permission java.lang.RuntimePermission \"createClassLoader\";";
+        assertEquals(expected, cp.toString());
+    }
+
+    @Test
     public void testCompareTo() throws Exception {
         final CustomPermission cp1 = new CustomPermission("java.io.FilePermission", "*", "read");
         final CustomPermission cp2 = new CustomPermission("java.io.FilePermission", "${user.home}${/}*", "read");