question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing SSE endpoints with JavalinTest

See original GitHub issue

Problem:

I want to achieve the maximum coverage of my controller tests.

What have I managed so far:

By following this tutorial I’ve managed to write a test that covers every normal method on my controller using the “Functional/integration” methodology described by the tutorial.

What I want to do:

listenToParameterChanges is a method on my controller invoked by an SSE declaration in my server description.

I want to make sure that method is also tested properly, is there a way to test it while maintaining the same methodology or should I change my methodology to the one described under “Unit” on the tutorial to cover that portion of my controller?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:38 (25 by maintainers)

github_iconTop GitHub Comments

2reactions
tipsycommented, May 24, 2022

@dzikoysk https://github.com/tipsy/javalin/commit/0e947377724bd32da28b1707a33c9d79b9f53386

Turns out we have two bugs:

  1. Javalin doesn’t release the request when the emitter is closed
  2. Javalin doesn’t call closeCallback when the user manually calls close()

I changed the close() method to also trigger the closeCallback, then I called the close() whenever the emitter is closed. This should fix both bugs.

1reaction
Incognitowskicommented, May 23, 2022

@tipsy sorry for the delayed answer.

I think client could be expanded to include SSE, since it’s just a HTTP connection. Having a .close() on client seems fair enough?

I believe that wold be perfect.

I’ll give it a shot with okhttp-sse as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to test server sent events with Spring? - Stack Overflow
... verifier for testing the Server Sent Event (SSE). Need to create WebTestClient object and make a call to endpoint. Below is an...
Read more >
Testing Javalin Applications
Since Javalin is a library, there are no requirements for how tests must be written. This guide will outline a few common approaches....
Read more >
Server Sent Events — Development & Test Automation
Establish a SSE connection to REST endpoint exposed by sse-server project. This is achieved with EventSource java object . This project has ...
Read more >
Mocking server sent events: Development and CI
Posted Nov 21, 2018 in Testing by Tim Vierbergen ... Although Node-RED has add-ons for SSE, I decided to start writing one myself....
Read more >
How to Load Test SSE Services with JMeter - BlazeMeter
In this post we will show you two ways to load test SSE with JMeter: by using Groovy or a Java Sampler.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found