Merge pull request #1167 from apache/fix/excluded-packages

Excludes new & old packages
This commit is contained in:
Lukasz Lenart
2025-01-04 14:37:47 +01:00
committed by GitHub
3 changed files with 64 additions and 43 deletions
@@ -29,6 +29,7 @@
<constant name="struts.excludedClasses"
value="
com.opensymphony.xwork2.ActionContext,
org.apache.struts2.ActionContext,
java.lang.Class,
java.lang.ClassLoader,
java.lang.InheritableThreadLocal,
@@ -75,10 +76,15 @@
value="
antlr.build,
com.opensymphony.xwork2.config,
org.apache.struts2.config,
com.opensymphony.xwork2.inject,
org.apache.struts2.inject,
com.opensymphony.xwork2.ognl,
org.apache.struts2.ognl,
com.opensymphony.xwork2.security,
org.apache.struts2.security,
com.opensymphony.xwork2.util,
org.apache.struts2.util,
freemarker.core,
freemarker.ext.jsp,
freemarker.ext.rhino,
@@ -108,10 +114,15 @@
value="
antlr.build,
com.opensymphony.xwork2.config,
org.apache.struts2.config,
com.opensymphony.xwork2.inject,
org.apache.struts2.inject,
com.opensymphony.xwork2.ognl,
org.apache.struts2.ognl,
com.opensymphony.xwork2.security,
org.apache.struts2.security,
com.opensymphony.xwork2.util,
org.apache.struts2.util,
freemarker.core,
freemarker.ext.jsp,
freemarker.ext.rhino,
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.opensymphony.xwork2.test;
public class StrutsUtilBean {
public String getMyString() {
return "myString";
}
public boolean getMyBoolean(boolean bool) {
return bool;
}
public String getFoo() {
return "bar";
}
public String getBarExpression() {
return "%{bar}";
}
public String getBar() {
return "bar";
}
}
@@ -19,6 +19,7 @@
package org.apache.struts2.util;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.test.StrutsUtilBean;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.TestAction;
@@ -37,7 +38,6 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Test case for StrutsUtil.
*
*/
public class StrutsUtilTest extends StrutsInternalTestCase {
@@ -53,14 +53,7 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
}
public void testIsTrueMethod() {
stack.push(new Object() {
public String getMyString() {
return "myString";
}
public boolean getMyBoolean(boolean bool) {
return bool;
}
});
stack.push(new StrutsUtilBean());
assertTrue(strutsUtil.isTrue("myString == 'myString'"));
assertFalse(strutsUtil.isTrue("myString == 'myOtherString'"));
assertTrue(strutsUtil.isTrue("getMyBoolean(true)"));
@@ -68,14 +61,7 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
}
public void testFindStringMethod() {
stack.push(new Object() {
public String getMyString() {
return "myString";
}
public boolean getMyBoolean(boolean bool) {
return bool;
}
});
stack.push(new StrutsUtilBean());
assertEquals(strutsUtil.findString("myString"), "myString");
assertNull(strutsUtil.findString("myOtherString"));
@@ -105,14 +91,7 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
public void testFindValueMethod() throws Exception {
stack.push(new Object() {
public String getMyString() {
return "myString";
}
public boolean getMyBoolean(boolean bool) {
return bool;
}
});
stack.push(new StrutsUtilBean());
Object obj1 = strutsUtil.findValue("myString", "java.lang.String");
Object obj2 = strutsUtil.findValue("getMyBoolean(true)", "java.lang.Boolean");
@@ -125,7 +104,6 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
}
public void testGetTextMethod() {
// this should be in xwork-messages.properties (included by default
// by LocalizedTextUtil
@@ -233,11 +211,7 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
}
public void testTranslateVariables() {
stack.push(new Object() {
public String getFoo() {
return "bar";
}
});
stack.push(new StrutsUtilBean());
String obj1 = strutsUtil.translateVariables("try: %{foo}");
assertNotNull(obj1);
@@ -245,15 +219,8 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
}
public void testTranslateVariablesRecursion() {
stack.push(new Object() {
public String getFoo() {
return "%{bar}";
}
public String getBar() {
return "bar";
}
});
String obj1 = strutsUtil.translateVariables("try: %{foo}");
stack.push(new StrutsUtilBean());
String obj1 = strutsUtil.translateVariables("try: %{barExpression}");
assertNotNull(obj1);
assertEquals("try: %{bar}", obj1);
@@ -277,12 +244,10 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
super.tearDown();
}
// === internal class to assist in testing
protected static class InternalMockHttpServletRequest extends MockHttpServletRequest {
InternalMockRequestDispatcher dispatcher = null;
public RequestDispatcher getRequestDispatcher(String path) {
dispatcher = new InternalMockRequestDispatcher(path);
return dispatcher;
@@ -296,10 +261,12 @@ public class StrutsUtilTest extends StrutsInternalTestCase {
protected static class InternalMockRequestDispatcher extends MockRequestDispatcher {
private final String url;
boolean included = false;
public InternalMockRequestDispatcher(String url) {
super(url);
this.url = url;
}
public void include(ServletRequest servletRequest, ServletResponse servletResponse) {
if (servletResponse instanceof MockHttpServletResponse) {
((MockHttpServletResponse) servletResponse).setIncludedUrl(this.url);