dasniko / testcontainers-keycloak

A Testcontainer implementation for Keycloak IAM & SSO.
Apache License 2.0
328 stars 51 forks source link

Not enough / duplicate Junit Classes in Jar #55

Closed cfraenkel closed 2 years ago

cfraenkel commented 2 years ago

I've tried updating to 2.0 of testcontainers-keycloak and stumbled over the now included junit4 classes (b3ce4dccc074cffb528f3ec395a91513c28f992d) . 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: https://github.com/testcontainers/testcontainers-java/issues/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.

dasniko commented 2 years ago

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.

dasniko commented 2 years ago

@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

cfraenkel commented 2 years ago

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.