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

Mocking fails with reactive endpoints in spring-boot v3 #1604

Open
kostja86 opened this issue Mar 20, 2023 · 0 comments
Open

Mocking fails with reactive endpoints in spring-boot v3 #1604

kostja86 opened this issue Mar 20, 2023 · 0 comments
Labels

Comments

@kostja86
Copy link

Describe the bug

After switching to spring-boot v3.x.x and groovy v4.0.9 with spock v2.4-M1-groovy-4.0 tests for a reactive (spring-webflux) controller with usage of org.springframework.test.web.reactive.server.WebTestClient in combination with mocked spring-services fail, when a given mocked instance has more than one (in another example less than three) interactions. The first interaction (or the first two interactions) are successfull and the defined value is returned for the mocked call. Further interactions fall back to the default behviour of returning null. Furthermore, these interactions are not counted.

To Reproduce

My team wrote an example project to demonstrate the behaviour. With spring-boot v3.0.4 several tests are failing. If you switch back to spring-boot v2.7.9, all test cases pass.

maybe-bug-discovered.zip

Expected behavior

All tests pass, independent of the spring-boot version.

Actual behavior

By using a mocked service within a reactor.core.publisher.Flux, the described behaviour is reproduceable

Java version

openjdk 17.0.4 2022-07-19 LTS
OpenJDK Runtime Environment Zulu17.36+13-CA (build 17.0.4+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.36+13-CA (build 17.0.4+8-LTS, mixed mode, sharing)

Buildtool version

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: C:\Program Files\maven
Java version: 17.0.4, vendor: Azul Systems, Inc., runtime: C:\Program Files\Java\jdk17
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

What operating system are you using

Windows

Dependencies

com.example.maybe.bug:bug-hunting:jar:0.0.1-SNAPSHOT
+- org.springframework.boot:spring-boot-starter-webflux:jar:3.0.4:compile
| +- org.springframework.boot:spring-boot-starter:jar:3.0.4:compile
| | +- org.springframework.boot:spring-boot:jar:3.0.4:compile
| | | - org.springframework:spring-context:jar:6.0.6:compile
| | | +- org.springframework:spring-aop:jar:6.0.6:compile
| | | - org.springframework:spring-expression:jar:6.0.6:compile
| | +- org.springframework.boot:spring-boot-autoconfigure:jar:3.0.4:compile
| | +- org.springframework.boot:spring-boot-starter-logging:jar:3.0.4:compile
| | | +- ch.qos.logback:logback-classic:jar:1.4.5:compile
| | | | - ch.qos.logback:logback-core:jar:1.4.5:compile
| | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.19.0:compile
| | | | - org.apache.logging.log4j:log4j-api:jar:2.19.0:compile
| | | - org.slf4j:jul-to-slf4j:jar:2.0.6:compile
| | +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile
| | - org.yaml:snakeyaml:jar:1.33:compile
| +- org.springframework.boot:spring-boot-starter-json:jar:3.0.4:compile
| | +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.2:compile
| | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2:compile
| | | - com.fasterxml.jackson.core:jackson-core:jar:2.14.2:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.14.2:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.14.2:compile
| | - com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.14.2:compile
| +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:3.0.4:compile
| | - io.projectreactor.netty:reactor-netty-http:jar:1.1.4:compile
| | +- io.netty:netty-codec-http:jar:4.1.89.Final:compile
| | | +- io.netty:netty-common:jar:4.1.89.Final:compile
| | | +- io.netty:netty-buffer:jar:4.1.89.Final:compile
| | | +- io.netty:netty-transport:jar:4.1.89.Final:compile
| | | +- io.netty:netty-codec:jar:4.1.89.Final:compile
| | | - io.netty:netty-handler:jar:4.1.89.Final:compile
| | +- io.netty:netty-codec-http2:jar:4.1.89.Final:compile
| | +- io.netty:netty-resolver-dns:jar:4.1.89.Final:compile
| | | +- io.netty:netty-resolver:jar:4.1.89.Final:compile
| | | - io.netty:netty-codec-dns:jar:4.1.89.Final:compile
| | +- io.netty:netty-resolver-dns-native-macos:jar:osx-x86_64:4.1.89.Final:compile
| | | - io.netty:netty-resolver-dns-classes-macos:jar:4.1.89.Final:compile
| | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.89.Final:compile
| | | +- io.netty:netty-transport-native-unix-common:jar:4.1.89.Final:compile
| | | - io.netty:netty-transport-classes-epoll:jar:4.1.89.Final:compile
| | - io.projectreactor.netty:reactor-netty-core:jar:1.1.4:compile
| | - io.netty:netty-handler-proxy:jar:4.1.89.Final:compile
| | - io.netty:netty-codec-socks:jar:4.1.89.Final:compile
| +- org.springframework:spring-web:jar:6.0.6:compile
| | +- org.springframework:spring-beans:jar:6.0.6:compile
| | - io.micrometer:micrometer-observation:jar:1.10.4:compile
| | - io.micrometer:micrometer-commons:jar:1.10.4:compile
| - org.springframework:spring-webflux:jar:6.0.6:compile
+- org.springframework.boot:spring-boot-starter-test:jar:3.0.4:test
| +- org.springframework.boot:spring-boot-test:jar:3.0.4:test
| +- org.springframework.boot:spring-boot-test-autoconfigure:jar:3.0.4:test
| +- com.jayway.jsonpath:json-path:jar:2.7.0:test
| | +- net.minidev:json-smart:jar:2.4.8:test
| | | - net.minidev:accessors-smart:jar:2.4.8:test
| | | - org.ow2.asm:asm:jar:9.1:test
| | - org.slf4j:slf4j-api:jar:2.0.6:compile
| +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0:test
| | - jakarta.activation:jakarta.activation-api:jar:2.1.1:test
| +- org.assertj:assertj-core:jar:3.23.1:test
| | - net.bytebuddy:byte-buddy:jar:1.12.23:test
| +- org.hamcrest:hamcrest:jar:2.2:test
| +- org.junit.jupiter:junit-jupiter:jar:5.9.2:test
| | +- org.junit.jupiter:junit-jupiter-api:jar:5.9.2:test
| | +- org.junit.jupiter:junit-jupiter-params:jar:5.9.2:test
| | - org.junit.jupiter:junit-jupiter-engine:jar:5.9.2:test
| +- org.mockito:mockito-core:jar:4.8.1:test
| | +- net.bytebuddy:byte-buddy-agent:jar:1.12.23:test
| | - org.objenesis:objenesis:jar:3.2:test
| +- org.mockito:mockito-junit-jupiter:jar:4.8.1:test
| +- org.skyscreamer:jsonassert:jar:1.5.1:test
| | - com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
| +- org.springframework:spring-core:jar:6.0.6:compile
| | - org.springframework:spring-jcl:jar:6.0.6:compile
| +- org.springframework:spring-test:jar:6.0.6:test
| - org.xmlunit:xmlunit-core:jar:2.9.1:test
+- io.projectreactor:reactor-test:jar:3.5.3:test
| - io.projectreactor:reactor-core:jar:3.5.3:compile
| - org.reactivestreams:reactive-streams:jar:1.0.4:compile
+- org.apache.groovy:groovy:jar:4.0.9:test
+- org.apache.groovy:groovy-json:jar:4.0.9:test
+- org.spockframework:spock-core:jar:2.4-M1-groovy-4.0:test
| - org.junit.platform:junit-platform-engine:jar:1.9.2:test
| +- org.opentest4j:opentest4j:jar:1.2.0:test
| +- org.junit.platform:junit-platform-commons:jar:1.9.2:test
| - org.apiguardian:apiguardian-api:jar:1.1.2:test
- org.spockframework:spock-spring:jar:2.4-M1-groovy-4.0:test

Additional context

No response

@kostja86 kostja86 added the bug label Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant