Author: estebanschifman Date: 2006-06-27 08:34:51 -0400 (Tue, 27 Jun 2006) New Revision: 4837 Added: labs/jbossesb/trunk/ESBCore/Tests/ labs/jbossesb/trunk/ESBCore/Tests/src/ labs/jbossesb/trunk/ESBCore/Tests/src/org/ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/Controller.java labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestObjStore.java labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java Log: A simple project to help unit testing of Rosetta components. Added: labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/Controller.java =================================================================== --- labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/Controller.java 2006-06-27 08:51:41 UTC (rev 4836) +++ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/Controller.java 2006-06-27 12:34:51 UTC (rev 4837) @@ -0,0 +1,51 @@ +/* +* 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 java.lang.reflect.*; + +public class Controller +{ + private static String[] s_saArgs; + static String[] getArgs() { return s_saArgs; } + public static void main(String[] args) throws Exception + { s_saArgs = args; new Controller(); } + + private Controller() throws Exception + { + Class[] oaTest = + { + TestParamsRepository.class + ,TestPersonAddrPhone.class + ,TestObjStore.class + }; + + for (Class oCls : oaTest) + { + Constructor oConst = oCls.getConstructor(new Class[] {}); + oConst.newInstance(new Object[] {}); + } + + Thread.sleep(500); + } //________________________________ + +} //____________________________________________________________________________ Added: labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestObjStore.java =================================================================== --- labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestObjStore.java 2006-06-27 08:51:41 UTC (rev 4836) +++ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestObjStore.java 2006-06-27 12:34:51 UTC (rev 4837) @@ -0,0 +1,62 @@ +/* +* 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 org.jboss.soa.esb.common.bizclasses.*; +import org.jboss.soa.esb.services.*; + +// The Rosetta Persistence handler has to be up and running + +public class TestObjStore +{ + private static final String JNDI_SERVER = "localhost"; + private static IpersistHandler m_oH; + + public TestObjStore () throws Exception + { performTest(); } + + static void performTest() throws Exception + { + m_oH = PersistHandlerFactory.getPersistHandler("remote",JNDI_SERVER); + int[] ia = {10,20,30}; + for (int iCurr : ia) + System.out.println + ("Requesting "+iCurr+" uids " + +" - First UID returned = " +m_oH.getUidChunk(iCurr) + ); + + storeAndRetrievePerson(); + } //________________________________ + + static void storeAndRetrievePerson() throws Exception + { + Person oPrs = TestPersonAddrPhone.getPerson(); + oPrs.setStamp(System.currentTimeMillis()); + long lUid = m_oH.addObject(oPrs); + oPrs.setUid(lUid); + oPrs.setSnap(lUid); + Person oP2 = (Person)m_oH.getObject(Person.class,lUid); + System.out.println(oPrs.toDTO().toXml()); + System.out.println(oP2.toDTO().toXml()); + + } //________________________________ +} //____________________________________________________________________________ Added: labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java =================================================================== --- labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java 2006-06-27 08:51:41 UTC (rev 4836) +++ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java 2006-06-27 12:34:51 UTC (rev 4837) @@ -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 javax.naming.*; + +import org.jboss.soa.esb.helpers.*; +import org.jboss.soa.esb.parameters.*; + +public class TestParamsRepository +{ + ParamsRepository m_oRepos; + public TestParamsRepository() throws Exception + { + m_oRepos = ParamsReposUtil.reposFromFactory(null,null); + performTest(); + } //________________________________ + + @SuppressWarnings("unused") + private void performTest() throws Exception + { + String sDir = "/tmp/jbossEsb/paramsDir"; + Name oInpName = ParamsReposUtil.nameFromString(sDir) + .add("FileMoverConfigExample.xml"); + + DomElement oElem = m_oRepos.getElement(oInpName); + + Name oOutName = ParamsReposUtil.nameFromString(sDir) + .add("outputTest.xml"); + m_oRepos.storeElement(oOutName,oElem); + + oElem = m_oRepos.getElement(oOutName); + System.out.println(oElem.toString()); + } //________________________________ + +} //____________________________________________________________________________ Added: labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java =================================================================== --- labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java 2006-06-27 08:51:41 UTC (rev 4836) +++ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java 2006-06-27 12:34:51 UTC (rev 4837) @@ -0,0 +1,96 @@ +/* +* 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 org.jboss.soa.esb.util.*; +import org.jboss.soa.esb.common.bizclasses.*; + +public class TestPersonAddrPhone +{ + public TestPersonAddrPhone() throws Exception + { performTest(); } + + static void performTest() throws Exception + { + BaseBusinessObject o = getPerson(); + o.setPackage(); + + BobjStdDTO oDto = o.toDTO(); + System.out.println(oDto.toXml()); + + o = BaseBusinessObject.getFromDTO(oDto); + System.out.println(o.toDTO().toXml()); + Thread.sleep(500); + + o.toDTO().Dump("Example dump of "+EsbUtil.classSuffix(o.getClass())); + + } //________________________________ + + 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("dbr...@gm...","home")); + oP.addEmail(OneValue.getStringValue("dan...@jb...","work")); + + oP.addPhone(newPhone("basement","1","416","322-5832",null)); + oP.addPhone(newPhone("cell",null,"416","561-2151",null)); + + return oP; + } //________________________________ + + static Address getAddress() throws Exception + { + Address oP = new Address((String)null); + oP.setField(Address.ATTRIB.strNum,"2155"); + oP.setField(Address.ATTRIB.strLine1,"Tres de Febrero"); + 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","628-1403",null)); + oP.addPhone(newPhone("home","54","11","4723-4085","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; + } + +} //____________________________________________________________________________ |