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

Junit test templating fails if another TestTemplateInvocationContextProvider used #248

Closed
k-wall opened this issue Dec 6, 2023 · 0 comments · Fixed by #249
Closed

Junit test templating fails if another TestTemplateInvocationContextProvider used #248

k-wall opened this issue Dec 6, 2023 · 0 comments · Fixed by #249
Labels
bug Something isn't working

Comments

@k-wall
Copy link
Contributor

k-wall commented Dec 6, 2023

Describe the bug

I'm trying to use test templating with a test class that also takes advantage of KafkaClusterExtension.

@ExtendWith(KafkaClusterExtension.class)
class EnvelopeEncryptionFilterIT {

    @TestTemplate
    @ExtendWith(KmsTestInvocationContextProvider.class)
    void roundTrip(KafkaCluster cluster, KmsTestInvocation details) throws Exception {
    }

It fails in the following way:

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [io.kroxylicious.testing.kafka.api.KafkaCluster cluster] in method [void io.kroxylicious.proxy.encryption.EnvelopeEncryptionFilterIT.roundTrip(io.kroxylicious.testing.kafka.api.KafkaCluster) throws java.lang.Exception].

	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

The issue is that there is no parameter resolve for the KafkaCluster type parameter. The reason for this is that:

  • io.kroxylicious.testing.kafka.junit5ext.KafkaClusterExtension#supportsParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext) says no because of the TestTemplate annotation.
  • io.kroxylicious.testing.kafka.junit5ext.KafkaClusterExtension#provideTestTemplateInvocationContexts fails to add parameter resolvers because it is not annotated with one of the special types - Dimension or ConstraintMethodSource.

To Reproduce
Steps to reproduce the behavior:

  1. Use kroxylicious-junit5-extension like this ...
  2. Run command '....'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Logs

Attach or copy and paste relevant logs.

Additional context
Add any other context about the problem here.

@k-wall k-wall added the bug Something isn't working label Dec 6, 2023
@k-wall k-wall changed the title Extension test templating fails if another TestTemplateInvocationContextProvider is provided Junit test templating fails if another TestTemplateInvocationContextProvider used Dec 6, 2023
k-wall added a commit to k-wall/kroxylicious-junit5-extension that referenced this issue Dec 6, 2023
k-wall added a commit to k-wall/kroxylicious-junit5-extension that referenced this issue Dec 6, 2023
k-wall added a commit to k-wall/kroxylicious-junit5-extension that referenced this issue Dec 6, 2023
k-wall added a commit to k-wall/kroxylicious-junit5-extension that referenced this issue Dec 6, 2023
…hen using KafkaClusterExtension

Signed-off-by: kwall <kwall@apache.org>
k-wall added a commit to k-wall/kroxylicious-junit5-extension that referenced this issue Dec 6, 2023
…hen using KafkaClusterExtension

Signed-off-by: kwall <kwall@apache.org>
k-wall added a commit that referenced this issue Dec 7, 2023
…Extension (#249)

* Fix #248: Allow user to bring their own test templating when using KafkaClusterExtension

Signed-off-by: kwall <kwall@apache.org>

* fix java:S5786 code smell

---------

Signed-off-by: kwall <kwall@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant