Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x daff7aad8 -> 572df64ce
  refs/heads/master ac9a7940b -> 1b7c19622


CAMEL-9409: wiretap - Allow to use endpoint injected instance


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

Branch: refs/heads/master
Commit: 1b7c1962246afd6acbac0451802b8c504d740ec5
Parents: ac9a794
Author: Claus Ibsen <davscl...@apache.org>
Authored: Thu Dec 10 11:21:21 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Thu Dec 10 11:21:32 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/model/ProcessorDefinition.java | 16 +++++++
 .../camel/processor/WireTapLogEndpointTest.java | 44 ++++++++++++++++++++
 2 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1b7c1962/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 55dd19e..eacb304 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
@@ -2250,6 +2250,22 @@ public abstract class ProcessorDefinition<Type extends 
ProcessorDefinition<Type>
      * destination gets a copy of the original message to avoid the processors
      * interfering with each other using {@link ExchangePattern#InOnly}.
      *
+     * @param endpoint  the endpoint to wiretap to
+     * @return the builder
+     */
+    public WireTapDefinition<Type> wireTap(Endpoint endpoint) {
+        WireTapDefinition answer = new WireTapDefinition();
+        answer.setUri(endpoint.getEndpointUri());
+        addOutput(answer);
+        return answer;
+    }
+
+    /**
+     * <a href="http://camel.apache.org/wiretap.html";>WireTap EIP:</a>
+     * Sends messages to all its child outputs; so that each processor and
+     * destination gets a copy of the original message to avoid the processors
+     * interfering with each other using {@link ExchangePattern#InOnly}.
+     *
      * @param uri  the dynamic endpoint to wiretap to (resolved using simple 
language by default)
      * @return the builder
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/1b7c1962/camel-core/src/test/java/org/apache/camel/processor/WireTapLogEndpointTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/processor/WireTapLogEndpointTest.java
 
b/camel-core/src/test/java/org/apache/camel/processor/WireTapLogEndpointTest.java
new file mode 100644
index 0000000..5f5a75b
--- /dev/null
+++ 
b/camel-core/src/test/java/org/apache/camel/processor/WireTapLogEndpointTest.java
@@ -0,0 +1,44 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.builder.RouteBuilder;
+
+public class WireTapLogEndpointTest extends ContextTestSupport {
+
+    public void testWireTapLog() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+    
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                Endpoint tap = endpoint("log:com.foo.MyApp?level=WARN");
+
+                from("direct:start")
+                    .wireTap(tap)
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

Reply via email to