You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/06/25 15:45:29 UTC

[2/3] git commit: Fix for CAMEL-7537 Expose the component options for Camel OptaPlanner

Fix for CAMEL-7537 Expose the component options for Camel OptaPlanner


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

Branch: refs/heads/master
Commit: 1024879df5c05a4bc79fa826a974aeb2ec18daf9
Parents: 8100a97
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Wed Jun 25 14:21:14 2014 +0200
Committer: Kevin Earls <ke...@kevinearls.com>
Committed: Wed Jun 25 14:21:14 2014 +0200

----------------------------------------------------------------------
 .../optaplanner/OptaPlannerComponent.java       |  8 ++-
 .../optaplanner/OptaPlannerEndpoint.java        |  2 +
 ...ponentConfigurationAndDocumentationTest.java | 56 ++++++++++++++++++++
 3 files changed, 64 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1024879d/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerComponent.java b/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerComponent.java
index 307dba5..f19fe5f 100644
--- a/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerComponent.java
+++ b/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerComponent.java
@@ -19,14 +19,18 @@ package org.apache.camel.component.optaplanner;
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
 import org.optaplanner.core.api.solver.SolverFactory;
 import org.optaplanner.core.config.solver.XmlSolverFactory;
 
 /**
  * OptaPlanner component for Camel
  */
-public class OptaPlannerComponent extends DefaultComponent {
+public class OptaPlannerComponent extends UriEndpointComponent {
+
+    public OptaPlannerComponent() {
+        super(OptaPlannerEndpoint.class);
+    }
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
         SolverFactory solverFactory = new XmlSolverFactory(remaining);

http://git-wip-us.apache.org/repos/asf/camel/blob/1024879d/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerEndpoint.java b/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerEndpoint.java
index fe4003b..c120fd0 100644
--- a/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerEndpoint.java
+++ b/components/camel-optaplanner/src/main/java/org/apache/camel/component/optaplanner/OptaPlannerEndpoint.java
@@ -20,6 +20,7 @@ import org.apache.camel.Component;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.component.ResourceEndpoint;
+import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.util.ObjectHelper;
 import org.optaplanner.core.api.solver.Solver;
 import org.optaplanner.core.api.solver.SolverFactory;
@@ -28,6 +29,7 @@ import org.optaplanner.core.impl.solution.Solution;
 /**
  * OptaPlanner endpoint for Camel
  */
+@UriEndpoint(scheme = "optaplanner")
 public class OptaPlannerEndpoint extends ResourceEndpoint {
 
     private SolverFactory solverFactory;

http://git-wip-us.apache.org/repos/asf/camel/blob/1024879d/components/camel-optaplanner/src/test/java/org/apache/camel/component/optaplanner/OptaPlannerComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-optaplanner/src/test/java/org/apache/camel/component/optaplanner/OptaPlannerComponentConfigurationAndDocumentationTest.java b/components/camel-optaplanner/src/test/java/org/apache/camel/component/optaplanner/OptaPlannerComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..f094e33
--- /dev/null
+++ b/components/camel-optaplanner/src/test/java/org/apache/camel/component/optaplanner/OptaPlannerComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.optaplanner;
+
+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 OptaPlannerComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        OptaPlannerComponent component = context.getComponent("optaplanner", OptaPlannerComponent.class);
+        EndpointConfiguration configuration = component.createConfiguration("optaplanner:/org/apache/camel/component/optaplanner/solverConfig.xml?" +
+                "synchronous=false&contentCache=true");
+
+        assertEquals("true", configuration.getParameter("contentCache"));
+
+        ComponentConfiguration componentConfiguration = component.createComponentConfiguration();
+        String json = componentConfiguration.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"resourceUri\": { \"type\": \"java.lang.String\" }"));
+        assertTrue(json.contains("\"synchronous\": { \"type\": \"boolean\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("optaplanner");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+
+}