camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/3] git commit: Fixes CAMEL-7508 Expose the component options for Camel Infinispan
Date Sat, 14 Jun 2014 07:10:43 GMT
Fixes CAMEL-7508 Expose the component options for Camel Infinispan


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2be3d6f8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2be3d6f8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2be3d6f8

Branch: refs/heads/master
Commit: 2be3d6f8d8c77a7f26d608c2b5048438d3ac6424
Parents: 0da7ade
Author: Kevin Earls <kevin@kevinearls.com>
Authored: Fri Jun 13 17:45:36 2014 +0200
Committer: Kevin Earls <kevin@kevinearls.com>
Committed: Fri Jun 13 17:45:36 2014 +0200

----------------------------------------------------------------------
 .../infinispan/InfinispanComponent.java         |  8 ++-
 .../infinispan/InfinispanConfiguration.java     |  7 +++
 .../infinispan/InfinispanEndpoint.java          |  4 ++
 ...ponentConfigurationAndDocumentationTest.java | 57 ++++++++++++++++++++
 4 files changed, 74 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
index cb2a6c8..7547836 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
@@ -19,9 +19,13 @@ package org.apache.camel.component.infinispan;
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
 
-public class InfinispanComponent extends DefaultComponent {
+public class InfinispanComponent extends UriEndpointComponent {
+
+    public InfinispanComponent() {
+        super(InfinispanEndpoint.class);
+    }
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
index 187daf3..0c31a0c 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
@@ -20,13 +20,20 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
 import org.infinispan.commons.api.BasicCacheContainer;
 
+@UriParams
 public class InfinispanConfiguration {
     private BasicCacheContainer cacheContainer;
+    @UriParam
     private String cacheName;
+    @UriParam
     private String host;
+    @UriParam
     private String command;
+    @UriParam
     private boolean sync = true;
     private Set<String> eventTypes;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
index 8680c26..899f7fb 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
@@ -20,8 +20,12 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 
+@UriEndpoint(scheme = "infinispan", consumerClass = InfinispanConsumer.class)
 public class InfinispanEndpoint extends DefaultEndpoint {
+    @UriParam
     private InfinispanConfiguration configuration;
 
     public InfinispanEndpoint() {

http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java
b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..6f5d94a
--- /dev/null
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.infinispan;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class InfinispanComponentConfigurationAndDocumentationTest extends CamelTestSupport
{
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        InfinispanComponent comp = context.getComponent("infinispan", InfinispanComponent.class);
+        String configUri = "infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED";
+        EndpointConfiguration conf = comp.createConfiguration(configUri);
+
+        assertEquals("localhost", conf.getParameter("host"));
+        assertEquals("cacheContainer=", conf.getParameter("query"));
+
+        ComponentConfiguration compConf = comp.createComponentConfiguration();
+        String json = compConf.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"command\": { \"type\": \"java.lang.String\" }"));
+        assertTrue(json.contains("\"sync\": { \"type\": \"boolean\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("infinispan");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+
+}


Mime
View raw message