Why is ServletServerContainerFactoryBean casuing problems when testing?

▼魔方 西西 提交于 2019-12-05 19:45:31

The solution is to run the test as an integration test by adding the @org.springframework.boot.test.IntegrationTest("server.port:0") annotation to the test class.

The problem is that Spring's unit test harness uses org.springframework.boot.test.SpringBootMockServletContext as the servlet context, and it doesn't have the "javax.websocket.server.ServerContainer" attribute set to an instance of javax.websocket.server.ServerContainer (SpringBootMockServletContext, in short, doesn't support WebSockets).

I've reported this issue at https://jira.spring.io/browse/SPR-14367

If anyone still has this issue, the solution that worked for me is :

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!