[hornetq-commits] JBoss hornetq SVN: r9693 - trunk/tests/src/org/hornetq/tests/soak/client.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Sep 15 16:30:04 EDT 2010


Author: clebert.suconic at jboss.com
Date: 2010-09-15 16:30:04 -0400 (Wed, 15 Sep 2010)
New Revision: 9693

Added:
   trunk/tests/src/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java
Log:
Adding a new simple test on sending and receiving messages to investigate a leak on LinkedList

Added: trunk/tests/src/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/soak/client/SimpleSendReceiveSoakTest.java	2010-09-15 20:30:04 UTC (rev 9693)
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat 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.hornetq.tests.soak.client;
+
+import java.util.HashMap;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.tests.util.ServiceTestBase;
+
+/**
+ * A ClientSoakTest
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class SimpleSendReceiveSoakTest extends ServiceTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private static final SimpleString ADDRESS = new SimpleString("ADD");
+
+   private static final boolean IS_NETTY = false;
+
+   private static final boolean IS_JOURNAL = false;
+
+   public static final int MIN_MESSAGES_ON_QUEUE = 1000;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   private HornetQServer server;
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      clearData();
+
+      Configuration config = createDefaultConfig(SimpleSendReceiveSoakTest.IS_NETTY);
+
+      config.setJournalFileSize(10 * 1024 * 1024);
+
+      server = createServer(IS_JOURNAL, config, -1, -1, new HashMap<String, AddressSettings>());
+
+      server.start();
+
+      ClientSessionFactory sf = createFactory(SimpleSendReceiveSoakTest.IS_NETTY);
+
+      ClientSession session = sf.createSession();
+
+      session.createQueue(SimpleSendReceiveSoakTest.ADDRESS, SimpleSendReceiveSoakTest.ADDRESS, true);
+
+      session.close();
+
+      sf.close();
+
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      server.stop();
+      server = null;
+   }
+
+   public void testSoakClient() throws Exception
+   {
+      final ClientSessionFactory sf = createFactory(IS_NETTY);
+
+      ClientSession session = sf.createSession(true, true);
+
+      ClientProducer producer = session.createProducer(ADDRESS);
+
+      long msgId = 0;
+
+      long msgReceivedID = 0;
+
+      for (int i = 0; i < MIN_MESSAGES_ON_QUEUE; i++)
+      {
+         ClientMessage msg = session.createMessage(IS_JOURNAL);
+         msg.putLongProperty("count", msgId++);
+         msg.getBodyBuffer().writeBytes(new byte[10 * 1024]);
+         producer.send(msg);
+      }
+
+      ClientSession sessionConsumer = sf.createSession(true, true, 0);
+      ClientConsumer consumer = sessionConsumer.createConsumer(ADDRESS);
+      sessionConsumer.start();
+
+      for (int loopNumber = 0; loopNumber < 1000; loopNumber++)
+      {
+         System.out.println("Loop " + loopNumber);
+         for (int i = 0; i < MIN_MESSAGES_ON_QUEUE; i++)
+         {
+            ClientMessage msg = session.createMessage(IS_JOURNAL);
+            msg.putLongProperty("count", msgId++);
+            msg.getBodyBuffer().writeBytes(new byte[10 * 1024]);
+            producer.send(msg);
+         }
+         
+         session.commit();
+
+         for (int i = 0; i < MIN_MESSAGES_ON_QUEUE; i++)
+         {
+            ClientMessage msg = consumer.receive(5000);
+            assertNotNull(msg);
+            msg.acknowledge();
+            assertEquals(msgReceivedID++, msg.getLongProperty("count").longValue());
+         }
+         
+         sessionConsumer.commit();
+      }
+
+      sessionConsumer.close();
+      session.close();
+      sf.close();
+
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}



More information about the hornetq-commits mailing list