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 migration WIP #3684

Closed
wants to merge 49 commits into from
Closed

JUnit migration WIP #3684

wants to merge 49 commits into from

Conversation

tduehr
Copy link
Contributor

@tduehr tduehr commented Dec 5, 2018

Complete the migration from junit4 to junit5.

This is a big patch that can't be broken up very well to implement it in individual modules so I organized it in discrete steps. Each commit is a different step in the process. This has been continuously rebased against master and to push missed changes into the correct commit.

  1. Add checkstyle rules
  2. Automated translations
    - All of the migrations that IDEA can perform automatically: @BeforeClass -> @BeforeAll, @After -> @AfterEach, org.junit.Test -> org.junit.jupiter.api.Test, etc.
  3. Remove Spring rules
    - @Rule is no longer supported and the functionality to be implemented using the Extension interface.
    - In Junit 5, the required SpringExtension is inherited by SpringBootTest and so is almost universally already applied.
  4. Migrate conditional test execution annotations.
    - Junit 5 has native support for enabling and disabling tests based on runtime conditions.
    - Adds (Disabled|Enabled)IfContinuousIntegration to replace @ConditionalIgnore(condition = RunningConditionalIntegrationCondition.class)
    - Adds EnabledIfStandalone to replace the not CI condition. Runs the test iff an environment variable STANDALONE is set to 'true'. This is for tests that are only run locally by a single maintainer. To be replaced by EnabledIfSystemProperty in a later commit.
    - Adds EnabledIfPortOpen to fulfill the other parameter of the old continuous integration condition. Runs the test if something is listening on the given port.
  5. org.junit.Assert to org.junit.jupiter.api.Assertions
    - Most of this just changing the import
    - The order of arguments for the assertions with messages has changed.
    - This also removes assertj dependency and reduces hamcrest use.
  6. Custom wrappers for assertThrows and assertDoesNotThrow
    - Adds org.apereo.cas.util.Assertions.
    - assertHasRootCause - assertThrows with a type check for the root cause of the thrown exception. - assertThrowsOrNot- WrapsassertThrowsandassertDoesNotThrowIf an exception is given, the thrown exception is verified against it. Ifnull` is passed, the block is expected not to throw.
  7. ExpectedException rule to org.junit.jupiter.api.Assertions.assertThrows
    - More explicit interface for expecting exceptions: wrap a statement that should throw an exception in a lambda.
    - Can be a little clunky when dealing with checked exceptions because lambdas are not declared as throwing Exception (somewhat handled in a later commit).
  8. Fixes a couple tests that broke along the way.
  9. Migrates from Spring specific IfProfileValue to Junit 5 EnabledIfSystemProperty.
    - May be used to enable specific tests on an individual basis. Exactly the same use case as EnabledIfStandalone. This will replace EnabledIfStandalone` in a later commit.
  10. Moves a block of tests to use assertAll
  11. Mockito rule migration
    - Replaces the Mockito rule with MockitoExtension.
  12. Fixes test gradle tasks to use defaults for finding tests. Older method was excluding a test class.
    - Abstract classes and interfaces are ignored for tests, sets two classes to be abstract to account for the change.
  13. Test suite class migration.
    - Both @Suite and @RunWith are deprecated.
    - Switch to @SelectClasses
  14. CouchDB tests get moved to @Tag from @Category and removes the CouchDb category class.
  15. Refactor ticket registry parameterized testing.
    - Parameter is required in test initializer (@BeforeEach).
    -@ParameterizedTest does not make the argument available to lifecycle callbacks.
    -@RepeatedTest used instead to pull arguments from array.
    - Most significant changes are made to BaseTicketRegistryTests. Most other changes are cleaning up the old references.
  16. Refactor service registry parameterized testing.
    - Parameter is only needed in tests.
    - Uses @ParameterizedTest for testing with the parameters.
    - Changes existing parameter method to work with @ParameterizedTest.
    - Most significant changes are in AbstractServiceRegistryTests.
    - Adds SAML, OAuth, WS, and OIDC as test dependencies to all service registry modules.
    - All registry implementations are now tested against all registered service types.
  17. Refactor RegexRegisteredService parameterized testing.
    - Inlines lifecycle callback so @ParameterizedTest may be used.
  18. Refactor CRL parameterized testing.
    - Renames AbstractCRLRevocationCheckerTests to BaseCRLRevocationCheckerTests as it's no longer abstract (no abstract methods)
    - Inlines AbstractCRLRevocationCheckerTests constructor to use @ParameterizedTest.
  19. Refactor x509 parameterized testing.
  20. Enable import rule enforcement.
  21. Fix tests in AbstractRegisteredServiceTests that started running and failing after 10.
  22. Refactors and corrects tests.gradle so tests run properly again.
  23. Fixes DefaultCasAttributeEncoderTests
  24. Cassandra category to tag.
  25. File system category to tag.
  26. Restful category to tag.
  27. AWS category to tag.
  28. CosmosDb category to tag.
  29. Couchbase category to tag.
  30. DynamoDb category to tag.
  31. Ignite category to tag.
  32. Influx category to tag.
  33. Ldap category to tag.
  34. Mail category to tag.
  35. MariaDb category to tag.
  36. Memcached category to tag.
  37. MongoDb category to tag.
  38. MS SQL Server category to tag.
  39. MySQL category to tag.
  40. Postgres category to tag.
  41. RADIUS category to tag.
  42. Redis category to tag.
  43. Final clean up of category logic.
  44. Fixes LDAP tests.
    - JUnit5 runtime changes were overloading the test LDAP server.
  45. Fixes Couchbase tests.
    - TKTK

