You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ge...@apache.org on 2015/10/29 09:49:21 UTC
camel git commit: CAMEL-9269: NotifyBuilder.fromRoute() does not work
for some endpoint types
Repository: camel
Updated Branches:
refs/heads/camel-2.16.x f5b926d10 -> 2d83364ac
CAMEL-9269: NotifyBuilder.fromRoute() does not work for some endpoint types
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2d83364a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2d83364a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2d83364a
Branch: refs/heads/camel-2.16.x
Commit: 2d83364ac60d3cd5c1d30ae0b6c95dc0a73bdd5e
Parents: f5b926d
Author: Gert Vanthienen <ge...@apache.org>
Authored: Thu Oct 29 09:44:10 2015 +0100
Committer: Gert Vanthienen <ge...@apache.org>
Committed: Thu Oct 29 09:46:10 2015 +0100
----------------------------------------------------------------------
.../org/apache/camel/builder/NotifyBuilder.java | 5 +
.../builder/NotifyBuilderFromRouteTest.java | 96 ++++++++++++++++++++
2 files changed, 101 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2d83364a/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
index 1c42ad9..e5933494 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/NotifyBuilder.java
@@ -154,6 +154,11 @@ public class NotifyBuilder {
@Override
public boolean onExchange(Exchange exchange) {
String id = EndpointHelper.getRouteIdFromEndpoint(exchange.getFromEndpoint());
+
+ if (id == null) {
+ id = exchange.getFromRouteId();
+ }
+
// filter non matching exchanges
return EndpointHelper.matchPattern(id, routeId);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/2d83364a/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderFromRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderFromRouteTest.java b/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderFromRouteTest.java
new file mode 100644
index 0000000..bf94389
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/builder/NotifyBuilderFromRouteTest.java
@@ -0,0 +1,96 @@
+/**
+ * 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.builder;
+
+import org.apache.camel.*;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @version
+ */
+public class NotifyBuilderFromRouteTest extends ContextTestSupport {
+
+ public void testDoneFromRoute() throws Exception {
+ // notify when exchange is done
+ NotifyBuilder builder =
+ new NotifyBuilder(context).fromRoute("foo").whenDone(1);
+ builder.create();
+
+ template.sendBody("seda:foo", "Hello world!");
+
+ assertTrue(builder.matchesMockWaitTime());
+ }
+
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ final JndiRegistry registry = super.createRegistry();
+ registry.bind("proxy", new ProxyComponent());
+ return registry;
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("proxy:seda:foo")
+ .routeId("foo")
+ .to("mock:foo");
+ }
+ };
+ }
+
+ private static final class ProxyComponent extends DefaultComponent {
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ return new ProxyEndpoint(this, uri, remaining);
+ }
+
+ }
+
+ private static final class ProxyEndpoint extends DefaultEndpoint {
+
+ private final Endpoint target;
+
+ private ProxyEndpoint(ProxyComponent component, String uri, String target) {
+ super(uri, component);
+ this.target = getCamelContext().getEndpoint(target);
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return target.createProducer();
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return target.createConsumer(processor);
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return target.isSingleton();
+ }
+ }
+}