import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.apache.struts2.StrutsSpringJUnit4TestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.opensymphony.xwork2.ActionProxy;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class TestActionJUnit4Test extends StrutsSpringJUnit4TestCase<TestAction> {

    @Override
    protected String getConfigPath() {
        return "struts-plugin.xml";
    }

    @Test
    public void testExecute() throws Exception {
        ActionProxy proxy = getActionProxy("/test/test.action");
        String result = proxy.execute();
        assertEquals("success", result);
        assertEquals("Test by Linus", ((TestAction) proxy.getAction()).getMessage());

        executeAction("/test/test");
        assertFalse(getAction().hasFieldErrors());
        assertEquals("Test by Linus", findValueAfterExecute("message"));
    }

}