dasniko/testcontainers-keycloak

Not enough / duplicate Junit Classes in Jar

cfraenkel opened this issue · 3 comments

I've tried updating to 2.0 of testcontainers-keycloak and stumbled over the now included junit4 classes (b3ce4dc) .
As part of our build we use a plugin that verifies that classes only appear in one jar and this of course conflicted with the jars already in junit:junit that where pulled in via testcontainers.

I tried excluding junit:junit from my build but as a result of that I startet to get java.lang.NoClassDefFoundError: org/junit/rules/ExternalResource via org.testcontainers.containers.Network.NetworkImpl. It seems you copied over some of the classes, but not all required by Testcontainers.

I've seen the junit4 issue at testcontainers github: testcontainers/testcontainers-java#970 . What do you think about including a dependency on https://github.com/quarkusio/quarkus/tree/main/core/junit4-mock instead of copying the junit classes to your jar? That way you wouldn't have to include junit sources and would give the projects that use your library the option to choose where they get their currently still necessary junit 4 classes from.

Hi @cfraenkel,
thanks for coming up with the junit-mock, might work, I'll give it try in the next few days. I didn't know that this exist, but if it works, I'm more than happy to remove my "hack" again.

@cfraenkel I've pushed a change. If you want, you can give it a try with the help of https://jitpack.io/#dasniko/testcontainers-keycloak/main-SNAPSHOT

Thanks for the update. I've tested the jitpack version and it works as expected - I can now exclude junit:junit from my build and the class uniqueness check will pass. Furthermore the tests will run / pass too as the junit-mock jar provides all necessary classes for testcontainers to work properly.