S
S
Sergey2017-02-04 14:23:50
Java
Sergey, 2017-02-04 14:23:50

How to implement integration test for Spring Websocket?

I want to make an integration test for websocket: connect to the server-> subscribe to the mailing list-> send a message-> enter the message into the database-> get a response.
The controller has a method that receives a message and sends it to the client:

@MessageMapping("/section/add")
    @SendTo("/section/add")
    public Message addSection(EntitySection section){
        sectionService.addSection(section);

        return MessageBuilder
                .withPayload("")
                .setHeader(HEADER_STATUS,STATUS_OK)
                .build();
    }

The annotation @MessageMapping("/section/add")is responsible for calling the method when a message is received.
The annotation @SendTo("/section/add")sends a response to the client.
When a message is received, it is entered into the database.
When unit testing, everything works correctly, I pass an object as a parameter and go to the database, but here's how to make a call not through a method, but through annotations to check the real functionality without starting the server?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question