This is an automated email from the ASF dual-hosted git repository.

squakez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 371ffe30b7011f4526e713440c4a078781f64319
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Sat Jun 6 10:06:09 2026 +0200

    fix(ci): custom component unit test
---
 e2e/common/misc/files/Unresolvable.java          | 29 ------------------------
 e2e/common/misc/files/custom-echo-component.yaml | 17 ++++++++++++++
 e2e/common/misc/integration_fail_test.go         | 28 -----------------------
 pkg/metadata/metadata_dependencies_test.go       |  4 +++-
 pkg/util/source/inspector_yaml_test.go           | 13 +++++------
 pkg/util/source/source_support_test.go           | 17 --------------
 6 files changed, 26 insertions(+), 82 deletions(-)

diff --git a/e2e/common/misc/files/Unresolvable.java 
b/e2e/common/misc/files/Unresolvable.java
deleted file mode 100644
index 768f32ad4..000000000
--- a/e2e/common/misc/files/Unresolvable.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.
- */
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class Unresolvable extends RouteBuilder {
-    @Override
-    public void configure() throws Exception {
-        from("timer:tick")
-            .setHeader("m").constant("string!")
-            .setBody().simple("Magic${header.m}")
-            .log("${body}")
-            .to("non-existent:hello");
-    }
-}
diff --git a/e2e/common/misc/files/custom-echo-component.yaml 
b/e2e/common/misc/files/custom-echo-component.yaml
index b539d0d06..02f258635 100644
--- a/e2e/common/misc/files/custom-echo-component.yaml
+++ b/e2e/common/misc/files/custom-echo-component.yaml
@@ -1,3 +1,20 @@
+# ---------------------------------------------------------------------------
+# 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.
+# ---------------------------------------------------------------------------
+
 - route:
     from:
       uri: timer:yaml
diff --git a/e2e/common/misc/integration_fail_test.go 
b/e2e/common/misc/integration_fail_test.go
index 2fd9b9b85..3f25de074 100644
--- a/e2e/common/misc/integration_fail_test.go
+++ b/e2e/common/misc/integration_fail_test.go
@@ -122,34 +122,6 @@ func TestBadRouteIntegration(t *testing.T) {
                        g.Eventually(BuildPhase(t, ctx, 
integrationKitRecoveryNamespace, kitRecoveryName), 
TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
                })
 
