actioncontext

Strut 2.3.1.2 Unit test, how to remove Spring codependency vs NPE with getContext()

那年仲夏 提交于 2019-11-28 12:10:11
问题 I'm just upgrading to Struts 2.3.1.2, and having a few issues with JUnit tests. My old test code was like this.... public class HomeActionTest { @Test public void testUserNameErrorMessage() throws Exception { HomeAction action = new HomeAction(); setupMocks(action); action.execute(); } } The action class's execute method has the code String text = getText(GLOBAL_SELECT); This causes a NullPointerExeception though in LocalizedTextUtil since it calls... ActionContext.getContext() Now I could