WW-5021 Introduces a new constant to allow define a path to static content

This commit is contained in:
Lukasz Lenart
2021-01-02 17:52:29 +01:00
parent 213990944f
commit ef72783f50
56 changed files with 163 additions and 124 deletions
@@ -40,7 +40,7 @@ public class StaticContentTest {
public void testInvalidRersources2() throws Exception {
try (final WebClient webClient = new WebClient()) {
try {
webClient.getPage(ParameterUtils.getBaseUrl() + "/struts/..%252f");
webClient.getPage(ParameterUtils.getBaseUrl() + "/static/..%252f");
Assert.fail("Previous request should have failed");
} catch (FailingHttpStatusCodeException e) {
}
@@ -49,7 +49,7 @@ public class StaticContentTest {
/*public void testInvalidRersources3() throws IOException {
try {
beginAt("/struts/..%252f..%252f..%252fWEB-INF/classes/org/apache/struts2/showcase/action/EmployeeAction.class/");
beginAt("/static/..%252f..%252f..%252fWEB-INF/classes/org/apache/struts2/showcase/action/EmployeeAction.class/");
fail("Previous request should have failed");
} catch (TestingEngineResponseException ex) {
// ok
@@ -22,13 +22,13 @@
<head>
<title>OSGi Console</title>
<link rel="stylesheet" type="text/css" href="<@s.url value="/static/css/shell.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="/static/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="/static/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/shell.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<script src="<@s.url value="/static/js/shell.js" />"></script>
<script src="<@s.url value="/static/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="/static/js/jquery-ui-1.12.1.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/shell.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-ui-1.12.1.min.js" />"></script>
</head>
<body>
<div class="menu">
@@ -22,11 +22,11 @@
<head>
<title>${bundle.symbolicName!}</title>
<link rel="stylesheet" type="text/css" href="<@s.url value="/static/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="/static/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<script src="<@s.url value="/static/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="/static/js/jquery-ui-1.12.1.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-ui-1.12.1.min.js" />"></script>
<script type="text/javascript">
$(function() {
@@ -22,11 +22,11 @@
<head>
<title>OSGi Bundles</title>
<link rel="stylesheet" type="text/css" href="<@s.url value="/static/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="/static/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/main.css" />" />
<link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/css/redmond/jquery-ui-1.12.1.redmond.css" />" />
<script src="<@s.url value="/static/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="/static/js/jquery-ui-1.12.1.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-1.12.4.min.js" />"></script>
<script src="<@s.url value="${parameters.staticContentPath}/js/jquery-ui-1.12.1.min.js" />"></script>
</head>
<body>
@@ -118,6 +118,9 @@ public final class StrutsConstants {
/** Token to use to indicate start of theme to be expanded. */
public static final String STRUTS_UI_THEME_EXPANSION_TOKEN = "struts.ui.theme.expansion.token";
/** A path to static content, by default and from historical point of view it's /static. */
public static final String STRUTS_UI_STATIC_CONTENT_PATH = "struts.ui.staticContentPath";
/** The maximize size of a multipart request (file upload) */
public static final String STRUTS_MULTIPART_MAXSIZE = "struts.multipart.maxSize";
@@ -317,7 +317,7 @@ import java.util.Map;
* <tr>
* <td>tooltipIcon</td>
* <td>String</td>
* <td>/struts/static/tooltip/tooltip.gif</td>
* <td>/static/tooltip/tooltip.gif</td>
* <td>The url to the tooltip icon</td>
* <tr>
* <td>tooltipDelay</td>
@@ -506,6 +506,8 @@ public abstract class UIBean extends Component {
protected String defaultTemplateDir;
protected String defaultUITheme;
protected String uiThemeExpansionToken;
protected String uiStaticContentPath;
protected TemplateEngineManager templateEngineManager;
@Inject(StrutsConstants.STRUTS_UI_TEMPLATEDIR)
@@ -523,6 +525,11 @@ public abstract class UIBean extends Component {
this.uiThemeExpansionToken = uiThemeExpansionToken;
}
@Inject(StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH)
public void setUiStaticContentPath(String uiStaticContentPath) {
this.uiStaticContentPath = uiStaticContentPath;
}
@Inject
public void setTemplateEngineManager(TemplateEngineManager mgr) {
this.templateEngineManager = mgr;
@@ -645,6 +652,8 @@ public abstract class UIBean extends Component {
addParameter("themeExpansionToken", uiThemeExpansionToken);
addParameter("expandTheme", uiThemeExpansionToken + theme);
addParameter("staticContentPath", findString(uiStaticContentPath));
String name = null;
String providedLabel = null;
@@ -143,6 +143,7 @@ public class ConstantConfig {
private BeanConfig localizedTextProvider;
private Boolean disallowProxyMemberAccess;
private Integer ognlAutoGrowthCollectionLimit;
private String staticContentPath;
protected String beanConfToString(BeanConfig beanConf) {
return beanConf == null ? null : beanConf.getName();
@@ -273,6 +274,7 @@ public class ConstantConfig {
map.put(StrutsConstants.STRUTS_LOCALIZED_TEXT_PROVIDER, beanConfToString(localizedTextProvider));
map.put(StrutsConstants.STRUTS_DISALLOW_PROXY_MEMBER_ACCESS, Objects.toString(disallowProxyMemberAccess, null));
map.put(StrutsConstants.STRUTS_OGNL_AUTO_GROWTH_COLLECTION_LIMIT, Objects.toString(ognlAutoGrowthCollectionLimit, null));
map.put(StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH, Objects.toString(staticContentPath, null));
return map;
}
@@ -1344,4 +1346,12 @@ public class ConstantConfig {
public void setOgnlAutoGrowthCollectionLimit(Integer ognlAutoGrowthCollectionLimit) {
this.ognlAutoGrowthCollectionLimit = ognlAutoGrowthCollectionLimit;
}
public String getStaticContentPath() {
return staticContentPath;
}
public void setStaticContentPath(String staticContentPath) {
this.staticContentPath = staticContentPath;
}
}
@@ -34,7 +34,12 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
/**
* <p>
@@ -43,8 +48,8 @@ import java.util.*;
*
* <p>
* This class is used to serve common static content needed when using various parts of Struts, such as JavaScript
* files, CSS files, etc. It works by looking for requests to /struts/* (or /static/*), and then mapping the value after "/struts/"
* to common packages in Struts and, optionally, in your class path. By default, the following packages are
* files, CSS files, etc. It works by looking for requests to {@link #staticContentPath}/* and then mapping the value
* after to common packages in Struts and, optionally, in your class path. By default, the following packages are
* automatically searched:
* </p>
*
@@ -55,7 +60,7 @@ import java.util.*;
* </ul>
*
* <p>
* This means that you can simply request /struts/xhtml/styles.css and the XHTML UI theme's default stylesheet
* This means that you can simply request {@link #staticContentPath}/xhtml/styles.css and the XHTML UI theme's default stylesheet
* will be returned. Likewise, many of the AJAX UI components require various JavaScript files, which are found in the
* org.apache.struts2.static package. If you wish to add additional packages to be searched, you can add a comma
* separated (space, tab and new line will do as well) list in the filter init parameter named "packages". <b>Be
@@ -68,7 +73,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
/**
* Provide a logging instance.
*/
private Logger LOG = LogManager.getLogger(DefaultStaticContentLoader.class);
private final Logger LOG = LogManager.getLogger(DefaultStaticContentLoader.class);
/**
* Store set of path prefixes to use with static resources.
@@ -80,6 +85,11 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
*/
protected boolean serveStatic;
/**
* Store state of StrutsConstants.STRUTS_STATIC_CONTENT_PATH setting.
*/
protected String staticContentPath;
/**
* Store state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE setting.
*/
@@ -100,20 +110,23 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
/**
* Modify state of StrutsConstants.STRUTS_SERVE_STATIC_CONTENT setting.
*
* @param serveStaticContent
* New setting
* @param serveStaticContent New setting
*/
@Inject(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)
public void setServeStaticContent(String serveStaticContent) {
this.serveStatic = BooleanUtils.toBoolean(serveStaticContent);
}
@Inject(StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH)
public void setStaticContentPath(String staticContentPath) {
this.staticContentPath = staticContentPath;
}
/**
* Modify state of StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE
* setting.
*
* @param serveStaticBrowserCache
* New setting
* @param serveStaticBrowserCache New setting
*/
@Inject(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE)
public void setServeStaticBrowserCache(String serveStaticBrowserCache) {
@@ -122,6 +135,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
/**
* Modify state of StrutsConstants.STRUTS_I18N_ENCODING setting.
*
* @param encoding New setting
*/
@Inject(StrutsConstants.STRUTS_I18N_ENCODING)
@@ -164,8 +178,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
/**
* Create a string array from a comma-delimited list of packages.
*
* @param packages
* A comma-delimited String listing packages
* @param packages A comma-delimited String listing packages
* @return A string array of packages
*/
protected List<String> parse(String packages) {
@@ -194,7 +207,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
* javax.servlet.http.HttpServletResponse)
*/
public void findStaticResource(String path, HttpServletRequest request, HttpServletResponse response)
throws IOException {
throws IOException {
String name = cleanupPath(path);
for (String pathPrefix : pathPrefixes) {
URL resourceUrl = findResource(buildPath(name, pathPrefix));
@@ -293,7 +306,7 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
}
/**
* @param name resource name
* @param name resource name
* @param packagePrefix The package prefix to use to locate the resource
* @return full path
* @throws UnsupportedEncodingException If there is a encoding problem
@@ -310,7 +323,6 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
}
/**
* Determine the content type for the resource name.
*
@@ -342,12 +354,9 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
/**
* Copy bytes from the input stream to the output stream.
*
* @param input
* The input stream
* @param output
* The output stream
* @throws IOException
* If anything goes wrong
* @param input The input stream
* @param output The output stream
* @throws IOException If anything goes wrong
*/
protected void copy(InputStream input, OutputStream output) throws IOException {
final byte[] buffer = new byte[4096];
@@ -359,15 +368,18 @@ public class DefaultStaticContentLoader implements StaticContentLoader {
}
public boolean canHandle(String resourcePath) {
return serveStatic && (resourcePath.startsWith("/struts/") || resourcePath.startsWith("/static/"));
return serveStatic && resourcePath.startsWith(staticContentPath + "/");
}
/**
* @param path requested path
* @return path without leading "/struts" or "/static"
* @return path without leading {@link #staticContentPath}
*/
protected String cleanupPath(String path) {
//path will start with "/struts" or "/static", remove them
return path.substring(7);
if (path.startsWith(staticContentPath)) {
return path.substring(staticContentPath.length());
} else {
return path;
}
}
}
@@ -39,12 +39,12 @@ public interface StaticContentLoader {
* @param path Requested resource path
* @return true if this loader is able to load this type of resource, false otherwise
*/
public boolean canHandle(String path);
boolean canHandle(String path);
/**
* @param filterConfig The filter configuration
*/
public abstract void setHostConfig(HostConfig filterConfig);
void setHostConfig(HostConfig filterConfig);
/**
* Locate a static resource and copy directly to the response, setting the
@@ -55,7 +55,6 @@ public interface StaticContentLoader {
* @param response The response
* @throws IOException If anything goes wrong
*/
public abstract void findStaticResource(String path, HttpServletRequest request, HttpServletResponse response)
throws IOException;
void findStaticResource(String path, HttpServletRequest request, HttpServletResponse response) throws IOException;
}
@@ -147,6 +147,9 @@ struts.ui.theme.expansion.token=~~~
#sets the default template type. Either ftl, vm, or jsp
struts.ui.templateSuffix=ftl
### A path from which a static content is served in case of tags
struts.ui.staticContentPath=/static
### Configuration reloading
### This will cause the configuration to reload struts.xml when it is changed
### struts.configuration.xml.reload=false
@@ -19,7 +19,7 @@
*/
-->
<#if parameters.validate!false == true>
<script type="text/javascript" src="${base}/struts/css_xhtml/validation.js"></script>
<script type="text/javascript" src="${base}${parameters.staticContentPath}/css_xhtml/validation.js"></script>
<#if parameters.onsubmit??>
${tag.addParameter('onsubmit', "${parameters.onsubmit}; return validateForm_${parameters.id}();")}
<#else>
@@ -18,5 +18,5 @@
* under the License.
*/
-->
<link <#include "/${parameters.templateDir}/simple/nonce.ftl" /> rel="stylesheet" href="<@s.url value='/struts/css_xhtml/styles.css' includeParams='none' encode='false' />" type="text/css" />
<link <#include "/${parameters.templateDir}/simple/nonce.ftl" /> rel="stylesheet" href="<@s.url value='${parameters.staticContentPath}/css_xhtml/styles.css' includeParams='none' encode='false' />" type="text/css" />
<#include "/${parameters.templateDir}/simple/head.ftl" />
@@ -24,7 +24,7 @@
--><#t/>
<#if (parameters.hasTooltip!false)><#t/>
<#lt/><!-- javascript that is needed for tooltips -->
<#lt/><script type="text/javascript" src='<@s.url value="/struts/domTT.js" includeParams="none" encode="false" />' <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > </script>
<#lt/><link rel="stylesheet" type="text/css" href="<@s.url value="/struts/domTT.css" includeParams="none" encode="false" />" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> />
<#lt/><script type="text/javascript" src='<@s.url value="${parameters.staticContentPath}/domTT.js" includeParams="none" encode="false" />' <#include "/${parameters.templateDir}/simple/nonce.ftl" /> > </script>
<#lt/><link rel="stylesheet" type="text/css" href="<@s.url value="${parameters.staticContentPath}/domTT.css" includeParams="none" encode="false" />" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> />
</#if><#t/>
@@ -18,4 +18,4 @@
* under the License.
*/
-->
<script src="${base}/struts/utils.js" type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<script src="${base}${parameters.staticContentPath}/utils.js" type="text/javascript" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
@@ -19,7 +19,7 @@
*/
-->
<#if !stack.findValue("#inputtransferselect_js_included")??><#t/>
<script type="text/javascript" src="<@s.url value="/struts/inputtransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<script type="text/javascript" src="<@s.url value="${parameters.staticContentPath}/inputtransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<#assign temporaryVariable = stack.setValue("#inputtransferselect_js_included", "true") /><#t/>
</#if><#t/>
<table>
@@ -19,7 +19,7 @@
*/
-->
<#if !stack.findValue("#optiontransferselect_js_included")??><#t/>
<script type="text/javascript" src="<@s.url value="/struts/optiontransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<script type="text/javascript" src="<@s.url value="${parameters.staticContentPath}/optiontransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<#assign temporaryVariable = stack.setValue("#optiontransferselect_js_included", "true") /><#t/>
</#if><#t/>
<table>
@@ -19,7 +19,7 @@
*/
-->
<#if !stack.findValue("#optiontransferselect_js_included")??><#t/>
<script type="text/javascript" src="<@s.url value="/struts/optiontransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<script type="text/javascript" src="<@s.url value="${parameters.staticContentPath}/optiontransferselect.js" encode='false' includeParams='none'/>" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<#assign temporaryVariable = stack.setValue("#optiontransferselect_js_included", "true") /><#t/>
</#if><#t/>
<table>
@@ -19,7 +19,7 @@
*/
-->
<#if parameters.validate!false == true>
<script type="text/javascript" src="${base}/struts/xhtml/validation.js" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<script type="text/javascript" src="${base}${parameters.staticContentPath}/xhtml/validation.js" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> ></script>
<#if parameters.onsubmit??>
${tag.addParameter('onsubmit', "${parameters.onsubmit}; return validateForm_${parameters.id?replace('[^a-zA-Z0-9_]', '_', 'r')}();")}
<#else>
@@ -18,5 +18,5 @@
* under the License.
*/
-->
<link rel="stylesheet" href="<@s.url value='/struts/xhtml/styles.css' includeParams='none' encode='false'/>" type="text/css" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> />
<link rel="stylesheet" href="<@s.url value='${parameters.staticContentPath}/xhtml/styles.css' includeParams='none' encode='false'/>" type="text/css" <#include "/${parameters.templateDir}/simple/nonce.ftl" /> />
<#include "/${parameters.templateDir}/simple/head.ftl" />
@@ -23,7 +23,7 @@
<#if parameters.tooltipIconPath??><#t/>
src='<@s.url value="${parameters.tooltipIconPath}" includeParams="none" encode="false" />'
<#else><#t/>
src='<@s.url value="/struts/tooltip.gif" includeParams="none" encode="false" />'
src='<@s.url value="${parameters.staticContentPath}/tooltip.gif" includeParams="none" encode="false" />'
</#if><#t/>
<#if (parameters.jsTooltipEnabled!'false') == 'true'>
onmouseover="domTT_activate(this, event, 'content', '<#outputformat 'JavaScript'>${parameters.tooltip}</#outputformat>'<#t/>
@@ -103,13 +103,14 @@ public class DefaultStaticContentLoaderTest extends StrutsInternalTestCase {
}
protected void setUp() {
requestMock = (HttpServletRequest) createMock(HttpServletRequest.class);
responseMock = (HttpServletResponse) createMock(HttpServletResponse.class);
hostConfigMock = (HostConfig) createMock(HostConfig.class);
requestMock = createMock(HttpServletRequest.class);
responseMock = createMock(HttpServletResponse.class);
hostConfigMock = createMock(HostConfig.class);
expect(hostConfigMock.getInitParameter("packages")).andStubReturn(null);
expect(hostConfigMock.getInitParameter("loggerFactory")).andStubReturn(null);
defaultStaticContentLoader = new DefaultStaticContentLoader();
defaultStaticContentLoader.setHostConfig(hostConfigMock);
defaultStaticContentLoader.setEncoding("UTF-8");
defaultStaticContentLoader.setStaticContentPath("/static");
}
}
@@ -39,7 +39,7 @@ public class StaticContentLoaderTest extends TestCase {
private MockHttpServletResponse res;
public void testCantHandleWithoutServingStatic() {
StaticContentLoader contentLoader = new DefaultStaticContentLoader();
DefaultStaticContentLoader contentLoader = new DefaultStaticContentLoader();
assertFalse(contentLoader.canHandle("/static/test1.css"));
assertFalse(contentLoader.canHandle("/struts/test1.css"));
@@ -49,14 +49,15 @@ public class StaticContentLoaderTest extends TestCase {
public void testCanHandle() {
DefaultStaticContentLoader contentLoader = new DefaultStaticContentLoader();
contentLoader.setServeStaticContent("true");
contentLoader.setStaticContentPath("/static");
assertTrue(contentLoader.canHandle("/static/test1.css"));
assertTrue(contentLoader.canHandle("/struts/test1.css"));
assertFalse(contentLoader.canHandle("/struts/test1.css"));
assertFalse(contentLoader.canHandle("test1.css"));
}
public void testValidRersources() throws IOException {
contentLoader.findStaticResource("/struts/resource.css", req, res);
public void testValidResources() throws IOException {
contentLoader.findStaticResource("/static/resource.css", req, res);
assertTrue(res.getContentAsString().contains("color: red;"));
}
@@ -67,25 +68,25 @@ public class StaticContentLoaderTest extends TestCase {
}
public void testInvalidRersources2() throws IOException {
contentLoader.findStaticResource("/struts/..", req, res);
contentLoader.findStaticResource("/static/..", req, res);
assertEquals(HttpServletResponse.SC_NOT_FOUND, res.getStatus());
assertEquals(0, res.getContentLength());
}
public void testInvalidRersources3() throws IOException {
contentLoader.findStaticResource("/struts/../othertest.properties", req, res);
contentLoader.findStaticResource("/static/../othertest.properties", req, res);
assertEquals(HttpServletResponse.SC_NOT_FOUND, res.getStatus());
assertEquals(0, res.getContentLength());
}
public void testInvalidRersources4() throws IOException {
contentLoader.findStaticResource("/struts/..%252f", req, res);
contentLoader.findStaticResource("/static/..%252f", req, res);
assertEquals(HttpServletResponse.SC_NOT_FOUND, res.getStatus());
assertEquals(0, res.getContentLength());
}
public void testInvalidRersources5() throws IOException {
contentLoader.findStaticResource("/struts/..%252fothertest.properties", req, res);
contentLoader.findStaticResource("/static/..%252fothertest.properties", req, res);
assertEquals(HttpServletResponse.SC_NOT_FOUND, res.getStatus());
assertEquals(0, res.getContentLength());
}
@@ -95,6 +96,7 @@ public class StaticContentLoaderTest extends TestCase {
super.setUp();
this.contentLoader = new DefaultStaticContentLoader();
this.contentLoader.setStaticContentPath("/static");
MockServletContext servletContext = new MockServletContext();
req = new MockHttpServletRequest(servletContext);
res = new MockHttpServletResponse();
@@ -179,7 +179,7 @@ public class StrutsPrepareAndExecuteFilterIntegrationTest extends TestCase {
}
};
request.setRequestURI("/struts/utils.js");
request.setRequestURI("/static/utils.js");
StrutsPrepareAndExecuteFilter filter = new StrutsPrepareAndExecuteFilter();
filter.init(filterConfig);
filter.doFilter(request, response, filterChain);
@@ -79,7 +79,7 @@ public class TwoFilterIntegrationTest extends TestCase {
}
public void testStaticExecute() throws ServletException, IOException {
MockHttpServletResponse response = run("/struts/utils.js", filterPrepare, filterExecute, failFilter);
MockHttpServletResponse response = run("/static/utils.js", filterPrepare, filterExecute, failFilter);
assertEquals(200, response.getStatus());
assertTrue(response.getContentAsString().contains("StrutsUtils"));
}
@@ -52,7 +52,7 @@ public class TooltipTest extends AbstractUITagTest {
tag.setTooltip("myTooltip");
tag.setTooltipConfig(
"#{" +
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
"'tooltipIcon':'/static/tooltip/myTooltip.gif', " +
"'tooltipDelay':'500', " +
"'jsTooltipEnabled':'true' "+
"}"
@@ -86,7 +86,7 @@ public class TooltipTest extends AbstractUITagTest {
tag.setTooltip("myTooltip");
tag.setTooltipConfig(
"#{" +
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
"'tooltipIcon':'/static/tooltip/myTooltip.gif', " +
"'tooltipDelay':'500', " +
"'jsTooltipEnabled':'false' "+
"}"
@@ -119,7 +119,7 @@ public class TooltipTest extends AbstractUITagTest {
//same parameters as the OGNL map configuration, output must be the same
tag.setTooltip("myTooltip");
tag.setTooltipIconPath("/struts/tooltip/myTooltip.gif");
tag.setTooltipIconPath("/static/tooltip/myTooltip.gif");
tag.setTooltipDelay("500");
tag.setJavascriptTooltip("true");
@@ -142,7 +142,7 @@ public class TooltipTest extends AbstractUITagTest {
formTag.setTooltipConfig(
"#{" +
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
"'tooltipIcon':'/static/tooltip/myTooltip.gif', " +
"'tooltipDelay':'500', " +
"'jsTooltipEnabled':'true' "+
"}"
@@ -174,7 +174,7 @@ public class TooltipTest extends AbstractUITagTest {
// same parameters as the OGNL map configuration, output must be the same
formTag.setTooltip("myTooltip");
formTag.setTooltipIconPath("/struts/tooltip/myTooltip.gif");
formTag.setTooltipIconPath("/static/tooltip/myTooltip.gif");
formTag.setTooltipDelay("500");
formTag.setJavascriptTooltip("true");
@@ -204,7 +204,7 @@ public class TooltipTest extends AbstractUITagTest {
formTag.setTooltipConfig(
"#{" +
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
"'tooltipIcon':'/static/tooltip/myTooltip.gif', " +
"'tooltipDelay':'500', " +
"'jsTooltipEnabled':'true' "+
"}"
@@ -219,7 +219,7 @@ public class TooltipTest extends AbstractUITagTest {
tag.setTooltip("myTooltip");
tag.setTooltipConfig(
"#{" +
"'tooltipIcon':'/struts/tooltip/myTooltip2.gif', " +
"'tooltipIcon':'/static/tooltip/myTooltip2.gif', " +
"'tooltipDelay':'5000' " +
"}"
);
@@ -242,7 +242,7 @@ public class TooltipTest extends AbstractUITagTest {
// same parameters as the OGNL map configuration, output must be the same
formTag.setTooltip("myTooltip");
formTag.setTooltipIconPath("/struts/tooltip/myTooltip.gif");
formTag.setTooltipIconPath("/static/tooltip/myTooltip.gif");
formTag.setTooltipDelay("500");
formTag.setJavascriptTooltip("true");
@@ -255,7 +255,7 @@ public class TooltipTest extends AbstractUITagTest {
//same parameters as the OGNL map configuration, output must be the same
tag.setTooltip("myTooltip");
tag.setTooltipIconPath("/struts/tooltip/myTooltip2.gif");
tag.setTooltipIconPath("/static/tooltip/myTooltip2.gif");
tag.setTooltipDelay("5000");
tag.setJavascriptTooltip("true");
@@ -280,7 +280,7 @@ public class TooltipTest extends AbstractUITagTest {
formParamTag.setName("tooltipConfig");
formParamTag.setValue(
"#{" +
"'tooltipIcon':'/struts/tooltip/myTooltip.gif', " +
"'tooltipIcon':'/static/tooltip/myTooltip.gif', " +
"'tooltipDelay':'500', " +
"'jsTooltipEnabled':'true' "+
"}"
@@ -298,7 +298,7 @@ public class TooltipTest extends AbstractUITagTest {
textFieldParamTag.setName("tooltipConfig");
textFieldParamTag.setValue(
"#{" +
"'tooltipIcon':'/struts/tooltip/myTooltip2.gif', " +
"'tooltipIcon':'/static/tooltip/myTooltip2.gif', " +
"'tooltipDelay':'5000' "+
"}"
);
@@ -330,7 +330,7 @@ public class TooltipTest extends AbstractUITagTest {
formParamTag.setName("tooltipConfig");
StrutsMockBodyContent bodyContent = new StrutsMockBodyContent(new MockJspWriter());
bodyContent.setString(
"tooltipIcon=/struts/tooltip/myTooltip.gif| " +
"tooltipIcon=/static/tooltip/myTooltip.gif| " +
"tooltipDelay=500| " +
"jsTooltipEnabled=true "
);
@@ -348,7 +348,7 @@ public class TooltipTest extends AbstractUITagTest {
textFieldParamTag.setName("tooltipConfig");
StrutsMockBodyContent bodyContent2 = new StrutsMockBodyContent(new MockJspWriter());
bodyContent2.setString(
"tooltipIcon=/struts/tooltip/myTooltip2.gif| " +
"tooltipIcon=/static/tooltip/myTooltip2.gif| " +
"tooltipDelay=5000 "
);
textFieldParamTag.setBodyContent(bodyContent2);
@@ -1,8 +1,8 @@
<script type="text/javascript" src="/struts/xhtml/validation.js"></script>
<script type="text/javascript" src="/static/xhtml/validation.js"></script>
<form id="testAction" name="myForm" onsubmit="submitMe(); return validateForm_testAction();" action="/testAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
<table class="wwFormTable"> <tr>
<td class="tdLabel"></td>
<td class="tdInput"> <script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<td class="tdInput"> <script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myUpDownSelectTag" size="5" id="testAction_myUpDownSelectTag" multiple="multiple">
@@ -1,8 +1,8 @@
<script type="text/javascript" src="/struts/xhtml/validation.js"></script>
<script type="text/javascript" src="/static/xhtml/validation.js"></script>
<form id="doubleValidationAction" name="myForm" onsubmit="submitMe(); return validateForm_doubleValidationAction();" action="/doubleValidationAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
<table class="wwFormTable"> <tr>
<td class="tdLabel"></td>
<td class="tdInput"> <script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<td class="tdInput"> <script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myUpDownSelectTag" size="5" id="doubleValidationAction_myUpDownSelectTag" multiple="multiple">
@@ -1,8 +1,8 @@
<script type="text/javascript" src="/struts/xhtml/validation.js"></script>
<script type="text/javascript" src="/static/xhtml/validation.js"></script>
<form id="doubleValidationAction" name="myForm" onsubmit="submitMe(); return validateForm_doubleValidationAction();" action="/doubleValidationAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
<table class="wwFormTable"> <tr>
<td class="tdLabel"></td>
<td class="tdInput"> <script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<td class="tdInput"> <script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myUpDownSelectTag" size="5" id="doubleValidationAction_myUpDownSelectTag" multiple="multiple">
@@ -1,8 +1,8 @@
<script type="text/javascript" src="/struts/xhtml/validation.js"></script>
<script type="text/javascript" src="/static/xhtml/validation.js"></script>
<form id="doubleValidationAction" name="myForm" onsubmit="submitMe(); return validateForm_doubleValidationAction();" action="/doubleValidationAction.action" method="post" enctype="myEncType" title="mytitle" accept-charset="UTF-8" onreset="clearErrorMessages(this);clearErrorLabels(this);">
<table class="wwFormTable"> <tr>
<td class="tdLabel"></td>
<td class="tdInput"> <script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<td class="tdInput"> <script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myUpDownSelectTag" size="5" id="doubleValidationAction_myUpDownSelectTag" multiple="multiple">
@@ -1,7 +1,7 @@
<form id="myAction" name="myForm" onsubmit="submitMe()" action="myAction" method="post" enctype="myEncType" title="mytitle">
<table class="wwFormTable"> <tr>
<td class="tdLabel"></td>
<td class="tdInput"> <script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<td class="tdInput"> <script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myUpDownSelectTag" size="5" id="myAction_myUpDownSelectTag" multiple="multiple">
@@ -1,2 +1,2 @@
<link rel="stylesheet" href="/struts/xhtml/styles.css" type="text/css" nonce="r4nd0m"/>
<script src="/struts/utils.js" type="text/javascript" nonce="r4nd0m"></script>
<link rel="stylesheet" href="/static/xhtml/styles.css" type="text/css" nonce="r4nd0m"/>
<script src="/static/utils.js" type="text/javascript" nonce="r4nd0m"></script>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/inputtransferselect.js" nonce="r4nd0m"></script>
<script type="text/javascript" src="/static/inputtransferselect.js" nonce="r4nd0m"></script>
<table>
<tr><td><input type="text" name="collection_input" id="collection_input"/></td>
<td class="tdTransferSelect"><inputtype="button"value="-&gt;"onclick="addOption(document.getElementById('collection_input'),document.getElementById('collection'))"/>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js" nonce="r4nd0m"></script>
<script type="text/javascript" src="/static/optiontransferselect.js" nonce="r4nd0m"></script>
<table>
<tr>
<td>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr>
<td>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr>
<td>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr>
<td>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr>
<td>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr>
<td>
@@ -1,7 +1,7 @@
<tr>
<td class="tdLabel"></td>
<td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr>
<td>
@@ -4,7 +4,7 @@
<td class="tdLabel">
<labelfor="myId"class="label">
MyLabel:<img
src='/struts/tooltip/myTooltip.gif'
src='/static/tooltip/myTooltip.gif'
onmouseover="domTT_activate(this,event,'content','myTooltip','delay','500','styleClass','StrutsTTClassic')"/>
</label>
</td>
@@ -15,7 +15,7 @@
</table>
</form>
<!--javascript that is needed for tooltips-->
<script type="text/javascript" src='/struts/domTT.js'></script>
<link rel="stylesheet" type="text/css" href="/struts/domTT.css"/>
<script type="text/javascript" src='/static/domTT.js'></script>
<link rel="stylesheet" type="text/css" href="/static/domTT.css"/>
@@ -4,7 +4,7 @@
<td class="tdLabel">
<labelfor="myId"class="label">
MyLabel:<img
src='/struts/tooltip/myTooltip.gif'
src='/static/tooltip/myTooltip.gif'
onmouseover="domTT_activate(this,event,'content','myTooltip','delay','500','styleClass','StrutsTTClassic')"/>
</label>
</td>
@@ -15,5 +15,5 @@
</table>
</form>
<!--javascript that is needed for tooltips-->
<script type="text/javascript" src='/struts/domTT.js'></script>
<link rel="stylesheet" type="text/css" href="/struts/domTT.css"/>
<script type="text/javascript" src='/static/domTT.js'></script>
<link rel="stylesheet" type="text/css" href="/static/domTT.css"/>
@@ -4,7 +4,7 @@
<td class="tdLabel">
<labelfor="myId"class="label">
MyLabel:<img
src='/struts/tooltip/myTooltip2.gif'
src='/static/tooltip/myTooltip2.gif'
onmouseover="domTT_activate(this,event,'content','myTooltip','delay','5000','styleClass','StrutsTTClassic')"/>
</label>
</td>
@@ -16,6 +16,6 @@
</form>
<!--javascript that is needed for tooltips-->
<script type="text/javascript" src='/struts/domTT.js'></script>
<link rel="stylesheet" type="text/css" href="/struts/domTT.css"/>
<script type="text/javascript" src='/static/domTT.js'></script>
<link rel="stylesheet" type="text/css" href="/static/domTT.css"/>
@@ -4,7 +4,7 @@
<td class="tdLabel">
<labelfor="myId"class="label">
MyLabel:<img
src='/struts/tooltip/myTooltip.gif'
src='/static/tooltip/myTooltip.gif'
title="myTooltip" alt="myTooltip" />
</label>
</td>
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js" nonce="r4nd0m"></script>
<script type="text/javascript" src="/static/optiontransferselect.js" nonce="r4nd0m"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -1,5 +1,5 @@
<tr> <td class="tdLabel"></td> <td class="tdInput">
<script type="text/javascript" src="/struts/optiontransferselect.js"></script>
<script type="text/javascript" src="/static/optiontransferselect.js"></script>
<table>
<tr><td>
<select name="myName" size="5" id="myId" multiple="multiple">
@@ -38,7 +38,7 @@ public class HeadHandler extends AbstractTagHandler implements TagGenerator {
sb.append(base);
}
sb.append("/struts/utils.js");
sb.append("/static/utils.js");
attrs.put("src", sb.toString());
super.start("script", attrs);
@@ -31,7 +31,7 @@ public class HeadTest extends AbstractTest {
map.putAll(tag.getParameters());
theme.renderTag(getTagName(), context);
String output = writer.getBuffer().toString();
String expected = s("<script type='text/javascript' base='/some/path' src='/some/path/struts/utils.js'></script>");
String expected = s("<script type='text/javascript' base='/some/path' src='/some/path/static/utils.js'></script>");
assertEquals(expected, output);
}