struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From musa...@apache.org
Subject svn commit: r820727 - in /struts/struts2/trunk/plugins/convention/src: main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
Date Thu, 01 Oct 2009 17:41:57 GMT
Author: musachy
Date: Thu Oct  1 17:41:57 2009
New Revision: 820727

URL: http://svn.apache.org/viewvc?rev=820727&view=rev
Log:
Ignore potential results that start with "."

Modified:
    struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
    struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java

Modified: struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java?rev=820727&r1=820726&r2=820727&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
(original)
+++ struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
Thu Oct  1 17:41:57 2009
@@ -259,7 +259,7 @@
                 }
 
                 String fileName = StringUtils.substringAfterLast(path, "/");
-                if (StringUtils.startsWith(fileName, ".")) {
+                if (StringUtils.isBlank(fileName) || StringUtils.startsWith(fileName, "."))
{
                     if (LOG.isTraceEnabled())
                         LOG.trace("Ignoring file without name [#0]", path);
                     continue;

Modified: struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java?rev=820727&r1=820726&r2=820727&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
(original)
+++ struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
Thu Oct  1 17:41:57 2009
@@ -114,6 +114,26 @@
         verify(context, "/class-level", results, false);
     }
 
+    public void testFromServletContextWithBadNames() throws Exception {
+        ServletContext context = EasyMock.createStrictMock(ServletContext.class);
+
+        // Setup some mock jsps
+        Set<String> resources = new HashSet<String>();
+        resources.add("/WEB-INF/location/namespace/.something");
+        resources.add("/WEB-INF/location/namespace/.somethingelse/");
+        EasyMock.expect(context.getResourcePaths("/WEB-INF/location/namespace/")).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");
+        Map<String, ResultConfig> results = builder.build(NoAnnotationAction.class,
null, "no-annotation", packageConfig);
+        assertEquals(0, results.size());
+        EasyMock.verify(context);
+
+    }
+
     public void testFromServletContext() throws Exception {
         ServletContext context = EasyMock.createStrictMock(ServletContext.class);
 



Mime
View raw message