[jboss-cvs] JBoss Messaging SVN: r4050 - in trunk/tests: src/org/jboss/messaging/core/remoting/impl/integration and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 14 12:15:01 EDT 2008
Author: jmesnil
Date: 2008-04-14 12:15:01 -0400 (Mon, 14 Apr 2008)
New Revision: 4050
Added:
trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/ClientExitTest.java
trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/GracefulClient.java
Removed:
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ClientExitTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/GracefulClient.java
Log:
* refactored ClientExitTest to check behaviour at the Core level (instead of JMS)
* removed serialization of JMS connection factory
Deleted: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ClientExitTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ClientExitTest.java 2008-04-14 15:09:30 UTC (rev 4049)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ClientExitTest.java 2008-04-14 16:15:01 UTC (rev 4050)
@@ -1,142 +0,0 @@
-/*
-* 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.test.messaging.jms;
-
-import java.io.File;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.test.messaging.JBMServerTestCase;
-
-/**
- * A test that makes sure that a Messaging client gracefully exists after the last connection is
- * closed. Test for http://jira.jboss.org/jira/browse/JBMESSAGING-417.
- *
- * This is not technically a crash test, but it uses the same type of topology as the crash tests
- * (local server, remote VM client).
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version 1.1
- *
- * $Id$
- */
-public class ClientExitTest extends JBMServerTestCase
-{
- // Constants ------------------------------------------------------------------------------------
-
- public static final String SERIALIZED_CF_FILE_NAME = "CFandQueue.ser";
- public static final String MESSAGE_TEXT = "kolowalu";
-
- // Static ---------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(ClientExitTest.class);
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ClientExitTest(String name)
- {
- super(name);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public void testGracefulClientExit() throws Exception
- {
- File serialized = null;
-
- Connection conn = null;
-
- try
- {
-
- //localServer.start("all", true);
- createQueue("Queue");
-
- // lookup the connection factory and the queue which we'll send to the client VM via a
- // serialized instances saved in file
-
- InitialContext ic = getInitialContext();
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup("/queue/Queue");
-
- serialized = SerializedClientSupport.writeToFile(SERIALIZED_CF_FILE_NAME, cf, queue);
-
- // spawn a JVM that creates a JMS client, which sends a test message
- Process p = SerializedClientSupport.spawnVM(GracefulClient.class.getName(), new String[] {serialized.getAbsolutePath()});
-
- // read the message from the queue
-
- conn = cf.createConnection();
- conn.start();
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue);
- TextMessage tm = (TextMessage)cons.receive(15000);
-
- assertNotNull(tm);
- assertEquals(MESSAGE_TEXT, tm.getText());
-
- // the client VM should exit by itself. If it doesn't, that means we have a problem
- // and the test will timeout
- log.info("waiting for the client VM to exit ...");
- p.waitFor();
-
- assertEquals(0, p.exitValue());
- }
- finally
- {
- try
- {
- if (conn != null)
- conn.close();
-
- // TODO delete the file
- if (serialized != null)
- {
- serialized.delete();
- }
-
- }
- catch (Throwable ignored)
- {
- log.warn("Exception ignored:" + ignored.toString(), ignored);
- }
- }
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Deleted: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/GracefulClient.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/GracefulClient.java 2008-04-14 15:09:30 UTC (rev 4049)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/GracefulClient.java 2008-04-14 16:15:01 UTC (rev 4050)
@@ -1,114 +0,0 @@
-/*
-* 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.test.messaging.jms;
-
-import java.io.FileInputStream;
-import java.io.ObjectInputStream;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-
-/**
- * Code to be run in an external VM, via main().
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class GracefulClient
-{
- // Constants ------------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- public static void main(String[] args) throws Exception
- {
-
- String serializedFileName = args[0];
-
- // we don't want to mess with JNDI, read the connection factory and the queue from their
- // serialized format, from disk
- ObjectInputStream ois =
- new ObjectInputStream(new FileInputStream(serializedFileName));
- ConnectionFactory cf =(ConnectionFactory)ois.readObject();
- Queue queue = (Queue)ois.readObject();
-
- ois.close();
-
- Connection conn = cf.createConnection();
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sess.createProducer(queue);
- MessageConsumer cons = sess.createConsumer(queue);
-
- prod.send(sess.createTextMessage(ClientExitTest.MESSAGE_TEXT));
-
- conn.start();
-
- // block in receiving for 5 secs, we won't receive anything
-
- cons.receive(5000);
-
- // this should silence any non-daemon thread and allow for graceful exit
- conn.close();
-
-// new Thread(new Runnable()
-// {
-// public void run()
-// {
-// // spin around in circles
-// while(true)
-// {
-// try
-// {
-// Thread.sleep(1000);
-// }
-// catch(Exception e)
-// {
-// // OK
-// }
-// }
-// }
-// }, "Spinner").start();
- }
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- // Command implementation -----------------------------------------------------------------------
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Copied: trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/ClientExitTest.java (from rev 4048, trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ClientExitTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/ClientExitTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/ClientExitTest.java 2008-04-14 16:15:01 UTC (rev 4050)
@@ -0,0 +1,131 @@
+/*
+* 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.core.remoting.impl.integration;
+
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.remoting.impl.ConfigurationHelper;
+import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.core.util.SerializedClientSupport;
+
+/**
+ * A test that makes sure that a Messaging client gracefully exists after the last connection is
+ * closed. Test for http://jira.jboss.org/jira/browse/JBMESSAGING-417.
+ *
+ * This is not technically a crash test, but it uses the same type of topology as the crash tests
+ * (local server, remote VM client).
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * $Id$
+ */
+public class ClientExitTest extends TestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ public static final String MESSAGE_TEXT = "kolowalu";
+
+ public static final String QUEUE = "ClientExitTestQueue";
+
+ // Static ---------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(ClientExitTest.class);
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private MessagingServer server;
+
+ private ClientConnection connection;
+
+ private ClientConsumer consumer;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void testGracefulClientExit() throws Exception
+ {
+ // spawn a JVM that creates a JMS client, which sends a test message
+ Process p = SerializedClientSupport.spawnVM(GracefulClient.class.getName());
+
+ // read the message from the queue
+
+ Message message = consumer.receive(15000);
+
+ assertNotNull(message);
+ assertEquals(MESSAGE_TEXT, new String(message.getPayload()));
+
+ // the client VM should exit by itself. If it doesn't, that means we have a problem
+ // and the test will timeout
+ log.info("waiting for the client VM to exit ...");
+ p.waitFor();
+
+ assertEquals(0, p.exitValue());
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ ConfigurationImpl config = ConfigurationHelper.newConfiguration(TCP,
+ "localhost", 9000);
+ server = new MessagingServerImpl(config);
+ server.start();
+
+ ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+ connection = cf.createConnection(null, null);
+ ClientSession session = connection.createClientSession(false, true, true, -1, false, false);
+ session.createQueue(QUEUE, QUEUE, null, false, false);
+ consumer = session.createConsumer(QUEUE, null, false, false, true);
+ connection.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ consumer.close();
+ connection.close();
+
+ server.stop();
+
+ super.tearDown();
+ }
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/GracefulClient.java (from rev 4048, trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/GracefulClient.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/GracefulClient.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/impl/integration/GracefulClient.java 2008-04-14 16:15:01 UTC (rev 4050)
@@ -0,0 +1,110 @@
+/*
+* 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.core.remoting.impl.integration;
+
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+import static org.jboss.messaging.core.remoting.impl.integration.ClientExitTest.QUEUE;
+
+import org.jboss.messaging.core.client.ClientConnection;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.impl.ClientConnectionFactoryImpl;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.core.remoting.impl.ConfigurationHelper;
+import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.impl.MessagingServerImpl;
+import org.jboss.messaging.jms.client.JBossTextMessage;
+
+/**
+ * Code to be run in an external VM, via main().
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class GracefulClient
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(GracefulClient.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static void main(String[] args) throws Exception
+ {
+ try
+ {
+ ConfigurationImpl config = ConfigurationHelper.newConfiguration(TCP,
+ "localhost", 9000);
+
+ // FIXME there should be another way to get a meaningful Version on the
+ // client side...
+ MessagingServer server = new MessagingServerImpl();
+ ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+ ClientConnection conn = cf.createConnection(null, null);
+ ClientSession session = conn.createClientSession(false, true, true, -1, false, false);
+ ClientProducer producer = session.createProducer(QUEUE);
+ ClientConsumer consumer = session.createConsumer(QUEUE, null, false, false, true);
+
+ MessageImpl message = new MessageImpl(JBossTextMessage.TYPE, false, 0,
+ System.currentTimeMillis(), (byte) 1);
+ message.setPayload(ClientExitTest.MESSAGE_TEXT.getBytes());
+ producer.send(message);
+
+ conn.start();
+
+ // block in receiving for 5 secs, we won't receive anything
+ consumer.receive(5000);
+
+ // this should silence any non-daemon thread and allow for graceful exit
+ conn.close();
+ } catch (Throwable t)
+ {
+ log.error(t.getMessage(), t);
+ System.exit(1);
+ }
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // Command implementation -----------------------------------------------------------------------
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list