You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by sc...@apache.org on 2008/12/01 22:29:21 UTC

svn commit: r722240 - in /incubator/etch/trunk: binding-csharp/runtime/src/test/csharp/Etch/Support/TestFreePool.cs binding-java/runtime/src/test/java/etch/bindings/java/support/TestFreePool.java

Author: sccomer
Date: Mon Dec  1 13:29:21 2008
New Revision: 722240

URL: http://svn.apache.org/viewvc?rev=722240&view=rev
Log:
fix issue with clock tick quanta in free pool tests.

Modified:
    incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestFreePool.cs
    incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/support/TestFreePool.java

Modified: incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestFreePool.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestFreePool.cs?rev=722240&r1=722239&r2=722240&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestFreePool.cs (original)
+++ incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Support/TestFreePool.cs Mon Dec  1 13:29:21 2008
@@ -23,6 +23,10 @@
     [TestFixture]
     public class TestFreePool
     {
+        private const int Q1 = 30; // 1 quanta of reliable clock tick
+        private const int Q2 = 60; // 2 quanta of reliable clock tick
+        private const int Q3 = 90; // 3 quanta of reliable clock tick
+
         [Test]
         public void close1()
         {
@@ -71,7 +75,7 @@
             Assert.IsFalse(r.done);
             Assert.IsNull(r.ex);
             p.Run(r.run, r.exception);
-            Thread.Sleep(30);
+            Thread.Sleep(Q2);
             Assert.IsTrue(r.done);
             Assert.IsNull(r.ex);
             p.Join();
@@ -82,7 +86,7 @@
         {
             FreePool p = new FreePool(2);
 
-            MyPoolRunnable r = new MyPoolRunnable(30, false);
+            MyPoolRunnable r = new MyPoolRunnable(Q1, false);
             Assert.IsFalse(r.done);
             Assert.IsNull(r.ex);
             p.Run(r.run, r.exception);
@@ -104,7 +108,7 @@
 
             p.Run(r.run, r.exception);
 
-            Thread.Sleep(30);
+            Thread.Sleep(Q1);
             Assert.IsTrue(r.done);
             Assert.IsNull(r.ex);
         }
@@ -121,7 +125,7 @@
 
                 p.Run(r.run, r.exception);
 
-                Thread.Sleep(30);
+                Thread.Sleep(Q1);
                 Assert.IsTrue(r.done);
                 Assert.IsNull(r.ex);
             }
@@ -138,7 +142,7 @@
 
             p.Run(r.run, r.exception);
 
-            Thread.Sleep(30);
+            Thread.Sleep(Q1);
             Assert.IsFalse(r.done);
             Assert.IsNotNull(r.ex);
         }
@@ -148,17 +152,17 @@
         {
             FreePool p = new FreePool(2);
 
-            MyPoolRunnable r = new MyPoolRunnable(30, false);
+            MyPoolRunnable r = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r.done);
             Assert.IsNull(r.ex);
 
             p.Run(r.run, r.exception);
 
-            Thread.Sleep(15);
+            Thread.Sleep(Q1);
             Assert.IsFalse(r.done);
             Assert.IsNull(r.ex);
 
-            Thread.Sleep(45);
+            Thread.Sleep(Q3);
             Assert.IsTrue(r.done);
             Assert.IsNull(r.ex);
         }
@@ -168,25 +172,25 @@
         {
             FreePool p = new FreePool(2);
 
-            MyPoolRunnable r1 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r1 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r1.done);
             Assert.IsNull(r1.ex);
 
-            MyPoolRunnable r2 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r2 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r2.done);
             Assert.IsNull(r2.ex);
 
             p.Run(r1.run, r1.exception);
             p.Run(r2.run, r2.exception);
 
-            Thread.Sleep(15);
+            Thread.Sleep(Q1);
             Assert.IsFalse(r1.done);
             Assert.IsNull(r1.ex);
 
             Assert.IsFalse(r2.done);
             Assert.IsNull(r2.ex);
 
-            Thread.Sleep(45);
+            Thread.Sleep(Q3);
             Assert.IsTrue(r1.done);
             Assert.IsNull(r1.ex);
 
@@ -201,15 +205,15 @@
             // free pool thread count exceeded
             FreePool p = new FreePool(2);
 
-            MyPoolRunnable r1 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r1 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r1.done);
             Assert.IsNull(r1.ex);
 
-            MyPoolRunnable r2 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r2 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r2.done);
             Assert.IsNull(r2.ex);
 
-            MyPoolRunnable r3 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r3 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r3.done);
             Assert.IsNull(r3.ex);
 
@@ -223,15 +227,15 @@
         {
             FreePool p = new FreePool(2);
 
-            MyPoolRunnable r1 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r1 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r1.done);
             Assert.IsNull(r1.ex);
 
-            MyPoolRunnable r2 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r2 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r2.done);
             Assert.IsNull(r2.ex);
 
-            MyPoolRunnable r3 = new MyPoolRunnable(30, false);
+            MyPoolRunnable r3 = new MyPoolRunnable(Q2, false);
             Assert.IsFalse(r3.done);
             Assert.IsNull(r3.ex);
 
@@ -239,7 +243,7 @@
             p.Run(r2.run, r2.exception);
             try { p.Run(r3.run, r3.exception); } catch (Exception) { }
 
-            Thread.Sleep(15);
+            Thread.Sleep(Q1);
             Assert.IsFalse(r1.done);
             Assert.IsNull(r1.ex);
 
@@ -249,7 +253,7 @@
             Assert.IsFalse(r3.done);
             Assert.IsNull(r3.ex);
 
-            Thread.Sleep(45);
+            Thread.Sleep(Q3);
             Assert.IsTrue(r1.done);
             Assert.IsNull(r1.ex);
 

