Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groovy Rest example fails due to Unable to find loader for language=xml #849

Merged
merged 3 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Session.vim
tags

### VisualStudioCode ###
.vscode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
Expand Down
2 changes: 1 addition & 1 deletion pkg/trait/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 e.Integration.Sources() {
meta := metadata.Extract(e.CamelCatalog, s)

switch s.InferLanguage() {
Expand Down
47 changes: 47 additions & 0 deletions pkg/trait/dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}