Fix tests

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@805237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Musachy Barroso
2009-08-18 00:36:15 +00:00
parent bebf30f3d1
commit ca8f4918ff
3 changed files with 49 additions and 6 deletions
@@ -25,8 +25,14 @@ import java.util.List;
import org.apache.struts2.TestAction;
import org.apache.struts2.views.jsp.AbstractUITagTest;
import org.easymock.EasyMock;
import com.opensymphony.xwork2.validator.validators.RequiredFieldValidator;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
/**
* <code>FormTest</code>
@@ -43,4 +49,21 @@ public class FormTest extends AbstractUITagTest {
assertEquals(1, v.size());
assertEquals(RequiredFieldValidator.class, v.get(0).getClass());
}
@Override
protected void setUp() throws Exception {
super.setUp();
ActionConfig config = new ActionConfig.Builder("", "name", "").build();
ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
ActionProxy proxy = EasyMock.createNiceMock(ActionProxy.class);
EasyMock.expect(invocation.getProxy()).andReturn(proxy).anyTimes();
EasyMock.expect(invocation.getAction()).andReturn(null).anyTimes();
EasyMock.expect(invocation.invoke()).andReturn(Action.SUCCESS).anyTimes();
EasyMock.expect(proxy.getMethod()).andReturn("execute").anyTimes();
EasyMock.expect(proxy.getConfig()).andReturn(config).anyTimes();
ActionContext.getContext().setActionInvocation(invocation);
}
}
@@ -22,11 +22,10 @@
package org.apache.struts2.interceptor.validation;
import org.apache.struts2.StrutsTestCase;
import org.easymock.EasyMock;
import com.mockobjects.dynamic.Mock;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.config.entities.ActionConfig;
public class AnnotationValidationInterceptorTest extends StrutsTestCase {
@@ -48,9 +47,13 @@ public class AnnotationValidationInterceptorTest extends StrutsTestCase {
mockActionInvocation.matchAndReturn("getProxy", (ActionProxy) mockActionProxy.proxy());
mockActionInvocation.matchAndReturn("getAction", test);
mockActionInvocation.expect("invoke");
ActionContext.getContext().setActionInvocation((ActionInvocation) mockActionInvocation.proxy());
}
public void testShouldNotSkip() throws Exception {
mockActionProxy.expectAndReturn("getMethod", "execute");
mockActionProxy.expectAndReturn("getActionName", "foo");
mockActionProxy.expectAndReturn("getMethod", "execute");
mockActionProxy.expectAndReturn("getConfig", config);
mockActionProxy.expectAndReturn("getMethod", "execute");
@@ -84,6 +87,8 @@ public class AnnotationValidationInterceptorTest extends StrutsTestCase {
public void testShouldNotSkipBase() throws Exception {
mockActionProxy.expectAndReturn("getMethod", "dontSkipMeBase");
mockActionProxy.expectAndReturn("getActionName", "foo");
mockActionProxy.expectAndReturn("getMethod", "execute");
mockActionProxy.expectAndReturn("getConfig", config);
mockActionProxy.expectAndReturn("getMethod", "dontSkipMeBase");
interceptor.doIntercept((ActionInvocation)mockActionInvocation.proxy());
@@ -33,10 +33,9 @@ import org.apache.struts2.TestConfigurationProvider;
import org.apache.struts2.components.Form;
import org.apache.struts2.views.jsp.AbstractUITagTest;
import org.apache.struts2.views.jsp.ActionTag;
import org.easymock.EasyMock;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.config.RuntimeConfiguration;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.InterceptorMapping;
@@ -762,5 +761,21 @@ public class FormTagTest extends AbstractUITagTest {
put("configProviders", TestConfigurationProvider.class.getName());
}});
ActionContext.getContext().setValueStack(stack);
ActionConfig config = new ActionConfig.Builder("", "name", "").build();
ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
ActionProxy proxy = EasyMock.createNiceMock(ActionProxy.class);
EasyMock.expect(invocation.getProxy()).andReturn(proxy).anyTimes();
EasyMock.expect(invocation.getAction()).andReturn(null).anyTimes();
EasyMock.expect(invocation.invoke()).andReturn(Action.SUCCESS).anyTimes();
EasyMock.expect(proxy.getMethod()).andReturn("execute").anyTimes();
EasyMock.expect(proxy.getConfig()).andReturn(config).anyTimes();
EasyMock.replay(invocation);
EasyMock.replay(proxy);
ActionContext.getContext().setActionInvocation(invocation);
}
}