Author: arvinder Date: 2006-07-10 18:01:18 -0400 (Mon, 10 Jul 2006) New Revision: 4999 Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/BaseTest.java labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/DUMMY labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/bizclasses/ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/bizclasses/AddressUnitTest.java Modified: labs/jbossesb/branches/refactor/ESBCore/build.xml labs/jbossesb/branches/refactor/ESBCore/tests/build.xml labs/jbossesb/branches/refactor/build.xml Log: Testing infrastructure and reporting setup together with initial unit test. Modified: labs/jbossesb/branches/refactor/ESBCore/build.xml =================================================================== --- labs/jbossesb/branches/refactor/ESBCore/build.xml 2006-07-10 21:58:28 UTC (rev 4998) +++ labs/jbossesb/branches/refactor/ESBCore/build.xml 2006-07-10 22:01:18 UTC (rev 4999) @@ -29,7 +29,6 @@ <!-- =================================================================== --> <!-- Compiles all the classes --> <!-- =================================================================== --> - <target name="org.jboss.esb.core.compile" depends="org.jboss.esb.core.prepare" description="Compile subprojects"> <echo message="Compiling submodules"/> <ant dir="common"/> @@ -38,6 +37,15 @@ <ant dir="listeners"/> <ant dir="tests"/> </target> + + <!-- =================================================================== --> + <!-- Test all the classes --> + <!-- =================================================================== --> + <target name="org.jboss.esb.core.test" depends="org.jboss.esb.core.compile" description="Test subprojects"> + <echo message="Testing submodules"/> + <ant dir="tests" target="org.jboss.esb.internal.test"/> + </target> + <!-- =================================================================== --> <!-- Assemble jars --> Modified: labs/jbossesb/branches/refactor/ESBCore/tests/build.xml =================================================================== --- labs/jbossesb/branches/refactor/ESBCore/tests/build.xml 2006-07-10 21:58:28 UTC (rev 4998) +++ labs/jbossesb/branches/refactor/ESBCore/tests/build.xml 2006-07-10 22:01:18 UTC (rev 4999) @@ -1,20 +1,22 @@ <?xml version="1.0"?> <project name="BuildEsbTests" default="org.jboss.esb.tests.compile" basedir="."> - <property name="org.jboss.esb.tests.bin.dir" value="${org.jboss.esb.internal.dest}/tests"/> - <property name="org.jboss.esb.core.bin.dir" value="${org.jboss.esb.internal.dest}/classes"/> + <property name="org.jboss.esb.tests.bin.dir" value="${org.jboss.esb.internal.dest}/tests"/> + <property name="org.jboss.esb.tests.report.dir" value="${org.jboss.esb.internal.dest}/tests/junit"/> + <property name="org.jboss.esb.core.bin.dir" value="${org.jboss.esb.internal.dest}/classes"/> <property name="org.jboss.esb.tests.src.dir" value="${basedir}/src"/> - <property name="org.jboss.esb.root.dir" value="../.."/> + <property name="org.jboss.esb.root.dir" value="../.."/> <property environment="env"/> - <property name="org.jboss.esb.ext.lib.dir" value="${org.jboss.esb.root.dir}/lib/ext"/> - <condition property="org.jboss.esb.ext.lib.dir" value="{org.jboss.esb.jboss.home}/client"> - <equals arg1="${org.jboss.esb.frominstall}" arg2="yes"/> - </condition> + <property name="org.jboss.esb.ext.lib.dir" value="${org.jboss.esb.root.dir}/lib/ext"/> + <condition property="org.jboss.esb.ext.lib.dir" value="{org.jboss.esb.jboss.home}/client"> + <equals arg1="${org.jboss.esb.frominstall}" arg2="yes"/> + </condition> - <path id="org.jboss.esb.tests.base.classpath"> - <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="activation.jar jbossall-client.jar log4j.jar mail.jar"/> - <pathelement location="${org.jboss.esb.core.bin.dir}"/> + <path id="org.jboss.esb.tests.base.classpath"> + <fileset dir="${org.jboss.esb.ext.lib.dir}" + includes="activation.jar jbossall-client.jar log4j.jar mail.jar junit.jar"/> + <pathelement location="${org.jboss.esb.core.bin.dir}"/> </path> <target name="org.jboss.esb.tests.init"> @@ -22,26 +24,94 @@ <format property="TODAY" pattern="d-MM-yy"/> </tstamp> - <mkdir dir="${org.jboss.esb.tests.bin.dir}"/> + <mkdir dir="${org.jboss.esb.tests.bin.dir}"/> + <mkdir dir="${org.jboss.esb.tests.report.dir}"/> </target> - <target name="clean"/> + <target name="clean"/> - <target name="purge" depends="clean"> - <delete dir="${org.jboss.esb.tests.bin.dir}"/> - </target> + <target name="purge" depends="clean"> + <delete dir="${org.jboss.esb.tests.bin.dir}"/> + </target> - <target name="org.jboss.esb.tests.compile" if="org.jboss.esb.buildtests" depends="org.jboss.esb.tests.init"> + <target name="org.jboss.esb.tests.compile" if="org.jboss.esb.buildtests" depends="org.jboss.esb.tests.init"> <javac - destdir="${org.jboss.esb.tests.bin.dir}" - classpathref="org.jboss.esb.tests.base.classpath" - debug="${org.jboss.esb.debug}" - optimize="${org.jboss.esb.optimize}" - > + destdir="${org.jboss.esb.tests.bin.dir}" + classpathref="org.jboss.esb.tests.base.classpath" + debug="${org.jboss.esb.debug}" + optimize="${org.jboss.esb.optimize}" + > <src path="${org.jboss.esb.tests.src.dir}"/> </javac> </target> + + <!-- ====================================================================== --> + <!-- T E S T --> + <!-- ====================================================================== --> + <target name="org.jboss.esb.internal.test"> + <antcall target="org.jboss.esb.internal.test.unit"/> + <antcall target="org.jboss.esb.internal.test.functional"/> + </target> + + + <!-- ====================================================================== --> + <!-- U N I T T E S T S --> + <!-- ====================================================================== --> + <target name="org.jboss.esb.internal.test.unit"> + <echo message="Running tests for module"/> + <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true"> + <formatter type="plain" usefile="false"/> + <formatter type="xml"/> + <batchtest todir="${org.jboss.esb.tests.report.dir}"> + <fileset dir="${org.jboss.esb.tests.bin.dir}"> + <include name="**/**/**/**/**UnitTest.class"/> + </fileset> + </batchtest> + <classpath> + <path refid="org.jboss.esb.tests.base.classpath"/> + <pathelement location="${org.jboss.esb.core.bin.dir}"/> + <pathelement location="${org.jboss.esb.tests.bin.dir}"/> + </classpath> + </junit> + <junitreport> + <fileset dir="${org.jboss.esb.tests.report.dir}"> + <include name="*.xml"/> + </fileset> + <report format="frames" todir="${org.jboss.esb.tests.report.dir}"/> + <report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/> + </junitreport> + </target> + + + <!-- ====================================================================== --> + <!-- F U NC T I O N A L T E S T S --> + <!-- ====================================================================== --> + <target name="org.jboss.esb.internal.test.functional"> + <echo message="Running tests for module"/> + <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" showoutput="no" fork="true"> + <formatter type="plain" usefile="false"/> + <formatter type="xml"/> + <batchtest todir="${org.jboss.esb.tests.report.dir}"> + <fileset dir="${org.jboss.esb.tests.bin.dir}"> + <include name="**/**/**FunctionalTest.class"/> + </fileset> + </batchtest> + <classpath> + <path refid="org.jboss.esb.tests.base.classpath"/> + <pathelement location="${org.jboss.esb.core.bin.dir}"/> + <pathelement location="${org.jboss.esb.tests.bin.dir}"/> + </classpath> + </junit> + <junitreport> + <fileset dir="${org.jboss.esb.tests.report.dir}"> + <include name="*.xml"/> + </fileset> + <report format="frames" todir="${org.jboss.esb.tests.report.dir}"/> + <report format="noframes" todir="${org.jboss.esb.tests.report.dir}"/> + </junitreport> + </target> + </project> Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/BaseTest.java =================================================================== --- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/BaseTest.java 2006-07-10 21:58:28 UTC (rev 4998) +++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/BaseTest.java 2006-07-10 22:01:18 UTC (rev 4999) @@ -0,0 +1,55 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2006, 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.soa.esb.tests; + +import junit.framework.TestCase; +import org.jboss.logging.Logger; + +/** + * Base test class for esb test classes, uses jboss logging. + * + * @author <a href="mailto:arv...@in...">Arvinder Singh</a> + * @version <tt>$Revision$</tt> + * $Id$ + */ +public class BaseTest extends TestCase { + + /** + * The Logger. + */ + protected Logger log = Logger.getLogger(getClass()); + + /** + * Default class constructor. + */ + public BaseTest() { + } + + /** + * Utility constructor. + * @param name The test name. + */ + public BaseTest(String name) { + super(name); + } + +} Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/DUMMY =================================================================== --- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/DUMMY 2006-07-10 21:58:28 UTC (rev 4998) +++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/DUMMY 2006-07-10 22:01:18 UTC (rev 4999) @@ -0,0 +1,2 @@ +For installation instructions see the manual in the docs subdirectory +or online at <http://ant.apache.org/manual/index.html>. Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/bizclasses/AddressUnitTest.java =================================================================== --- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/bizclasses/AddressUnitTest.java 2006-07-10 21:58:28 UTC (rev 4998) +++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/common/bizclasses/AddressUnitTest.java 2006-07-10 22:01:18 UTC (rev 4999) @@ -0,0 +1,91 @@ +/* +* JBoss, Home of Professional Open Source +* Copyright 2006, 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.soa.esb.tests.common.bizclasses; + +import junit.framework.TestCase; +import org.jboss.soa.esb.tests.BaseTest; +import org.jboss.soa.esb.common.bizclasses.Address; +import org.jboss.soa.esb.common.bizclasses.Telephone; + +/** + * Unit test for the address class. + * + * @author <a href="mailto:sch...@gm...">Esteban Shifman</a> + * @author <a href="mailto:arv...@in...">Arvinder Singh</a> + * @version <tt>$Revision$</tt> + * $Id$ + */ +public class AddressUnitTest extends BaseTest { + + + + + + + public void testAddress() throws Exception { + Address address = getAddress(); + assertTrue("Expecting Address.strNum to be 50. Actual was " + + address.getField(Address.ATTRIB.strNum), address.getField(Address.ATTRIB.strNum).equals("50")); + assertTrue("Expecting Address.strLine1 to be Balcarce. Actual was " + + address.getField(Address.ATTRIB.strLine1), address.getField(Address.ATTRIB.strLine1).equals("Balcarce")); + assertTrue("Expecting Address.twnCty1 to be San Isidro. Actual was " + + address.getField(Address.ATTRIB.twnCty1), address.getField(Address.ATTRIB.twnCty1).equals("San Isidro")); + assertTrue("Expecting Address.postalZip to be 1642. Actual was " + + address.getField(Address.ATTRIB.postalZip), address.getField(Address.ATTRIB.postalZip).equals("1642")); + assertTrue("Expecting Address.provSt to be Buenos Aires. Actual was " + + address.getField(Address.ATTRIB.provSt), address.getField(Address.ATTRIB.provSt).equals("Buenos Aires")); + assertTrue("Expecting Address.cntry to be Argentina. Actual was " + + address.getField(Address.ATTRIB.cntry), address.getField(Address.ATTRIB.cntry).equals("Argentina")); + + } + + + + static Address getAddress() throws Exception { + Address oP = new Address((String) null); + oP.setField(Address.ATTRIB.strNum, "50"); + oP.setField(Address.ATTRIB.strLine1, "Balcarce"); + oP.setField(Address.ATTRIB.twnCty1, "San Isidro"); + oP.setField(Address.ATTRIB.postalZip, "1642"); + oP.setField(Address.ATTRIB.provSt, "Buenos Aires"); + oP.setField(Address.ATTRIB.cntry, "Argentina"); + + oP.addPhone(newPhone("torIP", null, "416", "555-1212", null)); + oP.addPhone(newPhone("home", "54", "11", "4555-1111", "7")); + + return oP; + } + + public static Telephone newPhone(String p_sRole, String p_sCtry, String p_sCity, + String p_sNum, String p_sExt) { + Telephone oP = new Telephone((String)null); + oP.setRole(p_sRole); + oP.setField(Telephone.ATTRIB.cntry,p_sCtry); + oP.setField(Telephone.ATTRIB.city,p_sCity); + oP.setField(Telephone.ATTRIB.num,p_sNum); + oP.setField(Telephone.ATTRIB.ext,p_sExt); + + return oP; + } + + +} Modified: labs/jbossesb/branches/refactor/build.xml =================================================================== --- labs/jbossesb/branches/refactor/build.xml 2006-07-10 21:58:28 UTC (rev 4998) +++ labs/jbossesb/branches/refactor/build.xml 2006-07-10 22:01:18 UTC (rev 4999) @@ -78,7 +78,15 @@ <ant dir="ESBCore"/> </target> - <!-- javadocs paths --> + <!-- Test targets --> + <target name="org.jboss.esb.test" depends="org.jboss.esb.compile"> + <echo message="Testing modules"/> + <ant dir="ESBCore" target="org.jboss.esb.core.test"/> + </target> + + + + <!-- javadocs paths --> <path id="org.jboss.esb.javadocs.path"> <pathelement path="ESBCore/classes"/> </path> @@ -148,7 +156,7 @@ <target name="org.jboss.esb.clean"> <echo message="Cleaning modules"/> - <echo message="Compiling modules"/> + <echo message="Cleaning ESBCore"/> <ant dir="ESBCore" target="clean"/> </target> @@ -164,7 +172,8 @@ <!-- Short target names --> <target name="compile" depends="org.jboss.esb.compile"/> - <target name="jar" depends="org.jboss.esb.jar"/> + <target name="test" depends="org.jboss.esb.test"/> + <target name="jar" depends="org.jboss.esb.jar"/> <target name="clean" depends="org.jboss.esb.clean"/> <target name="purge" depends="org.jboss.esb.purge"/> </project> |