-
Notifications
You must be signed in to change notification settings - Fork 1.6k
GH-3873: Deprecate JUnit 4 utilities in the project #3878
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
base: main
Are you sure you want to change the base?
GH-3873: Deprecate JUnit 4 utilities in the project #3878
Conversation
Signed-off-by: chickenchickenlove <[email protected]>
* | ||
*/ | ||
public class Log4j2LevelAdjuster implements MethodRule { | ||
public class Log4j2LevelAdjuster implements InvocationInterceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this class used with Junit5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct.
The class is public and for end-user consumption.
It is totally wrong to change the class contract.
We develop here a library for target projects, so whatever is public
cannot be changed like this.
We have to revert the change here and deprecate it.
We may come up with JUnit 5 variant. But that is a different story.
You may take a inspiration from Spring AMQP: https://github.com/spring-projects/spring-amqp/blob/main/spring-rabbit-junit/src/main/java/org/springframework/amqp/rabbit/junit/LogLevels.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can deprecate it on the 3.3.x
line and then still remove it in 4.0.0. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... That would be inconsistent with Spring Framework plans.
They do deprecate JUnit 4 in version 7.0.
* | ||
*/ | ||
public class Log4j2LevelAdjuster implements MethodRule { | ||
public class Log4j2LevelAdjuster implements InvocationInterceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct.
The class is public and for end-user consumption.
It is totally wrong to change the class contract.
We develop here a library for target projects, so whatever is public
cannot be changed like this.
We have to revert the change here and deprecate it.
We may come up with JUnit 5 variant. But that is a different story.
You may take a inspiration from Spring AMQP: https://github.com/spring-projects/spring-amqp/blob/main/spring-rabbit-junit/src/main/java/org/springframework/amqp/rabbit/junit/LogLevels.java
@@ -378,9 +377,6 @@ project ('spring-kafka-test') { | |||
api 'org.junit.platform:junit-platform-launcher' | |||
optionalApi "org.hamcrest:hamcrest-core:$hamcrestVersion" | |||
optionalApi "org.mockito:mockito-core:$mockitoVersion" | |||
optionalApi ("junit:junit:$junit4Version") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct.
We are talking about deprecation of the utility, but not total removal.
Therefore dependency and deprecated classes must still be here.
Again: we develop library, so whatever we do here might break target projects using our library.
Removing it temporary locally is a good way to check if we still have any JUnit 4 tests left. 😄
@@ -14,7 +14,7 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
package org.springframework.kafka.test.rule; | |||
package org.springframework.kafka.test.extensions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like this class logic does something with log adjustment.
Might be better to move it to some other package.
Probably to the root one alongside with the EmbeddedKafkaKraftBrokerTests
The class that implements
MethodRule
in Junit4 is called whenever each test method is executed.Before executing the test method, it configures the log level.
Then, after executing the test method, it returns the log level back.
Like
MethodRule
in Junit4, the interfaceInvocationInterceptor
in Junit5 providesinterceptTestMethod(...)
.So, I migrated
MethodRule
toInvocationInterceptor
.