[jboss-cvs] JBoss Messaging SVN: r4635 - in trunk/tests/src/org/jboss/messaging/tests: timing and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jul 5 10:14:34 EDT 2008


Author: timfox
Date: 2008-07-05 10:14:33 -0400 (Sat, 05 Jul 2008)
New Revision: 4635

Added:
   trunk/tests/src/org/jboss/messaging/tests/timing/
   trunk/tests/src/org/jboss/messaging/tests/timing/core/
   trunk/tests/src/org/jboss/messaging/tests/timing/core/client/
   trunk/tests/src/org/jboss/messaging/tests/timing/core/client/impl/
   trunk/tests/src/org/jboss/messaging/tests/timing/core/client/impl/ClientConsumerImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/timing/core/util/
   trunk/tests/src/org/jboss/messaging/tests/timing/core/util/TokenBucketLimiterImplTest.java
Removed:
   trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TokenBucketLimiterImplTest.java
Modified:
   trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java
Log:
Moved some tests to timing


Added: trunk/tests/src/org/jboss/messaging/tests/timing/core/client/impl/ClientConsumerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/timing/core/client/impl/ClientConsumerImplTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/timing/core/client/impl/ClientConsumerImplTest.java	2008-07-05 14:14:33 UTC (rev 4635)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.timing.core.client.impl;
+
+import java.util.concurrent.ExecutorService;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.MessageHandler;
+import org.jboss.messaging.core.client.impl.ClientConsumerImpl;
+import org.jboss.messaging.core.client.impl.ClientConsumerInternal;
+import org.jboss.messaging.core.client.impl.ClientSessionInternal;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.PacketDispatcher;
+import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.tests.util.UnitTestCase;
+
+/**
+ * 
+ * A ClientConsumerImplTest
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class ClientConsumerImplTest extends UnitTestCase
+{
+   private static final Logger log = Logger.getLogger(ClientConsumerImplTest.class);
+
+   public void testSetHandlerWhileReceiving() throws Exception
+   {
+      ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
+      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
+      ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
+      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);  
+             
+      final ClientConsumerInternal consumer =
+         new ClientConsumerImpl(session, 675765, 67565, 787, false, rc, pd, executor, 878787);
+      
+      MessageHandler handler = new MessageHandler()
+      {
+         public void onMessage(ClientMessage msg)
+         {            
+         }
+      };
+      
+      Thread t = new Thread()
+      {
+         public void run()
+         {
+            try
+            {
+               consumer.receive(1000);
+            }
+            catch (Exception e)
+            {
+            }
+         }
+      };
+      
+      t.start();
+      
+      Thread.sleep(100);
+      
+      try
+      {
+         consumer.setMessageHandler(handler);
+         
+         fail("Should throw exception");
+      }
+      catch (MessagingException e)
+      {
+         assertEquals(MessagingException.ILLEGAL_STATE, e.getCode());
+      } 
+      finally
+      {
+         t.interrupt();
+      }
+   }
+
+   // Private -----------------------------------------------------------------------------------------------------------
+
+}

Copied: trunk/tests/src/org/jboss/messaging/tests/timing/core/util/TokenBucketLimiterImplTest.java (from rev 4631, trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TokenBucketLimiterImplTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/timing/core/util/TokenBucketLimiterImplTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/timing/core/util/TokenBucketLimiterImplTest.java	2008-07-05 14:14:33 UTC (rev 4635)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+
+package org.jboss.messaging.tests.timing.core.util;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.util.TokenBucketLimiterImpl;
+
+/**
+ * 
+ * A TokenBucketLimiterImplTest
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class TokenBucketLimiterImplTest extends TestCase
+{
+	private static final Logger log = Logger.getLogger(TokenBucketLimiterImplTest.class);
+	
+	public void testRateWithSpin1() throws Exception
+	{
+		testRate(1, true);		
+	}
+	
+	public void testRateWithSpin10() throws Exception
+	{
+		testRate(10, true);		
+	}
+	
+	public void testRateWithSpin100() throws Exception
+	{
+		testRate(100, true);		
+	}
+	
+	public void testRateWithSpin1000() throws Exception
+	{
+		testRate(1000, true);		
+	}
+	
+	public void testRateWithSpin10000() throws Exception
+	{
+		testRate(10000, true);		
+	}
+	
+	public void testRateWithSpin100000() throws Exception
+	{
+		testRate(100000, true);		
+	}
+		
+	public void testRateWithoutSpin1() throws Exception
+	{
+		testRate(1, false);		
+	}
+	
+	public void testRateWithoutSpin10() throws Exception
+	{
+		testRate(10, false);		
+	}
+	
+	public void testRateWithoutSpin100() throws Exception
+	{
+		testRate(100, false);		
+	}
+	
+	public void testRateWithoutSpin1000() throws Exception
+	{
+		testRate(1000, false);		
+	}
+	
+	public void testRateWithoutSpin10000() throws Exception
+	{
+		testRate(10000, false);		
+	}
+	
+	public void testRateWithoutSpin100000() throws Exception
+	{
+		testRate(100000, false);		
+	}
+	
+	private void testRate(int rate, boolean spin) throws Exception
+	{		
+		final double error = 0.05;    //Allow for 5% error
+		
+		TokenBucketLimiterImpl tbl = new TokenBucketLimiterImpl(rate, spin);
+		
+		long start = System.currentTimeMillis();
+		
+		long count = 0;
+		
+		final long measureTime = 5000;
+		
+		while (System.currentTimeMillis() - start < measureTime)
+		{				
+			tbl.limit();
+			
+			count++;
+		}
+				
+		long end  = System.currentTimeMillis();
+		
+		double actualRate = ((double)(1000 * count)) / ( end - start);
+    
+      log.info("Desired rate: " + rate + " Actual rate " + actualRate + " invs/sec");
+      
+      assertTrue(actualRate > rate * (1 - error));
+      
+      assertTrue(actualRate < rate * (1 + error));
+		
+	}
+}

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java	2008-07-04 15:51:41 UTC (rev 4634)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java	2008-07-05 14:14:33 UTC (rev 4635)
@@ -540,56 +540,6 @@
       }      
    }
    
-   public void testSetHandlerWhileReceiving() throws Exception
-   {
-      ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-      RemotingConnection rc = EasyMock.createStrictMock(RemotingConnection.class);
-      ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
-      PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);  
-             
-      final ClientConsumerInternal consumer =
-         new ClientConsumerImpl(session, 675765, 67565, 787, false, rc, pd, executor, 878787);
-      
-      MessageHandler handler = new MessageHandler()
-      {
-         public void onMessage(ClientMessage msg)
-         {            
-         }
-      };
-      
-      Thread t = new Thread()
-      {
-         public void run()
-         {
-            try
-            {
-               consumer.receive(1000);
-            }
-            catch (Exception e)
-            {
-            }
-         }
-      };
-      
-      t.start();
-      
-      Thread.sleep(100);
-      
-      try
-      {
-         consumer.setMessageHandler(handler);
-         
-         fail("Should throw exception");
-      }
-      catch (MessagingException e)
-      {
-         assertEquals(MessagingException.ILLEGAL_STATE, e.getCode());
-      } 
-      finally
-      {
-         t.interrupt();
-      }
-   }
 
    public void testClose() throws Exception
    {

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TokenBucketLimiterImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TokenBucketLimiterImplTest.java	2008-07-04 15:51:41 UTC (rev 4634)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/util/TokenBucketLimiterImplTest.java	2008-07-05 14:14:33 UTC (rev 4635)
@@ -1,131 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-
-package org.jboss.messaging.tests.unit.core.util;
-
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.util.TokenBucketLimiterImpl;
-
-/**
- * 
- * A TokenBucketLimiterImplTest
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class TokenBucketLimiterImplTest extends TestCase
-{
-	private static final Logger log = Logger.getLogger(TokenBucketLimiterImplTest.class);
-	
-	public void testRateWithSpin1() throws Exception
-	{
-		testRate(1, true);		
-	}
-	
-	public void testRateWithSpin10() throws Exception
-	{
-		testRate(10, true);		
-	}
-	
-	public void testRateWithSpin100() throws Exception
-	{
-		testRate(100, true);		
-	}
-	
-	public void testRateWithSpin1000() throws Exception
-	{
-		testRate(1000, true);		
-	}
-	
-	public void testRateWithSpin10000() throws Exception
-	{
-		testRate(10000, true);		
-	}
-	
-	public void testRateWithSpin100000() throws Exception
-	{
-		testRate(100000, true);		
-	}
-		
-	public void testRateWithoutSpin1() throws Exception
-	{
-		testRate(1, false);		
-	}
-	
-	public void testRateWithoutSpin10() throws Exception
-	{
-		testRate(10, false);		
-	}
-	
-	public void testRateWithoutSpin100() throws Exception
-	{
-		testRate(100, false);		
-	}
-	
-	public void testRateWithoutSpin1000() throws Exception
-	{
-		testRate(1000, false);		
-	}
-	
-	public void testRateWithoutSpin10000() throws Exception
-	{
-		testRate(10000, false);		
-	}
-	
-	public void testRateWithoutSpin100000() throws Exception
-	{
-		testRate(100000, false);		
-	}
-	
-	private void testRate(int rate, boolean spin) throws Exception
-	{		
-		final double error = 0.05;    //Allow for 5% error
-		
-		TokenBucketLimiterImpl tbl = new TokenBucketLimiterImpl(rate, spin);
-		
-		long start = System.currentTimeMillis();
-		
-		long count = 0;
-		
-		final long measureTime = 5000;
-		
-		while (System.currentTimeMillis() - start < measureTime)
-		{				
-			tbl.limit();
-			
-			count++;
-		}
-				
-		long end  = System.currentTimeMillis();
-		
-		double actualRate = ((double)(1000 * count)) / ( end - start);
-    
-      log.info("Desired rate: " + rate + " Actual rate " + actualRate + " invs/sec");
-      
-      assertTrue(actualRate > rate * (1 - error));
-      
-      assertTrue(actualRate < rate * (1 + error));
-		
-	}
-}




More information about the jboss-cvs-commits mailing list