struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts] branch master updated: Adds additional test to check is ArrayList.size() is accessible
Date Fri, 24 Aug 2018 11:05:10 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/master by this push:
     new 7bb1ea2  Adds additional test to check is ArrayList.size() is accessible
7bb1ea2 is described below

commit 7bb1ea25e0948b67a47d19dfca89b1f6cf2f4f45
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Fri Aug 24 13:05:02 2018 +0200

    Adds additional test to check is ArrayList.size() is accessible
---
 .../xwork2/ognl/OgnlUtilStrutsTest.java            | 30 +++++++++++++++++-----
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilStrutsTest.java b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilStrutsTest.java
index bd371dd..9f1f496 100644
--- a/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilStrutsTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/ognl/OgnlUtilStrutsTest.java
@@ -20,16 +20,19 @@ package com.opensymphony.xwork2.ognl;
 
 import org.apache.struts2.StrutsInternalTestCase;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class OgnlUtilStrutsTest extends StrutsInternalTestCase {
-    
+
     private OgnlUtil ognlUtil;
-    
+
     @Override
     public void setUp() throws Exception {
         super.setUp();
         ognlUtil = container.getInstance(OgnlUtil.class);
     }
-    
+
     public void testDefaultExcludes() {
         ognlUtil.setExcludedClasses("");
         ognlUtil.setExcludedPackageNames("");
@@ -39,18 +42,33 @@ public class OgnlUtilStrutsTest extends StrutsInternalTestCase {
 
         try {
             ognlUtil.getExcludedClasses().clear();
-        } catch (Exception ex){
+        } catch (Exception ex) {
             assertTrue(ex instanceof UnsupportedOperationException);
         }
         try {
             ognlUtil.getExcludedPackageNames().clear();
-        } catch (Exception ex){
+        } catch (Exception ex) {
             assertTrue(ex instanceof UnsupportedOperationException);
         }
         try {
             ognlUtil.getExcludedPackageNamePatterns().clear();
-        } catch (Exception ex){
+        } catch (Exception ex) {
             assertTrue(ex instanceof UnsupportedOperationException);
         }
     }
+
+    public void testAccessToSizeMethod() throws Exception {
+        // given
+        List<String> list = new ArrayList<>();
+        list.add("1");
+        list.add("2");
+
+        // when
+        Object value = ognlUtil.getValue("size() > 0", ognlUtil.createDefaultContext(list),
list);
+
+        // then
+        assertTrue(value instanceof Boolean);
+        assertTrue((Boolean) value);
+    }
+
 }


Mime
View raw message