struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [2/2] struts git commit: WW-4518 Cleans up deprecation flags
Date Tue, 23 Jun 2015 13:48:45 GMT
WW-4518 Cleans up deprecation flags


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

Branch: refs/heads/master
Commit: e133b9efc24cc3188810db19e9ae15b55758bfbe
Parents: 812afbb
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Tue Jun 23 15:48:31 2015 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Tue Jun 23 15:48:31 2015 +0200

----------------------------------------------------------------------
 .../xwork2/DefaultUnknownHandlerManager.java    |  3 +-
 .../xwork2/DefaultActionInvocationTest.java     | 49 +++++++++++++++-----
 2 files changed, 39 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/e133b9ef/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java
b/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java
index ef463b2..e2a4175 100644
--- a/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java
+++ b/core/src/main/java/com/opensymphony/xwork2/DefaultUnknownHandlerManager.java
@@ -92,7 +92,8 @@ public class DefaultUnknownHandlerManager implements UnknownHandlerManager
{
     }
 
     /**
-     * Iterate over UnknownHandlers and return the result of the first one that can handle
it
+     * Iterate over UnknownHandlers and return the result of the first one that can handle
it.
+     * Must throw an exception if method cannot be handled.
      *
      * @throws NoSuchMethodException
      */

http://git-wip-us.apache.org/repos/asf/struts/blob/e133b9ef/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
index b535067..042c1dc 100644
--- a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
@@ -180,7 +180,6 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
         assertTrue(actual instanceof IllegalArgumentException);
     }
 
-    @Deprecated
     public void testUnknownHandlerManagerThatThrowsException() throws Exception {
         // given
         DefaultActionInvocation dai = new DefaultActionInvocation(new HashMap<String,
Object>(), false) {
@@ -201,7 +200,6 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
             }
         };
 
-        SimpleAction action = new SimpleAction();
         MockActionProxy proxy = new MockActionProxy();
         proxy.setMethod("notExists");
 
@@ -213,7 +211,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
         // when
         Throwable actual = null;
         try {
-            dai.invokeAction(action, null);
+            dai.invokeAction(new SimpleAction(), null);
         } catch (Exception e) {
             actual = e;
         }
@@ -223,7 +221,6 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
         assertTrue(actual instanceof NoSuchMethodException);
     }
 
-    @Deprecated
     public void testUnknownHandlerManagerThatReturnsNull() throws Exception {
         // given
         DefaultActionInvocation dai = new DefaultActionInvocation(new HashMap<String,
Object>(), false) {
@@ -244,12 +241,6 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
             }
         };
 
-        SimpleAction action = new SimpleAction() {
-            @Override
-            public String execute() throws Exception {
-                throw new IllegalArgumentException();
-            }
-        };
         MockActionProxy proxy = new MockActionProxy();
         proxy.setMethod("notExists");
 
@@ -258,10 +249,9 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
         dai.unknownHandlerManager = uhm;
 
         // when
-        // when
         Throwable actual = null;
         try {
-            dai.invokeAction(action, null);
+            dai.invokeAction(new SimpleAction(), null);
         } catch (Exception e) {
             actual = e;
         }
@@ -271,6 +261,41 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
         assertTrue(actual instanceof NoSuchMethodException);
     }
 
+    public void testUnknownHandlerManagerThatReturnsSuccess() throws Exception {
+        // given
+        DefaultActionInvocation dai = new DefaultActionInvocation(new HashMap<String,
Object>(), false) {
+            public ValueStack getStack() {
+                return new StubValueStack();
+            }
+        };
+
+        UnknownHandlerManager uhm = new DefaultUnknownHandlerManager() {
+            @Override
+            public boolean hasUnknownHandlers() {
+                return true;
+            }
+
+            @Override
+            public Object handleUnknownMethod(Object action, String methodName) throws NoSuchMethodException
{
+                return "success";
+            }
+        };
+
+        MockActionProxy proxy = new MockActionProxy();
+        proxy.setMethod("notExists");
+
+        dai.proxy = proxy;
+        dai.ognlUtil = new OgnlUtil();
+        dai.unknownHandlerManager = uhm;
+
+        // when
+        String result = dai.invokeAction(new SimpleAction(), null);
+
+        // then
+        assertNotNull(result);
+        assertEquals("success", result);
+    }
+
 }
 
 class DefaultActionInvocationTester extends DefaultActionInvocation {


Mime
View raw message