You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "reswqa (via GitHub)" <gi...@apache.org> on 2023/06/25 06:48:42 UTC

[GitHub] [iceberg] reswqa opened a new pull request, #7906: Dell: Migrate tests in dell to junit5

reswqa opened a new pull request, #7906:
URL: https://github.com/apache/iceberg/pull/7906

   Migrate test class using junit4 `@Rule` or `@ClassRule` in dell package to Junit5. 
   
   This fixed #7888.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa closed pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa closed pull request #7906: Dell: Migrate TestRules to JUnit5
URL: https://github.com/apache/iceberg/pull/7906


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa commented on a diff in pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1250093257


##########
common/src/main/java/org/apache/iceberg/common/testutils/PerTestCallbackWrapper.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * This class is used to wrap a specific {@link CustomExtension} to junit5 extension with test-level
+ * callbacks {@link BeforeEachCallback} and {@link AfterEachCallback}. It can be used as a
+ * substitute for @Rule in junit4.
+ */
+public class PerTestCallbackWrapper<C extends CustomExtension>

Review Comment:
   Thank you for your reply, but I still have some doubts:
   
   If we implement both `beforeAllCallback` and `beforeEachCallback` for `EcsS3MockExtension` and register it using `static` field, then both `beforeEach` and `beforeAll` will be invoked(`class level` and `method level` respectively). If it is registered using a `non-static field`, only `beforeEach` will be called at the `method level`. 
   
   Is my usage incorrect? Is there any way we can avoid calling `method level` methods during static registration (which corresponds to `@ClassRule` in junit4).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] snazy commented on a diff in pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1248763133


##########
build.gradle:
##########
@@ -337,6 +337,7 @@ project(':iceberg-api') {
 project(':iceberg-common') {
   dependencies {
     implementation project(path: ':iceberg-bundled-guava', configuration: 'shadow')
+    implementation 'org.junit.jupiter:junit-jupiter'

Review Comment:
   JUnit is a test dependency, should not added to production ("main") code



##########
dell/src/test/java/org/apache/iceberg/dell/ecs/TestEcsCatalog.java:
##########
@@ -41,36 +42,39 @@
 import org.apache.iceberg.relocated.com.google.common.collect.Maps;
 import org.apache.iceberg.types.Types;
 import org.assertj.core.api.Assertions;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-public class TestEcsCatalog {

Review Comment:
   Let's not change the visibility in this PR, it's not necessary.



##########
common/src/main/java/org/apache/iceberg/common/testutils/PerTestCallbackWrapper.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * This class is used to wrap a specific {@link CustomExtension} to junit5 extension with test-level
+ * callbacks {@link BeforeEachCallback} and {@link AfterEachCallback}. It can be used as a
+ * substitute for @Rule in junit4.
+ */
+public class PerTestCallbackWrapper<C extends CustomExtension>

Review Comment:
   Agree with @nastra here. `EcsS3MockExtension` should be the only JUnit extension. JUnit allows injection - for static fields, instance fields and test parameters. Also, `ExtensionContext` in JUnit is hierarchical (root, ..., test class, test instance, test method, etc).
   
   BTW test code must not end in production ("main") code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] snazy commented on a diff in pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1250498663


##########
common/src/main/java/org/apache/iceberg/common/testutils/PerTestCallbackWrapper.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * This class is used to wrap a specific {@link CustomExtension} to junit5 extension with test-level
+ * callbacks {@link BeforeEachCallback} and {@link AfterEachCallback}. It can be used as a
+ * substitute for @Rule in junit4.
+ */
+public class PerTestCallbackWrapper<C extends CustomExtension>

Review Comment:
   I think, your understanding is not correct.
   The JUnit docs have good information about how that works: https://junit.org/junit5/docs/current/user-guide/#extensions-registration



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa commented on a diff in pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1244732356


##########
common/src/main/java/org/apache/iceberg/common/testutils/PerTestCallbackWrapper.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * This class is used to wrap a specific {@link CustomExtension} to junit5 extension with test-level
+ * callbacks {@link BeforeEachCallback} and {@link AfterEachCallback}. It can be used as a
+ * substitute for @Rule in junit4.
+ */
+public class PerTestCallbackWrapper<C extends CustomExtension>

Review Comment:
   If the `EcsS3MockExtension` implements both `BeforeEachCallback ` and `BeforeAllCallback `, then the lifecycle method like `initialize` of `EcsS3MockRule ` will be invoked double times.  Junit4 `TestRule` can take care of this by annotation with `@Rule` or `@ClassRule` respectively. As for Junit5, we can only register extension with single annotation `@RegisterExtension`. `PerTestCallbackWrapper ` and `PerClassCallbackWrapper ` is used to control the lifecycle of `initialize`(`before all` or `before each`).
   
   The core is to implement an `CustomExtension` similar to `TestRule`, and then select the appropriate `PerTest/PerClassCallBackWrapper` to wrap it based on the actual life cycle required for testing.
   
   The reason for introducing `CustomExtension` is for future extends. Of course, we may only need to migrate this `EcsS3TestRule` to Junit5 temporarily, but I think it is worth it. 🤔 
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa commented on pull request #7906: Dell: Migrate tests in dell to junit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#issuecomment-1605900939

   Format violations caused by #7872.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa commented on pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#issuecomment-1610689375

   Hi @nastra, I have rebased this on the latest master branch as #7872 has been merged, so it is reviewable atm. Would you mind taking a look at this in your free time, thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa commented on a diff in pull request #7906: Dell: Migrate tests in dell to junit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1241063700


##########
common/src/main/java/org/apache/iceberg/common/testutils/CustomExtension.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * An extension that is invoked before/after all/each tests, depending on whether it is wrapped in a
+ * {@link PerTestCallbackWrapper} or {@link PerClassCallbackWrapper}.
+ *
+ * <p>{@code before} method will be called in {@code beforeEach} or {@code beforeAll}. {@code after}
+ * will be called in {@code afterEach} or {@code afterAll}.
+ *
+ * <p>Usage example:
+ *
+ * <pre><code>
+ * public class Test{
+ *      {@literal @}RegisterExtension
+ *      static PerClassCallbackWrapper classCallbackWrapper = new PerClassCallbackWrapper(customExtension);
+ *      {@literal @}RegisterExtension
+ *      PerTestCallbackWrapper testCallbackWrapper = new PerTestCallbackWrapper(customExtension);
+ * }
+ * }</code></pre>
+ */
+public interface CustomExtension {

Review Comment:
   I'm not sure witch module these test utils should be placed as not familiar with the code base.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] nastra commented on a diff in pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1244717682


##########
common/src/main/java/org/apache/iceberg/common/testutils/PerTestCallbackWrapper.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * This class is used to wrap a specific {@link CustomExtension} to junit5 extension with test-level
+ * callbacks {@link BeforeEachCallback} and {@link AfterEachCallback}. It can be used as a
+ * substitute for @Rule in junit4.
+ */
+public class PerTestCallbackWrapper<C extends CustomExtension>

Review Comment:
   why do we need `PerTestCallbackWrapper` and `PerClassCallbackWrapper`? I think all of the logic should just go into `EcsS3MockExtension` and only implement `BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback`. Also I don't see a reason for having `CustomExtension`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa commented on a diff in pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1250513092


##########
common/src/main/java/org/apache/iceberg/common/testutils/PerTestCallbackWrapper.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * This class is used to wrap a specific {@link CustomExtension} to junit5 extension with test-level
+ * callbacks {@link BeforeEachCallback} and {@link AfterEachCallback}. It can be used as a
+ * substitute for @Rule in junit4.
+ */
+public class PerTestCallbackWrapper<C extends CustomExtension>

Review Comment:
   I just writing an example to verify this as following: 
   
   Define the extension:
   ```java
   public class TestExtension
       implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
   
     public void afterAll(ExtensionContext context) throws Exception {
       System.out.println("after all");
     }
   
     public void afterEach(ExtensionContext context) throws Exception {
       System.out.println("after each");
     }
   
     public void beforeAll(ExtensionContext context) throws Exception {
       System.out.println("before all");
     }
   
     @Override
     public void beforeEach(ExtensionContext context) throws Exception {
       System.out.println("before each");
     }
   }
   ```
   
   Test Class:
   ```java
   class ExtensionTest {
     @RegisterExtension static TestExtension testExtension = new TestExtension();
   
     @Test
     void test1() {
       System.out.println("test1");
     }
   
     @Test
     void test2() {
       System.out.println("test2");
     }
   }
   ```
   
   The output is:
   ```java
   before all
   before each
   test1
   after each
   before each
   test2
   after each
   after all
   ```
   
   And If I directly use the `ExtendWith` annotation instead of static `RegisterExtension`, the output is also the same.
   ```java
   @ExtendWith(TestExtension.class)
   class ExtensionTest {}
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] reswqa commented on a diff in pull request #7906: Dell: Migrate TestRules to JUnit5

Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on code in PR #7906:
URL: https://github.com/apache/iceberg/pull/7906#discussion_r1250513092


##########
common/src/main/java/org/apache/iceberg/common/testutils/PerTestCallbackWrapper.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.common.testutils;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * This class is used to wrap a specific {@link CustomExtension} to junit5 extension with test-level
+ * callbacks {@link BeforeEachCallback} and {@link AfterEachCallback}. It can be used as a
+ * substitute for @Rule in junit4.
+ */
+public class PerTestCallbackWrapper<C extends CustomExtension>

Review Comment:
   I just writing an example to verify this as following: 
   
   Define the extension:
   ```
   public class TestExtension
       implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
   
     public void afterAll(ExtensionContext context) throws Exception {
       System.out.println("after all");
     }
   
     public void afterEach(ExtensionContext context) throws Exception {
       System.out.println("after each");
     }
   
     public void beforeAll(ExtensionContext context) throws Exception {
       System.out.println("before all");
     }
   
     @Override
     public void beforeEach(ExtensionContext context) throws Exception {
       System.out.println("before each");
     }
   }
   ```
   
   Test Class:
   ```
   class ExtensionTest {
     @RegisterExtension static TestExtension testExtension = new TestExtension();
   
     @Test
     void test1() {
       System.out.println("test1");
     }
   
     @Test
     void test2() {
       System.out.println("test2");
     }
   }
   ```
   
   The output is:
   ```
   before all
   before each
   test1
   after each
   before each
   test2
   after each
   after all
   ```
   
   And If I directly use the `ExtendWith` annotation instead of static `RegisterExtension`, the output is also the same.
   ```
   @ExtendWith(TestExtension.class)
   class ExtensionTest {}
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org