[jboss-cvs] JBoss Messaging SVN: r6255 - in trunk/examples/jms/common: src/org/jboss/jms/example and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 1 04:41:08 EDT 2009


Author: jmesnil
Date: 2009-04-01 04:41:08 -0400 (Wed, 01 Apr 2009)
New Revision: 6255

Modified:
   trunk/examples/jms/common/build.xml
   trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java
Log:
run all the examples (to use them as smoke tests)

* in JMSExample, the JVM exits with 0 if there has been no exception thrown, or 1 else
* added a "all" target to examples/jms/common which will run all the JMS examples, stopping if an example is failing
* in JMSExample, after the example is run, print big SUCCESS or FAILURE output so that user can see at first glance if the example succeeded without reading carefully all the output

Modified: trunk/examples/jms/common/build.xml
===================================================================
--- trunk/examples/jms/common/build.xml	2009-04-01 07:56:30 UTC (rev 6254)
+++ trunk/examples/jms/common/build.xml	2009-04-01 08:41:08 UTC (rev 6255)
@@ -119,7 +119,7 @@
    </target>
 
    <target name="runExample" depends="compile">
-      <java classname="${example.classname}" fork="true">
+      <java classname="${example.classname}" fork="true" resultproperty="example-result">
          <jvmarg value="-XX:+UseParallelGC"/>
          <jvmarg value="-Xms512M"/>
          <jvmarg value="-Xmx2048M"/>
@@ -136,9 +136,24 @@
          <arg line="${jbm.example.beans.file}"/>
          <classpath refid="jms.runtime.classpath"/>
       </java>
+      <!-- if the example exited with a result value != 0, we fail the build -->
+      <fail message="Example ${example.classname} failed">
+          <condition>
+              <not>
+                <equals arg1="${example-result}" arg2="0" />
+              </not>
+          </condition>
+      </fail>
    </target>
 
    <target name="clean">
    	  <delete dir="./build" quiet="true" />
    </target>
+    
+   <target name="all" description="Run all the JMS examples">
+      <subant target="run" failonerror="true">
+         <fileset dir=".." includes="*/build.xml" excludes="common/build.xml"/>
+      </subant>
+   </target>
+
 </project>

Modified: trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java
===================================================================
--- trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java	2009-04-01 07:56:30 UTC (rev 6254)
+++ trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java	2009-04-01 08:41:08 UTC (rev 6255)
@@ -55,6 +55,10 @@
 
    private Connection conn;
 
+   private boolean failure = false;
+
+   public abstract void runExample() throws Exception;
+
    protected void run(String[] args)
    {
       String runServerProp = System.getProperty("jbm.example.runServer");
@@ -80,6 +84,7 @@
       }
       catch (Throwable e)
       {
+         failure = true;
          e.printStackTrace();
       }
       finally
@@ -107,6 +112,7 @@
             }
          }
       }
+      reportResultAndExit();
    }
 
 
@@ -218,7 +224,24 @@
       }
       return actArgs;
    }
-   public abstract void runExample() throws Exception;
-
-
+   
+   private void reportResultAndExit()
+   {
+      if (failure)
+      {
+         System.err.println();
+         System.err.println("#####################");
+         System.err.println("###    FAILURE!   ###");
+         System.err.println("#####################");
+         System.exit(1);
+      }
+      else
+      {
+         System.out.println();
+         System.out.println("#####################");
+         System.out.println("###    SUCCESS!   ###");
+         System.out.println("#####################");
+         System.exit(0);
+      }
+   }
 }




More information about the jboss-cvs-commits mailing list