[jboss-cvs] JBoss Messaging SVN: r4061 - in trunk/tests: jms-tests/src/org/jboss/test/messaging/tools/junit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 15 09:59:52 EDT 2008
Author: ataylor
Date: 2008-04-15 09:59:51 -0400 (Tue, 15 Apr 2008)
New Revision: 4061
Added:
trunk/tests/bin/runjmstest
trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java
Modified:
trunk/tests/bin/runtest
Log:
fixes to runner
Copied: trunk/tests/bin/runjmstest (from rev 4060, trunk/tests/bin/runtest)
===================================================================
--- trunk/tests/bin/runjmstest (rev 0)
+++ trunk/tests/bin/runjmstest 2008-04-15 13:59:51 UTC (rev 4061)
@@ -0,0 +1,205 @@
+#!/bin/sh
+#
+# bash script for running a single unit test case.
+#
+# It expects TARGET_CLASS and TARGET_TEST to be set. If they are not, it tries to load them
+# from ./.testrc.
+#
+# Options:
+# -debug start the client VM in debugging mode
+# -remote set the "remote" system property so the server start in a remote VM
+# -remotedebug starts the VM that runs the remote server in debugging mode. The remote VM
+# will attempt to connect to the debugger, which should be lisening on 'rmiserver'
+#
+#
+# $Id$
+#
+
+reldir=`dirname $0`
+
+
+ENV_TEST_DATABASE=$TEST_DATABASE
+ENV_TEST_CLUSTERED=$TEST_CLUSTERED
+ENV_TEST_REMOTING=$TEST_REMOTING
+ENV_TEST_BIND_ADDRESS=$TEST_BIND_ADDRESS
+ENV_TEST_OBJECTSTORE=$ENV_TEST_OBJECTSTORE
+
+if [ -z "$TARGET_CLASS" -a -f $reldir/.testrc ]; then
+ . $reldir/.testrc
+fi
+
+if [ -z "$TARGET_CLASS" ]; then
+ echo "No TARGET_CLASS found! Set the TARGET_CLASS environment variable and try again." 1>&2
+ exit 1
+fi
+
+if [ "$ENV_TEST_DATABASE" != "" ]; then
+ TEST_DATABASE=$ENV_TEST_DATABASE
+fi
+
+if [ "$ENV_TEST_CLUSTERED" != "" ]; then
+ TEST_CLUSTERED=$ENV_TEST_CLUSTERED
+fi
+
+if [ "$ENV_TEST_REMOTING" != "" ]; then
+ TEST_REMOTING=$ENV_TEST_REMOTING
+fi
+
+if [ "$ENV_TEST_OBJECTSTORE" != "" ]; then
+ TEST_OBJECTSTORE=$ENV_TEST_OBJECTSTORE
+else
+ TEST_OBJECTSTORE=ObjectStore
+fi
+
+#
+# We should use the same test execution classpath as the ant <junit> task, so we run ant to get
+# it from there.
+#
+
+ant -Dtest.execution.classpath.file=tests/bin/.test.execution.classpath -f $reldir/../../build-messaging.xml compile-jms-tests get-jms-test-execution-classpath
+CLASSPATH=`cat $reldir/.test.execution.classpath`
+
+outputdir="$reldir/../output"
+
+if ! mkdir -p $outputdir/logs; then
+ echo "failed to create $outputdir/logs"
+fi
+
+# reset the log files as by default log4j is configure to append
+rm -f $outputdir/logs/*.log
+
+cygwin=false;
+case "`uname`" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+esac
+
+if [ $cygwin = true ]; then
+ SEP=";"
+else
+ SEP=":"
+fi
+
+TEST_LOGFILE_SUFFIX=invm
+
+while [ "$1" != "" ]; do
+ if [ "$1" = "-debug" ]; then
+ if [ $cygwin = false ]; then
+ if [ "$DEBUG_OPTS_SOCKET" = "" ]; then
+ echo "No configured socket debugging options. Set DEBUG_OPTS_SOCKET in your environment or .testrc" 1>&2
+ exit 1
+ fi
+ JAVA_OPTS="$DEBUG_OPTS_SOCKET"
+ else
+ if [ "$DEBUG_OPTS" = "" ]; then
+ echo "No configured debugging options. Set DEBUG_OPTS in your environment or .testrc" 1>&2
+ exit 1
+ fi
+ JAVA_OPTS="$DEBUG_OPTS"
+ fi
+ shift
+ continue;
+ fi
+ if [ "$1" = "-remote" ]; then
+ isRemote=true;
+ REMOTE_TEST="-Dremote=true"
+ TEST_LOGFILE_SUFFIX=remote-client
+ shift
+ continue;
+ fi
+ if [ "$1" = "-remotedebug" ]; then
+ remote_debug=true
+ shift
+ continue;
+ fi
+ if [ "$1" = "0" -o "$1" = "1" -o "$1" = "2" ]; then
+ remote_debug_index=$1
+ shift
+ continue;
+ fi
+ if [ "$1" = "-clustered" ]; then
+ TEST_CLUSTERED=true
+ shift
+ continue;
+ else
+ echo "Error, unknown switch: $1"
+ exit 1
+ fi
+done
+
+if [ "$TEST_CLUSTERED" = "true" ]; then
+ TEST_LOGFILE_SUFFIX=clustering-client
+fi
+
+JAVA_OPTS="-Xmx1024M $JAVA_OPTS \
+-Dmodule.output=$reldir/../output \
+$REMOTE_TEST \
+-Dtest.database=$TEST_DATABASE \
+-Dtest.serialization=$TEST_SERIALIZATION \
+-Dtest.clustered=$TEST_CLUSTERED \
+-Dtest.remoting=$TEST_REMOTING \
+-Dtest.spawn.verbose=$TEST_SPAWN_VERBOSE \
+-Dtest.logfile.suffix=$TEST_LOGFILE_SUFFIX \
+-Dbuild.lib=../../output/lib"
+
+if [ "$TEST_BIND_ADDRESS" != "" ]; then
+ JAVA_OPTS="$JAVA_OPTS -Dtest.bind.address=$TEST_BIND_ADDRESS"
+fi
+
+if [ "$TEST_OBJECTSTORE" != "" ]; then
+ JAVA_OPTS="$JAVA_OPTS -Dobjectstore.dir=$TEST_OBJECTSTORE"
+fi
+
+if [ "$TARGET_TEST" != "" ]; then
+ TARGET_TEST="-t $TARGET_TEST"
+fi
+
+if [ "$remote_debug" = "true" ]; then
+ if [ "$remote_debug_index" = "" ]; then
+ REMOTE_DEBUG_FLAG_0="-debug"
+ JAVA_OPTS="$JAVA_OPTS -Dtest.remote.debug.index=0"
+ elif [ "$remote_debug_index" = "1" ]; then
+ REMOTE_DEBUG_FLAG_1="-debug"
+ JAVA_OPTS="$JAVA_OPTS -Dtest.remote.debug.index=1"
+ elif [ "$remote_debug_index" = "2" ]; then
+ REMOTE_DEBUG_FLAG_2="-debug"
+ JAVA_OPTS="$JAVA_OPTS -Dtest.remote.debug.index=2"
+ elif [ "$remote_debug_index" = "3" ]; then
+ REMOTE_DEBUG_FLAG_3="-debug"
+ JAVA_OPTS="$JAVA_OPTS -Dtest.remote.debug.index=3"
+ else
+ echo "Invalid argument: $remote_debug_index"
+ exit 1
+ fi
+fi
+
+mkdir $reldir/../jms-tests/build/etc
+cp $reldir/../../src/etc/*.xml $reldir/../jms-tests/build/etc
+
+"$JAVA_HOME/bin/java" -Xmx1024M $JAVA_OPTS -Djgroups.bind_addr=localhost -cp "$CLASSPATH" \
+org.jboss.test.messaging.tools.junit.SelectiveTestRunner $TARGET_CLASS $TARGET_TEST
+
+#
+# stop the servers in the reverse order
+#
+
+if [ "$isRemote" = "true" ]; then
+
+ if [ "$TEST_CLUSTERED" = "true" ]; then
+
+ # stop the fourth remote server
+ $reldir/stop-rmi-server -use-existent-test-classpath-file -index 3
+
+ # stop the third remote server
+ $reldir/stop-rmi-server -use-existent-test-classpath-file -index 2
+
+ # stop the second remote server
+ $reldir/stop-rmi-server -use-existent-test-classpath-file -index 1
+
+ fi
+
+ $reldir/stop-rmi-server -use-existent-test-classpath-file -index 0
+
+fi
+
Modified: trunk/tests/bin/runtest
===================================================================
--- trunk/tests/bin/runtest 2008-04-15 13:30:48 UTC (rev 4060)
+++ trunk/tests/bin/runtest 2008-04-15 13:59:51 UTC (rev 4061)
@@ -56,7 +56,7 @@
# it from there.
#
-ant -Dtest.execution.classpath.file=tests/bin/.test.execution.classpath -f $reldir/../../build-messaging.xml compile get-test-execution-classpath
+ant -Dtest.execution.classpath.file=tests/bin/.test.execution.classpath -f $reldir/../../build-messaging.xml compile-unit-tests get-unit-test-execution-classpath
CLASSPATH=`cat $reldir/.test.execution.classpath`
outputdir="$reldir/../output"
Copied: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java (from rev 4060, trunk/tests/src/org/jboss/messaging/tests/util/junit/SelectiveTestRunner.java)
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java (rev 0)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java 2008-04-15 13:59:51 UTC (rev 4061)
@@ -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.test.messaging.tools.junit;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * A text TestRunner than runs only test methods specified on command line with "-t".
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SelectiveTestRunner extends TestRunner
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ /**
+ * Specify -t testName1,testName2,... somewhere in the argument list.
+ */
+ public static void main(String[] args)
+ {
+ SelectiveTestRunner runner = new SelectiveTestRunner();
+
+ try
+ {
+ args = runner.preProcessCommandLine(args);
+
+ TestResult r = runner.start(args);
+
+ if (!r.wasSuccessful())
+ {
+ System.exit(FAILURE_EXIT);
+ }
+ System.exit(SUCCESS_EXIT);
+ }
+ catch(Exception e)
+ {
+ System.err.println(e.getMessage());
+ System.exit(EXCEPTION_EXIT);
+ }
+ }
+
+ // Attributes ----------------------------------------------------
+
+ private List methods = new ArrayList();
+
+ // Constructors --------------------------------------------------
+
+ // TestRunner overrides ------------------------------------------
+
+ public Test getTest(String suiteClassName)
+ {
+ Test t = super.getTest(suiteClassName);
+ if (methods.isEmpty())
+ {
+ return t;
+ }
+ else
+ {
+ return new SelectiveTestSuite((TestSuite)t, methods);
+ }
+ }
+
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+
+ // Private -------------------------------------------------------
+
+ /**
+ * Scan command line for an argument of type "-t testMethod1,testMethod2,..." and processes it.
+ */
+ private String[] preProcessCommandLine(String[] args)
+ {
+ List l = new ArrayList();
+ for (int i = 0; i < args.length; i++)
+ {
+ if ("-t".equals(args[i]))
+ {
+ i++;
+ for(StringTokenizer st = new StringTokenizer(args[i], ","); st.hasMoreTokens(); )
+ {
+ methods.add(st.nextToken());
+ }
+ }
+ else
+ {
+ l.add(args[i]);
+ }
+ }
+
+ String[] a = new String[l.size()];
+ return (String[])l.toArray(a);
+ }
+
+ // Inner classes -------------------------------------------------
+}
\ No newline at end of file
Copied: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java (from rev 4060, trunk/tests/src/org/jboss/messaging/tests/util/junit/SelectiveTestSuite.java)
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java (rev 0)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java 2008-04-15 13:59:51 UTC (rev 4061)
@@ -0,0 +1,109 @@
+/*
+* 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.tools.junit;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * A TestSuite that filters tests.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class SelectiveTestSuite extends TestSuite
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private List methods;
+ private List tests;
+
+ // Constructors --------------------------------------------------
+
+ public SelectiveTestSuite(TestSuite original, List methods)
+ {
+ tests = new ArrayList();
+ this.methods = new ArrayList(methods);
+ this.methods.add("warning");
+
+ for(Enumeration e = original.tests(); e.hasMoreElements();)
+ {
+ TestCase tc = (TestCase)e.nextElement();
+ if (methods.contains(tc.getName()))
+ {
+ tests.add(tc);
+ }
+ }
+
+ if (tests.isEmpty())
+ {
+ tests.add(new TestCase("warning")
+ {
+ protected void runTest()
+ {
+ fail("The SelectiveTestSuite did not select any test.");
+ }
+ });
+ }
+ }
+
+
+ // TestSuite overrides -------------------------------------------
+
+ public Test testAt(int index)
+ {
+ return (Test)tests.get(index);
+ }
+
+ public int testCount()
+ {
+ return tests.size();
+ }
+
+ public Enumeration tests()
+ {
+ return Collections.enumeration(tests);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list