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 <[email protected]>
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);
+ }
+
}