This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 5729a99c327 Fix Camel Jbang TransformTest on Windows
5729a99c327 is described below
commit 5729a99c32766f5ddf6d6e539c9abc65e59f62cc
Author: Aurélien Pupier <[email protected]>
AuthorDate: Tue Jun 3 15:04:26 2025 +0200
Fix Camel Jbang TransformTest on Windows
* one part was a regression for the test introduced with
https://github.com/apache/camel/commit/e732f61286f69bd9aec5802cff8ececf51a78377
. It emphasizes a potential lock remaining on the log file related to
the pid of a process started with Camel Jbang. Solution consists in
reusing the FileUtil method which has been already updated to use
java.nio anyway.
* one part was that it never passed because of end of line not
considered in the test
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../apache/camel/dsl/jbang/core/commands/Run.java | 2 +-
.../dsl/jbang/core/commands/TransformTest.java | 186 +++++++++++----------
2 files changed, 95 insertions(+), 93 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index 4044403564e..524c5abf4b4 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -1571,7 +1571,7 @@ public class Run extends CamelCommand {
// cleanup and delete log file
if (logFile != null) {
- Files.deleteIfExists(logFile);
+ FileUtil.deleteFile(logFile);
}
return main.getExitCode();
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformTest.java
index fbe2ab81005..58535bfc21d 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformTest.java
@@ -1,92 +1,94 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Arrays;
-
-import org.apache.camel.dsl.jbang.core.common.PathUtils;
-import org.apache.camel.util.IOHelper;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import picocli.CommandLine;
-
-class TransformTest {
-
- private Path workingDir;
-
- @BeforeEach
- public void setup() throws IOException {
- Path base = Paths.get("target");
- workingDir = Files.createTempDirectory(base, "camel-transform");
- }
-
- @AfterEach
- public void end() throws IOException {
- // force removing, since deleteOnExit is not removing.
- PathUtils.deleteDirectory(workingDir);
- }
-
- @Test
- public void shouldTransformToYaml() throws Exception {
- Path outPath = workingDir.resolve("transform.yaml");
-
- String[] args = new String[] { "--output=" + outPath.toString() };
- TransformRoute command = createCommand(new String[] {
"src/test/resources/transform.xml" }, args);
- int exit = command.doCall();
- Assertions.assertEquals(0, exit);
-
- Assertions.assertTrue(Files.exists(outPath));
- String data = Files.readString(outPath);
- String expected
- =
IOHelper.stripLineComments(Paths.get("src/test/resources/transform-out.yaml"),
"#", true);
- Assertions.assertEquals(expected, data);
- }
-
- @Test
- public void shouldTransformBlueprintToYaml() throws Exception {
- Path outPath = workingDir.resolve("blueprint.yaml");
-
- String[] args = new String[] { "--output=" + outPath.toString() };
- TransformRoute command = createCommand(new String[] {
"src/test/resources/blueprint.xml" }, args);
- int exit = command.doCall();
- Assertions.assertEquals(0, exit);
-
- Assertions.assertTrue(Files.exists(outPath));
- String data = Files.readString(outPath);
- String expected
- =
IOHelper.stripLineComments(Paths.get("src/test/resources/blueprint-out.yaml"),
"#", true);
- Assertions.assertEquals(expected, data);
- }
-
- private TransformRoute createCommand(String[] files, String... args) {
- TransformRoute command = new TransformRoute(new CamelJBangMain());
-
- CommandLine.populateCommand(command, "--format=yaml");
- if (args != null) {
- CommandLine.populateCommand(command, args);
- }
- command.files = Arrays.asList(files);
- return command;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import org.apache.camel.dsl.jbang.core.common.PathUtils;
+import org.apache.camel.util.IOHelper;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class TransformTest {
+
+ private Path workingDir;
+
+ @BeforeEach
+ public void setup() throws IOException {
+ Path base = Paths.get("target");
+ workingDir = Files.createTempDirectory(base, "camel-transform");
+ }
+
+ @AfterEach
+ public void end() throws IOException {
+ // force removing, since deleteOnExit is not removing.
+ PathUtils.deleteDirectory(workingDir);
+ }
+
+ @Test
+ public void shouldTransformToYaml() throws Exception {
+ Path outPath = workingDir.resolve("transform.yaml");
+
+ String[] args = new String[] { "--output=" + outPath.toString() };
+ TransformRoute command = createCommand(new String[] {
"src/test/resources/transform.xml" }, args);
+ int exit = command.doCall();
+ Assertions.assertEquals(0, exit);
+
+ Assertions.assertTrue(Files.exists(outPath));
+ String data = Files.readString(outPath);
+ String expected
+ =
IOHelper.stripLineComments(Paths.get("src/test/resources/transform-out.yaml"),
"#", true);
+ Assertions.assertEquals(expected, data);
+ }
+
+ @Test
+ public void shouldTransformBlueprintToYaml() throws Exception {
+ Path outPath = workingDir.resolve("blueprint.yaml");
+
+ String[] args = new String[] { "--output=" + outPath.toString() };
+ TransformRoute command = createCommand(new String[] {
"src/test/resources/blueprint.xml" }, args);
+ int exit = command.doCall();
+ Assertions.assertEquals(0, exit);
+
+ Assertions.assertTrue(Files.exists(outPath));
+ String data = Files.readString(outPath);
+ String expected
+ =
IOHelper.stripLineComments(Paths.get("src/test/resources/blueprint-out.yaml"),
"#", true);
+ assertThat(data).isEqualToIgnoringNewLines(expected);
+ }
+
+ private TransformRoute createCommand(String[] files, String... args) {
+ TransformRoute command = new TransformRoute(new CamelJBangMain());
+
+ CommandLine.populateCommand(command, "--format=yaml");
+ if (args != null) {
+ CommandLine.populateCommand(command, args);
+ }
+ command.files = Arrays.asList(files);
+ return command;
+ }
+
+}