Search in sources :

Example 51 with MockActionProxy

use of com.opensymphony.xwork2.mock.MockActionProxy in project struts by apache.

the class PrepareInterceptorTest method testFirstCallPrepareDoIsFalse.

public void testFirstCallPrepareDoIsFalse() throws Exception {
    MockActionInvocation mai = new MockActionInvocation();
    MockActionProxy mockActionProxy = new MockActionProxy();
    mockActionProxy.setMethod("submit");
    mai.setProxy(mockActionProxy);
    mai.setAction(mock.proxy());
    mock.expect("prepare");
    mock.expect("prepareSubmit");
    interceptor.setFirstCallPrepareDo("false");
    interceptor.intercept(mai);
}
Also used : MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Example 52 with MockActionProxy

use of com.opensymphony.xwork2.mock.MockActionProxy in project struts by apache.

the class PrepareInterceptorTest method testPrepareCalledTrue.

public void testPrepareCalledTrue() throws Exception {
    MockActionInvocation mai = new MockActionInvocation();
    MockActionProxy mockActionProxy = new MockActionProxy();
    mockActionProxy.setMethod("execute");
    mai.setProxy(mockActionProxy);
    mai.setAction(mock.proxy());
    mock.expect("prepare");
    interceptor.setAlwaysInvokePrepare("true");
    interceptor.intercept(mai);
}
Also used : MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Example 53 with MockActionProxy

use of com.opensymphony.xwork2.mock.MockActionProxy in project struts by apache.

the class PrepareInterceptorTest method testPrepareCalledDefault.

public void testPrepareCalledDefault() throws Exception {
    MockActionInvocation mai = new MockActionInvocation();
    MockActionProxy mockActionProxy = new MockActionProxy();
    mockActionProxy.setMethod("execute");
    mai.setProxy(mockActionProxy);
    mai.setAction(mock.proxy());
    mock.expect("prepare");
    interceptor.intercept(mai);
}
Also used : MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Example 54 with MockActionProxy

use of com.opensymphony.xwork2.mock.MockActionProxy in project struts by apache.

the class ScopedModelDrivenInterceptorTest method testNoScopedModelAction.

public void testNoScopedModelAction() throws Exception {
    Action action = new SimpleAction();
    MockActionInvocation mai = new MockActionInvocation();
    MockActionProxy map = new MockActionProxy();
    ActionConfig ac = new ActionConfig.Builder("", "", "").build();
    map.setConfig(ac);
    mai.setAction(action);
    mai.setProxy(map);
    inter.intercept(mai);
    inter.destroy();
// nothing happends
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) SimpleAction(com.opensymphony.xwork2.SimpleAction) Action(com.opensymphony.xwork2.Action) MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) SimpleAction(com.opensymphony.xwork2.SimpleAction) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Example 55 with MockActionProxy

use of com.opensymphony.xwork2.mock.MockActionProxy in project struts by apache.

the class ScopedModelDrivenInterceptorTest method testModelAlreadySetOnAction.

public void testModelAlreadySetOnAction() throws Exception {
    inter.setScope("request");
    inter.setName("king");
    User user = new User();
    user.setName("King George");
    ScopedModelDriven action = new MyUserScopedModelDrivenAction();
    action.setModel(user);
    MockActionInvocation mai = new MockActionInvocation();
    MockActionProxy map = new MockActionProxy();
    ActionConfig ac = new ActionConfig.Builder("", "", "").build();
    map.setConfig(ac);
    mai.setAction(action);
    mai.setProxy(map);
    inter.intercept(mai);
    inter.destroy();
    assertNotNull(action.getModel());
    // no scope key as nothing happended
    assertNull(action.getScopeKey());
}
Also used : ActionConfig(com.opensymphony.xwork2.config.entities.ActionConfig) User(com.opensymphony.xwork2.test.User) MockActionInvocation(com.opensymphony.xwork2.mock.MockActionInvocation) MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy)

Aggregations

MockActionProxy (com.opensymphony.xwork2.mock.MockActionProxy)43 MockActionInvocation (com.opensymphony.xwork2.mock.MockActionInvocation)34 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)29 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)19 ActionProxy (com.opensymphony.xwork2.ActionProxy)17 HashMap (java.util.HashMap)15 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)13 ActionContext (com.opensymphony.xwork2.ActionContext)12 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)11 SimpleFooAction (com.opensymphony.xwork2.SimpleFooAction)10 ServletActionContext (org.apache.struts2.ServletActionContext)10 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)10 OgnlUtil (com.opensymphony.xwork2.ognl.OgnlUtil)8 ActionMapper (org.apache.struts2.dispatcher.mapper.ActionMapper)7 IMocksControl (org.easymock.IMocksControl)7 ValueStack (com.opensymphony.xwork2.util.ValueStack)6 DefaultUrlHelper (org.apache.struts2.views.util.DefaultUrlHelper)6 Mock (com.mockobjects.dynamic.Mock)5 Action (com.opensymphony.xwork2.Action)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5