@apereocas-bot apereocas-bot added this to the 6.0.0 milestone Dec 5, 2018
@mmoayyed mmoayyed modified the milestones: 6.0.0, 6.1.0-RC1 Dec 5, 2018
@tduehr tduehr force-pushed the junit_migration branch 5 times, most recently from cc52dc8 to ab14007 Compare December 12, 2018 21:49
@codecov
Copy link

codecov bot commented Dec 12, 2018

Codecov Report

Merging #3684 into master will decrease coverage by 2.8%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3684      +/-   ##
============================================
- Coverage     33.95%   31.15%   -2.81%     
+ Complexity     2718     2503     -215     
============================================
  Files          1163     1163              
  Lines         24771    24728      -43     
  Branches       2228     2224       -4     
============================================
- Hits           8411     7703     -708     
- Misses        15455    16222     +767     
+ Partials        905      803     -102
Impacted Files Coverage Δ Complexity Δ
...entication/policy/RestfulAuthenticationPolicy.java 0% <0%> (-46.43%) 0 <0> (-3)
...rvices/CouchbaseRegisteredServiceDeletedEvent.java 0% <0%> (-100%) 0% <0%> (-1%)
...as/impl/token/BasePasswordlessTokenRepository.java 0% <0%> (-100%) 0% <0%> (-1%)
...services/CouchbaseRegisteredServiceSavedEvent.java 0% <0%> (-100%) 0% <0%> (-1%)
...reo/cas/util/gen/DefaultRandomNumberGenerator.java 0% <0%> (-100%) 0% <0%> (-3%)
...pereo/cas/pm/PasswordResetTokenCipherExecutor.java 0% <0%> (-100%) 0% <0%> (-4%)
...pereo/cas/adaptors/rest/RestAuthenticationApi.java 0% <0%> (-100%) 0% <0%> (-2%)
...g/apereo/cas/audit/CouchbaseAuditTrailManager.java 0% <0%> (-100%) 0% <0%> (-5%)
...cas/authentication/principal/PrincipalFactory.java 0% <0%> (-100%) 0% <0%> (-1%)
...as/impl/token/PasswordlessTokenCipherExecutor.java 0% <0%> (-100%) 0% <0%> (-4%)
... and 94 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08b92fb...29d4254. Read the comment docs.

@tduehr tduehr force-pushed the junit_migration branch 5 times, most recently from 33f440c to cb3ba8c Compare December 14, 2018 19:39
@mmoayyed
Copy link
Member

Heads up: this will need to be broken out into much smaller individual PRs before it can be merged. It is impossible to review, understand and/or maintain what's going on in 800+ files.

@CLAassistant
Copy link

CLAassistant commented Dec 17, 2018

CLA assistant check
All committers have signed the CLA.

@tduehr tduehr force-pushed the junit_migration branch 2 times, most recently from 995bf83 to 7f64d72 Compare December 20, 2018 19:04
@stale
Copy link

stale bot commented Dec 27, 2018

This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added Pending and removed Pending labels Dec 27, 2018
@stale
Copy link

stale bot commented Jan 1, 2019

This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Pending label Jan 1, 2019
@mmoayyed mmoayyed changed the title Junit migration WIP JUnit migration WIP Jan 3, 2019
@stale stale bot removed the Pending label Jan 3, 2019
@tduehr tduehr force-pushed the junit_migration branch 3 times, most recently from 65b3d96 to ddaf337 Compare January 8, 2019 01:30
@stale
Copy link

stale bot commented Jan 14, 2019

This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Feb 3, 2019

This patch has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Feb 9, 2019

This patch has been automatically closed because it has not had recent activity. If you wish to resume work, please re-open the pull request and continue as usual. Thank you for your contributions.

@stale stale bot closed this Feb 9, 2019
@tduehr tduehr deleted the junit_migration branch February 10, 2019 01:29
@tduehr
Copy link
Contributor Author

tduehr commented Feb 10, 2019

broken up into several commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants