[jboss-svn-commits] JBL Code SVN: r5054 - in labs/jbossesb/branches/refactor/ESBCore/common: . tests tests/src tests/src/org tests/src/org/jboss tests/src/org/jboss/soa tests/src/org/jboss/soa/esb tests/src/org/jboss/soa/esb/common tests/src/org/jboss/soa/esb/common/tests tests/src/org/jboss/soa/esb/common/tests/bizclasses
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 12 17:31:23 EDT 2006
Author: arvinder
Date: 2006-07-12 17:31:17 -0400 (Wed, 12 Jul 2006)
New Revision: 5054
Added:
labs/jbossesb/branches/refactor/ESBCore/common/tests/
labs/jbossesb/branches/refactor/ESBCore/common/tests/build.xml
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/BaseTest.java
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/AddressUnitTest.java
labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/PersonUnitTest.java
Modified:
labs/jbossesb/branches/refactor/ESBCore/common/build.xml
Log:
Move tests into module sub directory
Modified: labs/jbossesb/branches/refactor/ESBCore/common/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/common/build.xml 2006-07-12 21:30:48 UTC (rev 5053)
+++ labs/jbossesb/branches/refactor/ESBCore/common/build.xml 2006-07-12 21:31:17 UTC (rev 5054)
@@ -34,8 +34,17 @@
<target name="purge" depends="clean">
<delete dir="${org.jboss.esb.common.bin.dir}"/>
</target>
-
- <target name="org.jboss.esb.common.compile" depends="org.jboss.esb.common.prepare"
+
+
+ <target name="org.jboss.esb.common.compile">
+ <!-- Compile common -->
+ <antcall target="org.jboss.esb.common.internal.compile"/>
+ <!-- Compile common tests -->
+ <ant inheritAll="true" dir="tests" target="org.jboss.esb.common.tests.compile"/>
+ </target>
+
+
+ <target name="org.jboss.esb.common.internal.compile" depends="org.jboss.esb.common.prepare"
description="Compile all classes">
<javac
@@ -61,6 +70,16 @@
/>
</target>
- <target name="all" depends="recompile,jar" />
+
+ <target name="org.jboss.esb.common.test" description="Run tests for this module">
+ <!-- Compile common tests -->
+ <ant dir="tests" target="org.jboss.esb.common.internal.test"/>
+ </target>
+
+
+
+
+ <target name="all" depends="recompile,jar" />
+
</project>
Added: labs/jbossesb/branches/refactor/ESBCore/common/tests/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/common/tests/build.xml 2006-07-12 21:30:48 UTC (rev 5053)
+++ labs/jbossesb/branches/refactor/ESBCore/common/tests/build.xml 2006-07-12 21:31:17 UTC (rev 5054)
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<project name="build.common.tests" default="org.jboss.esb.common.tests.compile" basedir=".">
+
+ <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 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>
+
+ <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">
+ <tstamp>
+ <format property="TODAY" pattern="d-MM-yy"/>
+ </tstamp>
+
+ <mkdir dir="${org.jboss.esb.tests.bin.dir}"/>
+ <mkdir dir="${org.jboss.esb.tests.report.dir}"/>
+ </target>
+
+ <target name="clean"/>
+
+ <target name="purge" depends="clean">
+ <delete dir="${org.jboss.esb.tests.bin.dir}"/>
+ </target>
+
+ <target name="org.jboss.esb.common.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}"
+ >
+ <src path="${org.jboss.esb.tests.src.dir}"/>
+ </javac>
+
+ </target>
+
+
+ <!-- ====================================================================== -->
+ <!-- T E S T -->
+ <!-- ====================================================================== -->
+ <target name="org.jboss.esb.common.internal.test">
+ <antcall target="org.jboss.esb.common.internal.test.unit"/>
+ <antcall target="org.jboss.esb.common.internal.test.functional"/>
+ </target>
+
+
+ <!-- ====================================================================== -->
+ <!-- U N I T T E S T S -->
+ <!-- ====================================================================== -->
+ <target name="org.jboss.esb.common.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.common.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="**/**/**FuncTest.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/common/tests/src/org/jboss/soa/esb/common/tests/BaseTest.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/BaseTest.java 2006-07-12 21:30:48 UTC (rev 5053)
+++ labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/BaseTest.java 2006-07-12 21:31:17 UTC (rev 5054)
@@ -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.common.tests;
+
+import junit.framework.TestCase;
+import org.jboss.logging.Logger;
+
+/**
+ * Base test class for esb test classes, uses jboss logging.
+ *
+ * @author <a href="mailto:arvinder.singh at indigo-logic.com">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/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/AddressUnitTest.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/AddressUnitTest.java 2006-07-12 21:30:48 UTC (rev 5053)
+++ labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/AddressUnitTest.java 2006-07-12 21:31:17 UTC (rev 5054)
@@ -0,0 +1,124 @@
+/*
+* 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.common.tests.bizclasses;
+
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.common.bizclasses.Address;
+import org.jboss.soa.esb.common.bizclasses.Telephone;
+import org.jboss.soa.esb.util.BaseBusinessObject;
+import org.jboss.soa.esb.util.BobjStdDTO;
+
+/**
+ * Unit test for the address class.
+ *
+ * @author <a href="mailto:schifest at gmail.com">Esteban Shifman</a>
+ * @author <a href="mailto:arvinder.singh at indigo-logic.com">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"));
+
+ // Phone
+ assertTrue("Expecting Address.phone[0].role to be torIP. Actual was " +
+ address.getPhoneAt(0).getRole(), address.getPhoneAt(0).getRole().equals("torIP"));
+ assertTrue("Expecting Address.phone[0].country to be null. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.cntry), address.getPhoneAt(0).getField(Telephone.ATTRIB.cntry) == null);
+ assertTrue("Expecting Address.phone[0].city to be 416. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.city), address.getPhoneAt(0).getField(Telephone.ATTRIB.city).equals("416"));
+ assertTrue("Expecting Address.phone[0].num to be 555-1212. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.num), address.getPhoneAt(0).getField(Telephone.ATTRIB.num).equals("555-1212"));
+ assertTrue("Expecting Address.phone[0].ext to be null. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.ext), address.getPhoneAt(0).getField(Telephone.ATTRIB.ext) == null);
+
+ assertTrue("Expecting Address.phone[1].role to be home. Actual was " +
+ address.getPhoneAt(1).getRole(), address.getPhoneAt(1).getRole().equals("home"));
+ assertTrue("Expecting Address.phone[1].country to be 54. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.cntry), address.getPhoneAt(1).getField(Telephone.ATTRIB.cntry).equals("54"));
+ assertTrue("Expecting Address.phone[1].city to be 11. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.city), address.getPhoneAt(1).getField(Telephone.ATTRIB.city).equals("11"));
+ assertTrue("Expecting Address.phone[1].num to be 4555-1111. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.num), address.getPhoneAt(1).getField(Telephone.ATTRIB.num).equals("4555-1111"));
+ assertTrue("Expecting Address.phone[1].ext to be 7. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.ext), address.getPhoneAt(1).getField(Telephone.ATTRIB.ext).equals("7"));
+
+ }
+
+
+ public void testToDTO() throws Exception {
+ BaseBusinessObject addressA = getAddress();
+ addressA.setPackage();
+
+ BobjStdDTO oDto = addressA.toDTO();
+ System.out.println(oDto.toXml());
+
+ Address addressB = (Address) BaseBusinessObject.getFromDTO(oDto);
+ System.out.println(addressB.toDTO().toXml());
+
+ assertTrue("Expecting AddressA == AddressB", addressA.toDTO().toXml().equals(addressB.toDTO().toXml()));
+ }
+
+
+ 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;
+ }
+
+
+}
Added: labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/PersonUnitTest.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/PersonUnitTest.java 2006-07-12 21:30:48 UTC (rev 5053)
+++ labs/jbossesb/branches/refactor/ESBCore/common/tests/src/org/jboss/soa/esb/common/tests/bizclasses/PersonUnitTest.java 2006-07-12 21:31:17 UTC (rev 5054)
@@ -0,0 +1,204 @@
+/*
+* 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.common.tests.bizclasses;
+
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.common.bizclasses.Person;
+import org.jboss.soa.esb.common.bizclasses.OneValue;
+import org.jboss.soa.esb.common.bizclasses.Address;
+import org.jboss.soa.esb.common.bizclasses.Telephone;
+import org.jboss.soa.esb.util.BaseBusinessObject;
+import org.jboss.soa.esb.util.BobjStdDTO;
+
+/**
+ * Unit test for the person class.
+ *
+ * @author <a href="mailto:schifest at gmail.com">Esteban Shifman</a>
+ * @author <a href="mailto:arvinder.singh at indigo-logic.com">Arvinder Singh</a>
+ * @version <tt>$Revision$</tt>
+ * $Id:$
+ */
+public class PersonUnitTest extends BaseTest {
+
+
+ public void testPerson() throws Exception {
+
+ Person person = getPerson();
+
+ assertTrue("Expecting Person.pfx to be Mr. Actual was " +
+ person.getField(Person.ATTRIB.pfx), person.getField(Person.ATTRIB.pfx).equals("Mr."));
+ assertTrue("Expecting Person.fmlyN to be Brum. Actual was " +
+ person.getField(Person.ATTRIB.fmlyN), person.getField(Person.ATTRIB.fmlyN).equals("Brum"));
+ assertTrue("Expecting Person.givN to be Daniel. Actual was " +
+ person.getField(Person.ATTRIB.givN), person.getField(Person.ATTRIB.givN).equals("Daniel"));
+ assertTrue("Expecting Person.sfx to be the 1st.. Actual was " +
+ person.getField(Person.ATTRIB.sfx), person.getField(Person.ATTRIB.sfx).equals("the 1st."));
+
+ }
+
+ public void testPersonEmail() throws Exception {
+
+ Person person = getPerson();
+
+ String expectedEmail0 = "<OneValue rol=\"home\" v=\"myaddr at gmail.com\"/>";
+ assertTrue("Expecting Person.email[0] to be Actual was " +
+ person.getEmailAt(0).toString(), person.getEmailAt(0).toString().equals(expectedEmail0));
+
+ String expectedEmail1 = "<OneValue rol=\"work\" v=\"john.smith at jboss.com\"/>";
+ assertTrue("Expecting Person.email[0] to be Actual was " +
+ person.getEmailAt(1).toString(), person.getEmailAt(1).toString().equals(expectedEmail1));
+ }
+
+ public void testPersonTelephone() throws Exception {
+
+ Person person = getPerson();
+
+ assertTrue("Expecting Person.phone[0].role to be basement. Actual was " +
+ person.getPhoneAt(0).getRole(), person.getPhoneAt(0).getRole().equals("basement"));
+ assertTrue("Expecting Person.phone[0].country to be 1. Actual was " +
+ person.getPhoneAt(0).getField(Telephone.ATTRIB.cntry), person.getPhoneAt(0).getField(Telephone.ATTRIB.cntry).equals("1"));
+ assertTrue("Expecting Person.phone[0].city to be 416. Actual was " +
+ person.getPhoneAt(0).getField(Telephone.ATTRIB.city), person.getPhoneAt(0).getField(Telephone.ATTRIB.city).equals("416"));
+ assertTrue("Expecting Person.phone[0].num to be 555-1212. Actual was " +
+ person.getPhoneAt(0).getField(Telephone.ATTRIB.num), person.getPhoneAt(0).getField(Telephone.ATTRIB.num).equals("555-1212"));
+ assertTrue("Expecting Person.phone[0].ext to be null. Actual was " +
+ person.getPhoneAt(0).getField(Telephone.ATTRIB.ext), person.getPhoneAt(0).getField(Telephone.ATTRIB.ext) == null);
+
+ assertTrue("Expecting Person.phone[1].role to be basement. Actual was " +
+ person.getPhoneAt(1).getRole(), person.getPhoneAt(1).getRole().equals("cell"));
+ assertTrue("Expecting Person.phone[1].country to be null. Actual was " +
+ person.getPhoneAt(1).getField(Telephone.ATTRIB.cntry), person.getPhoneAt(1).getField(Telephone.ATTRIB.cntry) == null);
+ assertTrue("Expecting Person.phone[1].city to be 416. Actual was " +
+ person.getPhoneAt(1).getField(Telephone.ATTRIB.city), person.getPhoneAt(1).getField(Telephone.ATTRIB.city).equals("416"));
+ assertTrue("Expecting Person.phone[1].num to be 666-4444. Actual was " +
+ person.getPhoneAt(1).getField(Telephone.ATTRIB.num), person.getPhoneAt(1).getField(Telephone.ATTRIB.num).equals("666-4444"));
+ assertTrue("Expecting Person.phone[1].ext to be null. Actual was " +
+ person.getPhoneAt(1).getField(Telephone.ATTRIB.ext), person.getPhoneAt(1).getField(Telephone.ATTRIB.ext) == null);
+
+ }
+
+ public void testPersonAddress() throws Exception {
+
+ Address address = getPerson().getAddressAt(0);
+ 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"));
+
+ // Phone
+ assertTrue("Expecting Address.phone[0].role to be torIP. Actual was " +
+ address.getPhoneAt(0).getRole(), address.getPhoneAt(0).getRole().equals("torIP"));
+ assertTrue("Expecting Address.phone[0].country to be null. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.cntry), address.getPhoneAt(0).getField(Telephone.ATTRIB.cntry) == null);
+ assertTrue("Expecting Address.phone[0].city to be 416. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.city), address.getPhoneAt(0).getField(Telephone.ATTRIB.city).equals("416"));
+ assertTrue("Expecting Address.phone[0].num to be 555-1212. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.num), address.getPhoneAt(0).getField(Telephone.ATTRIB.num).equals("555-1212"));
+ assertTrue("Expecting Address.phone[0].ext to be null. Actual was " +
+ address.getPhoneAt(0).getField(Telephone.ATTRIB.ext), address.getPhoneAt(0).getField(Telephone.ATTRIB.ext) == null);
+
+ assertTrue("Expecting Address.phone[1].role to be home. Actual was " +
+ address.getPhoneAt(1).getRole(), address.getPhoneAt(1).getRole().equals("home"));
+ assertTrue("Expecting Address.phone[1].country to be 54. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.cntry), address.getPhoneAt(1).getField(Telephone.ATTRIB.cntry).equals("54"));
+ assertTrue("Expecting Address.phone[1].city to be 11. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.city), address.getPhoneAt(1).getField(Telephone.ATTRIB.city).equals("11"));
+ assertTrue("Expecting Address.phone[1].num to be 4555-1111. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.num), address.getPhoneAt(1).getField(Telephone.ATTRIB.num).equals("4555-1111"));
+ assertTrue("Expecting Address.phone[1].ext to be 7. Actual was " +
+ address.getPhoneAt(1).getField(Telephone.ATTRIB.ext), address.getPhoneAt(1).getField(Telephone.ATTRIB.ext).equals("7"));
+
+
+ }
+
+
+
+
+
+ public void testToDTO() throws Exception {
+ BaseBusinessObject personA = getPerson();
+ personA.setPackage();
+
+ BobjStdDTO oDto = personA.toDTO();
+ System.out.println(oDto.toXml());
+
+ Person personB = (Person) BaseBusinessObject.getFromDTO(oDto);
+ System.out.println(personB.toDTO().toXml());
+
+ assertTrue("Expecting PersonA == PersonB", personA.toDTO().toXml().equals(personB.toDTO().toXml()));
+ }
+
+
+ static Person getPerson() throws Exception {
+ Person oP = new Person((String) null);
+ oP.setField(Person.ATTRIB.pfx, "Mr.");
+ oP.setField(Person.ATTRIB.fmlyN, "Brum");
+ oP.setField(Person.ATTRIB.givN, "Daniel");
+ oP.setField(Person.ATTRIB.sfx, "the 1st.");
+
+ oP.addAddress(getAddress());
+
+ oP.addEmail(OneValue.getStringValue("myaddr at gmail.com", "home"));
+ oP.addEmail(OneValue.getStringValue("john.smith at jboss.com", "work"));
+
+ oP.addPhone(newPhone("basement", "1", "416", "555-1212", null));
+ oP.addPhone(newPhone("cell", null, "416", "666-4444", null));
+
+ return oP;
+ }
+
+ 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;
+ }
+
+}
More information about the jboss-svn-commits
mailing list