HandlerMethodMappingTests.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:spring4-understanding 作者:
@Test
public void getCorsConfigWithBeanNameHandler() throws Exception {

    String key = "foo";
    String beanName = "handler1";

    StaticWebApplicationContext context = new StaticWebApplicationContext();
    context.registerSingleton(beanName, MyHandler.class);

    this.mapping.setApplicationContext(context);
    this.mapping.registerMapping(key, beanName, this.method1);
    HandlerMethod handlerMethod = this.mapping.getHandlerInternal(new MockHttpServletRequest("GET", key));

    CorsConfiguration config = this.mapping.getMappingRegistry().getCorsConfiguration(handlerMethod);
    assertNotNull(config);
    assertEquals("http://" + beanName.hashCode() + this.method1.getName(), config.getAllowedOrigins().get(0));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号