Skip to content

Move tests to their recipe's package and name them after it (K10 of #1330) - #1358

Merged
timtebeek merged 4 commits into
mainfrom
tim/k10-test-packages
Oct 25, 2026
Merged

timtebeek merged 4 commits into
mainfrom
tim/k10-test-packages

Conversation

@timtebeek

Copy link
Copy Markdown
Member

Addresses K10 of #1330. Several tests sat in a different package from their recipe, or were named after a recipe other than the one they run. That makes them hard to find from the recipe, and in a few cases hid that the named sub-recipe wasn't tested on its own. Only test sources change.

Moves (git mv, so history follows; package declarations updated, and AddTableGeneratorTest no longer needs its import):

  • javaee/AddTableGeneratorTest and maven/MigrateJaxwsMavenPluginTest go to javax
  • javaee/ApacheDefaultProviderTest and ServletIsRequestedSessionIdFromURLTest go to javaee8
  • javaee/OpenJPAPersistenceProviderTest goes to javaee7
  • lang/MigrateZipErrorToZipExceptionTest goes to the root package
  • HttpSessionInvalidateTest was already in javax on main, so I skipped it.

Renames and retargets. Where the named recipe exists, I checked whether the test could run it directly with the same expected output:

  • NoGuavaPredicatesEqualToTest and NoGuavaSetsFilterTest are folded into NoGuavaTest, since both run NoGuava and these really are integration tests. I tried running NoGuavaPredicatesEqualTo and NoGuavaSetsFilter directly and 5 of 6 tests fail. Both rely on PreferJavaUtilPredicate to swap the Predicate import, and the equalTo cases also need NoGuavaPredicatesAndOr. Run alone, NoGuavaPredicatesEqualTo returns a java.util.function.Predicate where a Guava Predicate is declared, which doesn't compile; that may be worth a separate look. The two moved @DocumentExamples are dropped, so NoGuavaTest keeps one.
  • JakartaXmlBindRuntimeTest becomes AddJakartaXmlBindRuntimeTest, with AddJakartaXmlBindRuntime as the default recipe (8 of its 11 tests already overrode to it). The three end-to-end cases, including the document example, still run JavaxXmlBindMigrationToJakartaXmlBind explicitly.
  • UpdateAnnotationAttributeJavaxToJakartaTest becomes JakartaEE10AnnotationAttributesTest. I didn't retarget it: the javax to jakarta package change comes from JakartaEE10, and UpdateAnnotationAttributeJavaxToJakarta only rewrites literals on annotations that are already jakarta, so every expected output would change.
  • UpgradeSpringBootForJava25Test becomes UpgradeSpringBootParentForJava25Test and now runs UpgradeSpringBootParentForJava25 instead of UpgradePluginsForJava25. Outputs are unchanged, and the document example still checks that UpgradeToJava25 includes it.
  • MigrateJaxwsMavenPluginTest becomes MigrateJaxBWSPluginTest, after the javax.MigrateJaxBWSPlugin recipe it runs.
  • MigrateInflaterDeflaterToAutoCloseableTest becomes MigrateInflaterDeflaterToCloseTest, UseThreadsOrExecutorsTest becomes FindVirtualThreadOpportunitiesTest, and UseVarForObjectsTest becomes UseVarForObjectTest. These are renames only.
  • ConvertToLogAnnotationTest becomes UseSlf4jTest. Its single Log4j2, JUL, JBoss and Commons Logging cases move into UseLog4j2Test, UseLogTest, UseJBossLogTest and UseCommonsLogTest, one per recipe, each with its own document example.
  • ConvertAnyLogTest becomes UseLombokLogAnnotationsTest. It wasn't on the list, but it had the same problem.

recipeFromResources: UseVarKeywordTest, JavaLangAPIsTest and PreferJavaUtilOptionalTest no longer use Environment.builder().scanRuntimeClasspath(..). PreferJavaUtilOptionalTest also moves from all of NoGuava to PreferJavaUtilOptional; the one case that needs the Supplier type change adds PreferJavaUtilSupplier. Its second @DocumentExample sat on an @ExpectedToFail test, which is why examples.yml currently shows a wrong "after", so I dropped it.

For reviewers:

  • UseVarForObjectsTest and UseVarKeywordTest are also being edited in K11. Here they only get the rename and the loading change, so git's rename detection should keep a rebase simple.
  • examples.yml still names the old test classes. I left it alone because the best-practices automation regenerates it.
  • UseVarKeywordTest runs UseVar, so it's misnamed too. I left the name alone to avoid colliding with K11.

Verification: ./gradlew test for every moved, renamed, split or reloaded class (all of lombok.log, javaee7, javaee8, NoGuavaTest, AddJakartaXmlBindRuntimeTest, JakartaEE10AnnotationAttributesTest, UpgradeSpringBootParentForJava25Test, MigrateInflaterDeflaterToCloseTest, FindVirtualThreadOpportunitiesTest, UseVarForObjectTest, AddTableGeneratorTest, MigrateJaxBWSPluginTest, MigrateZipErrorToZipExceptionTest, UseVarKeywordTest, JavaLangAPIsTest, PreferJavaUtilOptionalTest). 165 tests ran with 0 failures; the 6 skipped are existing @Disabled/@ExpectedToFail tests.

`AddTableGeneratorTest` and `MigrateJaxwsMavenPluginTest` move to `javax`,
`ApacheDefaultProviderTest` and `ServletIsRequestedSessionIdFromURLTest` to
`javaee8`, `OpenJPAPersistenceProviderTest` to `javaee7`, and
`MigrateZipErrorToZipExceptionTest` to the root package.
Rename tests whose class name pointed at a different recipe, and retarget
`UpgradeSpringBootParentForJava25Test` and `AddJakartaXmlBindRuntimeTest` at
the recipe they mostly exercise, keeping the end-to-end cases on the composite.

Split the Log4j2, JUL, JBoss and Commons Logging cases out of `UseSlf4jTest`
into one test class per recipe, and fold the `NoGuava` integration tests for
`Predicates.equalTo` and `Sets.filter` into `NoGuavaTest`: their sub-recipes on
their own produce different output.
Replace `Environment.builder().scanRuntimeClasspath(..)` in `UseVarKeywordTest`,
`JavaLangAPIsTest` and `PreferJavaUtilOptionalTest`.

`PreferJavaUtilOptionalTest` now runs `PreferJavaUtilOptional` rather than all
of `NoGuava`; the one case that also relies on the `Supplier` type change adds
`PreferJavaUtilSupplier`. Drop the second `@DocumentExample`, which sat on an
`@ExpectedToFail` test.
@timtebeek
timtebeek merged commit 72b3f06 into main Oct 25, 2026
2 checks passed
@timtebeek
timtebeek deleted the tim/k10-test-packages branch October 25, 2026 12:26
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant