[hornetq-commits] JBoss hornetq SVN: r7914 - in trunk/tests: src/org/hornetq/tests/integration/jms and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 25 19:30:51 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-08-25 19:30:51 -0400 (Tue, 25 Aug 2009)
New Revision: 7914

Added:
   trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/
   trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
   trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
Removed:
   trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-107 - Move JMS test added by accident to integration-tests

Deleted: trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java	2009-08-25 20:13:48 UTC (rev 7913)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java	2009-08-25 23:30:51 UTC (rev 7914)
@@ -1,371 +0,0 @@
-/*
- * Copyright 2009 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.jms.tests.message;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.hornetq.jms.tests.JMSTestCase;
-
-/**
- *
- * @author <a href="mailto:clebert.suconic at feodorov.com">Clebert Suconic</a>
- * @version <tt>$Revision: 6220 $</tt>
- *
- * $Id: MessageHeaderTest.java 6220 2009-03-30 19:38:11Z timfox $
- */
-public class LargeMessageTest extends JMSTestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testSimpleLargeMessage() throws Exception
-   {
-      Connection conn = null;
-
-      try
-      {
-         conn = cf.createConnection();
-
-         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         MessageProducer prod = session.createProducer(queue1);
-
-         BytesMessage m = session.createBytesMessage();
-
-         m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(1024 * 1024));
-
-         prod.send(m);
-
-         conn.close();
-
-         conn = cf.createConnection();
-
-         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         MessageConsumer cons = session.createConsumer(queue1);
-
-         conn.start();
-
-         BytesMessage rm = (BytesMessage)cons.receive(10000);
-
-         byte data[] = new byte[1024];
-
-         System.out.println("Message = " + rm);
-
-         for (int i = 0; i < 1024 * 1024; i += 1024)
-         {
-            int numberOfBytes = rm.readBytes(data);
-            assertEquals(1024, numberOfBytes);
-            for (int j = 0; j < 1024; j++)
-            {
-               assertEquals(getSamplebyte(i + j), data[j]);
-            }
-         }
-
-         assertNotNull(rm);
-
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-
-   }
-
-   public void testSimpleLargeMessage2() throws Exception
-   {
-      Connection conn = null;
-
-      try
-      {
-         conn = cf.createConnection();
-
-         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         MessageProducer prod = session.createProducer(queue1);
-
-         BytesMessage m = session.createBytesMessage();
-
-         m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
-
-         prod.send(m);
-
-         conn.close();
-
-         conn = cf.createConnection();
-
-         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         MessageConsumer cons = session.createConsumer(queue1);
-
-         conn.start();
-
-         BytesMessage rm = (BytesMessage)cons.receive(10000);
-
-         byte data[] = new byte[1024];
-
-         System.out.println("Message = " + rm);
-
-         int numberOfBytes = rm.readBytes(data);
-         assertEquals(10, numberOfBytes);
-         for (int j = 0; j < numberOfBytes; j++)
-         {
-            assertEquals(getSamplebyte(j), data[j]);
-         }
-
-         assertNotNull(rm);
-
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-
-   }
-
-   public void testExceptionsOnSettingNonStreaming() throws Exception
-   {
-      Connection conn = null;
-
-      try
-      {
-         conn = cf.createConnection();
-
-         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         TextMessage msg = session.createTextMessage();
-
-         try
-         {
-            msg.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
-            fail("Exception was expected");
-         }
-         catch (JMSException e)
-         {
-         }
-
-         msg.setText("hello");
-
-         MessageProducer prod = session.createProducer(queue1);
-
-         prod.send(msg);
-
-         conn.close();
-
-         conn = cf.createConnection();
-
-         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         MessageConsumer cons = session.createConsumer(queue1);
-
-         conn.start();
-
-         TextMessage rm = (TextMessage)cons.receive(10000);
-
-         try
-         {
-            rm.setObjectProperty("JMS_HQ_OutputStream", new OutputStream()
-            {
-               @Override
-               public void write(int b) throws IOException
-               {
-                  System.out.println("b = " + b);
-               }
-
-            });
-            fail("Exception was expected");
-         }
-         catch (JMSException e)
-         {
-         }
-
-         
-         assertEquals("hello", rm.getText());
-
-         assertNotNull(rm);
-
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-
-   }
-
-   public void testWaitOnOutputStream() throws Exception
-   {
-      int msgSize = 1024 * 1024;
-
-      Connection conn = null;
-
-      try
-      {
-         conn = cf.createConnection();
-
-         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         MessageProducer prod = session.createProducer(queue1);
-
-         BytesMessage m = session.createBytesMessage();
-
-         m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(msgSize));
-
-         prod.send(m);
-
-         conn.close();
-
-         conn = cf.createConnection();
-
-         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         MessageConsumer cons = session.createConsumer(queue1);
-
-         conn.start();
-
-         BytesMessage rm = (BytesMessage)cons.receive(10000);
-         assertNotNull(rm);
-
-         final AtomicLong numberOfBytes = new AtomicLong(0);
-
-         final AtomicInteger numberOfErrors = new AtomicInteger(0);
-
-         OutputStream out = new OutputStream()
-         {
-
-            int position = 0;
-
-            @Override
-            public void write(int b) throws IOException
-            {
-               numberOfBytes.incrementAndGet();
-               if (getSamplebyte(position++) != b)
-               {
-                  System.out.println("Wrong byte at position " + position);
-                  numberOfErrors.incrementAndGet();
-               }
-            }
-
-         };
-
-         rm.setObjectProperty("JMS_HQ_SaveStream", out);
-
-         assertEquals(msgSize, numberOfBytes.get());
-
-         assertEquals(0, numberOfErrors.get());
-
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   protected byte getSamplebyte(final long position)
-   {
-      return (byte)('a' + (position) % ('z' - 'a' + 1));
-   }
-
-   // Creates a Fake LargeStream without using a real file
-   protected InputStream createFakeLargeStream(final long size) throws Exception
-   {
-      return new InputStream()
-      {
-         private long count;
-
-         private boolean closed = false;
-
-         @Override
-         public void close() throws IOException
-         {
-            super.close();
-            System.out.println("Sent " + count + " bytes over fakeOutputStream, while size = " + size);
-            closed = true;
-         }
-
-         @Override
-         public int read() throws IOException
-         {
-            if (closed)
-            {
-               throw new IOException("Stream was closed");
-            }
-            if (count++ < size)
-            {
-               return getSamplebyte(count - 1);
-            }
-            else
-            {
-               return -1;
-            }
-         }
-      };
-
-   }
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-   class ThreadReader extends Thread
-   {
-      CountDownLatch latch;
-
-      ThreadReader(CountDownLatch latch)
-      {
-         this.latch = latch;
-      }
-
-      public void run()
-      {
-      }
-   }
-
-}

Copied: trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java (from rev 7912, trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java)
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java	2009-08-25 23:30:51 UTC (rev 7914)
@@ -0,0 +1,352 @@
+/*
+ * Copyright 2009 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.integration.jms.largemessage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.hornetq.jms.tests.JMSTestCase;
+import org.hornetq.tests.util.JMSTestBase;
+
+/**
+ *
+ * @author <a href="mailto:clebert.suconic at feodorov.com">Clebert Suconic</a>
+ * @version <tt>$Revision: 6220 $</tt>
+ *
+ * $Id: MessageHeaderTest.java 6220 2009-03-30 19:38:11Z timfox $
+ */
+public class JMSLargeMessageTest extends JMSTestBase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   Queue queue1;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   protected boolean usePersistence()
+   {
+      return true;
+   }
+   
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      serverManager.createQueue("queue1", "/jms/queue1", null, true);
+      
+      queue1 = (Queue)context.lookup("/jms/queue1");
+   }
+   
+   protected void tearDown() throws Exception
+   {
+      queue1 = null;
+      super.tearDown();
+   }
+
+   public void testSimpleLargeMessage() throws Exception
+   {
+      Connection conn = null;
+
+      try
+      {
+         conn = cf.createConnection();
+
+         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageProducer prod = session.createProducer(queue1);
+
+         BytesMessage m = session.createBytesMessage();
+
+         m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(1024 * 1024));
+
+         prod.send(m);
+
+         conn.close();
+
+         conn = cf.createConnection();
+
+         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageConsumer cons = session.createConsumer(queue1);
+
+         conn.start();
+
+         BytesMessage rm = (BytesMessage)cons.receive(10000);
+
+         byte data[] = new byte[1024];
+
+         System.out.println("Message = " + rm);
+
+         for (int i = 0; i < 1024 * 1024; i += 1024)
+         {
+            int numberOfBytes = rm.readBytes(data);
+            assertEquals(1024, numberOfBytes);
+            for (int j = 0; j < 1024; j++)
+            {
+               assertEquals(getSamplebyte(i + j), data[j]);
+            }
+         }
+
+         assertNotNull(rm);
+
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+
+   public void testSimpleLargeMessage2() throws Exception
+   {
+      Connection conn = null;
+
+      try
+      {
+         conn = cf.createConnection();
+
+         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageProducer prod = session.createProducer(queue1);
+
+         BytesMessage m = session.createBytesMessage();
+
+         m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
+
+         prod.send(m);
+
+         conn.close();
+
+         conn = cf.createConnection();
+
+         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageConsumer cons = session.createConsumer(queue1);
+
+         conn.start();
+
+         BytesMessage rm = (BytesMessage)cons.receive(10000);
+
+         byte data[] = new byte[1024];
+
+         System.out.println("Message = " + rm);
+
+         int numberOfBytes = rm.readBytes(data);
+         assertEquals(10, numberOfBytes);
+         for (int j = 0; j < numberOfBytes; j++)
+         {
+            assertEquals(getSamplebyte(j), data[j]);
+         }
+
+         assertNotNull(rm);
+
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+
+   public void testExceptionsOnSettingNonStreaming() throws Exception
+   {
+      Connection conn = null;
+
+      try
+      {
+         conn = cf.createConnection();
+
+         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         TextMessage msg = session.createTextMessage();
+
+         try
+         {
+            msg.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
+            fail("Exception was expected");
+         }
+         catch (JMSException e)
+         {
+         }
+
+         msg.setText("hello");
+
+         MessageProducer prod = session.createProducer(queue1);
+
+         prod.send(msg);
+
+         conn.close();
+
+         conn = cf.createConnection();
+
+         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageConsumer cons = session.createConsumer(queue1);
+
+         conn.start();
+
+         TextMessage rm = (TextMessage)cons.receive(10000);
+
+         try
+         {
+            rm.setObjectProperty("JMS_HQ_OutputStream", new OutputStream()
+            {
+               @Override
+               public void write(int b) throws IOException
+               {
+                  System.out.println("b = " + b);
+               }
+
+            });
+            fail("Exception was expected");
+         }
+         catch (JMSException e)
+         {
+         }
+
+         
+         assertEquals("hello", rm.getText());
+
+         assertNotNull(rm);
+
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+
+   public void testWaitOnOutputStream() throws Exception
+   {
+      int msgSize = 1024 * 1024;
+
+      Connection conn = null;
+
+      try
+      {
+         conn = cf.createConnection();
+
+         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageProducer prod = session.createProducer(queue1);
+
+         BytesMessage m = session.createBytesMessage();
+
+         m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(msgSize));
+
+         prod.send(m);
+
+         conn.close();
+
+         conn = cf.createConnection();
+
+         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         MessageConsumer cons = session.createConsumer(queue1);
+
+         conn.start();
+
+         BytesMessage rm = (BytesMessage)cons.receive(10000);
+         assertNotNull(rm);
+
+         final AtomicLong numberOfBytes = new AtomicLong(0);
+
+         final AtomicInteger numberOfErrors = new AtomicInteger(0);
+
+         OutputStream out = new OutputStream()
+         {
+
+            int position = 0;
+
+            @Override
+            public void write(int b) throws IOException
+            {
+               numberOfBytes.incrementAndGet();
+               if (getSamplebyte(position++) != b)
+               {
+                  System.out.println("Wrong byte at position " + position);
+                  numberOfErrors.incrementAndGet();
+               }
+            }
+
+         };
+
+         rm.setObjectProperty("JMS_HQ_SaveStream", out);
+
+         assertEquals(msgSize, numberOfBytes.get());
+
+         assertEquals(0, numberOfErrors.get());
+
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+      }
+
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+   class ThreadReader extends Thread
+   {
+      CountDownLatch latch;
+
+      ThreadReader(CountDownLatch latch)
+      {
+         this.latch = latch;
+      }
+
+      public void run()
+      {
+      }
+   }
+
+}

Added: trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java	2009-08-25 23:30:51 UTC (rev 7914)
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2009 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.util;
+
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.ConnectionFactory;
+
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.core.server.HornetQ;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.integration.transports.netty.NettyAcceptorFactory;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+import org.hornetq.tests.unit.util.InVMContext;
+import org.hornetq.utils.Pair;
+
+/**
+ * A JMSBaseTest
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JMSTestBase extends ServiceTestBase
+{
+
+   protected HornetQServer server;
+
+   protected JMSServerManagerImpl serverManager;
+   
+   protected ConnectionFactory cf;
+
+   protected InVMContext context;
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // TestCase overrides -------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   protected boolean useSecurity()
+   {
+      return false;
+   }
+
+   protected boolean useJMX()
+   {
+      return true;
+   }
+
+   protected boolean usePersistence()
+   {
+      return false;
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      Configuration conf = createDefaultConfig(false);
+      conf.setSecurityEnabled(false);
+      conf.setJMXManagementEnabled(true);
+
+      conf.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
+
+      server = HornetQ.newHornetQServer(conf, false);
+
+      serverManager = new JMSServerManagerImpl(server);
+      context = new InVMContext();
+      serverManager.setContext(context);
+      serverManager.start();
+      serverManager.activated();
+
+      registerConnectionFactory();
+   }
+
+   protected void restartServer() throws Exception
+   {
+      serverManager.start();
+      serverManager.activated();
+      context = new InVMContext();
+      serverManager.setContext(context);
+      registerConnectionFactory();
+   }
+
+   protected void killServer() throws Exception
+   {
+      serverManager.stop();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+
+      serverManager.stop();
+
+      server.stop();
+
+      context.close();
+
+      server = null;
+
+      serverManager = null;
+
+      context = null;
+
+      super.tearDown();
+   }
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+   private void registerConnectionFactory() throws Exception
+   {
+      int retryInterval = 1000;
+      double retryIntervalMultiplier = 1.0;
+      int reconnectAttempts = -1;
+      boolean failoverOnServerShutdown = true;
+      int callTimeout = 30000;
+
+      List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+      connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(NettyConnectorFactory.class.getName()),
+                                                                                    null));
+
+      List<String> jndiBindings = new ArrayList<String>();
+      jndiBindings.add("/cf");
+
+      serverManager.createConnectionFactory("ManualReconnectionToSingleServerTest",
+                                            connectorConfigs,
+                                            null,
+                                            DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
+                                            DEFAULT_CONNECTION_TTL,
+                                            callTimeout,
+                                            DEFAULT_MAX_CONNECTIONS,
+                                            DEFAULT_CACHE_LARGE_MESSAGE_CLIENT,
+                                            DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+                                            DEFAULT_CONSUMER_WINDOW_SIZE,
+                                            DEFAULT_CONSUMER_MAX_RATE,
+                                            DEFAULT_PRODUCER_WINDOW_SIZE,
+                                            DEFAULT_PRODUCER_MAX_RATE,
+                                            DEFAULT_BLOCK_ON_ACKNOWLEDGE,
+                                            DEFAULT_BLOCK_ON_PERSISTENT_SEND,
+                                            DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
+                                            DEFAULT_AUTO_GROUP,
+                                            DEFAULT_PRE_ACKNOWLEDGE,
+                                            DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+                                            DEFAULT_ACK_BATCH_SIZE,
+                                            DEFAULT_ACK_BATCH_SIZE,
+                                            DEFAULT_USE_GLOBAL_POOLS,
+                                            DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+                                            DEFAULT_THREAD_POOL_MAX_SIZE,
+                                            retryInterval,
+                                            retryIntervalMultiplier,
+                                            reconnectAttempts,
+                                            failoverOnServerShutdown,
+                                            jndiBindings);
+      
+      cf = (ConnectionFactory)context.lookup("/cf");
+      
+   }
+
+}



More information about the hornetq-commits mailing list