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.ferr...@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",
        }
 )
 

Reply via email to