Skip to content

Commit 62a5b79

Browse files
committed
Normalize formatting
1 parent b0c4088 commit 62a5b79

File tree

1 file changed

+60
-58
lines changed

1 file changed

+60
-58
lines changed

src/test/java/org/apache/commons/jexl3/ComposePermissionsTest.java

+60-58
Original file line numberDiff line numberDiff line change
@@ -33,70 +33,72 @@
3333
* Tests for pragmas
3434
*/
3535
public class ComposePermissionsTest extends JexlTestCase {
36-
static final String SAMPLE_JSON = "src/test/scripts/sample.json";
37-
/**
38-
* Create a new test case.
39-
*/
40-
public ComposePermissionsTest() {
41-
super("PermissionsTest");
42-
}
36+
static final String SAMPLE_JSON = "src/test/scripts/sample.json";
4337

44-
void runComposePermissions(final JexlPermissions p) throws Exception {
45-
final String check = "http://example.com/content.jpg";
46-
final File jsonFile = new File(SAMPLE_JSON);
47-
final Gson gson = new Gson();
48-
final Object json = gson.fromJson(new FileReader(jsonFile), Object.class);
49-
assertNotNull(json);
38+
/**
39+
* Create a new test case.
40+
*/
41+
public ComposePermissionsTest() {
42+
super("PermissionsTest");
43+
}
5044

51-
// will succeed because java.util.Map is allowed and gson LinkedTreeMap is one
52-
final JexlEngine j0 = createEngine(false, p);
53-
final JexlScript s0 = j0.createScript("json.pageInfo.pagePic", "json");
54-
final Object r0 = s0.execute(null, json);
55-
assertEquals(check, r0);
45+
void runComposePermissions(final JexlPermissions p) throws Exception {
46+
final String check = "http://example.com/content.jpg";
47+
final File jsonFile = new File(SAMPLE_JSON);
48+
final Gson gson = new Gson();
49+
final Object json = gson.fromJson(new FileReader(jsonFile), Object.class);
50+
assertNotNull(json);
5651

57-
// will fail if gson package is denied
58-
JexlEngine j1 = createEngine(false, p.compose("com.google.gson.internal {}"));
59-
JexlScript s1 = j1.createScript("json.pageInfo.pagePic", "json");
60-
try {
61-
final Object r1 = s1.execute(null, json);
62-
fail("gson restricted");
63-
} catch (final JexlException.Property xproperty) {
64-
assertEquals("pageInfo", xproperty.getProperty());
65-
}
52+
// will succeed because java.util.Map is allowed and gson LinkedTreeMap is one
53+
final JexlEngine j0 = createEngine(false, p);
54+
final JexlScript s0 = j0.createScript("json.pageInfo.pagePic", "json");
55+
final Object r0 = s0.execute(null, json);
56+
assertEquals(check, r0);
6657

67-
// will fail since gson package is denied
68-
j1 = createEngine(false, p.compose("com.google.gson.internal { LinkedTreeMap {} }"));
69-
s1 = j1.createScript("json.pageInfo.pagePic", "json");
70-
try {
71-
final Object r1 = s1.execute(null, json);
72-
fail("gson LinkTreeMap restricted");
73-
} catch (final JexlException.Property xproperty) {
74-
assertEquals("pageInfo", xproperty.getProperty());
75-
}
58+
// will fail if gson package is denied
59+
JexlEngine j1 = createEngine(false, p.compose("com.google.gson.internal {}"));
60+
JexlScript s1 = j1.createScript("json.pageInfo.pagePic", "json");
61+
try {
62+
final Object r1 = s1.execute(null, json);
63+
fail("gson restricted");
64+
} catch (final JexlException.Property xproperty) {
65+
assertEquals("pageInfo", xproperty.getProperty());
66+
}
67+
68+
// will fail since gson package is denied
69+
j1 = createEngine(false, p.compose("com.google.gson.internal { LinkedTreeMap {} }"));
70+
s1 = j1.createScript("json.pageInfo.pagePic", "json");
71+
try {
72+
final Object r1 = s1.execute(null, json);
73+
fail("gson LinkTreeMap restricted");
74+
} catch (final JexlException.Property xproperty) {
75+
assertEquals("pageInfo", xproperty.getProperty());
76+
}
7677

77-
// will not fail since gson objects
78-
j1 = createEngine(false, JexlPermissions.RESTRICTED);
79-
s1 = j1.createScript("json.pageInfo.pagePic", "json");
80-
final Object r1 = s1.execute(null, json);
81-
assertEquals(check, r0);
82-
}
78+
// will not fail since gson objects
79+
j1 = createEngine(false, JexlPermissions.RESTRICTED);
80+
s1 = j1.createScript("json.pageInfo.pagePic", "json");
81+
final Object r1 = s1.execute(null, json);
82+
assertEquals(check, r0);
83+
}
8384

84-
@Test
85-
public void testComposePermissions() throws Exception {
86-
runComposePermissions(JexlPermissions.UNRESTRICTED);
87-
}
85+
@Test
86+
public void testComposePermissions() throws Exception {
87+
runComposePermissions(JexlPermissions.UNRESTRICTED);
88+
}
8889

89-
@Test
90-
public void testComposePermissions1() throws Exception {
91-
runComposePermissions(new JexlPermissions.Delegate(JexlPermissions.UNRESTRICTED) {
92-
@Override public String toString() {
93-
return "delegate:" + base.toString();
94-
}
95-
});
96-
}
90+
@Test
91+
public void testComposePermissions1() throws Exception {
92+
runComposePermissions(new JexlPermissions.Delegate(JexlPermissions.UNRESTRICTED) {
93+
@Override
94+
public String toString() {
95+
return "delegate:" + base.toString();
96+
}
97+
});
98+
}
9799

98-
@Test
99-
public void testComposePermissions2() throws Exception {
100-
runComposePermissions(new JexlPermissions.ClassPermissions(JexlPermissions.UNRESTRICTED, Collections.emptySet()));
101-
}
100+
@Test
101+
public void testComposePermissions2() throws Exception {
102+
runComposePermissions(new JexlPermissions.ClassPermissions(JexlPermissions.UNRESTRICTED, Collections.emptySet()));
103+
}
102104
}

0 commit comments

Comments
 (0)