camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [21/33] git commit: CAMEL-7354: Rest DSL can embed routes.
Date Sun, 20 Jul 2014 06:53:27 GMT
CAMEL-7354: Rest DSL can embed routes.


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

Branch: refs/heads/master
Commit: 89a945bf5c516af26adaa9e95d58980c68f20472
Parents: 96a521d
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jul 15 14:11:39 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Jul 19 09:38:51 2014 +0200

----------------------------------------------------------------------
 .../apache/camel/model/ProcessorDefinition.java | 32 +++++++
 .../apache/camel/model/rest/PathDefinition.java |  6 +-
 .../apache/camel/model/rest/VerbDefinition.java | 44 +++++----
 .../rest/FromRestGetEmbeddedRouteTest.java      | 94 ++++++++++++++++++++
 .../component/rest/FromRestGetEndPathTest.java  | 42 +++++++++
 .../camel/component/rest/FromRestGetTest.java   |  4 +-
 .../SpringFromRestGetEmbeddedRouteTest.java     | 44 +--------
 .../rest/SpringFromRestGetEmbeddedRouteTest.xml |  3 +
 .../component/rest/SpringFromRestGetTest.xml    |  1 +
 .../rest/FromRestGetEmbeddedRouteTest.java      | 74 +++++++++++++++
 .../rest/FromRestGetEmbeddedRouteTest.xml       | 50 +++++++++++
 .../component/rest/FromRestGetTest.xml          |  1 +
 12 files changed, 330 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 1503d3c..d2301b6 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -52,6 +52,8 @@ import org.apache.camel.builder.ProcessorBuilder;
 import org.apache.camel.model.language.ConstantExpression;
 import org.apache.camel.model.language.ExpressionDefinition;
 import org.apache.camel.model.language.LanguageExpression;
+import org.apache.camel.model.rest.PathDefinition;
+import org.apache.camel.model.rest.VerbDefinition;
 import org.apache.camel.processor.InterceptEndpointProcessor;
 import org.apache.camel.processor.Pipeline;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
@@ -1317,6 +1319,36 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
     }
 
     /**
+     * Ends the current block and returns back to the {@link ChoiceDefinition choice()} DSL.
+     *
+     * @return the builder
+     */
+    public PathDefinition endPath() {
+        ProcessorDefinition<?> def = this;
+        if (def.getParent() instanceof VerbDefinition) {
+            return ((VerbDefinition) def.getParent()).getPath();
+        }
+
+        // are we already a choice?
+        if (def instanceof VerbDefinition) {
+            return ((VerbDefinition) def).getPath();
+        }
+
+        // okay end this and get back to the choice
+        def = end();
+        if (def.getParent() instanceof VerbDefinition) {
+            return ((VerbDefinition) def.getParent()).getPath();
+        }
+
+        // are we already a choice?
+        if (def instanceof VerbDefinition) {
+            return ((VerbDefinition) def).getPath();
+        }
+
+        throw new IllegalArgumentException("Cannot find VerbDefinition to allow endPath");
+    }
+
+    /**
      * Ends the current block and returns back to the {@link TryDefinition doTry()} DSL.
      *
      * @return the builder

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java
index c41a610..92b072c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/PathDefinition.java
@@ -69,6 +69,7 @@ public class PathDefinition {
 
     public PathDefinition get(String url) {
         GetVerbDefinition answer = new GetVerbDefinition();
+        answer.setPath(this);
         getVerbs().add(answer);
         if (url != null) {
             answer.setUri(url);
@@ -82,6 +83,7 @@ public class PathDefinition {
 
     public PathDefinition post(String url) {
         PostVerbDefinition answer = new PostVerbDefinition();
+        answer.setPath(this);
         getVerbs().add(answer);
         if (url != null) {
             answer.setUri(url);
@@ -101,7 +103,7 @@ public class PathDefinition {
         return this;
     }
 
-    public PathDefinition to(String url) {
+    public VerbDefinition to(String url) {
         // add to last verb
         if (getVerbs().isEmpty()) {
             throw new IllegalArgumentException("Must add verb first, such as get/post/delete");
@@ -110,7 +112,7 @@ public class PathDefinition {
         VerbDefinition verb = getVerbs().get(getVerbs().size() - 1);
         verb.addOutput(new ToDefinition(url));
 
-        return this;
+        return verb;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
index 6dea3de..c4e006e 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
@@ -16,19 +16,17 @@
  */
 package org.apache.camel.model.rest;
 
