Search in sources :

Example 1 with MockResult

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

the class ChainResultTest method testNamespaceChain.

public void testNamespaceChain() throws Exception {
    ActionProxy proxy = actionProxyFactory.createActionProxy(null, "chain_with_namespace", null, null);
    ((SimpleAction) proxy.getAction()).setBlah("%{foo}");
    proxy.execute();
    assertTrue(proxy.getInvocation().getResult() instanceof MockResult);
    MockResult result = (MockResult) proxy.getInvocation().getResult();
    assertEquals("%{foo}", result.getInvocation().getProxy().getNamespace());
}
Also used : MockResult(com.opensymphony.xwork2.mock.MockResult)

Example 2 with MockResult

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

the class DefaultActionInvocationTester method testActionChainResult.

public void testActionChainResult() throws Exception {
    ActionProxy actionProxy = actionProxyFactory.createActionProxy("", "Foo", null, new HashMap<String, Object>());
    DefaultActionInvocation defaultActionInvocation = (DefaultActionInvocation) actionProxy.getInvocation();
    defaultActionInvocation.init(actionProxy);
    SimpleAction action = (SimpleAction) defaultActionInvocation.getAction();
    action.setFoo(1);
    action.setBar(2);
    defaultActionInvocation.invoke();
    // then
    assertTrue(defaultActionInvocation.result instanceof ActionChainResult);
    Result result = defaultActionInvocation.getResult();
    assertTrue(result instanceof MockResult);
}
Also used : MockActionProxy(com.opensymphony.xwork2.mock.MockActionProxy) MockResult(com.opensymphony.xwork2.mock.MockResult) MockResult(com.opensymphony.xwork2.mock.MockResult)

Example 3 with MockResult

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

the class XmlConfigurationProviderResultsTest method testResultTypes.

public void testResultTypes() throws ConfigurationException {
    final String filename = "com/opensymphony/xwork2/config/providers/xwork-test-results.xml";
    ConfigurationProvider provider = buildConfigurationProvider(filename);
    // setup expectations
    ResultTypeConfig chainResult = new ResultTypeConfig.Builder("chain", ActionChainResult.class.getName()).build();
    ResultTypeConfig mockResult = new ResultTypeConfig.Builder("mock", MockResult.class.getName()).build();
    // execute the configuration
    provider.init(configuration);
    provider.loadPackages();
    PackageConfig pkg = configuration.getPackageConfig("default");
    Map resultTypes = pkg.getResultTypeConfigs();
    // assertions
    assertEquals(2, resultTypes.size());
    assertEquals("chain", pkg.getDefaultResultType());
    assertEquals(chainResult, resultTypes.get("chain"));
    assertEquals(mockResult, resultTypes.get("mock"));
}
Also used : ConfigurationProvider(com.opensymphony.xwork2.config.ConfigurationProvider) ResultTypeConfig(com.opensymphony.xwork2.config.entities.ResultTypeConfig) Map(java.util.Map) HashMap(java.util.HashMap) PackageConfig(com.opensymphony.xwork2.config.entities.PackageConfig)

Aggregations

MockResult (com.opensymphony.xwork2.mock.MockResult)2 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)1 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)1 ResultTypeConfig (com.opensymphony.xwork2.config.entities.ResultTypeConfig)1 MockActionProxy (com.opensymphony.xwork2.mock.MockActionProxy)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1