Skip to content

Conversation

sbrannen
Copy link
Member

@sbrannen sbrannen commented Sep 7, 2025

Overview

org.junit.jupiter.api.extension.MediaType currently causes cycles between the api and api.extension packages in junit-jupiter-api.

Since the junit-jupiter-api artifact constitutes the public API for JUnit Jupiter, we have traditionally not allowed package cycles within that artifact.

Thus, in order to reduce package cycles and improve the quality of the code base, this PR introduces a new MediaType in the org.junit.jupiter.api package. Note that the existing MediaType now extends the new MediaType.

To encourage users to migrate to the new supported MediaType this commit also introduces the following deprecations.

  • org.junit.jupiter.api.extension.MediaType is now deprecated in favor of the new org.junit.jupiter.api.MediaType.
  • The publishFile(...) methods in TestReporter which accept an org.junit.jupiter.api.extension.MediaType are now deprecated in favor of new variants which accept an org.junit.jupiter.api.MediaType.
  • The publishFile(...) method in ExtensionContext which accepts an org.junit.jupiter.api.extension.MediaType is now deprecated in favor of a new variant which accepts an org.junit.jupiter.api.MediaType.

Furthermore, we plan to remove the deprecated MediaType in JUnit 6.2.

Related Issues

@sbrannen sbrannen force-pushed the issues/4886-jupiter.api.MediaType branch from ef2e5db to e9d4fe4 Compare September 12, 2025 12:26
@sbrannen sbrannen force-pushed the issues/4886-jupiter.api.MediaType branch 3 times, most recently from 98300a4 to 26a3691 Compare September 13, 2025 12:10
Copy link
Member

@marcphilipp marcphilipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the missing release notes entry.

org.junit.jupiter.api.extension.MediaType currently causes cycles
between the `api` and `api.extension` packages in junit-jupiter-api.

Since the junit-jupiter-api artifact constitutes the public API for
JUnit Jupiter, we have traditionally not allowed package cycles within
that artifact.

Thus, in order to reduce package cycles and improve the quality of the
code base, this commit introduces a new MediaType in the
org.junit.jupiter.api package. Note that the existing MediaType now
extends the new MediaType.

To encourage users to migrate to the new supported MediaType this
commit also introduces the following deprecations.

* `org.junit.jupiter.api.extension.MediaType` is now deprecated in
  favor of the new `org.junit.jupiter.api.MediaType`.

* The `publishFile(...)` methods in `TestReporter` which accept an
  `org.junit.jupiter.api.extension.MediaType` are now deprecated in
  favor of new variants which accept an
  `org.junit.jupiter.api.MediaType`.

* The `publishFile(...)` method in `ExtensionContext` which accepts an
  `org.junit.jupiter.api.extension.MediaType` is now deprecated in
  favor of a new variant which accepts an
  `org.junit.jupiter.api.MediaType`.

Furthermore, we plan to remove the deprecated MediaType in JUnit 6.2.

See junit-team#4876
Closes junit-team#4886
@sbrannen sbrannen force-pushed the issues/4886-jupiter.api.MediaType branch from 26a3691 to 9990349 Compare September 13, 2025 14:14
@sbrannen sbrannen marked this pull request as ready for review September 13, 2025 14:15
@sbrannen
Copy link
Member Author

Looks good except for the missing release notes entry.

I just added that and also made a final pass over the change set, polishing a bit along the way.

So, feel free to take another look...

@sbrannen sbrannen merged commit 135c4ec into junit-team:main Sep 13, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relocate MediaType to jupiter.api package and deprecate existing class
2 participants