Skip to content

MINOR: Migrate TestFooterIntegrity to JUnit 5 and AssertJ - #3878

Open
NopeCharon wants to merge 1 commit into
apache:masterfrom
NopeCharon:junit5-footer-integrity-test
Open

NopeCharon wants to merge 1 commit into
apache:masterfrom
NopeCharon:junit5-footer-integrity-test

Conversation

@NopeCharon

Copy link
Copy Markdown

Rationale for this change

TestFooterIntegrity, added in #3655, uses JUnit 4 (org.junit.Test, Assert.assertFalse, Assert.assertThrows). The enforce-banned-junit4-imports enforcer rule rejects those imports in process-test-sources, so parquet-hadoop and every module built after it fail on master before any test runs. The CI Hadoop 3 workflow has failed on master since ccbc37a.

What changes are included in this PR?

Migrate TestFooterIntegrity to JUnit 5 and AssertJ, following agents/docs/writing-tests.md:

  • org.junit.Test → org.junit.jupiter.api.Test
  • assertFalse(metaData.getBlocks().isEmpty()) → assertThat(metaData.getBlocks()).isNotEmpty()
  • assertThrows(TagVerificationException.class, ...) → assertThatThrownBy(...).isInstanceOf(TagVerificationException.class).hasMessage("Signature mismatch in plaintext footer"). The message check confirms the footer signature check is what rejects the file.

The test still covers the same behavior.

Are these changes tested?

Yes, on JDK 17 with Thrift 0.25.0:

  • ./mvnw -pl parquet-hadoop spotless:check test -Dtest=TestFooterIntegrity: both tests pass, and the banned-imports rule passes.
  • ./mvnw install -DskipTests across the whole default reactor: succeeds. On master it fails in parquet-hadoop with Banned imports detected in TEST code ... TestFooterIntegrity.java.

Are there any user-facing changes?

No. Only a test changes.

TestFooterIntegrity was added in apache#3655 using JUnit 4 (org.junit.Test,
Assert.assertFalse and Assert.assertThrows). Test code in this
repository must use JUnit 5 and AssertJ, and the
enforce-banned-junit4-imports enforcer rule rejects the JUnit 4
imports during process-test-sources. As a result the parquet-hadoop
module, and every build that includes it, currently fails on master
before any test runs.

Switch the test to org.junit.jupiter.api.Test and AssertJ, following
agents/docs/writing-tests.md:

- assert that the footer's block list is not empty with
  assertThat(...).isNotEmpty() instead of assertFalse(isEmpty())
- replace assertThrows with assertThatThrownBy, also checking the
  "Signature mismatch in plaintext footer" message so the test proves
  the rejection comes from the footer signature check

The behavior covered by the test is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant