From do-not-reply at jboss.org Thu Apr 28 19:02:24 2011 Content-Type: multipart/mixed; boundary="===============4065106067928116443==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: hornetq-commits at lists.jboss.org Subject: [hornetq-commits] JBoss hornetq SVN: r10573 - in branches/Branch_2_2_EAP/tests/src/org/hornetq/tests: util and 1 other directory. Date: Thu, 28 Apr 2011 19:02:24 -0400 Message-ID: <201104282302.p3SN2OJa013489@svn01.web.mwc.hst.phx2.redhat.com> --===============4065106067928116443== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: clebert.suconic(a)jboss.com Date: 2011-04-28 19:02:24 -0400 (Thu, 28 Apr 2011) New Revision: 10573 Added: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/clie= nt/ExpiryMessageTest.java Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSClusteredTes= tBase.java branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java Log: There is no such thing as enough tests. Created a test to verify a possible= issue and committed it Added: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/= client/ExpiryMessageTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/cli= ent/ExpiryMessageTest.java (rev 0) +++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/cli= ent/ExpiryMessageTest.java 2011-04-28 23:02:24 UTC (rev 10573) @@ -0,0 +1,113 @@ +/* + * 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.client; + +import javax.jms.Connection; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import javax.jms.Topic; + +import org.hornetq.api.jms.management.TopicControl; +import org.hornetq.core.config.Configuration; +import org.hornetq.tests.integration.management.ManagementControlHelper; +import org.hornetq.tests.util.JMSTestBase; + +/** + * = + * A MessageTest + * + * @author Tim Fox + * + * + */ +public class ExpiryMessageTest extends JMSTestBase +{ + // Constants ----------------------------------------------------- + + // Attributes ---------------------------------------------------- + + // Static -------------------------------------------------------- + + // Constructors -------------------------------------------------- + + // Public -------------------------------------------------------- + + @Override + protected Configuration createDefaultConfig(boolean netty) + { + Configuration conf =3D super.createDefaultConfig(netty); + = + conf.setMessageExpiryScanPeriod(1000); + = + return conf; + } + = + public void testSendTopicNoSubscription() throws Exception + { + = + Topic topic =3D createTopic("test-topic"); + TopicControl control =3D ManagementControlHelper.createTopicControl(= topic, mbeanServer); + = + System.out.println("size =3D " + control.getMessageCount()); + = + Connection conn2 =3D cf.createConnection(); + = + conn2.setClientID("client1"); + = + Session sess2 =3D conn2.createSession(true, Session.SESSION_TRANSACT= ED); + = + sess2.createDurableSubscriber(topic, "client-sub1"); + sess2.createDurableSubscriber(topic, "client-sub2"); + = + conn2.close(); + + Connection conn =3D cf.createConnection(); + Session sess =3D conn.createSession(true, Session.SESSION_TRANSACTED= ); + MessageProducer prod =3D sess.createProducer(topic); + prod.setTimeToLive(1000); + = + for (int i =3D 0 ; i < 100; i++) + { + TextMessage txt =3D sess.createTextMessage("txt"); + prod.send(txt); + } + = + sess.commit(); + = + conn.close(); + + // minimal time needed + Thread.sleep(2000); + = + long timeout =3D System.currentTimeMillis() + 10000; + = + // We will wait some time, but we will wait as minimal as possible + while (control.getMessageCount() !=3D 0 && System.currentTimeMillis(= ) > timeout) + { + Thread.sleep(100); + } + = + assertEquals(0, control.getMessageCount()); + = + = + } + + // Package protected --------------------------------------------- + + // Protected ----------------------------------------------------- + + // Private ------------------------------------------------------- + // Inner classes ------------------------------------------------- +} Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSClust= eredTestBase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSClusteredTe= stBase.java 2011-04-28 15:53:00 UTC (rev 10572) +++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSClusteredTe= stBase.java 2011-04-28 23:02:24 UTC (rev 10573) @@ -151,7 +151,7 @@ = "server2", = 1000, = true, - = true, + = false, = MAX_HOPS, = 1024, = toOtherServerPair, false)); @@ -196,7 +196,7 @@ = "server1", = 1000, = true, - = true, + = false, = MAX_HOPS, = 1024, = toOtherServerPair, false)); Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestB= ase.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.ja= va 2011-04-28 15:53:00 UTC (rev 10572) +++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.ja= va 2011-04-28 23:02:24 UTC (rev 10573) @@ -19,6 +19,8 @@ import javax.jms.ConnectionFactory; import javax.jms.Queue; import javax.jms.Topic; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; import javax.naming.NamingException; = import org.hornetq.api.core.TransportConfiguration; @@ -45,6 +47,8 @@ protected HornetQServer server; = protected JMSServerManagerImpl jmsServer; + = + protected MBeanServer mbeanServer; = protected ConnectionFactory cf; = @@ -101,15 +105,15 @@ protected void setUp() throws Exception { super.setUp(); + = + mbeanServer =3D MBeanServerFactory.createMBeanServer(); = Configuration conf =3D createDefaultConfig(false); - conf.setSecurityEnabled(false); - conf.setJMXManagementEnabled(true); = conf.getAcceptorConfigurations().add(new TransportConfiguration(Nett= yAcceptorFactory.class.getName())); conf.getConnectorConfigurations().put("netty", new TransportConfigur= ation(NettyConnectorFactory.class.getName())); = - server =3D HornetQServers.newHornetQServer(conf, usePersistence()); + server =3D HornetQServers.newHornetQServer(conf, mbeanServer, usePer= sistence()); = jmsServer =3D new JMSServerManagerImpl(server); context =3D new InVMContext(); @@ -118,6 +122,17 @@ = registerConnectionFactory(); } + = + @Override + protected Configuration createDefaultConfig(boolean netty) + { + Configuration conf =3D super.createDefaultConfig(netty); + = + conf.setSecurityEnabled(false); + conf.setJMXManagementEnabled(true); + = + return conf; + } = protected void restartServer() throws Exception { @@ -149,7 +164,14 @@ = context =3D null; = + MBeanServerFactory.releaseMBeanServer(mbeanServer); + + mbeanServer =3D null; + super.tearDown(); + + + super.tearDown(); } = // Private ------------------------------------------------------- --===============4065106067928116443==--