mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-3832 Solves problem when not using flat layout with Convention plugin
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1535364 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+1
-1
@@ -359,7 +359,7 @@ public class DefaultResultMapBuilder implements ResultMapBuilder {
|
||||
int indexOfDot = path.indexOf('.', resultPrefix.length());
|
||||
|
||||
// This case is when the path doesn't contain a result code
|
||||
if (indexOfDot == resultPrefix.length() || !flatResultLayout) {
|
||||
if (indexOfDot == resultPrefix.length()) {
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("The result file [#0] has no result code and therefore" +
|
||||
" will be associated with success, input and error by default. This might" +
|
||||
|
||||
+36
@@ -229,6 +229,42 @@ public class DefaultResultMapBuilderTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testFromServletContextNotFlat() throws Exception {
|
||||
ServletContext context = EasyMock.createStrictMock(ServletContext.class);
|
||||
|
||||
// Setup some mock jsps
|
||||
Set<String> resources = new HashSet<String>();
|
||||
resources.add("/WEB-INF/location/namespace/no-annotation/index.ftl");
|
||||
resources.add("/WEB-INF/location/namespace/no-annotation/success.jsp");
|
||||
resources.add("/WEB-INF/location/namespace/no-annotation/failure.jsp");
|
||||
EasyMock.expect(context.getResourcePaths("/WEB-INF/location/namespace/no-annotation")).andReturn(resources);
|
||||
EasyMock.replay(context);
|
||||
|
||||
PackageConfig packageConfig = createPackageConfigBuilder("/namespace");
|
||||
|
||||
this.conventionsService = new ConventionsServiceImpl("/WEB-INF/location");
|
||||
DefaultResultMapBuilder builder = new DefaultResultMapBuilder(context, container, "dispatcher,velocity,freemarker");
|
||||
builder.setFlatResultLayout("false");
|
||||
|
||||
Map<String, ResultConfig> results = builder.build(NoAnnotationAction.class, null, "no-annotation", packageConfig);
|
||||
|
||||
assertEquals(3, results.size());
|
||||
|
||||
assertEquals("success", results.get("success").getName());
|
||||
assertEquals(3, results.get("success").getParams().size());
|
||||
assertEquals("org.apache.struts2.dispatcher.ServletDispatcherResult", results.get("success").getClassName());
|
||||
assertEquals("/WEB-INF/location/namespace/no-annotation/success.jsp", results.get("success").getParams().get("location"));
|
||||
|
||||
assertEquals(1, results.get("index").getParams().size());
|
||||
assertEquals("org.apache.struts2.views.freemarker.FreemarkerResult", results.get("index").getClassName());
|
||||
assertEquals("/WEB-INF/location/namespace/no-annotation/index.ftl", results.get("index").getParams().get("location"));
|
||||
|
||||
assertEquals(3, results.get("failure").getParams().size());
|
||||
assertEquals("org.apache.struts2.dispatcher.ServletDispatcherResult", results.get("success").getClassName());
|
||||
assertEquals("/WEB-INF/location/namespace/no-annotation/failure.jsp", results.get("failure").getParams().get("location"));
|
||||
EasyMock.verify(context);
|
||||
}
|
||||
|
||||
public void testIgnoreFilesWithoutName() throws Exception {
|
||||
ServletContext context = EasyMock.createStrictMock(ServletContext.class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user