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 2009/06/09 10:17:36 UTC

svn commit: r782907 - in /camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress: FileAsyncStressReadLockLockFileTest.java FileAsyncStressReadLockNoneTest.java FileAsyncStressReadLockRenameTest.java

Author: davsclaus
Date: Tue Jun  9 08:17:35 2009
New Revision: 782907

URL: http://svn.apache.org/viewvc?rev=782907&view=rev
Log:
CAMEL-1670: Added unit test for the other read locks.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java   (contents, props changed)
      - copied, changed from r782905, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java   (with props)

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java (from r782905, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java&r1=782905&r2=782907&rev=782907&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java Tue Jun  9 08:17:35 2009
@@ -18,34 +18,14 @@
 
 import java.util.Random;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version $Revision$
  */
-public class FileAsyncStressTest extends ContextTestSupport {
-
-    private int files = 150;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        deleteDirectory("target/filestress");
-        for (int i = 0; i < files; i++) {
-            template.sendBodyAndHeader("file:target/filestress", "Hello World", Exchange.FILE_NAME, i + ".txt");
-        }
-    }
-
-    public void testAsyncStress() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedMinimumMessageCount(100);
-
-        assertMockEndpointsSatisfied();
-    }
+public class FileAsyncStressReadLockLockFileTest extends FileAsyncStressTest {
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -55,7 +35,7 @@
                 // leverage the fact that we can limit to max 50 files per poll
                 // this will result in polling again and potentially picking up files
                 // that already are in progress
-                from("file:target/filestress?maxMessagesPerPoll=50")
+                from("file:target/filestress?maxMessagesPerPoll=50&readLock=lockFile")
                     .threads(10)
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java?rev=782907&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java Tue Jun  9 08:17:35 2009
@@ -0,0 +1,52 @@
+/**
+ * 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.file.stress;
+
+import java.util.Random;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class FileAsyncStressReadLockNoneTest extends FileAsyncStressTest {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // leverage the fact that we can limit to max 50 files per poll
+                // this will result in polling again and potentially picking up files
+                // that already are in progress
+                from("file:target/filestress?maxMessagesPerPoll=50&readLock=none")
+                    .threads(10)
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            // simulate some work with random time to complete
+                            Random ran = new Random();
+                            int delay = ran.nextInt(500) + 10;
+                            Thread.sleep(delay);
+                        }
+                    }).to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java?rev=782907&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java Tue Jun  9 08:17:35 2009
@@ -0,0 +1,52 @@
+/**
+ * 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.file.stress;
+
+import java.util.Random;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class FileAsyncStressReadLockRenameTest extends FileAsyncStressTest {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // leverage the fact that we can limit to max 50 files per poll
+                // this will result in polling again and potentially picking up files
+                // that already are in progress
+                from("file:target/filestress?maxMessagesPerPoll=50&readLock=rename")
+                    .threads(10)
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            // simulate some work with random time to complete
+                            Random ran = new Random();
+                            int delay = ran.nextInt(500) + 10;
+                            Thread.sleep(delay);
+                        }
+                    }).to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date