@Test public void detectHandlerMethodsInAncestorContexts() { StaticApplicationContext cxt = new StaticApplicationContext(); cxt.registerSingleton("myHandler", MyHandler.class); AbstractHandlerMethodMapping<String> mapping1 = new MyHandlerMethodMapping(); mapping1.setApplicationContext(new StaticApplicationContext(cxt)); mapping1.afterPropertiesSet(); assertEquals(0, mapping1.getHandlerMethods().size()); AbstractHandlerMethodMapping<String> mapping2 = new MyHandlerMethodMapping(); mapping2.setDetectHandlerMethodsInAncestorContexts(true); mapping2.setApplicationContext(new StaticApplicationContext(cxt)); mapping2.afterPropertiesSet(); assertEquals(2, mapping2.getHandlerMethods().size()); }