Modified: incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/support/TestFreePool.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/support/TestFreePool.java?rev=722240&r1=722239&r2=722240&view=diff
==============================================================================
--- incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/support/TestFreePool.java (original)
+++ incubator/etch/trunk/binding-java/runtime/src/test/java/etch/bindings/java/support/TestFreePool.java Mon Dec  1 13:29:21 2008
@@ -27,6 +27,10 @@
  */
 public class TestFreePool
 {
+	private final static int Q1 = 30; // 1 quanta of dependable clock tick
+	private final static int Q2 = 60; // 2 quanta of dependable clock tick
+	private final static int Q3 = 90; // 3 quanta of dependable clock tick
+	
 	/** @throws Exception */
 	@Test
 	public void close1() throws Exception
@@ -77,10 +81,13 @@
 		MyPoolRunnable r = new MyPoolRunnable( 0, false );
 		assertFalse( r.done );
 		assertNull( r.ex );
+		
 		p.run( r );
-		Thread.sleep( 30 );
+		
+		Thread.sleep( Q1 );
 		assertTrue( r.done );
 		assertNull( r.ex );
+		
 		p.join();
 	}
 
@@ -90,12 +97,14 @@
 	{
 		FreePool p = new FreePool( 2 );
 		
-		MyPoolRunnable r = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r = new MyPoolRunnable( Q1, false );
 		assertFalse( r.done );
 		assertNull( r.ex );
+		
 		p.run( r );
 		assertFalse( r.done );
 		assertNull( r.ex );
+		
 		p.join();
 		assertTrue( r.done );
 		assertNull( r.ex );
@@ -113,7 +122,7 @@
 		
 		p.run( r );
 		
-		Thread.sleep( 30 );
+		Thread.sleep( Q1 );
 		assertTrue( r.done );
 		assertNull( r.ex );
 	}
@@ -131,7 +140,7 @@
 			
 			p.run( r );
 			
-			Thread.sleep( 30 );
+			Thread.sleep( Q1 );
 			assertTrue( r.done );
 			assertNull( r.ex );
 		}
@@ -149,7 +158,7 @@
 		
 		p.run( r );
 		
-		Thread.sleep( 30 );
+		Thread.sleep( Q1 );
 		assertFalse( r.done );
 		assertNotNull( r.ex );
 	}
@@ -160,17 +169,17 @@
 	{
 		FreePool p = new FreePool( 2 );
 		
-		MyPoolRunnable r = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r = new MyPoolRunnable( Q2, false );
 		assertFalse( r.done );
 		assertNull( r.ex );
 		
 		p.run( r );
 		
-		Thread.sleep( 15 );
+		Thread.sleep( Q1 );
 		assertFalse( r.done );
 		assertNull( r.ex );
 		
-		Thread.sleep( 45 );
+		Thread.sleep( Q3 );
 		assertTrue( r.done );
 		assertNull( r.ex );
 	}
@@ -181,25 +190,25 @@
 	{
 		FreePool p = new FreePool( 2 );
 		
-		MyPoolRunnable r1 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r1 = new MyPoolRunnable( Q2, false );
 		assertFalse( r1.done );
 		assertNull( r1.ex );
 		
-		MyPoolRunnable r2 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r2 = new MyPoolRunnable( Q2, false );
 		assertFalse( r2.done );
 		assertNull( r2.ex );
 
 		p.run( r1 );
 		p.run( r2 );
 		
-		Thread.sleep( 15 );
+		Thread.sleep( Q1 );
 		assertFalse( r1.done );
 		assertNull( r1.ex );
 		
 		assertFalse( r2.done );
 		assertNull( r2.ex );
 		
-		Thread.sleep( 45 );
+		Thread.sleep( Q3 );
 		assertTrue( r1.done );
 		assertNull( r1.ex );
 		
@@ -214,15 +223,15 @@
 		// free pool thread count exceeded
 		FreePool p = new FreePool( 2 );
 		
-		MyPoolRunnable r1 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r1 = new MyPoolRunnable( Q2, false );
 		assertFalse( r1.done );
 		assertNull( r1.ex );
 		
-		MyPoolRunnable r2 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r2 = new MyPoolRunnable( Q2, false );
 		assertFalse( r2.done );
 		assertNull( r2.ex );
 		
-		MyPoolRunnable r3 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r3 = new MyPoolRunnable( Q2, false );
 		assertFalse( r3.done );
 		assertNull( r3.ex );
 
@@ -237,15 +246,15 @@
 	{
 		FreePool p = new FreePool( 2 );
 		
-		MyPoolRunnable r1 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r1 = new MyPoolRunnable( Q2, false );
 		assertFalse( r1.done );
 		assertNull( r1.ex );
 		
-		MyPoolRunnable r2 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r2 = new MyPoolRunnable( Q2, false );
 		assertFalse( r2.done );
 		assertNull( r2.ex );
 		
-		MyPoolRunnable r3 = new MyPoolRunnable( 30, false );
+		MyPoolRunnable r3 = new MyPoolRunnable( Q2, false );
 		assertFalse( r3.done );
 		assertNull( r3.ex );
 
@@ -253,7 +262,7 @@
 		p.run( r2 );
 		try { p.run( r3 ); } catch ( IllegalStateException e ) {}
 		
-		Thread.sleep( 15 );
+		Thread.sleep( Q1 );
 		assertFalse( r1.done );
 		assertNull( r1.ex );
 		
@@ -263,7 +272,7 @@
 		assertFalse( r3.done );
 		assertNull( r3.ex );
 		
-		Thread.sleep( 45 );
+		Thread.sleep( Q3 );
 		assertTrue( r1.done );
 		assertNull( r1.ex );