[jboss-cvs] JBoss Messaging SVN: r7894 - in branches/Branch_1_4/tests/src/org/jboss/test/messaging: util and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 5 11:10:09 EST 2009
Author: gaohoward
Date: 2009-11-05 11:10:09 -0500 (Thu, 05 Nov 2009)
New Revision: 7894
Added:
branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtil.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtilTest.java
Modified:
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
Log:
JBMESSAGING-1757
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java 2009-11-04 01:47:16 UTC (rev 7893)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java 2009-11-05 16:10:09 UTC (rev 7894)
@@ -31,6 +31,7 @@
import org.jboss.jms.client.state.ConnectionState;
import org.jboss.jms.delegate.TopologyResult;
import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.util.TestUtil;
/**
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
@@ -80,7 +81,9 @@
// the sleep time has to be longer than the sum of validatorPingPeriod and validatorPingTimeout.
// see remoting-bisocket-service.xml
- Thread.sleep(20000);
+ long sleepTime = TestUtil.getProperSleepTime("clusterViewUpdateTest.testUpdateTopology", 20000);
+ log.info("Sleeping for " + sleepTime);
+ Thread.sleep(sleepTime);
assertEquals(1, clusterDelegate.getDelegates().length);
TopologyResult topology = clusterDelegate.getTopology();
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java 2009-11-04 01:47:16 UTC (rev 7893)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java 2009-11-05 16:10:09 UTC (rev 7894)
@@ -19,6 +19,7 @@
import org.jboss.jms.client.FailoverEvent;
import org.jboss.jms.client.JBossConnection;
import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.util.TestUtil;
import EDU.oswego.cs.dl.util.concurrent.Latch;
@@ -221,7 +222,9 @@
ServerManagement.kill(1);
log.info("KILLED SERVER 1");
- Thread.sleep(5000);
+ long sleepTime = TestUtil.getProperSleepTime("disableLoadBalancingAndFailoverTest.noFailover", 10000);
+ log.info("Sleeping for " + sleepTime);
+ Thread.sleep(sleepTime);
long start = System.currentTimeMillis();
try
Added: branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtil.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtil.java (rev 0)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtil.java 2009-11-05 16:10:09 UTC (rev 7894)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, 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.test.messaging.util;
+
+/**
+ * A TestUtil
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
+ */
+public class TestUtil
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Get the sleep time used by the test. It is used to adapt timing sensitive
+ * tests in different test environments.
+ *
+ * @param key The key used to retrieve the value from system property.
+ * @param originalVal if the property are not defined in system property by the key, originalVal
+ * will be used.
+ *
+ * @return the return value will be the effective value times the test.timeFactor system property.
+ *
+ */
+ public static long getProperSleepTime(String key, long originVal)
+ {
+ long eVal = originVal;
+ String value = System.getProperty(key);
+ if (value != null)
+ {
+ eVal = Long.valueOf(value);
+ }
+
+ long factor = 1;
+
+ value = System.getProperty("test.timeFactor");
+
+ if (value != null)
+ {
+ factor = Long.valueOf(value);
+ }
+
+ return factor * eVal;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtilTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtilTest.java (rev 0)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/util/TestUtilTest.java 2009-11-05 16:10:09 UTC (rev 7894)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, 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.test.messaging.util;
+
+import org.jboss.test.messaging.MessagingTestCase;
+
+/**
+ * A TestUtilTest
+ *
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
+ *
+ * Created Nov 5, 2009 9:48:18 PM
+ *
+ *
+ */
+public class TestUtilTest extends MessagingTestCase
+{
+
+ public TestUtilTest(String name)
+ {
+ super(name);
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+ public void testgetProperSleepTime() throws Exception
+ {
+ long st = TestUtil.getProperSleepTime("my.sleep", 2000);
+ assertEquals(2000, st);
+
+ System.setProperty("my.sleep", "5000");
+ st = TestUtil.getProperSleepTime("my.sleep", 2000);
+ assertEquals(5000, st);
+
+ System.setProperty("test.timeFactor", "2");
+ st = TestUtil.getProperSleepTime("my.sleep", 2000);
+ assertEquals(10000, st);
+
+ System.clearProperty("my.sleep");
+ st = TestUtil.getProperSleepTime("my.sleep", 2000);
+ assertEquals(4000, st);
+
+ System.clearProperty("test.timeFactor");
+ st = TestUtil.getProperSleepTime("my.sleep", 2000);
+ assertEquals(2000, st);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list