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/04/13 22:59:20 UTC
[camel-k] branch master updated: Fix #575: recognize hystrix
automatically
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
The following commit(s) were added to refs/heads/master by this push:
new e0bb7da Fix #575: recognize hystrix automatically
e0bb7da is described below
commit e0bb7da396d1d989d28f5b602a5bec5ae655fb87
Author: nferraro <ni...@gmail.com>
AuthorDate: Fri Apr 12 23:02:04 2019 +0200
Fix #575: recognize hystrix automatically
---
pkg/metadata/metadata_dependencies_test.go | 71 ++++++++++++++++++++++++++++++
pkg/util/source/inspector.go | 2 +
2 files changed, 73 insertions(+)
diff --git a/pkg/metadata/metadata_dependencies_test.go b/pkg/metadata/metadata_dependencies_test.go
index 1e66872..d006c93 100644
--- a/pkg/metadata/metadata_dependencies_test.go
+++ b/pkg/metadata/metadata_dependencies_test.go
@@ -118,3 +118,74 @@ func TestDependencies(t *testing.T) {
// assert all dependencies are found and sorted (removing duplicates)
assert.Equal(t, []string{"camel:core", "camel:http4", "camel:twitter"}, meta.Dependencies)
}
+
+func TestJacksonDependency(t *testing.T) {
+ code := v1alpha1.SourceSpec{
+ DataSpec: v1alpha1.DataSpec{
+ Name: "Request.java",
+ Content: `
+ from("http4:test").unmarshal().json(JsonLibrary.Jackson).to("log:end");
+ `,
+ },
+ Language: v1alpha1.LanguageJavaSource,
+ }
+
+ catalog, err := test.DefaultCatalog()
+ assert.Nil(t, err)
+
+ meta := Extract(catalog, code)
+
+ // assert all dependencies are found and sorted (removing duplicates)
+ assert.Equal(t, []string{"camel:core", "camel:http4", "camel:jackson"}, meta.Dependencies)
+}
+
+func TestHystrixDependency(t *testing.T) {
+ code := v1alpha1.SourceSpec{
+ DataSpec: v1alpha1.DataSpec{
+ Name: "Request.groovy",
+ Content: `
+ from("http4:test")
+ .hystrix()
+ .to("log:end")
+ .onFallback()
+ .to("log:fallback")
+ `,
+ },
+ Language: v1alpha1.LanguageGroovy,
+ }
+
+ catalog, err := test.DefaultCatalog()
+ assert.Nil(t, err)
+
+ meta := Extract(catalog, code)
+
+ // assert all dependencies are found and sorted (removing duplicates)
+ assert.Equal(t, []string{"camel:core", "camel:http4", "camel:hystrix"}, meta.Dependencies)
+}
+
+func TestXMLHystrixDependency(t *testing.T) {
+ code := v1alpha1.SourceSpec{
+
+ DataSpec: v1alpha1.DataSpec{
+ Name: "routes.xml",
+ Content: `
+ <from uri="direct:ciao" />
+ <hystrix>
+ <to uri="log:info" />
+ <onFallback>
+ <to uri="kafka:topic" />
+ </onFallback>
+ </hystrix>
+ `,
+ },
+ Language: v1alpha1.LanguageXML,
+ }
+
+ catalog, err := test.DefaultCatalog()
+ assert.Nil(t, err)
+
+ meta := Extract(catalog, code)
+
+ // assert all dependencies are found and sorted (removing duplicates)
+ assert.Equal(t, []string{"camel:core", "camel:hystrix", "camel:kafka"}, meta.Dependencies)
+}
\ No newline at end of file
diff --git a/pkg/util/source/inspector.go b/pkg/util/source/inspector.go
index a9310a4..6d32161 100644
--- a/pkg/util/source/inspector.go
+++ b/pkg/util/source/inspector.go
@@ -40,6 +40,8 @@ var (
additionalDependencies = map[string]string{
".*JsonLibrary\\.Jackson.*": "camel:jackson",
+ ".*\\.hystrix().*": "camel:hystrix",
+ ".*<hystrix>.*": "camel:hystrix",
}
)