This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git

commit 62a5b79574454ac3384959290e7f8f85c949e368
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 1 14:15:17 2024 -0400

    Normalize formatting
---
 .../commons/jexl3/ComposePermissionsTest.java      | 118 +++++++++++----------
 1 file changed, 60 insertions(+), 58 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java 
b/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
index fba993f8..359991bd 100644
--- a/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java
@@ -33,70 +33,72 @@ import com.google.gson.Gson;
  * Tests for pragmas
  */
 public class ComposePermissionsTest extends JexlTestCase {
-  static final String SAMPLE_JSON =  "src/test/scripts/sample.json";
-  /**
-   * Create a new test case.
-   */
-  public ComposePermissionsTest() {
-    super("PermissionsTest");
-  }
+    static final String SAMPLE_JSON = "src/test/scripts/sample.json";
 
-  void runComposePermissions(final JexlPermissions p) throws Exception {
-    final String check = "http://example.com/content.jpg";;
-    final File jsonFile = new File(SAMPLE_JSON);
-    final Gson gson = new Gson();
-    final Object json = gson.fromJson(new FileReader(jsonFile), Object.class);
-    assertNotNull(json);
+    /**
+     * Create a new test case.
+     */
+    public ComposePermissionsTest() {
+        super("PermissionsTest");
+    }
 
-    // will succeed because java.util.Map is allowed and gson LinkedTreeMap is 
one
-    final JexlEngine j0 = createEngine(false, p);
-    final JexlScript s0 = j0.createScript("json.pageInfo.pagePic", "json");
-    final Object r0 = s0.execute(null, json);
-    assertEquals(check, r0);
+    void runComposePermissions(final JexlPermissions p) throws Exception {
+        final String check = "http://example.com/content.jpg";;
+        final File jsonFile = new File(SAMPLE_JSON);
+        final Gson gson = new Gson();
+        final Object json = gson.fromJson(new FileReader(jsonFile), 
Object.class);
+        assertNotNull(json);
 
-    // will fail if gson package is denied
-    JexlEngine j1 = createEngine(false, p.compose("com.google.gson.internal 
{}"));
-    JexlScript s1 = j1.createScript("json.pageInfo.pagePic", "json");
-    try {
-      final Object r1 = s1.execute(null, json);
-      fail("gson restricted");
-    } catch (final JexlException.Property xproperty) {
-      assertEquals("pageInfo", xproperty.getProperty());
-    }
+        // will succeed because java.util.Map is allowed and gson 
LinkedTreeMap is one
+        final JexlEngine j0 = createEngine(false, p);
+        final JexlScript s0 = j0.createScript("json.pageInfo.pagePic", "json");
+        final Object r0 = s0.execute(null, json);
+        assertEquals(check, r0);
 
-    // will fail since gson package is denied
-     j1 = createEngine(false, p.compose("com.google.gson.internal { 
LinkedTreeMap {} }"));
-     s1 = j1.createScript("json.pageInfo.pagePic", "json");
-    try {
-      final Object r1 = s1.execute(null, json);
-      fail("gson LinkTreeMap restricted");
-    } catch (final JexlException.Property xproperty) {
-      assertEquals("pageInfo", xproperty.getProperty());
-    }
+        // will fail if gson package is denied
+        JexlEngine j1 = createEngine(false, 
p.compose("com.google.gson.internal {}"));
+        JexlScript s1 = j1.createScript("json.pageInfo.pagePic", "json");
+        try {
+            final Object r1 = s1.execute(null, json);
+            fail("gson restricted");
+        } catch (final JexlException.Property xproperty) {
+            assertEquals("pageInfo", xproperty.getProperty());
+        }
+
+        // will fail since gson package is denied
+        j1 = createEngine(false, p.compose("com.google.gson.internal { 
LinkedTreeMap {} }"));
+        s1 = j1.createScript("json.pageInfo.pagePic", "json");
+        try {
+            final Object r1 = s1.execute(null, json);
+            fail("gson LinkTreeMap restricted");
+        } catch (final JexlException.Property xproperty) {
+            assertEquals("pageInfo", xproperty.getProperty());
+        }
 
-    // will not fail since gson objects
-    j1 = createEngine(false, JexlPermissions.RESTRICTED);
-    s1 = j1.createScript("json.pageInfo.pagePic", "json");
-    final Object r1 = s1.execute(null, json);
-    assertEquals(check, r0);
-  }
+        // will not fail since gson objects
+        j1 = createEngine(false, JexlPermissions.RESTRICTED);
+        s1 = j1.createScript("json.pageInfo.pagePic", "json");
+        final Object r1 = s1.execute(null, json);
+        assertEquals(check, r0);
+    }
 
-  @Test
-  public void testComposePermissions() throws Exception {
-    runComposePermissions(JexlPermissions.UNRESTRICTED);
-  }
+    @Test
+    public void testComposePermissions() throws Exception {
+        runComposePermissions(JexlPermissions.UNRESTRICTED);
+    }
 
-  @Test
-  public void testComposePermissions1() throws Exception {
-    runComposePermissions(new 
JexlPermissions.Delegate(JexlPermissions.UNRESTRICTED) {
-      @Override public String toString() {
-        return "delegate:" + base.toString();
-      }
-    });
-  }
+    @Test
+    public void testComposePermissions1() throws Exception {
+        runComposePermissions(new 
JexlPermissions.Delegate(JexlPermissions.UNRESTRICTED) {
+            @Override
+            public String toString() {
+                return "delegate:" + base.toString();
+            }
+        });
+    }
 
-  @Test
-  public void testComposePermissions2() throws Exception {
-    runComposePermissions(new 
JexlPermissions.ClassPermissions(JexlPermissions.UNRESTRICTED, 
Collections.emptySet()));
-  }
+    @Test
+    public void testComposePermissions2() throws Exception {
+        runComposePermissions(new 
JexlPermissions.ClassPermissions(JexlPermissions.UNRESTRICTED, 
Collections.emptySet()));
+    }
 }

Reply via email to