I am testing my controllers usingOne of my controller method looks like:Code:AnnotationMethodHandlerAdapter
MyType sample:Code:@RequestMapping(value = "/") public String start(@Validated MyType myType, BindingResult errors) { ... }
Sample test class looks like:Code:@RooJavaBean @RooToString @RooJpaActiveRecord public class MyType { @OneToOne @JoinColumn(unique = true, nullable = false) private InnerType innerType; }
When application is deployed to tomcat innerType is injected by its id but in my tests it doesn't work. I discovered that converters are responsible for this. But how to mock service factory bean ?Code:@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/META-INF/spring/MyTest-context.xml" }) class ControllerTest{ @Autowired private AnnotationMethodHandlerAdapter handlerAdapter; private MockHttpServletRequest request; private MockHttpServletResponse response; @Before public void resetMockHttpServelt() { this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); } @Test public void test(){ request.setMethod("GET"); request.setRequestURI("/"); request.setParameter("innerType", 4); handlerAdapter.handle(request,response,controller); ... } }
PS. Some time ago i removed all of default entities controllers generated by roo - I found out that roo also removed ApplicationConversionServiceFactoryBean_Roo_Conver sionService.aj. So where the injection takes place ?
Sorry for my english... I am quite tired with this one![]()
Thanks in advance...


Reply With Quote
