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 2018/01/03 10:30:42 UTC
[camel] branch master updated: CAMEL-12108: Added unit test. Thanks
to Bas Claessen for the test.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 07533b9 CAMEL-12108: Added unit test. Thanks to Bas Claessen for the test.
07533b9 is described below
commit 07533b951e6df9f6a7b800a0f0530a2eae455804
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 3 11:08:58 2018 +0100
CAMEL-12108: Added unit test. Thanks to Bas Claessen for the test.
---
.../processor/SplitterWireTapStreamCacheTest.java | 83 ++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/camel-core/src/test/java/org/apache/camel/processor/SplitterWireTapStreamCacheTest.java b/camel-core/src/test/java/org/apache/camel/processor/SplitterWireTapStreamCacheTest.java
new file mode 100644
index 0000000..0c7ffd4
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/SplitterWireTapStreamCacheTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultStreamCachingStrategy;
+import org.apache.camel.spi.StreamCachingStrategy;
+
+public class SplitterWireTapStreamCacheTest extends ContextTestSupport {
+
+ private MockEndpoint startEnd;
+ private MockEndpoint splitEnd;
+ private MockEndpoint wiretapEnd;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ startEnd = getMockEndpoint("mock:startEnd");
+ splitEnd = getMockEndpoint("mock:splitEnd");
+ wiretapEnd = getMockEndpoint("mock:wireTapEnd");
+ }
+
+ public void testWireTapAfterSplitDeletesStreamCacheFileWhenSplitFinishes() throws Exception {
+ startEnd.expectedMessageCount(1);
+ splitEnd.expectedMessageCount(1);
+ wiretapEnd.expectedMessageCount(1);
+
+ // test.txt should contain more than one character
+ template.sendBody("direct:start", "text");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ StreamCachingStrategy streamCachingStrategy = new DefaultStreamCachingStrategy();
+ streamCachingStrategy.setSpoolThreshold(1l);
+
+ context.setStreamCachingStrategy(streamCachingStrategy);
+ context.setStreamCaching(true);
+
+ from("direct:start")
+ .split(bodyAs(String.class).tokenize())
+ .to("direct:split")
+ .to("mock:startEnd")
+ .end();
+
+ from("direct:split")
+ .wireTap("direct:wireTap")
+ //wait for the streamcache to be created in the wireTap route
+ .delay(1000)
+ //spool file is deleted when this route ends
+ .to("mock:splitEnd");
+
+ from("direct:wireTap")
+ //create streamcache
+ .setBody(constant(this.getClass().getResourceAsStream("/log4j2.properties")))
+ .delay(3000)
+ //spool file is deleted by the split route
+ .to("mock:wireTapEnd");
+ }
+ };
+ }
+}
--
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].