-import java.util.ArrayList;
-import java.util.List;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
-import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.OutputDefinition;
 
 @XmlRootElement(name = "verb")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class VerbDefinition {
+public class VerbDefinition extends OutputDefinition<VerbDefinition> {
 
     @XmlAttribute
     private String routeId;
@@ -42,8 +40,16 @@ public class VerbDefinition {
     @XmlAttribute
     private String accept;
 
-    @XmlElementRef
-    private List<ProcessorDefinition<?>> outputs = new ArrayList<ProcessorDefinition<?>>();
+    @XmlTransient
+    private PathDefinition path;
+
+    public PathDefinition getPath() {
+        return path;
+    }
+
+    public void setPath(PathDefinition path) {
+        this.path = path;
+    }
 
     public String getRouteId() {
         return routeId;
@@ -77,21 +83,23 @@ public class VerbDefinition {
         this.accept = accept;
     }
 
-    public List<ProcessorDefinition<?>> getOutputs() {
-        return outputs;
+    // Fluent API
+    // -------------------------------------------------------------------------
+
+    public PathDefinition get() {
+        return path.get();
     }
 
-    public void setOutputs(List<ProcessorDefinition<?>> outputs) {
-        this.outputs = outputs;
+    public PathDefinition get(String url) {
+        return path.get(url);
+    }
 
-        if (outputs != null) {
-            for (ProcessorDefinition<?> output : outputs) {
-                output.configureChild(output);
-            }
-        }
+    public PathDefinition post() {
+        return path.post();
     }
 
-    public void addOutput(ProcessorDefinition<?> output) {
-        outputs.add(output);
+    public PathDefinition post(String url) {
+        return path.post(url);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEmbeddedRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEmbeddedRouteTest.java
b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEmbeddedRouteTest.java
new file mode 100644
index 0000000..af5815a
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEmbeddedRouteTest.java
@@ -0,0 +1,94 @@
+/**
+ * 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.rest;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.model.ToDefinition;
+import org.apache.camel.model.rest.PathDefinition;
+import org.apache.camel.model.rest.RestDefinition;
+
+public class FromRestGetEmbeddedRouteTest extends ContextTestSupport {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("dummy-test", new DummyRestConsumerFactory());
+        return jndi;
+    }
+
+    protected int getExpectedNumberOfRoutes() {
+        return 3;
+    }
+
+    public void testFromRestModel() throws Exception {
+        assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
+
+        RestDefinition rest = context.getRestDefinitions().get(0);
+        assertNotNull(rest);
+
+        // we should have a hello and bye route
+        assertNotNull(context.getRouteDefinition("hello"));
+        assertNotNull(context.getRouteDefinition("bye"));
+
+        PathDefinition path = rest.getPaths().get(0);
+        assertNotNull(0);
+        assertEquals("/say", path.getUri());
+
+        assertEquals("/hello", path.getVerbs().get(0).getUri());
+        ToDefinition to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(0).getOutputs().get(0));
+        assertEquals("mock:hello", to.getUri());
+
+        assertEquals("/bye", path.getVerbs().get(1).getUri());
+        assertEquals("application/json", path.getVerbs().get(1).getAccept());
+        to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(1).getOutputs().get(0));
+        assertEquals("mock:bye", to.getUri());
+
+        assertEquals(null, path.getVerbs().get(2).getUri());
+
+        // the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
+
+        getMockEndpoint("mock:update").expectedMessageCount(1);
+        template.sendBody("seda:post-say", "I was here");
+        assertMockEndpointsSatisfied();
+
+        String out = template.requestBody("seda:get-say-hello", "Me", String.class);
+        assertEquals("Hello World", out);
+        String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
+        assertEquals("Bye World", out2);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                rest()
+                    .path("/say")
+                        .get("/hello").routeId("hello")
+                            .to("mock:hello")
+                            .transform(constant("Hello World"))
+                        .get("/bye").accept("application/json").routeId("bye")
+                            .to("mock:bye")
+                            .transform(constant("Bye World"))
+                        .post()
+                            .to("mock:update");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEndPathTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEndPathTest.java
b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEndPathTest.java
new file mode 100644
index 0000000..4910716
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetEndPathTest.java
@@ -0,0 +1,42 @@
+/**
+ * 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.rest;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class FromRestGetEndPathTest extends FromRestGetTest {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                rest()
+                    .path("/say")
+                        .get("/hello").routeId("hello").to("direct:hello").endPath()
+                        .get("/bye").accept("application/json").routeId("bye").to("direct:bye").endPath()
+                        .post().to("mock:update");
+
+                from("direct:hello")
+                    .transform().constant("Hello World");
+
+                from("direct:bye")
+                    .transform().constant("Bye World");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetTest.java
b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetTest.java
index f9076a6..7042051 100644
--- a/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/rest/FromRestGetTest.java
@@ -80,8 +80,8 @@ public class FromRestGetTest extends ContextTestSupport {
             public void configure() throws Exception {
                 rest()
                     .path("/say")
-                        .get("/hello").routeId("hello").to("direct:hello")
-                        .get("/bye").accept("application/json").routeId("bye").to("direct:bye")
+                        .get("/hello").routeId("hello").to("direct:hello").endPath()
+                        .get("/bye").accept("application/json").routeId("bye").to("direct:bye").endPath()
                         .post().to("mock:update");
 
                 from("direct:hello")

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.java
b/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.java
index daee273..9acb598 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.java
@@ -17,52 +17,10 @@
 package org.apache.camel.component.rest;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.model.TransformDefinition;
-import org.apache.camel.model.rest.PathDefinition;
-import org.apache.camel.model.rest.RestDefinition;
 
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
-public class SpringFromRestGetEmbeddedRouteTest extends FromRestGetTest {
-
-    @Override
-    protected int getExpectedNumberOfRoutes() {
-        return 3;
-    }
-
-    public void testFromRestModel() throws Exception {
-        assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
-
-        RestDefinition rest = context.getRestDefinitions().get(0);
-        assertNotNull(rest);
-
-        // we should have a hello and bye route
-        assertNotNull(context.getRouteDefinition("hello"));
-        assertNotNull(context.getRouteDefinition("bye"));
-
-        PathDefinition path = rest.getPaths().get(0);
-        assertNotNull(0);
-        assertEquals("/say", path.getUri());
-
-        assertEquals("/hello", path.getVerbs().get(0).getUri());
-        assertIsInstanceOf(TransformDefinition.class, path.getVerbs().get(1).getOutputs().get(0));
-
-        assertEquals("/bye", path.getVerbs().get(1).getUri());
-        assertEquals("application/json", path.getVerbs().get(1).getAccept());
-
-        assertEquals(null, path.getVerbs().get(2).getUri());
-
-        // the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
-
-        getMockEndpoint("mock:update").expectedMessageCount(1);
-        template.sendBody("seda:post-say", "I was here");
-        assertMockEndpointsSatisfied();
-
-        String out = template.requestBody("seda:get-say-hello", "Me", String.class);
-        assertEquals("Hello World", out);
-        String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
-        assertEquals("Bye World", out2);
-    }
+public class SpringFromRestGetEmbeddedRouteTest extends FromRestGetEmbeddedRouteTest {
 
     protected CamelContext createCamelContext() throws Exception {
         return createSpringCamelContext(this, "org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.xml");

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.xml
index ed9bc34..bd78d08 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetEmbeddedRouteTest.xml
@@ -30,11 +30,13 @@
     <rest component="dummy-rest">
       <path uri="/say">
         <get uri="/hello" routeId="hello">
+          <to uri="mock:hello"/>
           <transform>
             <constant>Hello World</constant>
           </transform>
         </get>
         <get uri="/bye" accept="application/json" routeId="bye">
+          <to uri="mock:bye"/>
           <transform>
             <constant>Bye World</constant>
           </transform>
@@ -44,6 +46,7 @@
         </post>
       </path>
     </rest>
+
   </camelContext>
 
 </beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetTest.xml
index 918085f..9bbd736 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/component/rest/SpringFromRestGetTest.xml
@@ -53,6 +53,7 @@
         <constant>Bye World</constant>
       </transform>
     </route>
+
   </camelContext>
 
 </beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.java
new file mode 100644
index 0000000..3671dfc
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.java
@@ -0,0 +1,74 @@
+/**
+ * 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.test.blueprint.component.rest;
+
+import org.apache.camel.model.ToDefinition;
+import org.apache.camel.model.rest.PathDefinition;
+import org.apache.camel.model.rest.RestDefinition;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+public class FromRestGetEmbeddedRouteTest extends CamelBlueprintTestSupport {
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.xml";
+    }
+
+    protected int getExpectedNumberOfRoutes() {
+        return 3;
+    }
+
+    @Test
+    public void testFromRestModel() throws Exception {
+        assertEquals(getExpectedNumberOfRoutes(), context.getRoutes().size());
+
+        RestDefinition rest = context.getRestDefinitions().get(0);
+        assertNotNull(rest);
+
+        // we should have a hello and bye route
+        assertNotNull(context.getRouteDefinition("hello"));
+        assertNotNull(context.getRouteDefinition("bye"));
+
+        PathDefinition path = rest.getPaths().get(0);
+        assertNotNull(0);
+        assertEquals("/say", path.getUri());
+
+        assertEquals("/hello", path.getVerbs().get(0).getUri());
+        ToDefinition to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(0).getOutputs().get(0));
+        assertEquals("mock:hello", to.getUri());
+
+        assertEquals("/bye", path.getVerbs().get(1).getUri());
+        assertEquals("application/json", path.getVerbs().get(1).getAccept());
+        to = assertIsInstanceOf(ToDefinition.class, path.getVerbs().get(1).getOutputs().get(0));
+        assertEquals("mock:bye", to.getUri());
+
+        assertEquals(null, path.getVerbs().get(2).getUri());
+
+        // the rest becomes routes and the input is a seda endpoint created by the DummyRestConsumerFactory
+
+        getMockEndpoint("mock:update").expectedMessageCount(1);
+        template.sendBody("seda:post-say", "I was here");
+        assertMockEndpointsSatisfied();
+
+        String out = template.requestBody("seda:get-say-hello", "Me", String.class);
+        assertEquals("Hello World", out);
+        String out2 = template.requestBody("seda:get-say-bye", "Me", String.class);
+        assertEquals("Bye World", out2);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.xml
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.xml
new file mode 100644
index 0000000..cf415fb
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetEmbeddedRouteTest.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+  <!-- use a dummy rest consumer factory for the rest engine -->
+  <bean id="dummy-rest" class="org.apache.camel.test.blueprint.component.rest.DummyRestConsumerFactory"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+
+    <rest component="dummy-rest">
+      <path uri="/say">
+        <get uri="/hello" routeId="hello">
+          <to uri="mock:hello"/>
+          <transform>
+            <constant>Hello World</constant>
+          </transform>
+        </get>
+        <get uri="/bye" accept="application/json" routeId="bye">
+          <to uri="mock:bye"/>
+          <transform>
+            <constant>Bye World</constant>
+          </transform>
+        </get>
+        <post>
+          <to uri="mock:update"/>
+        </post>
+      </path>
+    </rest>
+
+  </camelContext>
+
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/89a945bf/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetTest.xml
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetTest.xml
index ff38c7a..55db1fd 100644
--- a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetTest.xml
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/component/rest/FromRestGetTest.xml
@@ -51,6 +51,7 @@
         <constant>Bye World</constant>
       </transform>
     </route>
+
   </camelContext>
 
 </blueprint>
\ No newline at end of file


Mime
View raw message