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:27 UTC
[04/10] struts git commit: WW-4593: Easymock upgrade to 3.4
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);
}
}