From b9e27522384bbb48315e6e1e90a5740de0876042 Mon Sep 17 00:00:00 2001 From: Koen Aers Date: Wed, 10 Sep 2025 17:51:59 +0200 Subject: [PATCH] HBX-3110: Add a functional test to guard the sanity of the Ant examples - Add a test verifying the 'classpath' example Signed-off-by: Koen Aers --- .../hibernate/tool/ant/ExamplesTestIT.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ant/src/it/java/org/hibernate/tool/ant/ExamplesTestIT.java b/ant/src/it/java/org/hibernate/tool/ant/ExamplesTestIT.java index 8c832d3126..3508244e44 100644 --- a/ant/src/it/java/org/hibernate/tool/ant/ExamplesTestIT.java +++ b/ant/src/it/java/org/hibernate/tool/ant/ExamplesTestIT.java @@ -9,7 +9,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.PrintStream; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files; @@ -43,6 +45,23 @@ public void test5MinuteTutorial() throws Exception { assertTrue(personFile.exists()); } + @Test + public void testClasspath() throws Exception { + PrintStream savedOut = System.out; + try { + File buildFile = new File(baseFolder, "classpath/build.xml"); + Project project = createProject(buildFile); + assertNotNull(project); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + assertFalse(out.toString().contains("Hello from Exporter!")); + System.setOut(new PrintStream(out)); + project.executeTarget("reveng"); + assertTrue(out.toString().contains("Hello from Exporter!")); + } finally { + System.setOut(savedOut); + } + } + private Project createProject(File buildXmlFile) throws Exception { Project result = new Project(); ProjectHelper projectHelper = ProjectHelper.getProjectHelper();