mirror of
https://github.com/apache/struts.git
synced 2026-09-12 17:15:02 +00:00
WW-4593 Easymock upgrade to 3.4
This commit is contained in:
@@ -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();
|
||||
IMocksControl nodeControl2 = createControl();
|
||||
Node mockNode2 = (Node) nodeControl2.createMock(Node.class);
|
||||
|
||||
nodeControl2.expectAndDefaultReturn(mockNode2.getNodeValue(), "value2");
|
||||
nodeControl2.expectAndDefaultReturn(mockNode2.getNodeType(), Node.TEXT_NODE);
|
||||
expect(mockNode2.getNodeValue()).andStubReturn("value2");
|
||||
expect(mockNode2.getNodeType()).andStubReturn(Node.TEXT_NODE);
|
||||
|
||||
|
||||
MockControl nodeListControl2 = MockControl.createControl(NodeList.class);
|
||||
NodeList mockNodeList2 = (NodeList) nodeListControl2.getMock();
|
||||
IMocksControl nodeListControl2 = createControl();
|
||||
NodeList mockNodeList2 = (NodeList) nodeListControl2.createMock(NodeList.class);
|
||||
|
||||
nodeListControl2.expectAndDefaultReturn(mockNodeList2.getLength(), 1);
|
||||
nodeListControl2.expectAndDefaultReturn(mockNodeList2.item(0), mockNode2);
|
||||
expect(mockNodeList2.getLength()).andStubReturn(1);
|
||||
expect(mockNodeList2.item(0)).andStubReturn(mockNode2);
|
||||
|
||||
MockControl paramControl2 = MockControl.createControl(Element.class);
|
||||
Element mockParamElement2 = (Element) paramControl2.getMock();
|
||||
mockParamElement2.getNodeName();
|
||||
paramControl2.setReturnValue("param");
|
||||
IMocksControl paramControl2 = createControl();
|
||||
Element mockParamElement2 = (Element) paramControl2.createMock(Element.class);
|
||||
|
||||
expect(mockParamElement2.getNodeName()).andStubReturn("param");
|
||||
expect(mockParamElement2.getNodeType()).andStubReturn(Node.ELEMENT_NODE);
|
||||
|
||||
mockParamElement2.getNodeType();
|
||||
paramControl2.setReturnValue(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);
|
||||
|
||||
nodeControl1.verify();
|
||||
nodeListControl1.verify();
|
||||
paramControl1.verify();
|
||||
|
||||
|
||||
nodeControl2.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");
|
||||
|
||||
nodeControl1.verify();
|
||||
nodeListControl1.verify();
|
||||
paramControl1.verify();
|
||||
|
||||
|
||||
nodeControl2.verify();
|
||||
nodeListControl2.verify();
|
||||
paramControl2.verify();
|
||||
|
||||
|
||||
elementNodeListControl.verify();
|
||||
elementControl.verify();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-7
@@ -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 {
|
||||
|
||||
+66
-70
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+43
-38
@@ -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();
|
||||
IMocksControl controlActionProxy = createControl();
|
||||
ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.createMock(ActionProxy.class);
|
||||
|
||||
expect(mockActionProxy.getMethod()).andStubReturn("save");
|
||||
|
||||
|
||||
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();
|
||||
controlAction.setVoidCallable(1);
|
||||
|
||||
MockControl controlActionProxy = MockControl.createControl(ActionProxy.class);
|
||||
ActionProxy mockActionProxy = (ActionProxy) controlActionProxy.getMock();
|
||||
mockActionProxy.getMethod();
|
||||
controlActionProxy.setDefaultReturnValue("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);
|
||||
|
||||
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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+30
-28
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user