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.git


The following commit(s) were added to refs/heads/main by this push:
     new 84257c3afc3 CAMEL-21194: Added unit test
84257c3afc3 is described below

commit 84257c3afc3783c89993f4b07fe39676f66574f2
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Sep 11 08:36:45 2024 +0200

    CAMEL-21194: Added unit test
---
 .../dsl/jbang/core/commands/SourceHelperTest.java  | 45 ++++++++++++++++++++++
 .../camel-jbang-core/src/test/resources/Hey.java   | 32 +++++++++++++++
 .../src/test/resources/hello.camel.yaml            | 28 ++++++++++++++
 .../camel-jbang-core/src/test/resources/hello.yaml | 28 ++++++++++++++
 .../src/test/resources/hi.camel.xml                | 37 ++++++++++++++++++
 .../camel-jbang-core/src/test/resources/hi.xml     | 37 ++++++++++++++++++
 6 files changed, 207 insertions(+)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/SourceHelperTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/SourceHelperTest.java
new file mode 100644
index 00000000000..764be5d922d
--- /dev/null
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/SourceHelperTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.FileNotFoundException;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.dsl.jbang.core.common.SourceHelper;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.fail;
+
+class SourceHelperTest {
+
+    @Test
+    public void testResolveSource() {
+        
Assertions.assertNotNull(SourceHelper.resolveSource("file:src/test/resources/hello.yaml"));
+        
Assertions.assertNotNull(SourceHelper.resolveSource("file:src/test/resources/hello.camel.yaml"));
+        
Assertions.assertNotNull(SourceHelper.resolveSource("file:src/test/resources/Hey.java"));
+        
Assertions.assertNotNull(SourceHelper.resolveSource("file:src/test/resources/hi.xml"));
+        
Assertions.assertNotNull(SourceHelper.resolveSource("file:src/test/resources/hi.camel.xml"));
+
+        try {
+            
SourceHelper.resolveSource("file:src/test/resources/unknown.properties");
+            fail("Should throw exception");
+        } catch (RuntimeCamelException e) {
+            Assertions.assertInstanceOf(FileNotFoundException.class, 
e.getCause());
+        }
+    }
+}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/resources/Hey.java 
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/Hey.java
new file mode 100755
index 00000000000..02d279590c6
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/Hey.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+// use modeline to configure properties directly in the same source file
+// camel-k: language=java name=Cool property=period=1000
+
+public class Hey extends org.apache.camel.builder.RouteBuilder {
+
+  @Override
+  public void configure() throws Exception {
+      // Write your routes here, for example:
+      from("timer:java?period={{period}}")
+        .routeId("java")
+        .process(e -> {
+           e.getMessage().setBody("Hello from Camel");
+        })
+        .log("${body}");
+  }
+}
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/hello.camel.yaml 
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hello.camel.yaml
new file mode 100644
index 00000000000..d3b7b551a7f
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hello.camel.yaml
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+# camel-k: language=yaml
+
+# Write your routes here, for example:
+- from:
+    uri: "timer:yaml"
+    parameters:
+      period: "1000"
+    steps:
+      - setBody:
+          constant: "Hello Camel from yaml"
+      - log: "${body}"
diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/resources/hello.yaml 
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hello.yaml
new file mode 100644
index 00000000000..d3b7b551a7f
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hello.yaml
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+# camel-k: language=yaml
+
+# Write your routes here, for example:
+- from:
+    uri: "timer:yaml"
+    parameters:
+      period: "1000"
+    steps:
+      - setBody:
+          constant: "Hello Camel from yaml"
+      - log: "${body}"
diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/resources/hi.camel.xml 
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hi.camel.xml
new file mode 100644
index 00000000000..a229f1a01a9
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hi.camel.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<!-- camel-k: language=xml -->
+
+<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+        xmlns="http://camel.apache.org/schema/spring";
+        xsi:schemaLocation="
+            http://camel.apache.org/schema/spring
+            https://camel.apache.org/schema/spring/camel-spring.xsd";>
+
+       <!-- Write your routes here, for example: -->
+    <route id="xml">
+        <from uri="timer:xml?period={{time:1000}}"/>
+        <setBody>
+            <simple>Hello Camel from ${routeId}</simple>
+        </setBody>
+        <log message="${body}"/>
+    </route>
+
+</routes>
diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/resources/hi.xml 
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hi.xml
new file mode 100644
index 00000000000..a229f1a01a9
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/hi.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<!-- camel-k: language=xml -->
+
+<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+        xmlns="http://camel.apache.org/schema/spring";
+        xsi:schemaLocation="
+            http://camel.apache.org/schema/spring
+            https://camel.apache.org/schema/spring/camel-spring.xsd";>
+
+       <!-- Write your routes here, for example: -->
+    <route id="xml">
+        <from uri="timer:xml?period={{time:1000}}"/>
+        <setBody>
+            <simple>Hello Camel from ${routeId}</simple>
+        </setBody>
+        <log message="${body}"/>
+    </route>
+
+</routes>

Reply via email to