You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/03/04 07:10:24 UTC
[01/10] struts git commit: WW-4593 Easymock upgrade to 3.4
Repository: struts
Updated Branches:
refs/heads/master 5bcdd3d9f -> 754c8a247
WW-4593 Easymock upgrade to 3.4
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/900167da
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/900167da
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/900167da
Branch: refs/heads/master
Commit: 900167daeb9c92f4a61003c03494338cde034507
Parents: c167d6c
Author: Victor Sosa <vi...@gmail.com>
Authored: Wed Jan 20 16:14:35 2016 -0400
Committer: Victor Sosa <vi...@gmail.com>
Committed: Wed Jan 20 16:14:35 2016 -0400
----------------------------------------------------------------------
.../xwork2/config/providers/XmlHelperTest.java | 226 +++++++++----------
.../ParameterRemoverInterceptorTest.java | 15 +-
.../PrefixMethodInvocationUtilTest.java | 136 ++++++-----
.../interceptor/PrepareInterceptorTest.java | 75 +++---
.../org/apache/struts2/RequestUtilsTest.java | 49 ++--
.../interceptor/CookieInterceptorTest.java | 94 ++++----
.../ServletConfigInterceptorTest.java | 58 ++---
.../struts2/views/jsp/IncludeTagTest.java | 49 ++--
.../struts2/views/util/ResourceUtilTest.java | 17 +-
pom.xml | 9 +-
10 files changed, 367 insertions(+), 361 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
index 9e0f1a3..73f8e51 100644
--- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
@@ -1,7 +1,8 @@
package com.opensymphony.xwork2.config.providers;
import com.opensymphony.xwork2.XWorkTestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -18,26 +19,26 @@ public class XmlHelperTest extends XWorkTestCase {
public void testGetContent1() throws Exception {
// set up Node
- MockControl nodeControl = MockControl.createControl(Node.class);
- Node mockNode = (Node) nodeControl.getMock();
+ IMocksControl nodeControl = createControl();
+ Node mockNode = (Node) nodeControl.createMock(Node.class);
- nodeControl.expectAndDefaultReturn(mockNode.getNodeValue(), "testing testing 123");
- nodeControl.expectAndDefaultReturn(mockNode.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode.getNodeValue()).andStubReturn("testing testing 123");
+ expect(mockNode.getNodeType()).andStubReturn(Node.TEXT_NODE);
// set up NodeList
- MockControl nodeListControl = MockControl.createControl(NodeList.class);
- NodeList mockNodeList = (NodeList) nodeListControl.getMock();
+ IMocksControl nodeListControl = createControl();
+ NodeList mockNodeList = (NodeList) nodeListControl.createMock(NodeList.class);
- nodeListControl.expectAndDefaultReturn(mockNodeList.getLength(), 1);
- nodeListControl.expectAndDefaultReturn(mockNodeList.item(0), mockNode);
+ expect(mockNodeList.getLength()).andStubReturn(1);
+ expect(mockNodeList.item(0)).andStubReturn(mockNode);
// set up Element
- MockControl elementControl = MockControl.createControl(Element.class);
- Element mockElement = (Element) elementControl.getMock();
+ IMocksControl elementControl = createControl();
+ Element mockElement = (Element) elementControl.createMock(Element.class);
- elementControl.expectAndDefaultReturn(mockElement.getChildNodes(), mockNodeList);
+ expect(mockElement.getChildNodes()).andStubReturn(mockNodeList);
nodeControl.replay();
nodeListControl.replay();
@@ -45,77 +46,71 @@ public class XmlHelperTest extends XWorkTestCase {
String result = XmlHelper.getContent(mockElement);
+ assertEquals(result, "testing testing 123");
+
nodeControl.verify();
nodeListControl.verify();
elementControl.verify();
-
- assertEquals(result, "testing testing 123");
}
public void testGetContent2() throws Exception {
// set up Node
- MockControl nodeControl1 = MockControl.createControl(Node.class);
- Node mockNode1 = (Node) nodeControl1.getMock();
+ IMocksControl nodeControl1 = createControl();
+ Node mockNode1 = (Node) nodeControl1.createMock(Node.class);
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeValue(), "testing testing 123");
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode1.getNodeValue()).andStubReturn("testing testing 123");
+ expect(mockNode1.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeControl2 = MockControl.createControl(Node.class);
- Node mockNode2 = (Node) nodeControl2.getMock();
+ IMocksControl nodeControl2 = createControl();
+ Node mockNode2 = (Node) nodeControl2.createMock(Node.class);
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeValue(), "comment 1");
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeType(), Node.COMMENT_NODE);
+ expect(mockNode2.getNodeValue()).andStubReturn("comment 1");
+ expect(mockNode2.getNodeType()).andStubReturn(Node.COMMENT_NODE);
- MockControl nodeControl3 = MockControl.createControl(Node.class);
- Node mockNode3 = (Node) nodeControl3.getMock();
+ IMocksControl nodeControl3 = createControl();
+ Node mockNode3 = (Node) nodeControl3.createMock(Node.class);
- nodeControl3.expectAndDefaultReturn(mockNode3.getNodeValue(), " tmjee ");
- nodeControl3.expectAndDefaultReturn(mockNode3.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode3.getNodeValue()).andStubReturn(" tmjee ");
+ expect(mockNode3.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeControl4 = MockControl.createControl(Node.class);
- Node mockNode4 = (Node) nodeControl4.getMock();
+ IMocksControl nodeControl4 = createControl();
+ Node mockNode4 = (Node) nodeControl4.createMock(Node.class);
- nodeControl4.expectAndDefaultReturn(mockNode4.getNodeValue(), " phil ");
- nodeControl4.expectAndDefaultReturn(mockNode4.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode4.getNodeValue()).andStubReturn(" phil ");
+ expect(mockNode4.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeControl5 = MockControl.createControl(Node.class);
- Node mockNode5 = (Node) nodeControl5.getMock();
+ IMocksControl nodeControl5 = createControl();
+ Node mockNode5 = (Node) nodeControl5.createMock(Node.class);
- nodeControl5.expectAndDefaultReturn(mockNode5.getNodeValue(), "comment 2");
- nodeControl5.expectAndDefaultReturn(mockNode5.getNodeType(), Node.COMMENT_NODE);
+ expect(mockNode5.getNodeValue()).andStubReturn("comment 2");
+ expect(mockNode5.getNodeType()).andStubReturn(Node.COMMENT_NODE);
- MockControl nodeControl6 = MockControl.createControl(Node.class);
- Node mockNode6 = (Node) nodeControl6.getMock();
+ IMocksControl nodeControl6 = createControl();
+ Node mockNode6 = (Node) nodeControl6.createMock(Node.class);
- nodeControl6.expectAndDefaultReturn(mockNode6.getNodeValue(), "comment 3");
- nodeControl6.expectAndDefaultReturn(mockNode6.getNodeType(), Node.COMMENT_NODE);
+ expect(mockNode6.getNodeValue()).andStubReturn("comment 3");
+ expect(mockNode6.getNodeType()).andStubReturn(Node.COMMENT_NODE);
// set up NodeList
- MockControl nodeListControl = MockControl.createControl(NodeList.class);
- NodeList mockNodeList = (NodeList) nodeListControl.getMock();
-
- nodeListControl.expectAndDefaultReturn(mockNodeList.getLength(), 6);
- mockNodeList.item(0);
- nodeListControl.setReturnValue(mockNode1);
- mockNodeList.item(1);
- nodeListControl.setReturnValue(mockNode2);
- mockNodeList.item(2);
- nodeListControl.setDefaultReturnValue(mockNode3);
- mockNodeList.item(3);
- nodeListControl.setReturnValue(mockNode4);
- mockNodeList.item(4);
- nodeListControl.setReturnValue(mockNode5);
- mockNodeList.item(5);
- nodeListControl.setReturnValue(mockNode6);
-
+ IMocksControl nodeListControl = createControl();
+ NodeList mockNodeList = (NodeList) nodeListControl.createMock(NodeList.class);
+
+ expect(mockNodeList.getLength()).andStubReturn(6);
+
+ expect(mockNodeList.item(0)).andStubReturn(mockNode1);
+ expect(mockNodeList.item(1)).andStubReturn(mockNode2);
+ expect(mockNodeList.item(2)).andStubReturn(mockNode3);
+ expect(mockNodeList.item(3)).andStubReturn(mockNode4);
+ expect(mockNodeList.item(4)).andStubReturn(mockNode5);
+ expect(mockNodeList.item(5)).andStubReturn(mockNode6);
// set up Element
- MockControl elementControl = MockControl.createControl(Element.class);
- Element mockElement = (Element) elementControl.getMock();
+ IMocksControl elementControl = createControl();
+ Element mockElement = (Element) elementControl.createMock(Element.class);
- elementControl.expectAndDefaultReturn(mockElement.getChildNodes(), mockNodeList);
+ expect(mockElement.getChildNodes()).andStubReturn(mockNodeList);
nodeControl1.replay();
nodeControl2.replay();
@@ -128,6 +123,8 @@ public class XmlHelperTest extends XWorkTestCase {
String result = XmlHelper.getContent(mockElement);
+ assertEquals(result, "testing testing 123tmjeephil");
+
nodeControl1.verify();
nodeControl2.verify();
nodeControl3.verify();
@@ -135,73 +132,62 @@ public class XmlHelperTest extends XWorkTestCase {
nodeControl5.verify();
nodeControl6.verify();
nodeListControl.verify();
- elementControl.verify();
-
- assertEquals(result, "testing testing 123tmjeephil");
+ elementControl.verify();
}
public void testGetParams() throws Exception {
// <param name="param1">value1</param>
- MockControl nodeControl1 = MockControl.createControl(Node.class);
- Node mockNode1 = (Node) nodeControl1.getMock();
+ IMocksControl nodeControl1 = createControl();
+ Node mockNode1 = (Node) nodeControl1.createMock(Node.class);
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeValue(), "value1");
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode1.getNodeValue()).andStubReturn("value1");
+ expect(mockNode1.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeListControl1 = MockControl.createControl(NodeList.class);
- NodeList mockNodeList1 = (NodeList) nodeListControl1.getMock();
+ IMocksControl nodeListControl1 = createControl();
+ NodeList mockNodeList1 = (NodeList) nodeListControl1.createMock(NodeList.class);
- nodeListControl1.expectAndDefaultReturn(mockNodeList1.getLength(), 1);
- nodeListControl1.expectAndDefaultReturn(mockNodeList1.item(0), mockNode1);
+ expect(mockNodeList1.getLength()).andStubReturn(1);
+ expect(mockNodeList1.item(0)).andStubReturn(mockNode1);
- MockControl paramControl1 = MockControl.createControl(Element.class);
- Element mockParamElement1 = (Element) paramControl1.getMock();
- mockParamElement1.getNodeName();
- paramControl1.setReturnValue("param");
+ IMocksControl paramControl1 = createControl();
+ Element mockParamElement1 = (Element) paramControl1.createMock(Element.class);
+ expect(mockParamElement1.getNodeName()).andStubReturn("param");
- mockParamElement1.getNodeType();
- paramControl1.setReturnValue(Node.ELEMENT_NODE);
+ expect(mockParamElement1.getNodeType()).andStubReturn(Node.ELEMENT_NODE);
- mockParamElement1.getAttribute("name");
- paramControl1.setReturnValue("param1");
+ expect(mockParamElement1.getAttribute("name")).andStubReturn("param1");
- mockParamElement1.getChildNodes();
- paramControl1.setReturnValue(mockNodeList1);
+ expect(mockParamElement1.getChildNodes()).andStubReturn(mockNodeList1);
nodeControl1.replay();
nodeListControl1.replay();
paramControl1.replay();
// <param name="param2">value2</param>
- MockControl nodeControl2 = MockControl.createControl(Node.class);
- Node mockNode2 = (Node) nodeControl2.getMock();
-
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeValue(), "value2");
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeType(), Node.TEXT_NODE);
+ IMocksControl nodeControl2 = createControl();
+ Node mockNode2 = (Node) nodeControl2.createMock(Node.class);
+ expect(mockNode2.getNodeValue()).andStubReturn("value2");
+ expect(mockNode2.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeListControl2 = MockControl.createControl(NodeList.class);
- NodeList mockNodeList2 = (NodeList) nodeListControl2.getMock();
- nodeListControl2.expectAndDefaultReturn(mockNodeList2.getLength(), 1);
- nodeListControl2.expectAndDefaultReturn(mockNodeList2.item(0), mockNode2);
+ IMocksControl nodeListControl2 = createControl();
+ NodeList mockNodeList2 = (NodeList) nodeListControl2.createMock(NodeList.class);
- MockControl paramControl2 = MockControl.createControl(Element.class);
- Element mockParamElement2 = (Element) paramControl2.getMock();
- mockParamElement2.getNodeName();
- paramControl2.setReturnValue("param");
+ expect(mockNodeList2.getLength()).andStubReturn(1);
+ expect(mockNodeList2.item(0)).andStubReturn(mockNode2);
- mockParamElement2.getNodeType();
- paramControl2.setReturnValue(Node.ELEMENT_NODE);
+ IMocksControl paramControl2 = createControl();
+ Element mockParamElement2 = (Element) paramControl2.createMock(Element.class);
+
+ expect(mockParamElement2.getNodeName()).andStubReturn("param");
+ expect(mockParamElement2.getNodeType()).andStubReturn(Node.ELEMENT_NODE);
- mockParamElement2.getAttribute("name");
- paramControl2.setReturnValue("param2");
-
- mockParamElement2.getChildNodes();
- paramControl2.setReturnValue(mockNodeList2);
+ expect(mockParamElement2.getAttribute("name")).andStubReturn("param2");
+ expect(mockParamElement2.getChildNodes()).andStubReturn(mockNodeList2);
nodeControl2.replay();
nodeListControl2.replay();
@@ -211,45 +197,41 @@ public class XmlHelperTest extends XWorkTestCase {
// <some_element>
// ...
// </some_element>
- MockControl elementNodeListControl = MockControl.createControl(NodeList.class);
- NodeList mockElementNodeList = (NodeList) elementNodeListControl.getMock();
+ IMocksControl elementNodeListControl = createControl();
+ NodeList mockElementNodeList = (NodeList) elementNodeListControl.createMock(NodeList.class);
- elementNodeListControl.expectAndDefaultReturn(mockElementNodeList.getLength(), 2);
- mockElementNodeList.item(0);
- elementNodeListControl.setReturnValue(mockParamElement2);
- mockElementNodeList.item(1);
- elementNodeListControl.setReturnValue(mockParamElement1);
+ expect(mockElementNodeList.getLength()).andStubReturn(2);
+
+ expect(mockElementNodeList.item(0)).andStubReturn(mockParamElement2);
+ expect(mockElementNodeList.item(1)).andStubReturn(mockParamElement1);
- MockControl elementControl = MockControl.createControl(Element.class);
- Element element = (Element) elementControl.getMock();
+ IMocksControl elementControl = createControl();
+ Element element = (Element) elementControl.createMock(Element.class);
- elementControl.expectAndDefaultReturn(element.getChildNodes(), mockElementNodeList);
+ expect(element.getChildNodes()).andStubReturn(mockElementNodeList);
elementNodeListControl.replay();
elementControl.replay();
-
-
Map params = XmlHelper.getParams(element);
+ assertNotNull(params);
+ assertEquals(params.size(), 2);
+ assertEquals(params.get("param1"), "value1");
+ assertEquals(params.get("param2"), "value2");
+
nodeControl1.verify();
- nodeListControl1.verify();
- paramControl1.verify();
+ nodeListControl1.verify();
+ paramControl1.verify();
nodeControl2.verify();
- nodeListControl2.verify();
- paramControl2.verify();
+ nodeListControl2.verify();
+ paramControl2.verify();
elementNodeListControl.verify();
- elementControl.verify();
-
-
- assertNotNull(params);
- assertEquals(params.size(), 2);
- assertEquals(params.get("param1"), "value1");
- assertEquals(params.get("param2"), "value2");
+ elementControl.verify();
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
index e3b4e8f..95b8b20 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
@@ -4,7 +4,8 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -17,7 +18,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
protected Map<String, Object> contextMap;
protected ActionContext context;
- protected MockControl actionInvocationControl;
+ protected IMocksControl actionInvocationControl;
protected ActionInvocation actionInvocation;
@Override
@@ -25,11 +26,11 @@ public class ParameterRemoverInterceptorTest extends TestCase {
contextMap = new LinkedHashMap<>();
context = new ActionContext(contextMap);
- actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- actionInvocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(actionInvocation.getAction(), new SampleAction());
- actionInvocationControl.expectAndDefaultReturn(actionInvocation.getInvocationContext(), context);
- actionInvocationControl.expectAndDefaultReturn(actionInvocation.invoke(), "success");
+ actionInvocationControl = createControl();
+ actionInvocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(actionInvocation.getAction()).andStubReturn(new SampleAction());
+ expect(actionInvocation.getInvocationContext()).andStubReturn(context);
+ expect(actionInvocation.invoke()).andStubReturn("success");
}
public void testInterception1() throws Exception {
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
index fa02c8b..d91fb6f 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
@@ -18,7 +18,8 @@ package com.opensymphony.xwork2.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import java.lang.reflect.Method;
@@ -83,19 +84,18 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("save");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+
+ expect(mockActionProxy.getMethod()).andStubReturn("save");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -104,33 +104,31 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
-
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertTrue(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod2() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("submit");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ expect(mockActionProxy.getMethod()).andStubReturn("submit");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -140,32 +138,31 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertTrue(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod3() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("cancel");
-
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ expect(mockActionProxy.getMethod()).andStubReturn("cancel");
+
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -175,32 +172,32 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertTrue(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod4() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("noSuchMethod");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+
+ expect(mockActionProxy.getMethod()).andStubReturn("noSuchMethod");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -209,33 +206,32 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
-
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod5() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("save");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+
+ expect(mockActionProxy.getMethod()).andStubReturn("save");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -244,14 +240,14 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
new String[] { "noSuchPrefix", "noSuchPrefixDo" });
-
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
index 1b0f95d..11db72a 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
@@ -21,7 +21,9 @@ import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.mock.MockActionProxy;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
+
/**
* Unit test for PrepareInterceptor.
@@ -33,6 +35,9 @@ public class PrepareInterceptorTest extends TestCase {
private Mock mock;
private PrepareInterceptor interceptor;
+
+ IMocksControl controlAction;
+ ActionInterface mockAction;
public void testPrepareCalledDefault() throws Exception {
MockActionInvocation mai = new MockActionInvocation();
@@ -102,30 +107,27 @@ public class PrepareInterceptorTest extends TestCase {
}
public void testPrefixInvocation1() throws Exception {
+
+
- MockControl controlAction = MockControl.createControl(ActionInterface.class);
- ActionInterface mockAction = (ActionInterface) controlAction.getMock();
- mockAction.prepareSubmit();
- controlAction.setVoidCallable(1);
- mockAction.prepare();
- controlAction.setVoidCallable(1);
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setDefaultReturnValue("submit");
+ expect(mockActionProxy.getMethod()).andStubReturn("submit");
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setDefaultReturnValue(mockAction);
- mockActionInvocation.invoke();
- controlActionInvocation.setDefaultReturnValue("okok");
- mockActionInvocation.getProxy();
- controlActionInvocation.setDefaultReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ expect(mockActionInvocation.getAction()).andStubReturn(mockAction);
+ expect(mockActionInvocation.invoke()).andStubReturn("okok");
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
+ mockAction.prepareSubmit();
+ expectLastCall().times(1);
+ mockAction.prepare();
+ expectLastCall().times(1);
+
controlAction.replay();
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -141,27 +143,23 @@ public class PrepareInterceptorTest extends TestCase {
}
public void testPrefixInvocation2() throws Exception {
+
- MockControl controlAction = MockControl.createControl(ActionInterface.class);
- ActionInterface mockAction = (ActionInterface) controlAction.getMock();
- mockAction.prepare();
- controlAction.setVoidCallable(1);
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setDefaultReturnValue("save");
+ expect(mockActionProxy.getMethod()).andStubReturn("save");
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setDefaultReturnValue(mockAction);
- mockActionInvocation.invoke();
- controlActionInvocation.setDefaultReturnValue("okok");
- mockActionInvocation.getProxy();
- controlActionInvocation.setDefaultReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ expect(mockActionInvocation.getAction()).andStubReturn(mockAction);
+ expect(mockActionInvocation.invoke()).andStubReturn("okok");
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
+
+ mockAction.prepare();
+ expectLastCall().times(1);
controlAction.replay();
controlActionProxy.replay();
@@ -176,6 +174,7 @@ public class PrepareInterceptorTest extends TestCase {
controlActionProxy.verify();
controlActionInvocation.verify();
}
+
public void testPrepareThrowException() throws Exception {
MockActionInvocation mai = new MockActionInvocation();
@@ -200,14 +199,20 @@ public class PrepareInterceptorTest extends TestCase {
protected void setUp() throws Exception {
mock = new Mock(ActionInterface.class);
interceptor = new PrepareInterceptor();
+ controlAction = createControl();
+ mockAction = (ActionInterface) controlAction.createMock(ActionInterface.class);
}
+
@Override
protected void tearDown() throws Exception {
+ controlAction = null;
+ mockAction = null;
mock.verify();
}
+
/**
* Simple interface to test prefix action invocation
* eg. prepareSubmit(), prepareSave() etc.
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/RequestUtilsTest.java b/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
index 0e530bd..78e125c 100644
--- a/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
+++ b/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
@@ -26,61 +26,62 @@ package org.apache.struts2;
*
*/
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
public class RequestUtilsTest extends TestCase {
- private MockControl control;
+ private IMocksControl control;
private HttpServletRequest requestMock;
public void testGetServletPathWithServletPathSet() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/");
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/");
+ expect(requestMock.getServletPath()).andStubReturn("/mycontext/");
+ expect(requestMock.getRequestURI()).andStubReturn("/mycontext/");
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithRequestURIAndEmptyContextPath() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), null);
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/test.jsp");
- control.expectAndReturn(requestMock.getContextPath(), "");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
+ expect(requestMock.getServletPath()).andStubReturn(null);
+ expect(requestMock.getRequestURI()).andStubReturn("/mycontext/test.jsp");
+ expect(requestMock.getContextPath()).andStubReturn("");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithRequestURIAndContextPathSet() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), null);
- control.expectAndReturn(requestMock.getRequestURI(), "/servlet/mycontext/test.jsp");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
+ expect(requestMock.getServletPath()).andStubReturn(null);
+ expect(requestMock.getRequestURI()).andStubReturn("/servlet/mycontext/test.jsp");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithRequestURIAndContextPathSetButNoPatchInfo() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), null);
- control.expectAndReturn(requestMock.getRequestURI(), "/servlet/mycontext/");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getPathInfo(), null);
+ expect(requestMock.getServletPath()).andStubReturn(null);
+ expect(requestMock.getRequestURI()).andStubReturn("/servlet/mycontext/");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getPathInfo()).andStubReturn(null);
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithSemicolon() throws Exception {
- control.expectAndReturn(requestMock.getRequestURI(), "/friend/mycontext/jim;bob");
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/jim");
+ expect(requestMock.getRequestURI()).andStubReturn("/friend/mycontext/jim;bob");
+ expect(requestMock.getServletPath()).andStubReturn("/mycontext/jim");
control.replay();
assertEquals("/mycontext/jim;bob", RequestUtils.getServletPath(requestMock));
control.verify();
@@ -103,8 +104,8 @@ public class RequestUtilsTest extends TestCase {
protected void setUp() {
- control = MockControl.createControl(HttpServletRequest.class);
- requestMock = (HttpServletRequest) control.getMock();
+ control = createControl();
+ requestMock = (HttpServletRequest) control.createMock(HttpServletRequest.class);
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
index 187efc0..40571bb 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
@@ -30,11 +30,14 @@ import javax.servlet.http.Cookie;
import com.opensymphony.xwork2.security.DefaultAcceptedPatternsChecker;
import com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker;
import com.opensymphony.xwork2.mock.MockActionInvocation;
-import org.easymock.MockControl;
import org.springframework.mock.web.MockHttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsInternalTestCase;
+import org.easymock.IMocksControl;
+import org.easymock.MockType;
+import static org.easymock.EasyMock.*;
+
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
@@ -56,12 +59,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl(MockType.DEFAULT);
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -79,6 +81,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertNull(ActionContext.getContext().getValueStack().findValue("cookie1"));
assertNull(ActionContext.getContext().getValueStack().findValue("cookie2"));
assertNull(ActionContext.getContext().getValueStack().findValue("cookie3"));
+
+ actionInvocationControl.verify();
}
public void testInterceptAll1() throws Exception {
@@ -94,12 +98,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl(MockType.DEFAULT);
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -121,6 +124,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), "cookie2value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
@@ -137,12 +142,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -164,6 +167,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), "cookie2value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
public void testInterceptSelectedCookiesNameOnly1() throws Exception {
@@ -179,12 +184,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -206,6 +209,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
public void testInterceptSelectedCookiesNameOnly2() throws Exception {
@@ -221,12 +226,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -248,6 +252,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
public void testInterceptSelectedCookiesNameOnly3() throws Exception {
@@ -263,12 +269,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -290,6 +294,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
@@ -306,12 +312,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -333,6 +337,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), null);
+
+ actionInvocationControl.verify();
}
public void testCookiesWithClassPollution() throws Exception {
@@ -402,6 +408,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertFalse(excludedValue.get(pollution4));
assertFalse(excludedValue.get(pollution5));
assertFalse(excludedValue.get(pollution6));
+
+
}
public void testCookiesWithStrutsInternalsAccess() throws Exception {
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
index 857ed3a..616ad4e 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
@@ -30,8 +30,11 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy;
import org.apache.struts2.util.ServletContextAware;
-import org.easymock.MockControl;
+
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
@@ -49,8 +52,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
private ServletConfigInterceptor interceptor;
public void testServletRequestAware() throws Exception {
- MockControl control = MockControl.createControl(ServletRequestAware.class);
- ServletRequestAware mock = (ServletRequestAware) control.getMock();
+ IMocksControl control = createControl();
+ ServletRequestAware mock = (ServletRequestAware) control.createMock(ServletRequestAware.class);
MockHttpServletRequest req = new MockHttpServletRequest();
@@ -58,7 +61,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
mock.setServletRequest((HttpServletRequest) req);
- control.setVoidCallable();
+ expectLastCall();
control.replay();
interceptor.intercept(mai);
@@ -66,8 +69,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testServletResponseAware() throws Exception {
- MockControl control = MockControl.createControl(ServletResponseAware.class);
- ServletResponseAware mock = (ServletResponseAware) control.getMock();
+ IMocksControl control = createControl();
+ ServletResponseAware mock = (ServletResponseAware) control.createMock(ServletResponseAware.class);
MockHttpServletResponse res = new MockHttpServletResponse();
@@ -75,7 +78,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().put(StrutsStatics.HTTP_RESPONSE, res);
mock.setServletResponse((HttpServletResponse) res);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -83,8 +86,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testParameterAware() throws Exception {
- MockControl control = MockControl.createControl(ParameterAware.class);
- ParameterAware mock = (ParameterAware) control.getMock();
+ IMocksControl control = createControl();
+ ParameterAware mock = (ParameterAware) control.createMock(ParameterAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -92,7 +95,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().setParameters(param);
mock.setParameters((Map)param);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -100,8 +103,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testSessionAware() throws Exception {
- MockControl control = MockControl.createControl(SessionAware.class);
- SessionAware mock = (SessionAware) control.getMock();
+ IMocksControl control = createControl();
+ SessionAware mock = (SessionAware) control.createMock(SessionAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -109,7 +112,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().setSession(session);
mock.setSession(session);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -117,16 +120,16 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testApplicationAware() throws Exception {
- MockControl control = MockControl.createControl(ApplicationAware.class);
- ApplicationAware mock = (ApplicationAware) control.getMock();
+ IMocksControl control = createControl();
+ ApplicationAware mock = (ApplicationAware) control.createMock(ApplicationAware.class);
MockActionInvocation mai = createActionInvocation(mock);
Map<String, Object> app = new HashMap<String, Object>();
mai.getInvocationContext().setApplication(app);
-
+
mock.setApplication(app);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -137,9 +140,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
MockHttpServletRequest req = new MockHttpServletRequest();
req.setUserPrincipal(null);
req.setRemoteUser("Santa");
- MockControl control = MockControl.createControl(PrincipalAware.class);
- control.setDefaultMatcher(MockControl.ALWAYS_MATCHER); // less strick match is needed for this unit test to be conducted using mocks
- PrincipalAware mock = (PrincipalAware) control.getMock();
+ IMocksControl control = createControl();
+ PrincipalAware mock = (PrincipalAware) control.createMock(PrincipalAware.class);
MockActionInvocation mai = createActionInvocation(mock);
mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
@@ -147,9 +149,9 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
MockServletContext ctx = new MockServletContext();
mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
- mock.setPrincipalProxy(null); // we can do this because of ALWAYS_MATCHER
- control.setVoidCallable();
-
+ mock.setPrincipalProxy(anyObject(ServletPrincipalProxy.class)); // less strick match is needed for this unit test to be conducted using mocks
+ expectLastCall().times(1);
+
control.replay();
interceptor.intercept(mai);
control.verify();
@@ -178,17 +180,17 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testServletContextAware() throws Exception {
- MockControl control = MockControl.createControl(ServletContextAware.class);
- ServletContextAware mock = (ServletContextAware) control.getMock();
+ IMocksControl control = createControl();
+ ServletContextAware mock = (ServletContextAware) control.createMock(ServletContextAware.class);
MockActionInvocation mai = createActionInvocation(mock);
MockServletContext ctx = new MockServletContext();
mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
-
+
mock.setServletContext((ServletContext) ctx);
- control.setVoidCallable();
-
+ expectLastCall().times(1);
+
control.replay();
interceptor.intercept(mai);
control.verify();
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
index 1bb9ab5..93e7133 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
@@ -21,11 +21,16 @@
package org.apache.struts2.views.jsp;
+import static org.easymock.EasyMock.*;
+
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import org.apache.struts2.StrutsException;
import org.apache.struts2.components.Include;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import org.easymock.MockType;
import com.mockobjects.servlet.MockRequestDispatcher;
@@ -35,7 +40,7 @@ import com.mockobjects.servlet.MockRequestDispatcher;
*/
public class IncludeTagTest extends AbstractTagTest {
- private MockControl controlRequestDispatcher;
+ private IMocksControl controlRequestDispatcher;
private RequestDispatcher mockRequestDispatcher;
private IncludeTag tag;
@@ -51,22 +56,29 @@ public class IncludeTagTest extends AbstractTagTest {
}
public void testIncludeNoParam() throws Exception {
- mockRequestDispatcher.include(null, null);
- controlRequestDispatcher.setVoidCallable();
+
+ // use always matcher as we can not determine the excact objects used in mock.include(request, response) call
+ mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
+ expectLastCall().times(1);
+
controlRequestDispatcher.replay();
tag.setValue("person/list.jsp");
tag.doStartTag();
tag.doEndTag();
-
- controlRequestDispatcher.verify();
+
assertEquals("/person/list.jsp", request.getRequestDispatherString());
assertEquals("", writer.toString());
+
+ controlRequestDispatcher.verify();
}
public void testIncludeWithParameters() throws Exception {
- mockRequestDispatcher.include(null, null);
- controlRequestDispatcher.setVoidCallable();
+
+ // use always matcher as we can not determine the excact objects used in mock.include(request, response) call
+ mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
+ expectLastCall().times(1);
+
controlRequestDispatcher.replay();
tag.setValue("person/create.jsp");
@@ -76,15 +88,18 @@ public class IncludeTagTest extends AbstractTagTest {
include.addParameter("user", "Santa Claus");
tag.doEndTag();
- controlRequestDispatcher.verify();
assertEquals("/person/create.jsp?user=Santa+Claus", request.getRequestDispatherString());
assertEquals("", writer.toString());
+
+ controlRequestDispatcher.verify();
}
public void testIncludeRelative2Dots() throws Exception {
// TODO: we should test for .. in unit test - is this test correct?
- mockRequestDispatcher.include(null, null);
- controlRequestDispatcher.setVoidCallable();
+ // use always matcher as we can not determine the exact objects used in mock.include(request, response) call
+ mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
+ expectLastCall().times(1);
+
controlRequestDispatcher.replay();
request.setupGetServletPath("app/manager");
@@ -92,9 +107,11 @@ public class IncludeTagTest extends AbstractTagTest {
tag.doStartTag();
tag.doEndTag();
- controlRequestDispatcher.verify();
+
assertEquals("/car/view.jsp", request.getRequestDispatherString());
assertEquals("", writer.toString());
+
+ controlRequestDispatcher.verify();
}
protected void setUp() throws Exception {
@@ -102,10 +119,10 @@ public class IncludeTagTest extends AbstractTagTest {
request.setupGetRequestDispatcher(new MockRequestDispatcher());
tag = new IncludeTag();
- controlRequestDispatcher = MockControl.createNiceControl(RequestDispatcher.class);
- // use always matcher as we can not determine the excact objects used in mock.include(request, response) call
- controlRequestDispatcher.setDefaultMatcher(MockControl.ALWAYS_MATCHER);
- mockRequestDispatcher = (RequestDispatcher) controlRequestDispatcher.getMock();
+ controlRequestDispatcher = createControl(MockType.NICE);
+
+
+ mockRequestDispatcher = (RequestDispatcher) controlRequestDispatcher.createMock(RequestDispatcher.class);
request.setupGetRequestDispatcher(mockRequestDispatcher);
tag.setPageContext(pageContext);
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java b/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
index f0b082e..1dfe674 100644
--- a/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
+++ b/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
@@ -28,24 +28,25 @@ import javax.servlet.http.HttpServletRequest;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
public class ResourceUtilTest extends TestCase {
- private MockControl control;
+ private IMocksControl control;
private HttpServletRequest requestMock;
public void testGetResourceBase() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/");
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/");
+ expect(requestMock.getServletPath()).andReturn("/mycontext/");
+ expect(requestMock.getRequestURI()).andReturn("/mycontext/");
control.replay();
assertEquals("/mycontext", ResourceUtil.getResourceBase(requestMock));
control.verify();
control.reset();
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/test.jsp");
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/test.jsp");
+ expect(requestMock.getServletPath()).andReturn("/mycontext/test.jsp");
+ expect(requestMock.getRequestURI()).andReturn("/mycontext/test.jsp");
control.replay();
assertEquals("/mycontext", ResourceUtil.getResourceBase(requestMock));
@@ -55,7 +56,7 @@ public class ResourceUtilTest extends TestCase {
protected void setUp() {
- control = MockControl.createControl(HttpServletRequest.class);
- requestMock = (HttpServletRequest) control.getMock();
+ control = createControl();
+ requestMock = (HttpServletRequest) control.createMock(HttpServletRequest.class);
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/900167da/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 08c94b4..8cccc87 100644
--- a/pom.xml
+++ b/pom.xml
@@ -578,14 +578,7 @@
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>2.4</version>
+ <version>3.4</version>
<scope>test</scope>
</dependency>
[08/10] struts git commit: Merge branch 'easymock_update' of
git@github.com:victorsosa/struts.git into easymock_update
Posted by lu...@apache.org.
Merge branch 'easymock_update' of git@github.com:victorsosa/struts.git
into easymock_update
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/a0a70581
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/a0a70581
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/a0a70581
Branch: refs/heads/master
Commit: a0a70581f91db9bd4c7cd5104f400dc83d479c54
Parents: d8e4cb8 eddd8e0
Author: victorsosa <vi...@peopleware.do>
Authored: Thu Mar 3 17:49:06 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Thu Mar 3 17:56:44 2016 -0400
----------------------------------------------------------------------
.../interceptor/CookieInterceptorTest.java | 25 --------------------
1 file changed, 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/a0a70581/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
index f4b41ee,211a9bd..6542f81
--- a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
@@@ -392,15 -384,15 +384,6 @@@ public class CookieInterceptorTest exte
assertFalse(excludedName.get(pollution4));
assertFalse(excludedName.get(pollution5));
assertFalse(excludedName.get(pollution6));
--
-- assertFalse(excludedValue.get(pollution1));
-- assertFalse(excludedValue.get(pollution2));
-- assertFalse(excludedValue.get(pollution3));
-- assertFalse(excludedValue.get(pollution4));
-- assertFalse(excludedValue.get(pollution5));
-- assertFalse(excludedValue.get(pollution6));
--
--
}
public void testCookiesWithStrutsInternalsAccess() throws Exception {
[05/10] struts git commit: Merge branch 'master' into easymock_update
Posted by lu...@apache.org.
Merge branch 'master' into easymock_update
# Conflicts:
# core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/eddd8e05
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/eddd8e05
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/eddd8e05
Branch: refs/heads/master
Commit: eddd8e054771d9330ec142215f75591ecb3e3964
Parents: 20e9d13 f34283b
Author: victorsosa <vi...@peopleware.do>
Authored: Thu Mar 3 14:38:13 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Thu Mar 3 14:38:13 2016 -0400
----------------------------------------------------------------------
.gitignore | 1 -
.../showcase/tiles/TilesAnnotationsAction.java | 40 +++
apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 10 +-
.../src/main/webapp/WEB-INF/tiles/body.jsp | 3 +
.../webapp/WEB-INF/tiles/layout-annotations.jsp | 14 ++
.../WEB-INF/validation/ajaxFormSubmit.jsp | 7 +-
assembly/pom.xml | 5 -
assembly/src/main/assembly/all.xml | 4 -
assembly/src/main/assembly/docs.xml | 4 -
bom/pom.xml | 5 -
.../xwork2/DefaultActionInvocation.java | 7 +-
.../com/opensymphony/xwork2/XWorkConstants.java | 1 +
...ervletContextAwareConfigurationProvider.java | 32 +++
.../xwork2/config/entities/ActionConfig.java | 1 +
.../xwork2/config/entities/AllowedMethods.java | 30 +++
.../xwork2/config/entities/PackageConfig.java | 2 +-
.../xwork2/config/impl/ActionConfigMatcher.java | 1 +
.../providers/XmlConfigurationProvider.java | 32 +--
.../interceptor/DefaultWorkflowInterceptor.java | 4 +-
.../interceptor/ParametersInterceptor.java | 29 +--
.../com/opensymphony/xwork2/ognl/OgnlUtil.java | 15 +-
.../xwork2/ognl/OgnlValueStack.java | 1 +
.../xwork2/ognl/SecurityMemberAccess.java | 16 +-
.../xwork2/util/LocalizedTextUtil.java | 26 +-
.../validator/DelegatingValidatorContext.java | 7 +-
.../org/apache/struts2/StrutsConstants.java | 1 +
.../org/apache/struts2/components/UIBean.java | 4 +-
.../config/DefaultBeanSelectionProvider.java | 1 +
.../apache/struts2/dispatcher/Dispatcher.java | 3 +
.../multipart/JakartaMultiPartRequest.java | 12 +-
.../struts2/interceptor/CookieInterceptor.java | 12 +-
.../interceptor/MessageStoreInterceptor.java | 58 +----
.../MessageStorePreResultListener.java | 95 +++++++
core/src/main/resources/struts-default.xml | 20 +-
.../xwork2/DefaultActionInvocationTest.java | 3 +
.../config/entities/ActionConfigTest.java | 4 +-
.../config/entities/AllowedMethodsTest.java | 15 ++
.../config/impl/ActionConfigMatcherTest.java | 16 +-
...ConfigurationProviderAllowedMethodsTest.java | 38 ++-
.../XmlConfigurationProviderResultsTest.java | 54 ++++
.../xwork2/ognl/SecurityMemberAccessTest.java | 20 +-
.../validator/VisitorFieldValidatorTest.java | 2 +-
.../interceptor/CookieInterceptorTest.java | 20 --
.../MessageStoreInterceptorTest.java | 184 +++-----------
.../MessageStorePreResultListenerTest.java | 252 +++++++++++++++++++
.../apache/struts2/views/jsp/ActionTagTest.java | 3 +-
.../com/opensymphony/xwork2/TestBean.properties | 2 +-
.../providers/xwork-test-allowed-methods.xml | 6 +-
.../providers/xwork-test-result-names.xml | 48 ++++
.../convention/DefaultResultMapBuilder.java | 20 +-
.../PackageBasedActionConfigBuilder.java | 6 +-
.../convention/annotation/AllowedMethods.java | 2 +-
.../struts2/convention/annotation/Result.java | 2 +-
.../convention/DefaultResultMapBuilderTest.java | 58 +++++
.../PackageBasedActionConfigBuilderTest.java | 4 +-
.../actions/allowedmethods/package-info.java | 2 +-
.../result/ActionLevelResultsNamesAction.java | 47 ++++
.../rest/DefaultContentTypeHandlerManager.java | 69 ++++-
.../apache/struts2/rest/RestActionMapper.java | 3 +-
.../DefaultContentTypeHandlerManagerTest.java | 42 ++++
.../struts2/rest/RestActionMapperTest.java | 39 +++
.../tiles/StrutsTilesAnnotationProcessor.java | 177 +++++++++++++
.../tiles/annotation/TilesAddAttribute.java | 30 +++
.../tiles/annotation/TilesAddListAttribute.java | 28 +++
.../tiles/annotation/TilesDefinition.java | 66 +++++
.../tiles/annotation/TilesDefinitions.java | 36 +++
.../tiles/annotation/TilesPutAttribute.java | 32 +++
.../tiles/annotation/TilesPutListAttribute.java | 32 +++
.../apache/struts2/views/tiles/TilesResult.java | 69 ++++-
.../StrutsTilesAnnotationProcessorTest.java | 147 +++++++++++
.../TilesTestActionMultipleAnnotations.java | 12 +
.../tiles/TilesTestActionSingleAnnotation.java | 49 ++++
...TilesTestActionSingleAnnotationAllEmpty.java | 28 +++
pom.xml | 8 +-
.../VisitorValidatorTestAction.properties | 1 +
75 files changed, 1794 insertions(+), 385 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/eddd8e05/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/eddd8e05/pom.xml
----------------------------------------------------------------------
[09/10] struts git commit: Merge branch 'easymock_update' of
git@github.com:victorsosa/struts.git into easymock_update
Posted by lu...@apache.org.
Merge branch 'easymock_update' of git@github.com:victorsosa/struts.git into easymock_update
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/3df363e7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/3df363e7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/3df363e7
Branch: refs/heads/master
Commit: 3df363e7a76ae34354e77b5170128ba899d02b62
Parents: a0a7058 88b37cd
Author: victorsosa <vi...@peopleware.do>
Authored: Thu Mar 3 17:57:27 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Thu Mar 3 17:57:27 2016 -0400
----------------------------------------------------------------------
----------------------------------------------------------------------
[06/10] struts git commit: Merge branch 'master' into easymock_update
Posted by lu...@apache.org.
Merge branch 'master' into easymock_update
# Conflicts:
# core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d8e4cb8b
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d8e4cb8b
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d8e4cb8b
Branch: refs/heads/master
Commit: d8e4cb8b48a935273ee9e4726dca643d4c57a34d
Parents: 20e9d13 f34283b
Author: victorsosa <vi...@peopleware.do>
Authored: Thu Mar 3 14:38:13 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Thu Mar 3 17:43:17 2016 -0400
----------------------------------------------------------------------
.gitignore | 1 -
.../showcase/tiles/TilesAnnotationsAction.java | 40 +++
apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 10 +-
.../src/main/webapp/WEB-INF/tiles/body.jsp | 3 +
.../webapp/WEB-INF/tiles/layout-annotations.jsp | 14 ++
.../WEB-INF/validation/ajaxFormSubmit.jsp | 7 +-
assembly/pom.xml | 5 -
assembly/src/main/assembly/all.xml | 4 -
assembly/src/main/assembly/docs.xml | 4 -
bom/pom.xml | 5 -
.../xwork2/DefaultActionInvocation.java | 7 +-
.../com/opensymphony/xwork2/XWorkConstants.java | 1 +
...ervletContextAwareConfigurationProvider.java | 32 +++
.../xwork2/config/entities/ActionConfig.java | 1 +
.../xwork2/config/entities/AllowedMethods.java | 30 +++
.../xwork2/config/entities/PackageConfig.java | 2 +-
.../xwork2/config/impl/ActionConfigMatcher.java | 1 +
.../providers/XmlConfigurationProvider.java | 32 +--
.../interceptor/DefaultWorkflowInterceptor.java | 4 +-
.../interceptor/ParametersInterceptor.java | 29 +--
.../com/opensymphony/xwork2/ognl/OgnlUtil.java | 15 +-
.../xwork2/ognl/OgnlValueStack.java | 1 +
.../xwork2/ognl/SecurityMemberAccess.java | 16 +-
.../xwork2/util/LocalizedTextUtil.java | 26 +-
.../validator/DelegatingValidatorContext.java | 7 +-
.../org/apache/struts2/StrutsConstants.java | 1 +
.../org/apache/struts2/components/UIBean.java | 4 +-
.../config/DefaultBeanSelectionProvider.java | 1 +
.../apache/struts2/dispatcher/Dispatcher.java | 3 +
.../multipart/JakartaMultiPartRequest.java | 12 +-
.../struts2/interceptor/CookieInterceptor.java | 12 +-
.../interceptor/MessageStoreInterceptor.java | 58 +----
.../MessageStorePreResultListener.java | 95 +++++++
core/src/main/resources/struts-default.xml | 20 +-
.../xwork2/DefaultActionInvocationTest.java | 3 +
.../config/entities/ActionConfigTest.java | 4 +-
.../config/entities/AllowedMethodsTest.java | 15 ++
.../config/impl/ActionConfigMatcherTest.java | 16 +-
...ConfigurationProviderAllowedMethodsTest.java | 38 ++-
.../XmlConfigurationProviderResultsTest.java | 54 ++++
.../xwork2/ognl/SecurityMemberAccessTest.java | 20 +-
.../validator/VisitorFieldValidatorTest.java | 2 +-
.../interceptor/CookieInterceptorTest.java | 4 -
.../MessageStoreInterceptorTest.java | 184 +++-----------
.../MessageStorePreResultListenerTest.java | 252 +++++++++++++++++++
.../apache/struts2/views/jsp/ActionTagTest.java | 3 +-
.../com/opensymphony/xwork2/TestBean.properties | 2 +-
.../providers/xwork-test-allowed-methods.xml | 6 +-
.../providers/xwork-test-result-names.xml | 48 ++++
.../convention/DefaultResultMapBuilder.java | 20 +-
.../PackageBasedActionConfigBuilder.java | 6 +-
.../convention/annotation/AllowedMethods.java | 2 +-
.../struts2/convention/annotation/Result.java | 2 +-
.../convention/DefaultResultMapBuilderTest.java | 58 +++++
.../PackageBasedActionConfigBuilderTest.java | 4 +-
.../actions/allowedmethods/package-info.java | 2 +-
.../result/ActionLevelResultsNamesAction.java | 47 ++++
.../rest/DefaultContentTypeHandlerManager.java | 69 ++++-
.../apache/struts2/rest/RestActionMapper.java | 3 +-
.../DefaultContentTypeHandlerManagerTest.java | 42 ++++
.../struts2/rest/RestActionMapperTest.java | 39 +++
.../tiles/StrutsTilesAnnotationProcessor.java | 177 +++++++++++++
.../tiles/annotation/TilesAddAttribute.java | 30 +++
.../tiles/annotation/TilesAddListAttribute.java | 28 +++
.../tiles/annotation/TilesDefinition.java | 66 +++++
.../tiles/annotation/TilesDefinitions.java | 36 +++
.../tiles/annotation/TilesPutAttribute.java | 32 +++
.../tiles/annotation/TilesPutListAttribute.java | 32 +++
.../apache/struts2/views/tiles/TilesResult.java | 69 ++++-
.../StrutsTilesAnnotationProcessorTest.java | 147 +++++++++++
.../TilesTestActionMultipleAnnotations.java | 12 +
.../tiles/TilesTestActionSingleAnnotation.java | 49 ++++
...TilesTestActionSingleAnnotationAllEmpty.java | 28 +++
pom.xml | 8 +-
.../VisitorValidatorTestAction.properties | 1 +
75 files changed, 1794 insertions(+), 369 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/d8e4cb8b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/d8e4cb8b/pom.xml
----------------------------------------------------------------------
[07/10] struts git commit: Merge branch 'easymock_update' of
git@github.com:victorsosa/struts.git into easymock_update
Posted by lu...@apache.org.
Merge branch 'easymock_update' of git@github.com:victorsosa/struts.git into easymock_update
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/88b37cdb
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/88b37cdb
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/88b37cdb
Branch: refs/heads/master
Commit: 88b37cdb40996881e7a0f0f00a6f64fbf3f3638a
Parents: d8e4cb8 eddd8e0
Author: victorsosa <vi...@peopleware.do>
Authored: Thu Mar 3 17:49:06 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Thu Mar 3 17:49:06 2016 -0400
----------------------------------------------------------------------
----------------------------------------------------------------------
[02/10] struts git commit: WW-4593 Easymock upgrade to 3.4
Posted by lu...@apache.org.
WW-4593 Easymock upgrade to 3.4
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/20e13f16
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/20e13f16
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/20e13f16
Branch: refs/heads/master
Commit: 20e13f1625f5fd5be6e1f83ac3b63788bd8553f7
Parents: c167d6c
Author: Victor Sosa <vi...@gmail.com>
Authored: Wed Jan 20 16:14:35 2016 -0400
Committer: Victor Sosa <vi...@gmail.com>
Committed: Wed Jan 20 16:28:36 2016 -0400
----------------------------------------------------------------------
.../xwork2/config/providers/XmlHelperTest.java | 226 +++++++++----------
.../ParameterRemoverInterceptorTest.java | 15 +-
.../PrefixMethodInvocationUtilTest.java | 136 ++++++-----
.../interceptor/PrepareInterceptorTest.java | 75 +++---
.../org/apache/struts2/RequestUtilsTest.java | 49 ++--
.../interceptor/CookieInterceptorTest.java | 94 ++++----
.../ServletConfigInterceptorTest.java | 58 ++---
.../struts2/views/jsp/IncludeTagTest.java | 49 ++--
.../struts2/views/util/ResourceUtilTest.java | 17 +-
plugins/convention/pom.xml | 5 -
.../ConventionUnknownHandlerTest.java | 6 +-
plugins/javatemplates/pom.xml | 6 +-
.../struts2/views/java/simple/AbstractTest.java | 36 +--
pom.xml | 9 +-
14 files changed, 388 insertions(+), 393 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
index 9e0f1a3..73f8e51 100644
--- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
@@ -1,7 +1,8 @@
package com.opensymphony.xwork2.config.providers;
import com.opensymphony.xwork2.XWorkTestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -18,26 +19,26 @@ public class XmlHelperTest extends XWorkTestCase {
public void testGetContent1() throws Exception {
// set up Node
- MockControl nodeControl = MockControl.createControl(Node.class);
- Node mockNode = (Node) nodeControl.getMock();
+ IMocksControl nodeControl = createControl();
+ Node mockNode = (Node) nodeControl.createMock(Node.class);
- nodeControl.expectAndDefaultReturn(mockNode.getNodeValue(), "testing testing 123");
- nodeControl.expectAndDefaultReturn(mockNode.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode.getNodeValue()).andStubReturn("testing testing 123");
+ expect(mockNode.getNodeType()).andStubReturn(Node.TEXT_NODE);
// set up NodeList
- MockControl nodeListControl = MockControl.createControl(NodeList.class);
- NodeList mockNodeList = (NodeList) nodeListControl.getMock();
+ IMocksControl nodeListControl = createControl();
+ NodeList mockNodeList = (NodeList) nodeListControl.createMock(NodeList.class);
- nodeListControl.expectAndDefaultReturn(mockNodeList.getLength(), 1);
- nodeListControl.expectAndDefaultReturn(mockNodeList.item(0), mockNode);
+ expect(mockNodeList.getLength()).andStubReturn(1);
+ expect(mockNodeList.item(0)).andStubReturn(mockNode);
// set up Element
- MockControl elementControl = MockControl.createControl(Element.class);
- Element mockElement = (Element) elementControl.getMock();
+ IMocksControl elementControl = createControl();
+ Element mockElement = (Element) elementControl.createMock(Element.class);
- elementControl.expectAndDefaultReturn(mockElement.getChildNodes(), mockNodeList);
+ expect(mockElement.getChildNodes()).andStubReturn(mockNodeList);
nodeControl.replay();
nodeListControl.replay();
@@ -45,77 +46,71 @@ public class XmlHelperTest extends XWorkTestCase {
String result = XmlHelper.getContent(mockElement);
+ assertEquals(result, "testing testing 123");
+
nodeControl.verify();
nodeListControl.verify();
elementControl.verify();
-
- assertEquals(result, "testing testing 123");
}
public void testGetContent2() throws Exception {
// set up Node
- MockControl nodeControl1 = MockControl.createControl(Node.class);
- Node mockNode1 = (Node) nodeControl1.getMock();
+ IMocksControl nodeControl1 = createControl();
+ Node mockNode1 = (Node) nodeControl1.createMock(Node.class);
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeValue(), "testing testing 123");
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode1.getNodeValue()).andStubReturn("testing testing 123");
+ expect(mockNode1.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeControl2 = MockControl.createControl(Node.class);
- Node mockNode2 = (Node) nodeControl2.getMock();
+ IMocksControl nodeControl2 = createControl();
+ Node mockNode2 = (Node) nodeControl2.createMock(Node.class);
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeValue(), "comment 1");
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeType(), Node.COMMENT_NODE);
+ expect(mockNode2.getNodeValue()).andStubReturn("comment 1");
+ expect(mockNode2.getNodeType()).andStubReturn(Node.COMMENT_NODE);
- MockControl nodeControl3 = MockControl.createControl(Node.class);
- Node mockNode3 = (Node) nodeControl3.getMock();
+ IMocksControl nodeControl3 = createControl();
+ Node mockNode3 = (Node) nodeControl3.createMock(Node.class);
- nodeControl3.expectAndDefaultReturn(mockNode3.getNodeValue(), " tmjee ");
- nodeControl3.expectAndDefaultReturn(mockNode3.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode3.getNodeValue()).andStubReturn(" tmjee ");
+ expect(mockNode3.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeControl4 = MockControl.createControl(Node.class);
- Node mockNode4 = (Node) nodeControl4.getMock();
+ IMocksControl nodeControl4 = createControl();
+ Node mockNode4 = (Node) nodeControl4.createMock(Node.class);
- nodeControl4.expectAndDefaultReturn(mockNode4.getNodeValue(), " phil ");
- nodeControl4.expectAndDefaultReturn(mockNode4.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode4.getNodeValue()).andStubReturn(" phil ");
+ expect(mockNode4.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeControl5 = MockControl.createControl(Node.class);
- Node mockNode5 = (Node) nodeControl5.getMock();
+ IMocksControl nodeControl5 = createControl();
+ Node mockNode5 = (Node) nodeControl5.createMock(Node.class);
- nodeControl5.expectAndDefaultReturn(mockNode5.getNodeValue(), "comment 2");
- nodeControl5.expectAndDefaultReturn(mockNode5.getNodeType(), Node.COMMENT_NODE);
+ expect(mockNode5.getNodeValue()).andStubReturn("comment 2");
+ expect(mockNode5.getNodeType()).andStubReturn(Node.COMMENT_NODE);
- MockControl nodeControl6 = MockControl.createControl(Node.class);
- Node mockNode6 = (Node) nodeControl6.getMock();
+ IMocksControl nodeControl6 = createControl();
+ Node mockNode6 = (Node) nodeControl6.createMock(Node.class);
- nodeControl6.expectAndDefaultReturn(mockNode6.getNodeValue(), "comment 3");
- nodeControl6.expectAndDefaultReturn(mockNode6.getNodeType(), Node.COMMENT_NODE);
+ expect(mockNode6.getNodeValue()).andStubReturn("comment 3");
+ expect(mockNode6.getNodeType()).andStubReturn(Node.COMMENT_NODE);
// set up NodeList
- MockControl nodeListControl = MockControl.createControl(NodeList.class);
- NodeList mockNodeList = (NodeList) nodeListControl.getMock();
-
- nodeListControl.expectAndDefaultReturn(mockNodeList.getLength(), 6);
- mockNodeList.item(0);
- nodeListControl.setReturnValue(mockNode1);
- mockNodeList.item(1);
- nodeListControl.setReturnValue(mockNode2);
- mockNodeList.item(2);
- nodeListControl.setDefaultReturnValue(mockNode3);
- mockNodeList.item(3);
- nodeListControl.setReturnValue(mockNode4);
- mockNodeList.item(4);
- nodeListControl.setReturnValue(mockNode5);
- mockNodeList.item(5);
- nodeListControl.setReturnValue(mockNode6);
-
+ IMocksControl nodeListControl = createControl();
+ NodeList mockNodeList = (NodeList) nodeListControl.createMock(NodeList.class);
+
+ expect(mockNodeList.getLength()).andStubReturn(6);
+
+ expect(mockNodeList.item(0)).andStubReturn(mockNode1);
+ expect(mockNodeList.item(1)).andStubReturn(mockNode2);
+ expect(mockNodeList.item(2)).andStubReturn(mockNode3);
+ expect(mockNodeList.item(3)).andStubReturn(mockNode4);
+ expect(mockNodeList.item(4)).andStubReturn(mockNode5);
+ expect(mockNodeList.item(5)).andStubReturn(mockNode6);
// set up Element
- MockControl elementControl = MockControl.createControl(Element.class);
- Element mockElement = (Element) elementControl.getMock();
+ IMocksControl elementControl = createControl();
+ Element mockElement = (Element) elementControl.createMock(Element.class);
- elementControl.expectAndDefaultReturn(mockElement.getChildNodes(), mockNodeList);
+ expect(mockElement.getChildNodes()).andStubReturn(mockNodeList);
nodeControl1.replay();
nodeControl2.replay();
@@ -128,6 +123,8 @@ public class XmlHelperTest extends XWorkTestCase {
String result = XmlHelper.getContent(mockElement);
+ assertEquals(result, "testing testing 123tmjeephil");
+
nodeControl1.verify();
nodeControl2.verify();
nodeControl3.verify();
@@ -135,73 +132,62 @@ public class XmlHelperTest extends XWorkTestCase {
nodeControl5.verify();
nodeControl6.verify();
nodeListControl.verify();
- elementControl.verify();
-
- assertEquals(result, "testing testing 123tmjeephil");
+ elementControl.verify();
}
public void testGetParams() throws Exception {
// <param name="param1">value1</param>
- MockControl nodeControl1 = MockControl.createControl(Node.class);
- Node mockNode1 = (Node) nodeControl1.getMock();
+ IMocksControl nodeControl1 = createControl();
+ Node mockNode1 = (Node) nodeControl1.createMock(Node.class);
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeValue(), "value1");
- nodeControl1.expectAndDefaultReturn(mockNode1.getNodeType(), Node.TEXT_NODE);
+ expect(mockNode1.getNodeValue()).andStubReturn("value1");
+ expect(mockNode1.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeListControl1 = MockControl.createControl(NodeList.class);
- NodeList mockNodeList1 = (NodeList) nodeListControl1.getMock();
+ IMocksControl nodeListControl1 = createControl();
+ NodeList mockNodeList1 = (NodeList) nodeListControl1.createMock(NodeList.class);
- nodeListControl1.expectAndDefaultReturn(mockNodeList1.getLength(), 1);
- nodeListControl1.expectAndDefaultReturn(mockNodeList1.item(0), mockNode1);
+ expect(mockNodeList1.getLength()).andStubReturn(1);
+ expect(mockNodeList1.item(0)).andStubReturn(mockNode1);
- MockControl paramControl1 = MockControl.createControl(Element.class);
- Element mockParamElement1 = (Element) paramControl1.getMock();
- mockParamElement1.getNodeName();
- paramControl1.setReturnValue("param");
+ IMocksControl paramControl1 = createControl();
+ Element mockParamElement1 = (Element) paramControl1.createMock(Element.class);
+ expect(mockParamElement1.getNodeName()).andStubReturn("param");
- mockParamElement1.getNodeType();
- paramControl1.setReturnValue(Node.ELEMENT_NODE);
+ expect(mockParamElement1.getNodeType()).andStubReturn(Node.ELEMENT_NODE);
- mockParamElement1.getAttribute("name");
- paramControl1.setReturnValue("param1");
+ expect(mockParamElement1.getAttribute("name")).andStubReturn("param1");
- mockParamElement1.getChildNodes();
- paramControl1.setReturnValue(mockNodeList1);
+ expect(mockParamElement1.getChildNodes()).andStubReturn(mockNodeList1);
nodeControl1.replay();
nodeListControl1.replay();
paramControl1.replay();
// <param name="param2">value2</param>
- MockControl nodeControl2 = MockControl.createControl(Node.class);
- Node mockNode2 = (Node) nodeControl2.getMock();
-
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeValue(), "value2");
- nodeControl2.expectAndDefaultReturn(mockNode2.getNodeType(), Node.TEXT_NODE);
+ IMocksControl nodeControl2 = createControl();
+ Node mockNode2 = (Node) nodeControl2.createMock(Node.class);
+ expect(mockNode2.getNodeValue()).andStubReturn("value2");
+ expect(mockNode2.getNodeType()).andStubReturn(Node.TEXT_NODE);
- MockControl nodeListControl2 = MockControl.createControl(NodeList.class);
- NodeList mockNodeList2 = (NodeList) nodeListControl2.getMock();
- nodeListControl2.expectAndDefaultReturn(mockNodeList2.getLength(), 1);
- nodeListControl2.expectAndDefaultReturn(mockNodeList2.item(0), mockNode2);
+ IMocksControl nodeListControl2 = createControl();
+ NodeList mockNodeList2 = (NodeList) nodeListControl2.createMock(NodeList.class);
- MockControl paramControl2 = MockControl.createControl(Element.class);
- Element mockParamElement2 = (Element) paramControl2.getMock();
- mockParamElement2.getNodeName();
- paramControl2.setReturnValue("param");
+ expect(mockNodeList2.getLength()).andStubReturn(1);
+ expect(mockNodeList2.item(0)).andStubReturn(mockNode2);
- mockParamElement2.getNodeType();
- paramControl2.setReturnValue(Node.ELEMENT_NODE);
+ IMocksControl paramControl2 = createControl();
+ Element mockParamElement2 = (Element) paramControl2.createMock(Element.class);
+
+ expect(mockParamElement2.getNodeName()).andStubReturn("param");
+ expect(mockParamElement2.getNodeType()).andStubReturn(Node.ELEMENT_NODE);
- mockParamElement2.getAttribute("name");
- paramControl2.setReturnValue("param2");
-
- mockParamElement2.getChildNodes();
- paramControl2.setReturnValue(mockNodeList2);
+ expect(mockParamElement2.getAttribute("name")).andStubReturn("param2");
+ expect(mockParamElement2.getChildNodes()).andStubReturn(mockNodeList2);
nodeControl2.replay();
nodeListControl2.replay();
@@ -211,45 +197,41 @@ public class XmlHelperTest extends XWorkTestCase {
// <some_element>
// ...
// </some_element>
- MockControl elementNodeListControl = MockControl.createControl(NodeList.class);
- NodeList mockElementNodeList = (NodeList) elementNodeListControl.getMock();
+ IMocksControl elementNodeListControl = createControl();
+ NodeList mockElementNodeList = (NodeList) elementNodeListControl.createMock(NodeList.class);
- elementNodeListControl.expectAndDefaultReturn(mockElementNodeList.getLength(), 2);
- mockElementNodeList.item(0);
- elementNodeListControl.setReturnValue(mockParamElement2);
- mockElementNodeList.item(1);
- elementNodeListControl.setReturnValue(mockParamElement1);
+ expect(mockElementNodeList.getLength()).andStubReturn(2);
+
+ expect(mockElementNodeList.item(0)).andStubReturn(mockParamElement2);
+ expect(mockElementNodeList.item(1)).andStubReturn(mockParamElement1);
- MockControl elementControl = MockControl.createControl(Element.class);
- Element element = (Element) elementControl.getMock();
+ IMocksControl elementControl = createControl();
+ Element element = (Element) elementControl.createMock(Element.class);
- elementControl.expectAndDefaultReturn(element.getChildNodes(), mockElementNodeList);
+ expect(element.getChildNodes()).andStubReturn(mockElementNodeList);
elementNodeListControl.replay();
elementControl.replay();
-
-
Map params = XmlHelper.getParams(element);
+ assertNotNull(params);
+ assertEquals(params.size(), 2);
+ assertEquals(params.get("param1"), "value1");
+ assertEquals(params.get("param2"), "value2");
+
nodeControl1.verify();
- nodeListControl1.verify();
- paramControl1.verify();
+ nodeListControl1.verify();
+ paramControl1.verify();
nodeControl2.verify();
- nodeListControl2.verify();
- paramControl2.verify();
+ nodeListControl2.verify();
+ paramControl2.verify();
elementNodeListControl.verify();
- elementControl.verify();
-
-
- assertNotNull(params);
- assertEquals(params.size(), 2);
- assertEquals(params.get("param1"), "value1");
- assertEquals(params.get("param2"), "value2");
+ elementControl.verify();
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
index e3b4e8f..95b8b20 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
@@ -4,7 +4,8 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -17,7 +18,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
protected Map<String, Object> contextMap;
protected ActionContext context;
- protected MockControl actionInvocationControl;
+ protected IMocksControl actionInvocationControl;
protected ActionInvocation actionInvocation;
@Override
@@ -25,11 +26,11 @@ public class ParameterRemoverInterceptorTest extends TestCase {
contextMap = new LinkedHashMap<>();
context = new ActionContext(contextMap);
- actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- actionInvocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(actionInvocation.getAction(), new SampleAction());
- actionInvocationControl.expectAndDefaultReturn(actionInvocation.getInvocationContext(), context);
- actionInvocationControl.expectAndDefaultReturn(actionInvocation.invoke(), "success");
+ actionInvocationControl = createControl();
+ actionInvocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(actionInvocation.getAction()).andStubReturn(new SampleAction());
+ expect(actionInvocation.getInvocationContext()).andStubReturn(context);
+ expect(actionInvocation.invoke()).andStubReturn("success");
}
public void testInterception1() throws Exception {
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
index fa02c8b..d91fb6f 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
@@ -18,7 +18,8 @@ package com.opensymphony.xwork2.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import java.lang.reflect.Method;
@@ -83,19 +84,18 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("save");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+
+ expect(mockActionProxy.getMethod()).andStubReturn("save");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -104,33 +104,31 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
-
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertTrue(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod2() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("submit");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ expect(mockActionProxy.getMethod()).andStubReturn("submit");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -140,32 +138,31 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertTrue(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod3() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("cancel");
-
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ expect(mockActionProxy.getMethod()).andStubReturn("cancel");
+
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -175,32 +172,32 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertTrue(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod4() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("noSuchMethod");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+
+ expect(mockActionProxy.getMethod()).andStubReturn("noSuchMethod");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -209,33 +206,32 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
new String[] { "prepare", "prepareDo" });
-
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
public void testInvokePrefixMethod5() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setReturnValue("save");
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+
+ expect(mockActionProxy.getMethod()).andStubReturn("save");
// ActionInvocation
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setReturnValue(action);
- mockActionInvocation.getProxy();
- controlActionInvocation.setReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+
+ expect(mockActionInvocation.getAction()).andStubReturn(action);
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -244,14 +240,14 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
new String[] { "noSuchPrefix", "noSuchPrefixDo" });
-
- controlActionProxy.verify();
- controlActionInvocation.verify();
-
+
assertFalse(action.prepareSaveInvoked);
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
+
+ controlActionProxy.verify();
+ controlActionInvocation.verify();
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
index 1b0f95d..11db72a 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
@@ -21,7 +21,9 @@ import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.mock.MockActionProxy;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
+
/**
* Unit test for PrepareInterceptor.
@@ -33,6 +35,9 @@ public class PrepareInterceptorTest extends TestCase {
private Mock mock;
private PrepareInterceptor interceptor;
+
+ IMocksControl controlAction;
+ ActionInterface mockAction;
public void testPrepareCalledDefault() throws Exception {
MockActionInvocation mai = new MockActionInvocation();
@@ -102,30 +107,27 @@ public class PrepareInterceptorTest extends TestCase {
}
public void testPrefixInvocation1() throws Exception {
+
+
- MockControl controlAction = MockControl.createControl(ActionInterface.class);
- ActionInterface mockAction = (ActionInterface) controlAction.getMock();
- mockAction.prepareSubmit();
- controlAction.setVoidCallable(1);
- mockAction.prepare();
- controlAction.setVoidCallable(1);
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setDefaultReturnValue("submit");
+ expect(mockActionProxy.getMethod()).andStubReturn("submit");
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setDefaultReturnValue(mockAction);
- mockActionInvocation.invoke();
- controlActionInvocation.setDefaultReturnValue("okok");
- mockActionInvocation.getProxy();
- controlActionInvocation.setDefaultReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ expect(mockActionInvocation.getAction()).andStubReturn(mockAction);
+ expect(mockActionInvocation.invoke()).andStubReturn("okok");
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
+ mockAction.prepareSubmit();
+ expectLastCall().times(1);
+ mockAction.prepare();
+ expectLastCall().times(1);
+
controlAction.replay();
controlActionProxy.replay();
controlActionInvocation.replay();
@@ -141,27 +143,23 @@ public class PrepareInterceptorTest extends TestCase {
}
public void testPrefixInvocation2() throws Exception {
+
- MockControl controlAction = MockControl.createControl(ActionInterface.class);
- ActionInterface mockAction = (ActionInterface) controlAction.getMock();
- mockAction.prepare();
- controlAction.setVoidCallable(1);
+ IMocksControl controlActionProxy = createControl();
+ ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
- MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
- mockActionProxy.getMethod();
- controlActionProxy.setDefaultReturnValue("save");
+ expect(mockActionProxy.getMethod()).andStubReturn("save");
- MockControl controlActionInvocation = MockControl.createControl(ActionInvocation.class);
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.getMock();
- mockActionInvocation.getAction();
- controlActionInvocation.setDefaultReturnValue(mockAction);
- mockActionInvocation.invoke();
- controlActionInvocation.setDefaultReturnValue("okok");
- mockActionInvocation.getProxy();
- controlActionInvocation.setDefaultReturnValue(mockActionProxy);
+ IMocksControl controlActionInvocation = createControl();
+ ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ expect(mockActionInvocation.getAction()).andStubReturn(mockAction);
+ expect(mockActionInvocation.invoke()).andStubReturn("okok");
+ expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
+
+ mockAction.prepare();
+ expectLastCall().times(1);
controlAction.replay();
controlActionProxy.replay();
@@ -176,6 +174,7 @@ public class PrepareInterceptorTest extends TestCase {
controlActionProxy.verify();
controlActionInvocation.verify();
}
+
public void testPrepareThrowException() throws Exception {
MockActionInvocation mai = new MockActionInvocation();
@@ -200,14 +199,20 @@ public class PrepareInterceptorTest extends TestCase {
protected void setUp() throws Exception {
mock = new Mock(ActionInterface.class);
interceptor = new PrepareInterceptor();
+ controlAction = createControl();
+ mockAction = (ActionInterface) controlAction.createMock(ActionInterface.class);
}
+
@Override
protected void tearDown() throws Exception {
+ controlAction = null;
+ mockAction = null;
mock.verify();
}
+
/**
* Simple interface to test prefix action invocation
* eg. prepareSubmit(), prepareSave() etc.
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/RequestUtilsTest.java b/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
index 0e530bd..78e125c 100644
--- a/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
+++ b/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
@@ -26,61 +26,62 @@ package org.apache.struts2;
*
*/
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
public class RequestUtilsTest extends TestCase {
- private MockControl control;
+ private IMocksControl control;
private HttpServletRequest requestMock;
public void testGetServletPathWithServletPathSet() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/");
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/");
+ expect(requestMock.getServletPath()).andStubReturn("/mycontext/");
+ expect(requestMock.getRequestURI()).andStubReturn("/mycontext/");
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithRequestURIAndEmptyContextPath() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), null);
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/test.jsp");
- control.expectAndReturn(requestMock.getContextPath(), "");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
+ expect(requestMock.getServletPath()).andStubReturn(null);
+ expect(requestMock.getRequestURI()).andStubReturn("/mycontext/test.jsp");
+ expect(requestMock.getContextPath()).andStubReturn("");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithRequestURIAndContextPathSet() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), null);
- control.expectAndReturn(requestMock.getRequestURI(), "/servlet/mycontext/test.jsp");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
- control.expectAndReturn(requestMock.getPathInfo(), "test.jsp");
+ expect(requestMock.getServletPath()).andStubReturn(null);
+ expect(requestMock.getRequestURI()).andStubReturn("/servlet/mycontext/test.jsp");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
+ expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithRequestURIAndContextPathSetButNoPatchInfo() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), null);
- control.expectAndReturn(requestMock.getRequestURI(), "/servlet/mycontext/");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getContextPath(), "/servlet");
- control.expectAndReturn(requestMock.getPathInfo(), null);
+ expect(requestMock.getServletPath()).andStubReturn(null);
+ expect(requestMock.getRequestURI()).andStubReturn("/servlet/mycontext/");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getContextPath()).andStubReturn("/servlet");
+ expect(requestMock.getPathInfo()).andStubReturn(null);
control.replay();
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
control.verify();
}
public void testGetServletPathWithSemicolon() throws Exception {
- control.expectAndReturn(requestMock.getRequestURI(), "/friend/mycontext/jim;bob");
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/jim");
+ expect(requestMock.getRequestURI()).andStubReturn("/friend/mycontext/jim;bob");
+ expect(requestMock.getServletPath()).andStubReturn("/mycontext/jim");
control.replay();
assertEquals("/mycontext/jim;bob", RequestUtils.getServletPath(requestMock));
control.verify();
@@ -103,8 +104,8 @@ public class RequestUtilsTest extends TestCase {
protected void setUp() {
- control = MockControl.createControl(HttpServletRequest.class);
- requestMock = (HttpServletRequest) control.getMock();
+ control = createControl();
+ requestMock = (HttpServletRequest) control.createMock(HttpServletRequest.class);
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
index 187efc0..40571bb 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
@@ -30,11 +30,14 @@ import javax.servlet.http.Cookie;
import com.opensymphony.xwork2.security.DefaultAcceptedPatternsChecker;
import com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker;
import com.opensymphony.xwork2.mock.MockActionInvocation;
-import org.easymock.MockControl;
import org.springframework.mock.web.MockHttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsInternalTestCase;
+import org.easymock.IMocksControl;
+import org.easymock.MockType;
+import static org.easymock.EasyMock.*;
+
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
@@ -56,12 +59,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl(MockType.DEFAULT);
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -79,6 +81,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertNull(ActionContext.getContext().getValueStack().findValue("cookie1"));
assertNull(ActionContext.getContext().getValueStack().findValue("cookie2"));
assertNull(ActionContext.getContext().getValueStack().findValue("cookie3"));
+
+ actionInvocationControl.verify();
}
public void testInterceptAll1() throws Exception {
@@ -94,12 +98,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl(MockType.DEFAULT);
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -121,6 +124,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), "cookie2value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
@@ -137,12 +142,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -164,6 +167,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), "cookie2value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
public void testInterceptSelectedCookiesNameOnly1() throws Exception {
@@ -179,12 +184,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -206,6 +209,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
public void testInterceptSelectedCookiesNameOnly2() throws Exception {
@@ -221,12 +226,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -248,6 +252,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
public void testInterceptSelectedCookiesNameOnly3() throws Exception {
@@ -263,12 +269,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -290,6 +294,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
+
+ actionInvocationControl.verify();
}
@@ -306,12 +312,10 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- MockControl actionInvocationControl = MockControl.createControl(ActionInvocation.class);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.getMock();
- actionInvocationControl.expectAndDefaultReturn(
- invocation.getAction(), action);
- actionInvocationControl.expectAndDefaultReturn(
- invocation.invoke(), Action.SUCCESS);
+ IMocksControl actionInvocationControl = createControl();
+ ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ expect(invocation.getAction()).andReturn(action);
+ expect(invocation.invoke()).andReturn(Action.SUCCESS);
actionInvocationControl.replay();
@@ -333,6 +337,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie1"), "cookie1value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), null);
+
+ actionInvocationControl.verify();
}
public void testCookiesWithClassPollution() throws Exception {
@@ -402,6 +408,8 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertFalse(excludedValue.get(pollution4));
assertFalse(excludedValue.get(pollution5));
assertFalse(excludedValue.get(pollution6));
+
+
}
public void testCookiesWithStrutsInternalsAccess() throws Exception {
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
index 857ed3a..616ad4e 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
@@ -30,8 +30,11 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy;
import org.apache.struts2.util.ServletContextAware;
-import org.easymock.MockControl;
+
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
@@ -49,8 +52,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
private ServletConfigInterceptor interceptor;
public void testServletRequestAware() throws Exception {
- MockControl control = MockControl.createControl(ServletRequestAware.class);
- ServletRequestAware mock = (ServletRequestAware) control.getMock();
+ IMocksControl control = createControl();
+ ServletRequestAware mock = (ServletRequestAware) control.createMock(ServletRequestAware.class);
MockHttpServletRequest req = new MockHttpServletRequest();
@@ -58,7 +61,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
mock.setServletRequest((HttpServletRequest) req);
- control.setVoidCallable();
+ expectLastCall();
control.replay();
interceptor.intercept(mai);
@@ -66,8 +69,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testServletResponseAware() throws Exception {
- MockControl control = MockControl.createControl(ServletResponseAware.class);
- ServletResponseAware mock = (ServletResponseAware) control.getMock();
+ IMocksControl control = createControl();
+ ServletResponseAware mock = (ServletResponseAware) control.createMock(ServletResponseAware.class);
MockHttpServletResponse res = new MockHttpServletResponse();
@@ -75,7 +78,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().put(StrutsStatics.HTTP_RESPONSE, res);
mock.setServletResponse((HttpServletResponse) res);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -83,8 +86,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testParameterAware() throws Exception {
- MockControl control = MockControl.createControl(ParameterAware.class);
- ParameterAware mock = (ParameterAware) control.getMock();
+ IMocksControl control = createControl();
+ ParameterAware mock = (ParameterAware) control.createMock(ParameterAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -92,7 +95,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().setParameters(param);
mock.setParameters((Map)param);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -100,8 +103,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testSessionAware() throws Exception {
- MockControl control = MockControl.createControl(SessionAware.class);
- SessionAware mock = (SessionAware) control.getMock();
+ IMocksControl control = createControl();
+ SessionAware mock = (SessionAware) control.createMock(SessionAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -109,7 +112,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mai.getInvocationContext().setSession(session);
mock.setSession(session);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -117,16 +120,16 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testApplicationAware() throws Exception {
- MockControl control = MockControl.createControl(ApplicationAware.class);
- ApplicationAware mock = (ApplicationAware) control.getMock();
+ IMocksControl control = createControl();
+ ApplicationAware mock = (ApplicationAware) control.createMock(ApplicationAware.class);
MockActionInvocation mai = createActionInvocation(mock);
Map<String, Object> app = new HashMap<String, Object>();
mai.getInvocationContext().setApplication(app);
-
+
mock.setApplication(app);
- control.setVoidCallable();
+ expectLastCall().times(1);
control.replay();
interceptor.intercept(mai);
@@ -137,9 +140,8 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
MockHttpServletRequest req = new MockHttpServletRequest();
req.setUserPrincipal(null);
req.setRemoteUser("Santa");
- MockControl control = MockControl.createControl(PrincipalAware.class);
- control.setDefaultMatcher(MockControl.ALWAYS_MATCHER); // less strick match is needed for this unit test to be conducted using mocks
- PrincipalAware mock = (PrincipalAware) control.getMock();
+ IMocksControl control = createControl();
+ PrincipalAware mock = (PrincipalAware) control.createMock(PrincipalAware.class);
MockActionInvocation mai = createActionInvocation(mock);
mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
@@ -147,9 +149,9 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
MockServletContext ctx = new MockServletContext();
mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
- mock.setPrincipalProxy(null); // we can do this because of ALWAYS_MATCHER
- control.setVoidCallable();
-
+ mock.setPrincipalProxy(anyObject(ServletPrincipalProxy.class)); // less strick match is needed for this unit test to be conducted using mocks
+ expectLastCall().times(1);
+
control.replay();
interceptor.intercept(mai);
control.verify();
@@ -178,17 +180,17 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testServletContextAware() throws Exception {
- MockControl control = MockControl.createControl(ServletContextAware.class);
- ServletContextAware mock = (ServletContextAware) control.getMock();
+ IMocksControl control = createControl();
+ ServletContextAware mock = (ServletContextAware) control.createMock(ServletContextAware.class);
MockActionInvocation mai = createActionInvocation(mock);
MockServletContext ctx = new MockServletContext();
mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
-
+
mock.setServletContext((ServletContext) ctx);
- control.setVoidCallable();
-
+ expectLastCall().times(1);
+
control.replay();
interceptor.intercept(mai);
control.verify();
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
index 1bb9ab5..93e7133 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
@@ -21,11 +21,16 @@
package org.apache.struts2.views.jsp;
+import static org.easymock.EasyMock.*;
+
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import org.apache.struts2.StrutsException;
import org.apache.struts2.components.Include;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import org.easymock.MockType;
import com.mockobjects.servlet.MockRequestDispatcher;
@@ -35,7 +40,7 @@ import com.mockobjects.servlet.MockRequestDispatcher;
*/
public class IncludeTagTest extends AbstractTagTest {
- private MockControl controlRequestDispatcher;
+ private IMocksControl controlRequestDispatcher;
private RequestDispatcher mockRequestDispatcher;
private IncludeTag tag;
@@ -51,22 +56,29 @@ public class IncludeTagTest extends AbstractTagTest {
}
public void testIncludeNoParam() throws Exception {
- mockRequestDispatcher.include(null, null);
- controlRequestDispatcher.setVoidCallable();
+
+ // use always matcher as we can not determine the excact objects used in mock.include(request, response) call
+ mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
+ expectLastCall().times(1);
+
controlRequestDispatcher.replay();
tag.setValue("person/list.jsp");
tag.doStartTag();
tag.doEndTag();
-
- controlRequestDispatcher.verify();
+
assertEquals("/person/list.jsp", request.getRequestDispatherString());
assertEquals("", writer.toString());
+
+ controlRequestDispatcher.verify();
}
public void testIncludeWithParameters() throws Exception {
- mockRequestDispatcher.include(null, null);
- controlRequestDispatcher.setVoidCallable();
+
+ // use always matcher as we can not determine the excact objects used in mock.include(request, response) call
+ mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
+ expectLastCall().times(1);
+
controlRequestDispatcher.replay();
tag.setValue("person/create.jsp");
@@ -76,15 +88,18 @@ public class IncludeTagTest extends AbstractTagTest {
include.addParameter("user", "Santa Claus");
tag.doEndTag();
- controlRequestDispatcher.verify();
assertEquals("/person/create.jsp?user=Santa+Claus", request.getRequestDispatherString());
assertEquals("", writer.toString());
+
+ controlRequestDispatcher.verify();
}
public void testIncludeRelative2Dots() throws Exception {
// TODO: we should test for .. in unit test - is this test correct?
- mockRequestDispatcher.include(null, null);
- controlRequestDispatcher.setVoidCallable();
+ // use always matcher as we can not determine the exact objects used in mock.include(request, response) call
+ mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
+ expectLastCall().times(1);
+
controlRequestDispatcher.replay();
request.setupGetServletPath("app/manager");
@@ -92,9 +107,11 @@ public class IncludeTagTest extends AbstractTagTest {
tag.doStartTag();
tag.doEndTag();
- controlRequestDispatcher.verify();
+
assertEquals("/car/view.jsp", request.getRequestDispatherString());
assertEquals("", writer.toString());
+
+ controlRequestDispatcher.verify();
}
protected void setUp() throws Exception {
@@ -102,10 +119,10 @@ public class IncludeTagTest extends AbstractTagTest {
request.setupGetRequestDispatcher(new MockRequestDispatcher());
tag = new IncludeTag();
- controlRequestDispatcher = MockControl.createNiceControl(RequestDispatcher.class);
- // use always matcher as we can not determine the excact objects used in mock.include(request, response) call
- controlRequestDispatcher.setDefaultMatcher(MockControl.ALWAYS_MATCHER);
- mockRequestDispatcher = (RequestDispatcher) controlRequestDispatcher.getMock();
+ controlRequestDispatcher = createControl(MockType.NICE);
+
+
+ mockRequestDispatcher = (RequestDispatcher) controlRequestDispatcher.createMock(RequestDispatcher.class);
request.setupGetRequestDispatcher(mockRequestDispatcher);
tag.setPageContext(pageContext);
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java b/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
index f0b082e..1dfe674 100644
--- a/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
+++ b/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
@@ -28,24 +28,25 @@ import javax.servlet.http.HttpServletRequest;
import junit.framework.TestCase;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
+import static org.easymock.EasyMock.*;
public class ResourceUtilTest extends TestCase {
- private MockControl control;
+ private IMocksControl control;
private HttpServletRequest requestMock;
public void testGetResourceBase() throws Exception {
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/");
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/");
+ expect(requestMock.getServletPath()).andReturn("/mycontext/");
+ expect(requestMock.getRequestURI()).andReturn("/mycontext/");
control.replay();
assertEquals("/mycontext", ResourceUtil.getResourceBase(requestMock));
control.verify();
control.reset();
- control.expectAndReturn(requestMock.getServletPath(), "/mycontext/test.jsp");
- control.expectAndReturn(requestMock.getRequestURI(), "/mycontext/test.jsp");
+ expect(requestMock.getServletPath()).andReturn("/mycontext/test.jsp");
+ expect(requestMock.getRequestURI()).andReturn("/mycontext/test.jsp");
control.replay();
assertEquals("/mycontext", ResourceUtil.getResourceBase(requestMock));
@@ -55,7 +56,7 @@ public class ResourceUtilTest extends TestCase {
protected void setUp() {
- control = MockControl.createControl(HttpServletRequest.class);
- requestMock = (HttpServletRequest) control.getMock();
+ control = createControl();
+ requestMock = (HttpServletRequest) control.createMock(HttpServletRequest.class);
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/plugins/convention/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/convention/pom.xml b/plugins/convention/pom.xml
index 79211ea..a7c6d63 100644
--- a/plugins/convention/pom.xml
+++ b/plugins/convention/pom.xml
@@ -38,11 +38,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/plugins/convention/src/test/java/org/apache/struts2/convention/ConventionUnknownHandlerTest.java
----------------------------------------------------------------------
diff --git a/plugins/convention/src/test/java/org/apache/struts2/convention/ConventionUnknownHandlerTest.java b/plugins/convention/src/test/java/org/apache/struts2/convention/ConventionUnknownHandlerTest.java
index ad40e59..1522d0d 100644
--- a/plugins/convention/src/test/java/org/apache/struts2/convention/ConventionUnknownHandlerTest.java
+++ b/plugins/convention/src/test/java/org/apache/struts2/convention/ConventionUnknownHandlerTest.java
@@ -28,7 +28,6 @@ import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
import com.opensymphony.xwork2.inject.Container;
import junit.framework.TestCase;
import org.apache.struts2.result.ServletDispatcherResult;
-import org.easymock.EasyMock;
import javax.servlet.ServletContext;
import java.net.URL;
@@ -37,8 +36,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.classextension.EasyMock.*;
+import static org.easymock.EasyMock.*;
public class ConventionUnknownHandlerTest extends TestCase {
@@ -150,7 +148,7 @@ public class ConventionUnknownHandlerTest extends TestCase {
private Container container() {
final Container mock = createNiceMock(Container.class);
- ConventionsService service = EasyMock.createNiceMock(ConventionsService.class);
+ ConventionsService service = createNiceMock(ConventionsService.class);
expect(mock.getInstance(String.class, ConventionConstants.CONVENTION_CONVENTIONS_SERVICE)).andReturn("test");
expect(mock.getInstance(ConventionsService.class, "test")).andStubReturn(service);
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/plugins/javatemplates/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/javatemplates/pom.xml b/plugins/javatemplates/pom.xml
index cfc15aa..a4a274b 100644
--- a/plugins/javatemplates/pom.xml
+++ b/plugins/javatemplates/pom.xml
@@ -42,11 +42,7 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <scope>test</scope>
- </dependency>
+
</dependencies>
<properties>
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java
----------------------------------------------------------------------
diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java
index 23064b1..7dd36c9 100644
--- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java
+++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AbstractTest.java
@@ -34,7 +34,7 @@ import org.apache.struts2.components.Component;
import org.apache.struts2.components.UIBean;
import org.apache.struts2.components.template.Template;
import org.apache.struts2.components.template.TemplateRenderingContext;
-import org.easymock.EasyMock;
+import static org.easymock.EasyMock.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -91,32 +91,32 @@ public abstract class AbstractTest extends TestCase {
writer = new StringWriter();
map = new HashMap();
- template = org.easymock.classextension.EasyMock.createMock(Template.class);
- stack = EasyMock.createNiceMock(ValueStack.class);
+ template = createMock(Template.class);
+ stack = createNiceMock(ValueStack.class);
setUpStack();
stackContext = new HashMap();
context = new TemplateRenderingContext(template, writer, stack, map, null);
stackContext.put(Component.COMPONENT_STACK, new Stack());
- request = EasyMock.createNiceMock(HttpServletRequest.class);
- EasyMock.expect(request.getContextPath()).andReturn("/some/path").anyTimes();
- response = EasyMock.createNiceMock(HttpServletResponse.class);
+ request = createNiceMock(HttpServletRequest.class);
+ expect(request.getContextPath()).andReturn("/some/path").anyTimes();
+ response = createNiceMock(HttpServletResponse.class);
- EasyMock.expect(stack.getContext()).andReturn(stackContext).anyTimes();
+ expect(stack.getContext()).andReturn(stackContext).anyTimes();
- Container container = EasyMock.createNiceMock(Container.class);
+ Container container = createNiceMock(Container.class);
XWorkConverter converter = new ConverterEx();
- EasyMock.expect(container.getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX)).andReturn("true").anyTimes();
- EasyMock.expect(container.getInstance(XWorkConverter.class)).andReturn(converter).anyTimes();
+ expect(container.getInstance(String.class, StrutsConstants.STRUTS_TAG_ALTSYNTAX)).andReturn("true").anyTimes();
+ expect(container.getInstance(XWorkConverter.class)).andReturn(converter).anyTimes();
TextParser parser = new OgnlTextParser();
- EasyMock.expect(container.getInstance(TextParser.class)).andReturn(parser).anyTimes();
+ expect(container.getInstance(TextParser.class)).andReturn(parser).anyTimes();
stackContext.put(ActionContext.CONTAINER, container);
- EasyMock.replay(request);
- EasyMock.replay(stack);
- EasyMock.replay(container);
+ replay(request);
+ replay(stack);
+ replay(container);
ActionContext.setContext(new ActionContext(stackContext));
ServletActionContext.setRequest(request);
@@ -127,13 +127,13 @@ public abstract class AbstractTest extends TestCase {
}
protected void expectFind(String expr, Class toClass, Object returnVal) {
- EasyMock.expect(stack.findValue(expr, toClass)).andReturn(returnVal);
- EasyMock.expect(stack.findValue(expr, toClass, false)).andReturn(returnVal);
+ expect(stack.findValue(expr, toClass)).andReturn(returnVal);
+ expect(stack.findValue(expr, toClass, false)).andReturn(returnVal);
}
protected void expectFind(String expr, Object returnVal) {
- EasyMock.expect(stack.findValue(expr)).andReturn(returnVal).anyTimes();
- EasyMock.expect(stack.findValue(expr, false)).andReturn(returnVal).anyTimes();
+ expect(stack.findValue(expr)).andReturn(returnVal).anyTimes();
+ expect(stack.findValue(expr, false)).andReturn(returnVal).anyTimes();
}
protected void setUpStack() {
http://git-wip-us.apache.org/repos/asf/struts/blob/20e13f16/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 08c94b4..8cccc87 100644
--- a/pom.xml
+++ b/pom.xml
@@ -578,14 +578,7 @@
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>2.4</version>
+ <version>3.4</version>
<scope>test</scope>
</dependency>
[10/10] struts git commit: WW-4593 Upgrades easy-mock
Posted by lu...@apache.org.
WW-4593 Upgrades easy-mock
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/754c8a24
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/754c8a24
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/754c8a24
Branch: refs/heads/master
Commit: 754c8a247a5a773762cf6b93e7669f8541a4df7b
Parents: 5bcdd3d 3df363e
Author: Lukasz Lenart <lu...@apache.org>
Authored: Fri Mar 4 07:09:53 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Fri Mar 4 07:09:53 2016 +0100
----------------------------------------------------------------------
.../xwork2/config/providers/XmlHelperTest.java | 234 +++++++------------
.../ParameterRemoverInterceptorTest.java | 24 +-
.../PrefixMethodInvocationUtilTest.java | 135 +++++------
.../interceptor/PrepareInterceptorTest.java | 83 +++----
.../org/apache/struts2/RequestUtilsTest.java | 66 +++---
.../interceptor/CookieInterceptorTest.java | 97 ++++----
.../ServletConfigInterceptorTest.java | 78 +++----
.../struts2/views/jsp/IncludeTagTest.java | 50 ++--
.../struts2/views/util/ResourceUtilTest.java | 24 +-
plugins/convention/pom.xml | 5 -
.../ConventionUnknownHandlerTest.java | 6 +-
plugins/javatemplates/pom.xml | 6 +-
.../struts2/views/java/simple/AbstractTest.java | 36 +--
pom.xml | 9 +-
14 files changed, 361 insertions(+), 492 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/754c8a24/pom.xml
----------------------------------------------------------------------
[04/10] struts git commit: WW-4593: Easymock upgrade to 3.4
Posted by lu...@apache.org.
WW-4593: Easymock upgrade to 3.4
Task-Url: https://issues.apache.org/jira/browse/WW-4593
Simplify code on new easymock version
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/20e9d13b
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/20e9d13b
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/20e9d13b
Branch: refs/heads/master
Commit: 20e9d13b179a54a88fe60026e2578e501c87bd2e
Parents: 35aacc7
Author: victorsosa <vi...@peopleware.do>
Authored: Tue Jan 26 09:28:44 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Tue Jan 26 09:28:44 2016 -0400
----------------------------------------------------------------------
.../xwork2/config/providers/XmlHelperTest.java | 112 +++++--------------
.../ParameterRemoverInterceptorTest.java | 17 ++-
.../PrefixMethodInvocationUtilTest.java | 67 ++++-------
.../interceptor/PrepareInterceptorTest.java | 34 ++----
.../org/apache/struts2/RequestUtilsTest.java | 25 ++---
.../interceptor/CookieInterceptorTest.java | 51 ++++-----
.../ServletConfigInterceptorTest.java | 50 ++++-----
.../struts2/views/jsp/IncludeTagTest.java | 21 ++--
.../struts2/views/util/ResourceUtilTest.java | 15 +--
9 files changed, 134 insertions(+), 258 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
index 73f8e51..6a4ef52 100644
--- a/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/XmlHelperTest.java
@@ -1,7 +1,6 @@
package com.opensymphony.xwork2.config.providers;
import com.opensymphony.xwork2.XWorkTestCase;
-import org.easymock.IMocksControl;
import static org.easymock.EasyMock.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -19,83 +18,69 @@ public class XmlHelperTest extends XWorkTestCase {
public void testGetContent1() throws Exception {
// set up Node
- IMocksControl nodeControl = createControl();
- Node mockNode = (Node) nodeControl.createMock(Node.class);
+ Node mockNode = (Node) createMock(Node.class);
expect(mockNode.getNodeValue()).andStubReturn("testing testing 123");
expect(mockNode.getNodeType()).andStubReturn(Node.TEXT_NODE);
// set up NodeList
- IMocksControl nodeListControl = createControl();
- NodeList mockNodeList = (NodeList) nodeListControl.createMock(NodeList.class);
+ NodeList mockNodeList = (NodeList) createMock(NodeList.class);
expect(mockNodeList.getLength()).andStubReturn(1);
expect(mockNodeList.item(0)).andStubReturn(mockNode);
// set up Element
- IMocksControl elementControl = createControl();
- Element mockElement = (Element) elementControl.createMock(Element.class);
+ Element mockElement = (Element) createMock(Element.class);
expect(mockElement.getChildNodes()).andStubReturn(mockNodeList);
- nodeControl.replay();
- nodeListControl.replay();
- elementControl.replay();
+ replay(mockNode, mockNodeList, mockElement);
String result = XmlHelper.getContent(mockElement);
assertEquals(result, "testing testing 123");
- nodeControl.verify();
- nodeListControl.verify();
- elementControl.verify();
+ verify(mockNode, mockNodeList, mockElement);
}
public void testGetContent2() throws Exception {
// set up Node
- IMocksControl nodeControl1 = createControl();
- Node mockNode1 = (Node) nodeControl1.createMock(Node.class);
+ Node mockNode1 = (Node) createMock(Node.class);
expect(mockNode1.getNodeValue()).andStubReturn("testing testing 123");
expect(mockNode1.getNodeType()).andStubReturn(Node.TEXT_NODE);
- IMocksControl nodeControl2 = createControl();
- Node mockNode2 = (Node) nodeControl2.createMock(Node.class);
+ Node mockNode2 = (Node) createMock(Node.class);
expect(mockNode2.getNodeValue()).andStubReturn("comment 1");
expect(mockNode2.getNodeType()).andStubReturn(Node.COMMENT_NODE);
- IMocksControl nodeControl3 = createControl();
- Node mockNode3 = (Node) nodeControl3.createMock(Node.class);
+ Node mockNode3 = (Node) createMock(Node.class);
expect(mockNode3.getNodeValue()).andStubReturn(" tmjee ");
expect(mockNode3.getNodeType()).andStubReturn(Node.TEXT_NODE);
- IMocksControl nodeControl4 = createControl();
- Node mockNode4 = (Node) nodeControl4.createMock(Node.class);
+ Node mockNode4 = (Node) createMock(Node.class);
expect(mockNode4.getNodeValue()).andStubReturn(" phil ");
expect(mockNode4.getNodeType()).andStubReturn(Node.TEXT_NODE);
- IMocksControl nodeControl5 = createControl();
- Node mockNode5 = (Node) nodeControl5.createMock(Node.class);
+ Node mockNode5 = (Node) createMock(Node.class);
expect(mockNode5.getNodeValue()).andStubReturn("comment 2");
expect(mockNode5.getNodeType()).andStubReturn(Node.COMMENT_NODE);
- IMocksControl nodeControl6 = createControl();
- Node mockNode6 = (Node) nodeControl6.createMock(Node.class);
+ Node mockNode6 = (Node) createMock(Node.class);
expect(mockNode6.getNodeValue()).andStubReturn("comment 3");
expect(mockNode6.getNodeType()).andStubReturn(Node.COMMENT_NODE);
// set up NodeList
- IMocksControl nodeListControl = createControl();
- NodeList mockNodeList = (NodeList) nodeListControl.createMock(NodeList.class);
+ NodeList mockNodeList = (NodeList) createMock(NodeList.class);
expect(mockNodeList.getLength()).andStubReturn(6);
@@ -107,53 +92,37 @@ public class XmlHelperTest extends XWorkTestCase {
expect(mockNodeList.item(5)).andStubReturn(mockNode6);
// set up Element
- IMocksControl elementControl = createControl();
- Element mockElement = (Element) elementControl.createMock(Element.class);
+ Element mockElement = (Element) createMock(Element.class);
expect(mockElement.getChildNodes()).andStubReturn(mockNodeList);
- nodeControl1.replay();
- nodeControl2.replay();
- nodeControl3.replay();
- nodeControl4.replay();
- nodeControl5.replay();
- nodeControl6.replay();
- nodeListControl.replay();
- elementControl.replay();
+ replay(mockNode1, mockNode2, mockNode3, mockNode4, mockNode5, mockNode6, mockNodeList, mockElement);
+
String result = XmlHelper.getContent(mockElement);
assertEquals(result, "testing testing 123tmjeephil");
- nodeControl1.verify();
- nodeControl2.verify();
- nodeControl3.verify();
- nodeControl4.verify();
- nodeControl5.verify();
- nodeControl6.verify();
- nodeListControl.verify();
- elementControl.verify();
+ verify(mockNode1, mockNode2, mockNode3, mockNode4, mockNode5, mockNode6, mockNodeList, mockElement);
+
}
public void testGetParams() throws Exception {
// <param name="param1">value1</param>
- IMocksControl nodeControl1 = createControl();
- Node mockNode1 = (Node) nodeControl1.createMock(Node.class);
+ Node mockNode1 = (Node) createMock(Node.class);
expect(mockNode1.getNodeValue()).andStubReturn("value1");
expect(mockNode1.getNodeType()).andStubReturn(Node.TEXT_NODE);
- IMocksControl nodeListControl1 = createControl();
- NodeList mockNodeList1 = (NodeList) nodeListControl1.createMock(NodeList.class);
+ NodeList mockNodeList1 = (NodeList) createMock(NodeList.class);
expect(mockNodeList1.getLength()).andStubReturn(1);
expect(mockNodeList1.item(0)).andStubReturn(mockNode1);
- IMocksControl paramControl1 = createControl();
- Element mockParamElement1 = (Element) paramControl1.createMock(Element.class);
+ Element mockParamElement1 = (Element) createMock(Element.class);
expect(mockParamElement1.getNodeName()).andStubReturn("param");
expect(mockParamElement1.getNodeType()).andStubReturn(Node.ELEMENT_NODE);
@@ -162,26 +131,22 @@ public class XmlHelperTest extends XWorkTestCase {
expect(mockParamElement1.getChildNodes()).andStubReturn(mockNodeList1);
- nodeControl1.replay();
- nodeListControl1.replay();
- paramControl1.replay();
+ replay(mockNode1, mockNodeList1, mockParamElement1);
+
// <param name="param2">value2</param>
- IMocksControl nodeControl2 = createControl();
- Node mockNode2 = (Node) nodeControl2.createMock(Node.class);
+ Node mockNode2 = (Node) createMock(Node.class);
expect(mockNode2.getNodeValue()).andStubReturn("value2");
expect(mockNode2.getNodeType()).andStubReturn(Node.TEXT_NODE);
- IMocksControl nodeListControl2 = createControl();
- NodeList mockNodeList2 = (NodeList) nodeListControl2.createMock(NodeList.class);
+ NodeList mockNodeList2 = (NodeList) createMock(NodeList.class);
expect(mockNodeList2.getLength()).andStubReturn(1);
expect(mockNodeList2.item(0)).andStubReturn(mockNode2);
- IMocksControl paramControl2 = createControl();
- Element mockParamElement2 = (Element) paramControl2.createMock(Element.class);
+ Element mockParamElement2 = (Element) createMock(Element.class);
expect(mockParamElement2.getNodeName()).andStubReturn("param");
expect(mockParamElement2.getNodeType()).andStubReturn(Node.ELEMENT_NODE);
@@ -189,30 +154,24 @@ public class XmlHelperTest extends XWorkTestCase {
expect(mockParamElement2.getAttribute("name")).andStubReturn("param2");
expect(mockParamElement2.getChildNodes()).andStubReturn(mockNodeList2);
- nodeControl2.replay();
- nodeListControl2.replay();
- paramControl2.replay();
+ replay(mockNode2, mockNodeList2, mockParamElement2);
// <some_element>
// ...
// </some_element>
- IMocksControl elementNodeListControl = createControl();
- NodeList mockElementNodeList = (NodeList) elementNodeListControl.createMock(NodeList.class);
+ NodeList mockElementNodeList = (NodeList) createMock(NodeList.class);
expect(mockElementNodeList.getLength()).andStubReturn(2);
expect(mockElementNodeList.item(0)).andStubReturn(mockParamElement2);
expect(mockElementNodeList.item(1)).andStubReturn(mockParamElement1);
- IMocksControl elementControl = createControl();
- Element element = (Element) elementControl.createMock(Element.class);
+ Element element = (Element) createMock(Element.class);
expect(element.getChildNodes()).andStubReturn(mockElementNodeList);
-
- elementNodeListControl.replay();
- elementControl.replay();
+ replay(mockElementNodeList, element);
Map params = XmlHelper.getParams(element);
@@ -221,17 +180,6 @@ public class XmlHelperTest extends XWorkTestCase {
assertEquals(params.get("param1"), "value1");
assertEquals(params.get("param2"), "value2");
- nodeControl1.verify();
- nodeListControl1.verify();
- paramControl1.verify();
-
-
- nodeControl2.verify();
- nodeListControl2.verify();
- paramControl2.verify();
-
-
- elementNodeListControl.verify();
- elementControl.verify();
+ verify(mockNode1, mockNodeList1, mockParamElement1, mockNode2, mockNodeList2, mockParamElement2, mockElementNodeList, element);
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
index 95b8b20..720ef93 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java
@@ -4,7 +4,6 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import junit.framework.TestCase;
-import org.easymock.IMocksControl;
import static org.easymock.EasyMock.*;
import java.util.LinkedHashMap;
@@ -18,7 +17,6 @@ public class ParameterRemoverInterceptorTest extends TestCase {
protected Map<String, Object> contextMap;
protected ActionContext context;
- protected IMocksControl actionInvocationControl;
protected ActionInvocation actionInvocation;
@Override
@@ -26,8 +24,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
contextMap = new LinkedHashMap<>();
context = new ActionContext(contextMap);
- actionInvocationControl = createControl();
- actionInvocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ actionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(actionInvocation.getAction()).andStubReturn(new SampleAction());
expect(actionInvocation.getInvocationContext()).andStubReturn(context);
expect(actionInvocation.invoke()).andStubReturn("success");
@@ -44,7 +41,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
}
});
- actionInvocationControl.replay();
+ replay(actionInvocation);
ParameterRemoverInterceptor interceptor = new ParameterRemoverInterceptor();
interceptor.setParamNames("param1,param2");
@@ -58,7 +55,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
assertEquals(((String[])params.get("param3"))[0], "paramValue3");
assertEquals(((String[])params.get("param"))[0], "paramValue");
- actionInvocationControl.verify();
+ verify(actionInvocation);
}
@@ -71,7 +68,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
}
});
- actionInvocationControl.replay();
+ replay(actionInvocation);
ParameterRemoverInterceptor interceptor = new ParameterRemoverInterceptor();
interceptor.setParamNames("param1,param2");
@@ -81,7 +78,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
Map params = (Map) contextMap.get(ActionContext.PARAMETERS);
assertEquals(params.size(), 0);
- actionInvocationControl.verify();
+ verify(actionInvocation);
}
@@ -94,7 +91,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
}
});
- actionInvocationControl.replay();
+ replay(actionInvocation);
ParameterRemoverInterceptor interceptor = new ParameterRemoverInterceptor();
interceptor.setParamNames("param1,param2");
@@ -108,7 +105,7 @@ public class ParameterRemoverInterceptorTest extends TestCase {
assertEquals(((String[])params.get("param1"))[0], "paramValueOne");
assertEquals(((String[])params.get("param2"))[0], "paramValueTwo");
- actionInvocationControl.verify();
+ verify(actionInvocation);
}
class SampleAction extends ActionSupport {
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
index d91fb6f..06cd534 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtilTest.java
@@ -18,7 +18,6 @@ package com.opensymphony.xwork2.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import junit.framework.TestCase;
-import org.easymock.IMocksControl;
import static org.easymock.EasyMock.*;
import java.lang.reflect.Method;
@@ -84,21 +83,18 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- IMocksControl controlActionProxy = createControl();
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("save");
// ActionInvocation
- IMocksControl controlActionInvocation = createControl();
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(action);
expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
- controlActionProxy.replay();
- controlActionInvocation.replay();
+ replay(mockActionProxy, mockActionInvocation);
PrefixMethodInvocationUtil.invokePrefixMethod(
@@ -110,29 +106,24 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
- controlActionProxy.verify();
- controlActionInvocation.verify();
+ verify(mockActionProxy, mockActionInvocation);
}
public void testInvokePrefixMethod2() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- IMocksControl controlActionProxy = createControl();
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("submit");
// ActionInvocation
- IMocksControl controlActionInvocation = createControl();
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(action);
expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
- controlActionProxy.replay();
- controlActionInvocation.replay();
-
+ replay(mockActionProxy, mockActionInvocation);
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
@@ -144,29 +135,24 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
assertTrue(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
- controlActionProxy.verify();
- controlActionInvocation.verify();
+ verify(mockActionProxy, mockActionInvocation);
}
public void testInvokePrefixMethod3() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- IMocksControl controlActionProxy = createControl();
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("cancel");
// ActionInvocation
- IMocksControl controlActionInvocation = createControl();
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(action);
expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
- controlActionProxy.replay();
- controlActionInvocation.replay();
-
+ replay(mockActionProxy, mockActionInvocation);
PrefixMethodInvocationUtil.invokePrefixMethod(
mockActionInvocation,
@@ -177,30 +163,26 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
assertFalse(action.prepareDoSaveInvoked);
assertFalse(action.prepareSubmitInvoked);
assertTrue(action.prepareDoCancelInvoked);
-
- controlActionProxy.verify();
- controlActionInvocation.verify();
+
+ verify(mockActionProxy, mockActionInvocation);
}
public void testInvokePrefixMethod4() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- IMocksControl controlActionProxy = createControl();
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("noSuchMethod");
// ActionInvocation
- IMocksControl controlActionInvocation = createControl();
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(action);
expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
- controlActionProxy.replay();
- controlActionInvocation.replay();
+ replay(mockActionProxy, mockActionInvocation);
PrefixMethodInvocationUtil.invokePrefixMethod(
@@ -212,29 +194,25 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
- controlActionProxy.verify();
- controlActionInvocation.verify();
+ verify(mockActionProxy, mockActionInvocation);
}
public void testInvokePrefixMethod5() throws Exception {
PrefixMethodInvocationUtilTest.Action1 action = new PrefixMethodInvocationUtilTest.Action1();
// ActionProxy
- IMocksControl controlActionProxy = createControl();
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("save");
// ActionInvocation
- IMocksControl controlActionInvocation = createControl();
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(action);
expect(mockActionInvocation.getProxy()).andStubReturn(mockActionProxy);
-
- controlActionProxy.replay();
- controlActionInvocation.replay();
+
+ replay(mockActionProxy, mockActionInvocation);
PrefixMethodInvocationUtil.invokePrefixMethod(
@@ -246,8 +224,7 @@ public class PrefixMethodInvocationUtilTest extends TestCase {
assertFalse(action.prepareSubmitInvoked);
assertFalse(action.prepareDoCancelInvoked);
- controlActionProxy.verify();
- controlActionInvocation.verify();
+ verify(mockActionProxy, mockActionInvocation);
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
index 11db72a..1d5c8c3 100644
--- a/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java
@@ -21,7 +21,6 @@ import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import com.opensymphony.xwork2.mock.MockActionProxy;
import junit.framework.TestCase;
-import org.easymock.IMocksControl;
import static org.easymock.EasyMock.*;
@@ -36,7 +35,6 @@ public class PrepareInterceptorTest extends TestCase {
private Mock mock;
private PrepareInterceptor interceptor;
- IMocksControl controlAction;
ActionInterface mockAction;
public void testPrepareCalledDefault() throws Exception {
@@ -110,14 +108,12 @@ public class PrepareInterceptorTest extends TestCase {
- IMocksControl controlActionProxy = createControl();
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("submit");
- IMocksControl controlActionInvocation = createControl();
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(mockAction);
expect(mockActionInvocation.invoke()).andStubReturn("okok");
@@ -128,31 +124,25 @@ public class PrepareInterceptorTest extends TestCase {
mockAction.prepare();
expectLastCall().times(1);
- controlAction.replay();
- controlActionProxy.replay();
- controlActionInvocation.replay();
+ replay(mockAction, mockActionProxy, mockActionInvocation);
PrepareInterceptor interceptor = new PrepareInterceptor();
String result = interceptor.intercept(mockActionInvocation);
assertEquals("okok", result);
- controlAction.verify();
- controlActionProxy.verify();
- controlActionInvocation.verify();
+ verify(mockAction, mockActionProxy, mockActionInvocation);
}
public void testPrefixInvocation2() throws Exception {
- IMocksControl controlActionProxy = createControl();
- ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
+ ActionProxy mockActionProxy = (ActionProxy) createMock(ActionProxy.class);
expect(mockActionProxy.getMethod()).andStubReturn("save");
- IMocksControl controlActionInvocation = createControl();
- ActionInvocation mockActionInvocation = (ActionInvocation) controlActionInvocation.createMock(ActionInvocation.class);
+ ActionInvocation mockActionInvocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(mockActionInvocation.getAction()).andStubReturn(mockAction);
expect(mockActionInvocation.invoke()).andStubReturn("okok");
@@ -161,18 +151,14 @@ public class PrepareInterceptorTest extends TestCase {
mockAction.prepare();
expectLastCall().times(1);
- controlAction.replay();
- controlActionProxy.replay();
- controlActionInvocation.replay();
+ replay(mockAction, mockActionProxy, mockActionInvocation);
PrepareInterceptor interceptor = new PrepareInterceptor();
String result = interceptor.intercept(mockActionInvocation);
assertEquals("okok", result);
- controlAction.verify();
- controlActionProxy.verify();
- controlActionInvocation.verify();
+ verify(mockAction, mockActionProxy, mockActionInvocation);
}
@@ -199,14 +185,12 @@ public class PrepareInterceptorTest extends TestCase {
protected void setUp() throws Exception {
mock = new Mock(ActionInterface.class);
interceptor = new PrepareInterceptor();
- controlAction = createControl();
- mockAction = (ActionInterface) controlAction.createMock(ActionInterface.class);
+ mockAction = (ActionInterface) createMock(ActionInterface.class);
}
@Override
protected void tearDown() throws Exception {
- controlAction = null;
mockAction = null;
mock.verify();
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/RequestUtilsTest.java b/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
index 78e125c..54a9994 100644
--- a/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
+++ b/core/src/test/java/org/apache/struts2/RequestUtilsTest.java
@@ -26,7 +26,6 @@ package org.apache.struts2;
*
*/
import junit.framework.TestCase;
-import org.easymock.IMocksControl;
import static org.easymock.EasyMock.*;
import javax.servlet.http.HttpServletRequest;
@@ -34,15 +33,14 @@ import java.util.Date;
public class RequestUtilsTest extends TestCase {
- private IMocksControl control;
private HttpServletRequest requestMock;
public void testGetServletPathWithServletPathSet() throws Exception {
expect(requestMock.getServletPath()).andStubReturn("/mycontext/");
expect(requestMock.getRequestURI()).andStubReturn("/mycontext/");
- control.replay();
+ replay(requestMock);
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
- control.verify();
+ verify(requestMock);
}
public void testGetServletPathWithRequestURIAndEmptyContextPath() throws Exception {
@@ -51,9 +49,9 @@ public class RequestUtilsTest extends TestCase {
expect(requestMock.getContextPath()).andStubReturn("");
expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
- control.replay();
+ replay(requestMock);
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
- control.verify();
+ verify(requestMock);
}
public void testGetServletPathWithRequestURIAndContextPathSet() throws Exception {
@@ -63,9 +61,9 @@ public class RequestUtilsTest extends TestCase {
expect(requestMock.getContextPath()).andStubReturn("/servlet");
expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
expect(requestMock.getPathInfo()).andStubReturn("test.jsp");
- control.replay();
+ replay(requestMock);
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
- control.verify();
+ verify(requestMock);
}
public void testGetServletPathWithRequestURIAndContextPathSetButNoPatchInfo() throws Exception {
@@ -74,17 +72,17 @@ public class RequestUtilsTest extends TestCase {
expect(requestMock.getContextPath()).andStubReturn("/servlet");
expect(requestMock.getContextPath()).andStubReturn("/servlet");
expect(requestMock.getPathInfo()).andStubReturn(null);
- control.replay();
+ replay(requestMock);
assertEquals("/mycontext/", RequestUtils.getServletPath(requestMock));
- control.verify();
+ verify(requestMock);
}
public void testGetServletPathWithSemicolon() throws Exception {
expect(requestMock.getRequestURI()).andStubReturn("/friend/mycontext/jim;bob");
expect(requestMock.getServletPath()).andStubReturn("/mycontext/jim");
- control.replay();
+ replay(requestMock);
assertEquals("/mycontext/jim;bob", RequestUtils.getServletPath(requestMock));
- control.verify();
+ verify(requestMock);
}
public void testParseRFC1123() {
@@ -104,8 +102,7 @@ public class RequestUtilsTest extends TestCase {
protected void setUp() {
- control = createControl();
- requestMock = (HttpServletRequest) control.createMock(HttpServletRequest.class);
+ requestMock = (HttpServletRequest) createMock(HttpServletRequest.class);
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
index 40571bb..cf64288 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/CookieInterceptorTest.java
@@ -34,8 +34,6 @@ import org.springframework.mock.web.MockHttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsInternalTestCase;
-import org.easymock.IMocksControl;
-import org.easymock.MockType;
import static org.easymock.EasyMock.*;
import com.opensymphony.xwork2.Action;
@@ -59,13 +57,12 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- IMocksControl actionInvocationControl = createControl(MockType.DEFAULT);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ ActionInvocation invocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(invocation.getAction()).andReturn(action);
expect(invocation.invoke()).andReturn(Action.SUCCESS);
- actionInvocationControl.replay();
+ replay(invocation);
// by default the interceptor doesn't accept any cookies
CookieInterceptor interceptor = new CookieInterceptor();
@@ -82,7 +79,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertNull(ActionContext.getContext().getValueStack().findValue("cookie2"));
assertNull(ActionContext.getContext().getValueStack().findValue("cookie3"));
- actionInvocationControl.verify();
+ verify(invocation);
}
public void testInterceptAll1() throws Exception {
@@ -98,13 +95,12 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- IMocksControl actionInvocationControl = createControl(MockType.DEFAULT);
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ ActionInvocation invocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(invocation.getAction()).andReturn(action);
expect(invocation.invoke()).andReturn(Action.SUCCESS);
- actionInvocationControl.replay();
+ replay(invocation);
CookieInterceptor interceptor = new CookieInterceptor();
interceptor.setExcludedPatternsChecker(new DefaultExcludedPatternsChecker());
@@ -125,7 +121,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), "cookie2value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
- actionInvocationControl.verify();
+ verify(invocation);
}
@@ -142,12 +138,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- IMocksControl actionInvocationControl = createControl();
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ ActionInvocation invocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(invocation.getAction()).andReturn(action);
expect(invocation.invoke()).andReturn(Action.SUCCESS);
- actionInvocationControl.replay();
+ replay(invocation);
CookieInterceptor interceptor = new CookieInterceptor();
interceptor.setExcludedPatternsChecker(new DefaultExcludedPatternsChecker());
@@ -168,7 +163,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), "cookie2value");
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
- actionInvocationControl.verify();
+ verify(invocation);
}
public void testInterceptSelectedCookiesNameOnly1() throws Exception {
@@ -184,12 +179,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- IMocksControl actionInvocationControl = createControl();
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ ActionInvocation invocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(invocation.getAction()).andReturn(action);
expect(invocation.invoke()).andReturn(Action.SUCCESS);
- actionInvocationControl.replay();
+ replay(invocation);
CookieInterceptor interceptor = new CookieInterceptor();
interceptor.setExcludedPatternsChecker(new DefaultExcludedPatternsChecker());
@@ -210,7 +204,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
- actionInvocationControl.verify();
+ verify(invocation);
}
public void testInterceptSelectedCookiesNameOnly2() throws Exception {
@@ -226,13 +220,12 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- IMocksControl actionInvocationControl = createControl();
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ ActionInvocation invocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(invocation.getAction()).andReturn(action);
expect(invocation.invoke()).andReturn(Action.SUCCESS);
- actionInvocationControl.replay();
+ replay(invocation);
CookieInterceptor interceptor = new CookieInterceptor();
interceptor.setExcludedPatternsChecker(new DefaultExcludedPatternsChecker());
@@ -253,7 +246,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
- actionInvocationControl.verify();
+ verify(invocation);
}
public void testInterceptSelectedCookiesNameOnly3() throws Exception {
@@ -269,12 +262,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- IMocksControl actionInvocationControl = createControl();
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ ActionInvocation invocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(invocation.getAction()).andReturn(action);
expect(invocation.invoke()).andReturn(Action.SUCCESS);
- actionInvocationControl.replay();
+ replay(invocation);
CookieInterceptor interceptor = new CookieInterceptor();
interceptor.setExcludedPatternsChecker(new DefaultExcludedPatternsChecker());
@@ -295,7 +287,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), "cookie3value");
- actionInvocationControl.verify();
+ verify(invocation);
}
@@ -312,12 +304,11 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
ActionContext.getContext().getValueStack().push(action);
- IMocksControl actionInvocationControl = createControl();
- ActionInvocation invocation = (ActionInvocation) actionInvocationControl.createMock(ActionInvocation.class);
+ ActionInvocation invocation = (ActionInvocation) createMock(ActionInvocation.class);
expect(invocation.getAction()).andReturn(action);
expect(invocation.invoke()).andReturn(Action.SUCCESS);
- actionInvocationControl.replay();
+ replay(invocation);
CookieInterceptor interceptor = new CookieInterceptor();
interceptor.setExcludedPatternsChecker(new DefaultExcludedPatternsChecker());
@@ -338,7 +329,7 @@ public class CookieInterceptorTest extends StrutsInternalTestCase {
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie2"), null);
assertEquals(ActionContext.getContext().getValueStack().findValue("cookie3"), null);
- actionInvocationControl.verify();
+ verify(invocation);
}
public void testCookiesWithClassPollution() throws Exception {
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
index 616ad4e..a3b8a7b 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
@@ -33,7 +33,6 @@ import org.apache.struts2.StrutsStatics;
import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy;
import org.apache.struts2.util.ServletContextAware;
-import org.easymock.IMocksControl;
import static org.easymock.EasyMock.*;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -52,8 +51,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
private ServletConfigInterceptor interceptor;
public void testServletRequestAware() throws Exception {
- IMocksControl control = createControl();
- ServletRequestAware mock = (ServletRequestAware) control.createMock(ServletRequestAware.class);
+ ServletRequestAware mock = (ServletRequestAware) createMock(ServletRequestAware.class);
MockHttpServletRequest req = new MockHttpServletRequest();
@@ -63,14 +61,13 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mock.setServletRequest((HttpServletRequest) req);
expectLastCall();
- control.replay();
+ replay(mock);
interceptor.intercept(mai);
- control.verify();
+ verify(mock);
}
public void testServletResponseAware() throws Exception {
- IMocksControl control = createControl();
- ServletResponseAware mock = (ServletResponseAware) control.createMock(ServletResponseAware.class);
+ ServletResponseAware mock = (ServletResponseAware) createMock(ServletResponseAware.class);
MockHttpServletResponse res = new MockHttpServletResponse();
@@ -80,14 +77,13 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mock.setServletResponse((HttpServletResponse) res);
expectLastCall().times(1);
- control.replay();
+ replay(mock);
interceptor.intercept(mai);
- control.verify();
+ verify(mock);
}
public void testParameterAware() throws Exception {
- IMocksControl control = createControl();
- ParameterAware mock = (ParameterAware) control.createMock(ParameterAware.class);
+ ParameterAware mock = (ParameterAware) createMock(ParameterAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -97,14 +93,13 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mock.setParameters((Map)param);
expectLastCall().times(1);
- control.replay();
+ replay(mock);
interceptor.intercept(mai);
- control.verify();
+ verify(mock);
}
public void testSessionAware() throws Exception {
- IMocksControl control = createControl();
- SessionAware mock = (SessionAware) control.createMock(SessionAware.class);
+ SessionAware mock = (SessionAware) createMock(SessionAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -114,14 +109,13 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mock.setSession(session);
expectLastCall().times(1);
- control.replay();
+ replay(mock);
interceptor.intercept(mai);
- control.verify();
+ verify(mock);
}
public void testApplicationAware() throws Exception {
- IMocksControl control = createControl();
- ApplicationAware mock = (ApplicationAware) control.createMock(ApplicationAware.class);
+ ApplicationAware mock = (ApplicationAware) createMock(ApplicationAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -131,17 +125,16 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mock.setApplication(app);
expectLastCall().times(1);
- control.replay();
+ replay(mock);
interceptor.intercept(mai);
- control.verify();
+ verify(mock);
}
public void testPrincipalAware() throws Exception {
MockHttpServletRequest req = new MockHttpServletRequest();
req.setUserPrincipal(null);
req.setRemoteUser("Santa");
- IMocksControl control = createControl();
- PrincipalAware mock = (PrincipalAware) control.createMock(PrincipalAware.class);
+ PrincipalAware mock = (PrincipalAware) createMock(PrincipalAware.class);
MockActionInvocation mai = createActionInvocation(mock);
mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
@@ -152,9 +145,9 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mock.setPrincipalProxy(anyObject(ServletPrincipalProxy.class)); // less strick match is needed for this unit test to be conducted using mocks
expectLastCall().times(1);
- control.replay();
+ replay(mock);
interceptor.intercept(mai);
- control.verify();
+ verify(mock);
}
public void testPrincipalProxy() throws Exception {
@@ -180,8 +173,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testServletContextAware() throws Exception {
- IMocksControl control = createControl();
- ServletContextAware mock = (ServletContextAware) control.createMock(ServletContextAware.class);
+ ServletContextAware mock = (ServletContextAware) createMock(ServletContextAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -191,9 +183,9 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
mock.setServletContext((ServletContext) ctx);
expectLastCall().times(1);
- control.replay();
+ replay(mock);
interceptor.intercept(mai);
- control.verify();
+ verify(mock);
}
private MockActionInvocation createActionInvocation(Object mock) {
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
index 93e7133..8fba186 100644
--- a/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
+++ b/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java
@@ -29,8 +29,6 @@ import javax.servlet.ServletResponse;
import org.apache.struts2.StrutsException;
import org.apache.struts2.components.Include;
-import org.easymock.IMocksControl;
-import org.easymock.MockType;
import com.mockobjects.servlet.MockRequestDispatcher;
@@ -40,7 +38,6 @@ import com.mockobjects.servlet.MockRequestDispatcher;
*/
public class IncludeTagTest extends AbstractTagTest {
- private IMocksControl controlRequestDispatcher;
private RequestDispatcher mockRequestDispatcher;
private IncludeTag tag;
@@ -61,7 +58,7 @@ public class IncludeTagTest extends AbstractTagTest {
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
expectLastCall().times(1);
- controlRequestDispatcher.replay();
+ replay(mockRequestDispatcher);
tag.setValue("person/list.jsp");
tag.doStartTag();
@@ -70,7 +67,7 @@ public class IncludeTagTest extends AbstractTagTest {
assertEquals("/person/list.jsp", request.getRequestDispatherString());
assertEquals("", writer.toString());
- controlRequestDispatcher.verify();
+ verify(mockRequestDispatcher);
}
public void testIncludeWithParameters() throws Exception {
@@ -79,7 +76,7 @@ public class IncludeTagTest extends AbstractTagTest {
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
expectLastCall().times(1);
- controlRequestDispatcher.replay();
+ replay(mockRequestDispatcher);
tag.setValue("person/create.jsp");
tag.doStartTag();
@@ -91,7 +88,7 @@ public class IncludeTagTest extends AbstractTagTest {
assertEquals("/person/create.jsp?user=Santa+Claus", request.getRequestDispatherString());
assertEquals("", writer.toString());
- controlRequestDispatcher.verify();
+ verify(mockRequestDispatcher);
}
public void testIncludeRelative2Dots() throws Exception {
@@ -100,7 +97,7 @@ public class IncludeTagTest extends AbstractTagTest {
mockRequestDispatcher.include(anyObject(ServletRequest.class), anyObject(ServletResponse.class));
expectLastCall().times(1);
- controlRequestDispatcher.replay();
+ replay(mockRequestDispatcher);
request.setupGetServletPath("app/manager");
tag.setValue("../car/view.jsp");
@@ -111,7 +108,7 @@ public class IncludeTagTest extends AbstractTagTest {
assertEquals("/car/view.jsp", request.getRequestDispatherString());
assertEquals("", writer.toString());
- controlRequestDispatcher.verify();
+ verify(mockRequestDispatcher);
}
protected void setUp() throws Exception {
@@ -119,10 +116,7 @@ public class IncludeTagTest extends AbstractTagTest {
request.setupGetRequestDispatcher(new MockRequestDispatcher());
tag = new IncludeTag();
- controlRequestDispatcher = createControl(MockType.NICE);
-
-
- mockRequestDispatcher = (RequestDispatcher) controlRequestDispatcher.createMock(RequestDispatcher.class);
+ mockRequestDispatcher = (RequestDispatcher) createMock(RequestDispatcher.class);
request.setupGetRequestDispatcher(mockRequestDispatcher);
tag.setPageContext(pageContext);
@@ -132,7 +126,6 @@ public class IncludeTagTest extends AbstractTagTest {
protected void tearDown() throws Exception {
super.tearDown();
tag = null;
- controlRequestDispatcher = null;
mockRequestDispatcher = null;
}
http://git-wip-us.apache.org/repos/asf/struts/blob/20e9d13b/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java b/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
index 1dfe674..67aa4cf 100644
--- a/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
+++ b/core/src/test/java/org/apache/struts2/views/util/ResourceUtilTest.java
@@ -28,35 +28,32 @@ import javax.servlet.http.HttpServletRequest;
import junit.framework.TestCase;
-import org.easymock.IMocksControl;
import static org.easymock.EasyMock.*;
public class ResourceUtilTest extends TestCase {
- private IMocksControl control;
private HttpServletRequest requestMock;
public void testGetResourceBase() throws Exception {
expect(requestMock.getServletPath()).andReturn("/mycontext/");
expect(requestMock.getRequestURI()).andReturn("/mycontext/");
- control.replay();
+ replay(requestMock);
assertEquals("/mycontext", ResourceUtil.getResourceBase(requestMock));
- control.verify();
+ verify(requestMock);
- control.reset();
+ reset(requestMock);
expect(requestMock.getServletPath()).andReturn("/mycontext/test.jsp");
expect(requestMock.getRequestURI()).andReturn("/mycontext/test.jsp");
- control.replay();
+ replay(requestMock);
assertEquals("/mycontext", ResourceUtil.getResourceBase(requestMock));
- control.verify();
+ verify(requestMock);
}
protected void setUp() {
- control = createControl();
- requestMock = (HttpServletRequest) control.createMock(HttpServletRequest.class);
+ requestMock = (HttpServletRequest) createMock(HttpServletRequest.class);
}
}
[03/10] struts git commit: Merge branch 'easymock_update' of
git@github.com:victorsosa/struts.git into easymock_update
Posted by lu...@apache.org.
Merge branch 'easymock_update' of git@github.com:victorsosa/struts.git into easymock_update
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/35aacc7a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/35aacc7a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/35aacc7a
Branch: refs/heads/master
Commit: 35aacc7a6353b64f68c7a5f3590f5eaacfef553f
Parents: 20e13f1 900167d
Author: Victor Sosa <vi...@gmail.com>
Authored: Wed Jan 20 16:28:56 2016 -0400
Committer: Victor Sosa <vi...@gmail.com>
Committed: Wed Jan 20 16:28:56 2016 -0400
----------------------------------------------------------------------
----------------------------------------------------------------------