Spring 2.5準拠のコードをSpring 3.0へアップデートしているところです。
Spring 2.5でのコントローラーは以下の通りです。(参考):
public class TargetController implements Controller { public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { return new ModelAndView("test.jsp"); } }
コントローラーのJUnitテストコードは以下の通りです。(参考):
public class TargetControllerTests extends TestCase { public void testHandleRequestView() throws Exception{ TargetController controller = new TargetController(); ModelAndView mav = controller.handleRequest(null, null); assertEquals("test", mav.getViewName()); } }
アノテーション使用のためにJUnit 4.9を使いはじめたのですが、コントローラーに対しユニットテストを行うにはどのような方法がありますでしょうか?
どうぞよろしくお願いします。
@Controller public class TargetController { @RequestMapping("/someview") public ModelAndView handleRequest() { return new ModelAndView("test", "message", "メッセージ"); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。