Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP – use NakadiMock in the spring-boot-2-test #109

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ePaul
Copy link
Member

@ePaul ePaul commented Dec 19, 2018

Part of my Hackweek project. Please don't merge yet (we want to have a stable release of nakadi-mock first), but comments are already appreciated.

This is a Proof-of-concept of how to use my nakadi-mock project to test the event sending of spring-boot applications.

It turned out to be more complicated than I thought, because Spring-Boot-Autoconfigure detected that Undertow (an alternative web server, which I'm using in nakadi-mock) is on the class path, and tried to set it up as the application's web server (beside the Tomcat).
I solved that on the library side by shading undertow (renaming all class names and including in the Jar, thus removing the dependency).

Another issue is that we need to get the port number for the mock before configuring our Nakadi-Producer, which is why we are now using an ApplicationContextInitializer instead of normal @Configuration classes for that.

Includes the changes of #107 and #108, so those should be merged first.

@ePaul ePaul added in progress nakadi-submission spring-boot-2 Issues/PRs which only apply to the Spring-Boot 2 versions (Releases 20.*+) tests only changes test code, not the actual library labels Dec 19, 2018
@ePaul ePaul requested a review from BGehrels as a code owner December 19, 2018 16:30
@zalando-nakadi zalando-nakadi deleted a comment Dec 19, 2018
@zalando-nakadi zalando-nakadi deleted a comment Dec 19, 2018
@zalando-nakadi zalando-nakadi deleted a comment Dec 19, 2018
@zalando-nakadi zalando-nakadi deleted a comment Dec 19, 2018
} else if (withIdGreaterThan.equals("1")) {
return Collections.singletonList(new Snapshot("2", "foo", filter));
return Collections.singletonList(new Snapshot("2", "foo", new Data("2", filter)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this so we actually get objects sent, not just null or strings.

<dependency>
<groupId>org.zalando</groupId>
<artifactId>nakadi-mock</artifactId>
<version>0.0.1-SNAPSHOT</version>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently not yet released, and if it gets released, it might be under a different group name.

@@ -63,6 +69,7 @@
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.1.0</version>
<scope>test</scope>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated, I just noted that this does need only test scope.

import java.util.Collections;

@EnableAutoConfiguration
@EnableNakadiProducer
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the deprecated annotation here.

/**
* An application context initializer which sets up a NakadiMock bean and registers the server URL as a property.
*/
class NakadiServerMockInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext>{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether it makes sense to move this class into either my Nakadi-Mock or even a new artifact, as this is useful whenever we are using both nakadi-producer and nakadi-mock together.

@ePaul ePaul marked this pull request as draft September 23, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress nakadi-submission spring-boot-2 Issues/PRs which only apply to the Spring-Boot 2 versions (Releases 20.*+) tests only changes test code, not the actual library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant