lintingbin opened a new pull request, #4205:
URL: https://github.com/apache/amoro/pull/4205

   ## What is this PR for?
   
   Closes part of #4203 (Step 3 — `amoro-format-iceberg`). 49 test files 
migrated to JUnit Jupiter, including 15 `@RunWith(Parameterized.class)` classes 
rewritten as `@ParameterizedTest @MethodSource` per @czy006's preference 
expressed on #4004.
   
   ## Dual-mode test bases (the central design decision)
   
   `CatalogTestBase`, `TableTestBase`, and `TableDataTestBase` are still 
extended by ~19 JUnit 4 `@RunWith(Parameterized.class)` subclasses in 
`amoro-format-mixed-hive` and `amoro-ams` that Steps 4 and 8 of #4203 will 
migrate later. Migrating them now would either force a 200+ file mega-PR or 
drop into the same trap as #4004. Instead, this PR keeps the JUnit 4 surface 
intact and adds a parallel JUnit 5 surface:
   
   - The original `(CatalogTestHelper, TableTestHelper)` constructor and 
`@Before setupCatalog()` / `@Before setupTable()` are preserved — JUnit 4 
Parameterized callers continue to work unchanged.
   - A no-arg constructor is added.
   - New `protected void setupCatalog(CatalogTestHelper)` / `protected void 
setupTable(CatalogTestHelper, TableTestHelper)` entry points let JUnit 5 
callers initialise the catalog/table state explicitly from their 
`@ParameterizedTest` method body.
   - `@ClassRule TestAms` and `@Rule TemporaryFolder` are kept for the JUnit 4 
path. For the JUnit 5 path we add `@BeforeAll startTestAms()` / `@AfterAll 
stopTestAms()` calling the public `before()` / `after()` of `TestAms` directly, 
and the `TemporaryFolder` is initialised manually inside `setupCatalog(helper)` 
because JUnit 4 `@Rule` does not fire under the JUnit Platform engine.
   
   Cross-module compile is verified: `mvn -pl amoro-format-mixed-hive,amoro-ams 
-am test-compile` builds cleanly. All this dual plumbing is removed in the 
closing PR of #4203.
   
   ## Files intentionally kept on JUnit 4 in this PR
   
   - `TestMixedCatalog`, `TestTaskReader`, `TestTaskWriter`, 
`TestTableTrashManagers` — same dual-mode reasoning, they are subclassed by 
`TestMixedHiveCatalog`/`TestHiveTaskReader`/`TestHiveTaskWriter`/`TestHiveTableTrashManagers`
 in mixed-hive.
   - `TestIcebergAmoroCatalog`, `TestMixedIcebergFormatCatalog` — extend 
`TestAmoroCatalogBase` in `amoro-common`, which the umbrella plan keeps on 
JUnit 4 until the closing PR.
   
   ## Parameterized rewrite template
   
   ```java
   public class TestX extends TableTestBase {
     public static Stream<Arguments> parameters() {
       return Stream.of(Arguments.of(c1, t1), Arguments.of(c2, t2), ...);
     }
   
     @ParameterizedTest(name = "{0}, {1}")
     @MethodSource("parameters")
     public void testFoo(CatalogTestHelper c, TableTestHelper t) throws 
Exception {
       setupTable(c, t);
       // existing body
     }
   }
   ```
   
   `TestIcebergFindFiles` is a small exception: its parent 
`org.apache.iceberg.TestBase` (Iceberg 1.7.2) is already JUnit 5 native, so it 
migrates to `@TestTemplate` + `ParameterizedTestExtension` to match upstream's 
pattern.
   
   ## Other mechanical changes
   
   - `org.junit.*` → `org.junit.jupiter.api.*`
   - `@Before` / `@After` → `@BeforeEach` / `@AfterEach`
   - `Assert.assertX(...)` → `Assertions.assertX(...)` with corrected 
message-arg order (JUnit 4's leading-message position flips to trailing in 
JUnit 5)
   - `@Rule TemporaryFolder` → `@TempDir Path` in non-dual-mode files; 
`temp.newFolder()` → `Files.createTempDirectory(temp, "...").toFile()`
   - `@Test(expected = X.class)` → `Assertions.assertThrows(X.class, () -> ...)`
   - `@Ignore` → `@Disabled`
   - `org.junit.Assume` → `Assumptions`
   
   ## Type of change
   
   - [x] Improvement (test infrastructure)
   
   ## How was this patch tested?
   
   - `mvn -pl amoro-format-iceberg -am test` → **501 run, 0 failures, 0 errors, 
5 skipped** (skipped via JUnit 5 `Assumptions.assumeTrue/False`, not failures). 
Both Vintage and Jupiter engines run.
   - `mvn -pl amoro-format-mixed-hive,amoro-ams -am test-compile` → **BUILD 
SUCCESS** (dual-mode contract preserved for downstream Steps 4 / 8).
   - `mvn -pl amoro-format-iceberg spotless:check` clean.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to