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

kusal pushed a commit to branch WW-5343-sec-extend
in repository https://gitbox.apache.org/repos/asf/struts.git

commit eba79a784436912ab3e57cb9cafba64f6eaee6d5
Author: Kusal Kithul-Godage <g...@kusal.io>
AuthorDate: Thu Nov 23 01:09:49 2023 +1100

    WW-5343 Fix final test
---
 .../com/opensymphony/xwork2/ognl/OgnlUtilTest.java | 27 ++++++++++------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java 
b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
index 16f1c3850..5df410e2b 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilTest.java
@@ -61,6 +61,9 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertThrows;
+
 public class OgnlUtilTest extends XWorkTestCase {
 
     // Fields for static field access test
@@ -1174,22 +1177,16 @@ public class OgnlUtilTest extends XWorkTestCase {
         assertNull(expected);
     }
 
-    public void testAllowCallingMethodsOnObjectClassInDevModeFalse() {
-        Exception expected = null;
-        try {
-            ognlUtil.setExcludedClasses(Foo.class.getName());
-            ognlUtil.setDevModeExcludedClasses("");
-            ognlUtil.setDevMode(Boolean.FALSE.toString());
+    public void testExclusionListDevModeOnOff() throws Exception {
+        ognlUtil.setDevModeExcludedClasses(Foo.class.getName());
+        Foo foo = new Foo();
 
-            Foo foo = new Foo();
-            String result = (String) ognlUtil.getValue("toString", 
ognlUtil.createDefaultContext(foo), foo, String.class);
-            assertEquals("Foo", result);
-        } catch (OgnlException e) {
-            expected = e;
-        }
-        assertNotNull(expected);
-        assertSame(NoSuchPropertyException.class, expected.getClass());
-        assertEquals("com.opensymphony.xwork2.util.Foo.toString", 
expected.getMessage());
+        ognlUtil.setDevMode(Boolean.TRUE.toString());
+        OgnlException e = assertThrows(OgnlException.class, () -> 
ognlUtil.getValue("toString", ognlUtil.createDefaultContext(foo), foo, 
String.class));
+        
assertThat(e).hasMessageContaining("com.opensymphony.xwork2.util.Foo.toString");
+
+        ognlUtil.setDevMode(Boolean.FALSE.toString());
+        assertEquals("Foo", (String) ognlUtil.getValue("toString", 
ognlUtil.createDefaultContext(foo), foo, String.class));
     }
 
     public void testAvoidCallingMethodsOnObjectClassUpperCased() {

Reply via email to