java - springboot junit test when use websocket , it doesn't work -
1.when using @serverendpoint
, junit
not work,the websocket config list,when @serverendpoint commend out, junit works well
@serverendpoint(value = "/websocket", configurator = sessionforwebsocket.class) @component public class websocketbean { .... }
2. myjunit config is
@runwith(springjunit4classrunner.class) @springboottest(classes = hdconsumerapplication.class) @webappconfiguration @transactional public class hdjunittest {}
3.when run junit,i got error:
2017-08-18 21:47:17 info [main] org.springframework.boot.actuate.endpoint.mvc.endpointhandlermapping - mapped "{[/env || /env.json],methods=[get],produces=[application/json]}" onto public java.lang.object org.springframework.boot.actuate.endpoint.mvc.endpointmvcadapter.invoke() 2017-08-18 21:47:17 info [main] org.springframework.boot.actuate.endpoint.mvc.endpointhandlermapping - mapped "{[/actuator || /actuator.json],produces=[application/json]}" onto public org.springframework.hateoas.resourcesupport org.springframework.boot.actuate.endpoint.mvc.haljsonmvcendpoint.links() 2017-08-18 21:47:17 info [main] org.springframework.web.socket.server.standard.serverendpointexporter - registering @serverendpoint class: class net.huadong.tech.msg.websocketbean 2017-08-18 21:47:17 info [main] org.springframework.boot.autoconfigure.logging.autoconfigurationreportlogginginitializer - error starting applicationcontext. display auto-configuration report re-run application 'debug' enabled. 2017-08-18 21:47:17 error [main] org.springframework.boot.springapplication - application startup failed java.lang.unsupportedoperationexception: mockservercontainer not support addendpoint(class) @ org.springframework.test.context.web.socket.mockservercontainer.addendpoint(mockservercontainer.java:126) @ org.springframework.web.socket.server.standard.serverendpointexporter.registerendpoint(serverendpointexporter.java:145) @ org.springframework.web.socket.server.standard.serverendpointexporter.registerendpoints(serverendpointexporter.java:129)`enter code here` @ org.springframework.web.socket.server.standard.serverendpointexporter.aftersingletonsinstantiated(serverendpointexporter.java:107) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:779) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:866) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:542) @ org.springframework.boot.springapplication.refresh(springapplication.java:761) @ org.springframework.boot.springapplication.refreshcontext(springapplication.java:371)
4.is anymethod can me,fix matter ,or when junit exclude websocketbean
Comments
Post a Comment