-               t.Run("run unresolvable component java route", func(t 
*testing.T) {
-                       name := RandomizedSuffixName("unresolvable-route")
-                       g.Expect(KamelRun(t, ctx, ns, 
"files/Unresolvable.java", "--name", name, "-t", 
"health.enabled=false").Execute()).To(Succeed())
-                       // Integration in error with Initialization Failed 
condition
-                       g.Eventually(IntegrationPhase(t, ctx, ns, name), 
TestTimeoutShort).Should(Equal(v1.IntegrationPhaseError))
-                       g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionReady), TestTimeoutShort).
-                               Should(Equal(corev1.ConditionFalse))
-                       g.Eventually(IntegrationCondition(t, ctx, ns, name, 
v1.IntegrationConditionReady), TestTimeoutShort).Should(And(
-                               WithTransform(IntegrationConditionReason, 
Equal(v1.IntegrationConditionInitializationFailedReason)),
-                               WithTransform(IntegrationConditionMessage, 
HavePrefix("error during trait customization")),
-                       ))
-                       // Kit shouldn't be created
-                       g.Consistently(IntegrationKitName(t, ctx, ns, name), 
10*time.Second).Should(BeEmpty())
-
-                       // Fixing the route should reconcile the Integration in 
Initialization Failed condition to Running
-                       g.Expect(KamelRun(t, ctx, ns, "files/Java.java", 
"--name", name, "-t", "health.enabled=false").Execute()).To(Succeed())
-                       g.Eventually(IntegrationPodPhase(t, ctx, ns, name), 
TestTimeoutLong).Should(Equal(corev1.PodRunning))
-                       g.Eventually(IntegrationConditionStatus(t, ctx, ns, 
name, v1.IntegrationConditionReady), TestTimeoutShort).
-                               Should(Equal(corev1.ConditionTrue))
-                       g.Eventually(IntegrationLogs(t, ctx, ns, name), 
TestTimeoutShort).Should(ContainSubstring("Magicstring!"))
-                       // New Kit success
-                       kitRecoveryName := IntegrationKitName(t, ctx, ns, 
name)()
-                       integrationKitRecoveryNamespace := 
IntegrationKitNamespace(t, ctx, ns, name)()
-                       g.Eventually(KitPhase(t, ctx, 
integrationKitRecoveryNamespace, kitRecoveryName), 
TestTimeoutShort).Should(Equal(v1.IntegrationKitPhaseReady))
-                       // New Build success
-                       g.Eventually(BuildPhase(t, ctx, 
integrationKitRecoveryNamespace, kitRecoveryName), 
TestTimeoutShort).Should(Equal(v1.BuildPhaseSucceeded))
-               })
-
                t.Run("run invalid java route", func(t *testing.T) {
                        name := RandomizedSuffixName("invalid-java-route")
                        // Skip the health check so we can quickly read from log
diff --git a/pkg/metadata/metadata_dependencies_test.go 
b/pkg/metadata/metadata_dependencies_test.go
index c9c453802..22eb0f493 100644
--- a/pkg/metadata/metadata_dependencies_test.go
+++ b/pkg/metadata/metadata_dependencies_test.go
@@ -109,7 +109,9 @@ func TestDependencyInexistent(t *testing.T) {
        require.NoError(t, err)
 
        _, err = extract(catalog, code)
-       require.Error(t, err)
+       // No error because it may be a custom component and the user
+       // has to provide the dependency explicitly
+       require.NoError(t, err)
 }
 
 func TestDependenciesQuarkus(t *testing.T) {
diff --git a/pkg/util/source/inspector_yaml_test.go 
b/pkg/util/source/inspector_yaml_test.go
index 770da30a9..eff3e1d16 100644
--- a/pkg/util/source/inspector_yaml_test.go
+++ b/pkg/util/source/inspector_yaml_test.go
@@ -19,7 +19,6 @@ package source
 
 import (
        "fmt"
-       "strings"
        "testing"
 
        "github.com/stretchr/testify/assert"
@@ -624,7 +623,7 @@ const yamlFromDSLWithUnknownFromScheme = `
       - to: "log:info"
 `
 
-const yamlFromDSLWithUnknownToScheme = `
+const yamlFromDSLWithCustomComponentScheme = `
 - route:
     id: route2
     from:
@@ -633,12 +632,12 @@ const yamlFromDSLWithUnknownToScheme = `
       - to: "unknown:foo"
 `
 
-func TestYAMLRouteWithUnknownScheme(t *testing.T) {
+func TestYAMLRouteWithCustomComponentScheme(t *testing.T) {
        inspector := newTestYAMLInspector(t)
-       for i, source := range []string{yamlFromDSLWithUnknownFromScheme, 
yamlFromDSLWithUnknownToScheme} {
-               t.Run(fmt.Sprintf("TestYAMLRouteWithUnknownScheme-%d", i), 
func(t *testing.T) {
-                       assertExtractYAMLError(t, inspector, source, func(err 
error) {
-                               assert.True(t, strings.HasPrefix(err.Error(), 
fmt.Sprintf("component not found for uri %q", "unknown:foo")))
+       for i, source := range []string{yamlFromDSLWithUnknownFromScheme, 
yamlFromDSLWithCustomComponentScheme} {
+               t.Run(fmt.Sprintf("TestYAMLRouteWithCustomComponent-%d", i), 
func(t *testing.T) {
+                       assertExtractYAML(t, inspector, source, func(meta 
*Metadata) {
+                               // all good
                        })
                })
        }
diff --git a/pkg/util/source/source_support_test.go 
b/pkg/util/source/source_support_test.go
index bc3ebcffa..53e16aa9b 100644
--- a/pkg/util/source/source_support_test.go
+++ b/pkg/util/source/source_support_test.go
@@ -56,20 +56,3 @@ func assertExtractYAML(t *testing.T, inspector 
YAMLInspector, source string, ass
 
        assertFn(&meta)
 }
-
-func assertExtractYAMLError(t *testing.T, inspector YAMLInspector, source 
string, assertFn func(err error)) {
-       t.Helper()
-
-       srcSpec := v1.SourceSpec{
-               DataSpec: v1.DataSpec{
-                       Name:    "route.yaml",
-                       Content: source,
-               },
-               Language: v1.LanguageYaml,
-       }
-       meta := NewMetadata()
-       err := inspector.Extract(srcSpec, &meta)
-       require.Error(t, err)
-
-       assertFn(err)
-}

Reply via email to