From 51f505135f8ee4c19d12b729854537cfc6c5d3d8 Mon Sep 17 00:00:00 2001 From: DemchaAV Date: Fri, 3 Jul 2026 13:47:33 +0100 Subject: [PATCH] test: guard the layered template surface against PDFBox and engine leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The layered template packages (templates.core / cv / coverletter / invoice / proposal / data) compose against the canonical DSL and are backend-neutral by construction, but nothing enforced it — the PDFBox-isolation and engine-leak guards both scanned the rest of the public surface while skipping templates. That gap is what let the old CanonicalTemplateComposerPdfBoundaryTest (which only covered the removed templates.support composers) disappear with no replacement. Add document/templates as a scanned root to both existing guards: PdfBackendIsolationGuardTest (no org.apache.pdfbox references) and PublicApiNoEngineLeakTest (no com.demcha.compose.engine imports). The surface is clean today, so both pass; a preset or component that reached for a PDFBox or engine type would now fail the build, naming the file. Tests: ./mvnw verify -pl . — 1378 tests, 0 failures. Verified negatively by injecting a PDFBox reference into a preset and watching the guard fail. --- .../demcha/documentation/PdfBackendIsolationGuardTest.java | 7 +++++-- .../demcha/documentation/PublicApiNoEngineLeakTest.java | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/demcha/documentation/PdfBackendIsolationGuardTest.java b/src/test/java/com/demcha/documentation/PdfBackendIsolationGuardTest.java index d93658bc6..d69f60ed7 100644 --- a/src/test/java/com/demcha/documentation/PdfBackendIsolationGuardTest.java +++ b/src/test/java/com/demcha/documentation/PdfBackendIsolationGuardTest.java @@ -15,8 +15,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Architectural guard that keeps PDFBox out of the canonical document API and - * non-PDF fixed-layout contracts. + * Architectural guard that keeps PDFBox out of the canonical document API, the + * layered template surface, and non-PDF fixed-layout contracts. Templates + * compose against the canonical DSL and must stay backend-neutral, so a preset + * or component that reached for a PDFBox type would fail here. */ class PdfBackendIsolationGuardTest { @@ -34,6 +36,7 @@ class PdfBackendIsolationGuardTest { PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/image"), PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/layout"), PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/snapshot"), + PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/templates"), PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/backend/fixed")); @Test diff --git a/src/test/java/com/demcha/documentation/PublicApiNoEngineLeakTest.java b/src/test/java/com/demcha/documentation/PublicApiNoEngineLeakTest.java index a8a47a220..98d1b5df9 100644 --- a/src/test/java/com/demcha/documentation/PublicApiNoEngineLeakTest.java +++ b/src/test/java/com/demcha/documentation/PublicApiNoEngineLeakTest.java @@ -45,6 +45,7 @@ class PublicApiNoEngineLeakTest { PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/snapshot"), PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/exceptions"), PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/emoji"), + PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/document/templates"), PROJECT_ROOT.resolve("src/main/java/com/demcha/compose/font")); /**