This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new f256d59d3ee CAMEL-22891: fix Corrupted channel error on junit
reporting (#1681)
f256d59d3ee is described below
commit f256d59d3eee63038eeba9478cf3deb2d91bdfaa
Author: Marco Carletti <[email protected]>
AuthorDate: Thu Feb 26 22:13:32 2026 +0100
CAMEL-22891: fix Corrupted channel error on junit reporting (#1681)
---
tests/camel-itest-spring-boot/pom.xml | 11 ++-
.../common/AbstractSpringBootBaseTestSupport.java | 16 ++--
.../common/ArchetypeGenerationExtension.java | 89 +++++++++++-----------
3 files changed, 59 insertions(+), 57 deletions(-)
diff --git a/tests/camel-itest-spring-boot/pom.xml
b/tests/camel-itest-spring-boot/pom.xml
index 2940f43422b..3e76173bfce 100644
--- a/tests/camel-itest-spring-boot/pom.xml
+++ b/tests/camel-itest-spring-boot/pom.xml
@@ -33,7 +33,6 @@
<description>Spring-Boot Camel integration test</description>
<properties>
- <archetype-common-version>3.4.1</archetype-common-version>
<delete-after-test>true</delete-after-test>
<mvn-command>./mvnw</mvn-command>
</properties>
@@ -58,16 +57,16 @@
</dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.apache.maven.archetype</groupId>
- <artifactId>archetype-common</artifactId>
- <version>${archetype-common-version}</version>
- </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-xml</artifactId>
+ <version>${plexus-xml-version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-api</artifactId>
diff --git
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
index 053b964448a..f754efba160 100644
---
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
+++
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/AbstractSpringBootBaseTestSupport.java
@@ -78,7 +78,7 @@ public abstract class AbstractSpringBootBaseTestSupport {
Path projectDir = archetype.getGeneratedProject().getProjectDir();
List<String> command = new ArrayList<>(List.of(
- System.getProperty("mvn-command"), "compile",
"dependency:build-classpath",
+ System.getProperty("mvn-command"), "-q", "compile",
"dependency:build-classpath",
"-DincludeScope=runtime",
"-Dmdep.outputFile=" + CLASSPATH_FILE,
"-B"));
@@ -97,7 +97,7 @@ public abstract class AbstractSpringBootBaseTestSupport {
int exitCode = process.waitFor();
if (exitCode != 0) {
throw new RuntimeException(String.join(" ", command) + " failed
(exit code "
- + exitCode + ") for " + projectDir + ":\n" + output);
+ + exitCode + ") for " + projectDir + ":" +
System.lineSeparator() + output);
}
Path classpathFile = projectDir.resolve(CLASSPATH_FILE);
@@ -313,23 +313,23 @@ public abstract class AbstractSpringBootBaseTestSupport {
StringBuilder message = new StringBuilder();
for (String mismatch : mismatches) {
- message.append("Version mismatch for
").append(mismatch).append(":\n");
+ message.append("Version mismatch for
").append(mismatch).append(":").append(System.lineSeparator());
for (Map.Entry<String, Set<String>> entry :
status.get(mismatch).entrySet()) {
- message.append(" - ").append(entry.getKey()).append(" -->
").append(entry.getValue()).append("\n");
+ message.append(" - ").append(entry.getKey()).append(" -->
").append(entry.getValue()).append(System.lineSeparator());
}
}
StringBuilder warnings = new StringBuilder();
for (String mismatch : potentialMismatches) {
- warnings.append("Potential version mismatch for
").append(mismatch).append(":\n");
+ warnings.append("Potential version mismatch for
").append(mismatch).append(":").append(System.lineSeparator());
for (Map.Entry<String, Set<String>> entry :
status.get(mismatch).entrySet()) {
- warnings.append(" - ").append(entry.getKey()).append(" -->
").append(entry.getValue()).append("\n");
+ warnings.append(" - ").append(entry.getKey()).append(" -->
").append(entry.getValue()).append(System.lineSeparator());
}
}
if (!warnings.isEmpty()) {
String moduleName = inferModuleName(getClass());
- String warningText = "=== Potential version mismatches for " +
moduleName + " ===\n" + warnings;
+ String warningText = "=== Potential version mismatches for " +
moduleName + " ===" + System.lineSeparator() + warnings;
LOG.warn(warningText);
try {
String reportsDir =
System.getProperty("project.build.directory", "target") + "/failsafe-reports";
@@ -342,7 +342,7 @@ public abstract class AbstractSpringBootBaseTestSupport {
}
Assertions.assertTrue(mismatches.isEmpty(),
- "Library version mismatches found in runtime dependencies:\n"
+ message);
+ "Library version mismatches found in runtime dependencies:" +
System.lineSeparator() + message);
}
/**
diff --git
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
index 38778d4eb44..6b57f9b59f1 100644
---
a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
+++
b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/common/ArchetypeGenerationExtension.java
@@ -17,19 +17,11 @@
package org.apache.camel.itest.springboot.common;
import ch.qos.logback.classic.LoggerContext;
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.archetype.ArchetypeGenerationRequest;
-import org.apache.maven.archetype.ArchetypeGenerationResult;
-import org.apache.maven.archetype.generator.ArchetypeGenerator;
+import org.apache.camel.util.FileUtil;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
-import org.codehaus.plexus.DefaultContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusConstants;
-import org.eclipse.aether.DefaultRepositorySystemSession;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -45,6 +37,8 @@ import java.io.Reader;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -101,16 +95,11 @@ public class ArchetypeGenerationExtension implements
BeforeAllCallback, BeforeEa
Files.createDirectories(targetDir);
Path outputDir = Files.createTempDirectory(targetDir,
"archetype-test-");
- DefaultContainerConfiguration config = new
DefaultContainerConfiguration();
- config.setClassPathScanning(PlexusConstants.SCANNING_ON);
- DefaultPlexusContainer container = new
DefaultPlexusContainer(config);
- ArchetypeGenerator generator =
container.lookup(ArchetypeGenerator.class);
-
- String mavenVersion = requireSystemProperty("maven-version");
String archetypeVersion = requireSystemProperty("project-version");
String camelVersion = requireSystemProperty("camel-version");
String springBootVersion =
requireSystemProperty("spring-boot-version");
String mavenCompilerPluginVersion =
requireSystemProperty("maven-compiler-plugin-version");
+ String mavenVersion = requireSystemProperty("maven-version");
File archetypeFile = resolveArchetypeJar(archetypeVersion);
if (!archetypeFile.exists()) {
@@ -118,32 +107,46 @@ public class ArchetypeGenerationExtension implements
BeforeAllCallback, BeforeEa
+ ". Run 'mvn install -pl
archetypes/camel-archetype-spring-boot -am -DskipTests' first.");
}
- Properties additionalProperties = new Properties();
- additionalProperties.setProperty("camel-version", camelVersion);
- additionalProperties.setProperty("spring-boot-version",
springBootVersion);
- additionalProperties.setProperty("maven-compiler-plugin-version",
mavenCompilerPluginVersion);
- additionalProperties.setProperty("maven-version", mavenVersion);
-
- DefaultRepositorySystemSession session =
MavenRepositorySystemUtils.newSession();
- session.setSystemProperties(System.getProperties());
-
- ArchetypeGenerationRequest request = new
ArchetypeGenerationRequest()
- .setArchetypeGroupId(ARCHETYPE_GROUP_ID)
- .setArchetypeArtifactId(ARCHETYPE_ARTIFACT_ID)
- .setArchetypeVersion(archetypeVersion)
- .setGroupId(archetypeConfig.groupId)
- .setArtifactId(archetypeConfig.artifactId)
- .setVersion(archetypeConfig.version)
- .setPackage(archetypeConfig.packageName)
- .setOutputDirectory(outputDir.toString())
- .setProperties(additionalProperties)
- .setRepositorySession(session);
-
- ArchetypeGenerationResult result = new ArchetypeGenerationResult();
- generator.generateArchetype(request, archetypeFile, result);
-
- if (result.getCause() != null) {
- throw result.getCause();
+ // Resolve absolute path to Maven wrapper
+ String mvnwPath = System.getProperty("mvn-command");
+ if (mvnwPath.startsWith("./")) {
+ // Convert relative path to absolute based on
multiModuleProjectDirectory
+ String projectRoot =
System.getProperty("maven.multiModuleProjectDirectory");
+ if (projectRoot != null) {
+ mvnwPath = Path.of(projectRoot,
mvnwPath.substring(2)).toString();
+ }
+ }
+
+ List<String> command = new ArrayList<>(List.of(
+ mvnwPath, "-q", "archetype:generate",
+ "-B",
+ "-DarchetypeGroupId=" + ARCHETYPE_GROUP_ID,
+ "-DarchetypeArtifactId=" + ARCHETYPE_ARTIFACT_ID,
+ "-DarchetypeVersion=" + archetypeVersion,
+ "-DgroupId=" + archetypeConfig.groupId,
+ "-DartifactId=" + archetypeConfig.artifactId,
+ "-Dversion=" + archetypeConfig.version,
+ "-Dpackage=" + archetypeConfig.packageName,
+ "-Dcamel-version=" + camelVersion,
+ "-Dspring-boot-version=" + springBootVersion,
+ "-Dmaven-compiler-plugin-version=" +
mavenCompilerPluginVersion,
+ "-Dmaven-version=" + mavenVersion));
+
+ String localRepo = System.getProperty("maven.repo.local");
+ if (localRepo != null) {
+ command.add("-Dmaven.repo.local=" + localRepo);
+ }
+
+ ProcessBuilder pb = new ProcessBuilder(command)
+ .directory(outputDir.toFile())
+ .redirectOutput(ProcessBuilder.Redirect.DISCARD)
+ .redirectError(ProcessBuilder.Redirect.DISCARD);
+ Process process = pb.start();
+ int exitCode = process.waitFor();
+
+ if (exitCode != 0) {
+ throw new RuntimeException("Archetype generation failed (exit
code "
+ + exitCode + ")");
}
Path projectDir = outputDir.resolve(archetypeConfig.artifactId);
@@ -184,7 +187,7 @@ public class ArchetypeGenerationExtension implements
BeforeAllCallback, BeforeEa
public static void customizeArchetype(Path projectDir, ArchetypeConfig
config) throws Exception {
String mainClassFile = config.getMainClassName() + ".java";
- FileUtils.deleteQuietly(projectDir.resolve("src/test").toFile());
+ FileUtil.removeDir(projectDir.resolve("src/test").toFile());
Path mainJavaDir = projectDir.resolve("src/main/java");
if (Files.exists(mainJavaDir)) {
@@ -281,7 +284,7 @@ public class ArchetypeGenerationExtension implements
BeforeAllCallback, BeforeEa
public void close() throws Exception {
if (Boolean.parseBoolean(System.getProperty("delete-after-test",
"true"))
&& outputDir != null && Files.exists(outputDir)) {
- FileUtils.deleteQuietly(outputDir.toFile());
+ FileUtil.removeDir(outputDir.toFile());
}
}
}