struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From musa...@apache.org
Subject svn commit: r820353 - in /struts/struts2/trunk/plugins/convention/src: main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java test/resources/WEB-INF/component/.boom
Date Wed, 30 Sep 2009 17:29:07 GMT
Author: musachy
Date: Wed Sep 30 17:29:07 2009
New Revision: 820353

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

Added:
    struts/struts2/trunk/plugins/convention/src/test/resources/WEB-INF/component/.boom
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=820353&r1=820352&r2=820353&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
Wed Sep 30 17:29:07 2009
@@ -258,6 +258,13 @@
                     LOG.trace("Processing resource path [#0]", path);
                 }
 
+                String fileName = StringUtils.substringAfterLast(path, "/");
+                if (StringUtils.startsWith(fileName, ".")) {
+                    if (LOG.isTraceEnabled())
+                        LOG.trace("Ignoring file without name [#0]", path);
+                    continue;
+                }
+
                 makeResults(actionClass, path, resultPrefix, results, packageConfig, resultsByExtension);
             }
         }

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=820353&r1=820352&r2=820353&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
Wed Sep 30 17:29:07 2009
@@ -148,6 +148,30 @@
 
     }
 
+    public void testIgnoreFilesWithoutName() 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/.svn");
+        resources.add("/WEB-INF/location/namespace/no-annotation-success.jsp");
+        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(1, 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"));
+        EasyMock.verify(context);
+
+    }
+
     public void testClassLevelSingleResultAnnotation() throws Exception {
         ServletContext context = EasyMock.createStrictMock(ServletContext.class);
 

Added: struts/struts2/trunk/plugins/convention/src/test/resources/WEB-INF/component/.boom
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/test/resources/WEB-INF/component/.boom?rev=820353&view=auto
==============================================================================
    (empty)



Mime
View raw message