struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [3/4] struts git commit: Result annotation name attribute as an array, removed one of ResultInfo constructors
Date Thu, 21 Jan 2016 07:45:27 GMT
Result annotation name attribute as an array, removed one of ResultInfo constructors


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/2a46a658
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/2a46a658
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/2a46a658

Branch: refs/heads/master
Commit: 2a46a6586ec22e174dedce56f93e5993f757a87b
Parents: 930f6e4
Author: Aleksandr Mashchenko <aleksandr.7m@gmail.com>
Authored: Wed Jan 20 18:03:57 2016 +0200
Committer: Aleksandr Mashchenko <aleksandr.7m@gmail.com>
Committed: Wed Jan 20 18:03:57 2016 +0200

----------------------------------------------------------------------
 .../convention/DefaultResultMapBuilder.java     | 17 +-------
 .../struts2/convention/annotation/Result.java   |  2 +-
 .../convention/DefaultResultMapBuilderTest.java | 46 --------------------
 .../PackageBasedActionConfigBuilderTest.java    |  2 -
 .../result/ActionLevelResultsNamesAction.java   | 16 +------
 5 files changed, 3 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/2a46a658/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
----------------------------------------------------------------------
diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
b/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
index b7c5b51..40ea279 100644
--- a/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
+++ b/plugins/convention/src/main/java/org/apache/struts2/convention/DefaultResultMapBuilder.java
@@ -410,15 +410,7 @@ public class DefaultResultMapBuilder implements ResultMapBuilder {
             Class<?> actionClass, Map<String, ResultTypeConfig> resultsByExtension)
{
         // Check for multiple results on the class
         for (Result result : results) {
-            Set<String> names;
-            if (",".equals(result.name().trim())) {
-                names = new HashSet<>(1);
-                names.add(result.name());
-            } else {
-                names = TextParseUtil.commaDelimitedStringToSet(result.name());
-            }
-
-            for (String name : names) {
+            for (String name : result.name()) {
                 ResultConfig config = createResultConfig(actionClass, new ResultInfo(
                         name, result, packageConfig, resultPath, actionClass,
                         resultsByExtension), packageConfig, result);
@@ -515,13 +507,6 @@ public class DefaultResultMapBuilder implements ResultMapBuilder {
             }
         }
 
-        public ResultInfo(Result result, PackageConfig packageConfig,
-                String resultPath, Class<?> actionClass,
-                Map<String, ResultTypeConfig> resultsByExtension) {
-            this(result.name(), result, packageConfig, resultPath, actionClass,
-                    resultsByExtension);
-        }
-
         String determineType(String location, PackageConfig packageConfig,
                 Map<String, ResultTypeConfig> resultsByExtension) {
             int indexOfDot = location.lastIndexOf(".");

http://git-wip-us.apache.org/repos/asf/struts/blob/2a46a658/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/Result.java
----------------------------------------------------------------------
diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/Result.java
b/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/Result.java
index f8e9ecd..f90e7b5 100644
--- a/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/Result.java
+++ b/plugins/convention/src/main/java/org/apache/struts2/convention/annotation/Result.java
@@ -69,7 +69,7 @@ public @interface Result {
      * @return  The name of the result mapping. This is the value that is returned from the
action
      *          method and is used to associate a location with a return value.
      */
-    String name() default com.opensymphony.xwork2.Action.SUCCESS;
+    String[] name() default com.opensymphony.xwork2.Action.SUCCESS;
 
     /**
      * @return  The location of the result within the web application or anywhere on disk.
This location

http://git-wip-us.apache.org/repos/asf/struts/blob/2a46a658/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
----------------------------------------------------------------------
diff --git a/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
b/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
index b73667a..8a4325b 100644
--- a/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
+++ b/plugins/convention/src/test/java/org/apache/struts2/convention/DefaultResultMapBuilderTest.java
@@ -522,52 +522,6 @@ public class DefaultResultMapBuilderTest extends TestCase {
         EasyMock.verify(context);
     }
 
-    public void testActionLevelMultipleResultNamesAnnotationErrorInput() throws Exception
{
-        ServletContext context = EasyMock.createStrictMock(ServletContext.class);
-
-        // Setup some mock jsps
-        Set<String> resources = new HashSet<>();
-        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(ActionLevelResultsNamesAction.class,
getAnnotation(ActionLevelResultsNamesAction.class, "errorinput", Action.class), "action-level-results",
packageConfig);
-        assertEquals(2, results.size());
-        assertEquals("error", results.get("error").getName());
-        assertEquals("input", results.get("input").getName());
-        assertEquals(3, results.get("error").getParams().size());
-        assertEquals("/WEB-INF/location/namespace/error.jsp", results.get("error").getParams().get("location"));
-        assertEquals("org.apache.struts2.result.ServletDispatcherResult", results.get("error").getClassName());
-        assertEquals(3, results.get("input").getParams().size());
-        assertEquals("/WEB-INF/location/namespace/error.jsp", results.get("input").getParams().get("location"));
-        assertEquals("org.apache.struts2.result.ServletDispatcherResult", results.get("input").getClassName());
-        EasyMock.verify(context);
-    }
-
-    public void testActionLevelMultipleResultNamesAnnotationComma() throws Exception {
-        ServletContext context = EasyMock.createStrictMock(ServletContext.class);
-
-        // Setup some mock jsps
-        Set<String> resources = new HashSet<>();
-        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(ActionLevelResultsNamesAction.class,
getAnnotation(ActionLevelResultsNamesAction.class, "comma", Action.class), "action-level-results",
packageConfig);
-        assertEquals(1, results.size());
-        assertEquals(" , ", results.get(" , ").getName());
-        assertEquals(3, results.get(" , ").getParams().size());
-        assertEquals("/WEB-INF/location/namespace/error.jsp", results.get(" , ").getParams().get("location"));
-        assertEquals("org.apache.struts2.result.ServletDispatcherResult", results.get(" ,
").getClassName());
-        EasyMock.verify(context);
-    }
-
     public void testActionLevelMultipleResultNamesAnnotationNoName() throws Exception {
         ServletContext context = EasyMock.createStrictMock(ServletContext.class);
 

http://git-wip-us.apache.org/repos/asf/struts/blob/2a46a658/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
----------------------------------------------------------------------
diff --git a/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
b/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
index 7e47ff6..dfa1ad6 100644
--- a/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
+++ b/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
@@ -292,8 +292,6 @@ public class PackageBasedActionConfigBuilderTest extends TestCase {
         expect(resultMapBuilder.build(GlobalResultAction.class, null, "global-result", globalResultPkg)).andReturn(results);
         expect(resultMapBuilder.build(GlobalResultOverrideAction.class, null, "global-result-override",
globalResultPkg)).andReturn(results);
         expect(resultMapBuilder.build(ActionLevelResultsNamesAction.class, getAnnotation(ActionLevelResultsNamesAction.class,
"execute", Action.class), "action-level-results-names", resultPkg)).andReturn(results);
-        expect(resultMapBuilder.build(ActionLevelResultsNamesAction.class, getAnnotation(ActionLevelResultsNamesAction.class,
"errorinput", Action.class), "action-level-results-names", resultPkg)).andReturn(results);
-        expect(resultMapBuilder.build(ActionLevelResultsNamesAction.class, getAnnotation(ActionLevelResultsNamesAction.class,
"comma", Action.class), "action-level-results-names", resultPkg)).andReturn(results);
         expect(resultMapBuilder.build(ActionLevelResultsNamesAction.class, getAnnotation(ActionLevelResultsNamesAction.class,
"noname", Action.class), "action-level-results-names", resultPkg)).andReturn(results);
 
         /* org.apache.struts2.convention.actions.resultpath */

http://git-wip-us.apache.org/repos/asf/struts/blob/2a46a658/plugins/convention/src/test/java/org/apache/struts2/convention/actions/result/ActionLevelResultsNamesAction.java
----------------------------------------------------------------------
diff --git a/plugins/convention/src/test/java/org/apache/struts2/convention/actions/result/ActionLevelResultsNamesAction.java
b/plugins/convention/src/test/java/org/apache/struts2/convention/actions/result/ActionLevelResultsNamesAction.java
index 8ad30f1..2ae4bb6 100644
--- a/plugins/convention/src/test/java/org/apache/struts2/convention/actions/result/ActionLevelResultsNamesAction.java
+++ b/plugins/convention/src/test/java/org/apache/struts2/convention/actions/result/ActionLevelResultsNamesAction.java
@@ -30,7 +30,7 @@ import org.apache.struts2.convention.annotation.Result;
  */
 public class ActionLevelResultsNamesAction {
     @Action(results = {
-        @Result(name="error, input", location="error.jsp"),
+        @Result(name={"error", "input"}, location="error.jsp"),
         @Result(name="success", location="/WEB-INF/location/namespace/action-success.jsp"),
         @Result(name="failure", location="/WEB-INF/location/namespace/action-failure.jsp")
     })
@@ -39,20 +39,6 @@ public class ActionLevelResultsNamesAction {
     }
 
     @Action(results = {
-        @Result(name="error, input, ", location="error.jsp")
-    })
-    public String errorinput() {
-        return null;
-    }
-
-    @Action(results = {
-            @Result(name=" , ", location="error.jsp")
-    })
-    public String comma() {
-        return null;
-    }
-
-    @Action(results = {
         @Result(location="/WEB-INF/location/namespace/action-success.jsp")
     })
     public String noname() {


Mime
View raw message