Hi all
I'm currently exploring the recommended "test first" approach in Spring development, and I must admit I'm fascinated by all the possibilities theis method has.
But I'm also a newbie in this way of thinking, and have run into problems
I wonder why
generates the following exceptionCode:private MockControl control = null; private LogicFacade mockLogic = null; private DateSearchFormController datefc = null; private MockHttpServletRequest mockreq = null; protected void setUp() throws Exception { control = MockControl.createControl(LogicFacade.class); mockLogic = (LogicFacade) control.getMock(); datefc = new DateSearchFormController(); datefc.setLogic(mockLogic); mockreq = new MockHttpServletRequest(); } protected void tearDown() throws Exception { control = null; mockLogic = null; datefc = null; mockreq = null; } public void testLoginCheck() throws Exception { MockHttpSession mockSession = new MockHttpSession(); MockControl sessionControl = MockControl.createControl(UserSession.class); UserSession session = (UserSession) sessionControl.getMock(); AvikUser user = new AvikUser(); user.setRole(AvikRole.POWERUSER); session.setUser(user); mockSession.setAttribute("usersession", session); mockreq.setAttribute("something", new Object()); mockreq.setSession(mockSession); datefc.handleRequest( mockreq , new MockHttpServletResponse() ); }
testing this codeCode:[junit] Testcase: testLoginCheck(ks.rah.avik2.test.TestSearchController): Caused an ERROR [junit] Request method 'null' not supported [junit] org.springframework.web.servlet.support.RequestMethodNotSupportedException: Request method 'null' not suppor ted [junit] at org.springframework.web.servlet.support.WebContentGenerator.checkAndPrepare(WebContentGenerator.java: 199) [junit] at org.springframework.web.servlet.support.WebContentGenerator.checkAndPrepare(WebContentGenerator.java: 178) [junit] at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:109) [junit] at ks.rah.avik2.test.TestSearchController.testLoginCheck(TestSearchController.java:61) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Seems like the MockHttpServletRequest/Response is null somehow.....Code:protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { DateSearchForm form = (DateSearchForm) command; AvikUser user = AvikController.checkLoggedIn(request, AvikRole.POWERUSER, false); . . .
Anybody have an idea?


Reply With Quote