You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/07/24 08:37:54 UTC

[camel-k] 01/03: Groovy Rest example fails due to Unable to find loader for language=xml Fixes #838

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

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

commit 0181d78c3fae31bf2c83316d07d2314a448bb930
Author: Dmitry Volodin <dm...@gmail.com>
AuthorDate: Mon Jul 22 15:28:09 2019 +0300

    Groovy Rest example fails due to Unable to find loader for language=xml
    Fixes #838
---
 pkg/trait/dependencies.go      |  2 +-
 pkg/trait/dependencies_test.go | 47 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index 2fd1a56..67dfec7 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -50,7 +50,7 @@ func (t *dependenciesTrait) Apply(e *Environment) error {
 			util.StringSliceUniqueAdd(&dependencies, dep)
 		}
 	}
-	for _, s := range e.Integration.Spec.Sources {
+	for _, s := range append(e.Integration.Spec.Sources, e.Integration.Status.GeneratedSources...) {
 		meta := metadata.Extract(e.CamelCatalog, s)
 
 		switch s.InferLanguage() {
diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go
index 3744264..1854915 100644
--- a/pkg/trait/dependencies_test.go
+++ b/pkg/trait/dependencies_test.go
@@ -125,3 +125,50 @@ func TestIntegrationCustomDeps(t *testing.T) {
 		e.Integration.Status.Dependencies,
 	)
 }
+
+func TestIntegrationAutoGeneratedDeps(t *testing.T) {
+	catalog, err := test.DefaultCatalog()
+	assert.Nil(t, err)
+
+	e := &Environment{
+		CamelCatalog: catalog,
+		Integration: &v1alpha1.Integration{
+			Spec: v1alpha1.IntegrationSpec{
+				Sources: []v1alpha1.SourceSpec{
+					{
+						DataSpec: v1alpha1.DataSpec{
+							Name:    "Request.java",
+							Content: `from("direct:foo").to("log:bar");`,
+						},
+						Language: v1alpha1.LanguageJavaSource,
+					},
+				},
+			},
+			Status: v1alpha1.IntegrationStatus{
+				Phase: v1alpha1.IntegrationPhaseInitialization,
+				GeneratedSources: []v1alpha1.SourceSpec{
+					{
+						DataSpec: v1alpha1.DataSpec{
+							Name:    "RequestAuto.xml",
+							Content: `<rests xmlns="http://camel.apache.org/schema/spring"><rest path="/camel/"></rest></rests>`,
+						},
+						Language: v1alpha1.LanguageXML,
+					},
+				},
+			},
+		},
+	}
+
+	trait := newDependenciesTrait()
+	enabled, err := trait.Configure(e)
+	assert.Nil(t, err)
+	assert.True(t, enabled)
+
+	err = trait.Apply(e)
+	assert.Nil(t, err)
+	assert.ElementsMatch(
+		t,
+		[]string{"camel:direct", "camel:log", "mvn:org.apache.camel.k/camel-k-loader-java", "mvn:org.apache.camel.k/camel-k-loader-xml", "mvn:org.apache.camel.k/camel-k-runtime-main"},
+		e.Integration.Status.Dependencies,
+	)
+}
\ No newline at end of file