Author: arvinder
Date: 2006-07-10 14:03:13 -0400 (Mon, 10 Jul 2006)
New Revision: 4968
Added:
labs/jbossesb/branches/refactor/ESBCore/tests/
labs/jbossesb/branches/refactor/ESBCore/tests/bin/
labs/jbossesb/branches/refactor/ESBCore/tests/build.xml
labs/jbossesb/branches/refactor/ESBCore/tests/realbuild.xml
labs/jbossesb/branches/refactor/ESBCore/tests/src/
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/Controller.java
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/DrainQueuesAndTopics.java
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestNotification.java
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestObjStore.java
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java
labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java
Log:
Delete Tests directory and renamed to tests
Added: labs/jbossesb/branches/refactor/ESBCore/tests/build.xml
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/build.xml 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/build.xml 2006-07-10 18:03:13 UTC (rev 4968)
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<project name="BuildTestClasses" default="compile" basedir=".">
+
+ <property name="jar.name" value="jboss_esb_tests"/>
+ <property name="distrib.dir" value="../dist"/>
+ <property name="bin.dir" value="${basedir}/bin"/>
+ <property name="src.dir" value="${basedir}/src"/>
+ <property environment="env"/>
+
+ <path id="base.class.path">
+ <fileset dir="${env.JBOSS_HOME}/client" includes="activation.jar jbossall-client.jar log4j.jar mail.jar"/>
+ </path>
+
+ <path id="default.class.path">
+ <path refid="base.class.path"/>
+ <pathelement location="../EsbCommon/bin"/>
+ <pathelement location="../EsbServices/bin"/>
+ </path>
+
+ <target name="init">
+ <tstamp>
+ <format property="TODAY" pattern="d-MM-yy"/>
+ </tstamp>
+ </target>
+
+ <target name="prepare" depends="init">
+ <mkdir dir="${bin.dir}"/>
+ <mkdir dir="${distrib.dir}"/>
+ </target>
+
+ <target name="clean" description="Remove bin directory">
+ <delete dir="${bin.dir}"/>
+ </target>
+
+ <target name="compile" depends="prepare"
+ description="Compile all classes">
+
+ <javac
+ destdir="${bin.dir}"
+ classpathref="default.class.path"
+ debug="on"
+ optimize="off"
+ >
+ <src path="${src.dir}"/>
+ </javac>
+
+ </target>
+
+ <target name="recompile" depends="clean,compile"
+ description="Clean and compile"/>
+
+ <target name="jar" depends="compile" description="Assemble jar files">
+ <delete file="${distrib.dir}/${jar.name}.jar" />
+ <jar destfile="${distrib.dir}/${jar.name}.jar"
+ basedir="${bin.dir}"
+ includes="**/*.class"
+ excludes="test/**"
+ />
+ </target>
+
+ <target name="all" depends="recompile,jar" />
+
+</project>
Added: labs/jbossesb/branches/refactor/ESBCore/tests/realbuild.xml
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/realbuild.xml 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/realbuild.xml 2006-07-10 18:03:13 UTC (rev 4968)
@@ -0,0 +1,47 @@
+<?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.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"/>
+ <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}"/>
+ </target>
+
+ <target name="clean"/>
+
+ <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">
+
+ <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>
+
+</project>
Property changes on: labs/jbossesb/branches/refactor/ESBCore/tests/realbuild.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/Controller.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/Controller.java 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/Controller.java 2006-07-10 18:03:13 UTC (rev 4968)
@@ -0,0 +1,56 @@
+/*
+* 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
+ {
+ // build this Class[] with the list of classes you wish to test
+ // Tested classes should have a public constructor with no arguments
+
+ Class[] oaTest =
+ {
+// TestParamsRepository.class
+// ,TestPersonAddrPhone.class
+// ,TestObjStore.class
+// ,TestNotification.class
+ DrainQueuesAndTopics.class
+ };
+
+ for (Class oCls : oaTest)
+ {
+ Constructor oConst = oCls.getConstructor(new Class[] {});
+ oConst.newInstance(new Object[] {});
+ }
+
+ Thread.sleep(500);
+ } //________________________________
+
+} //____________________________________________________________________________
Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/DrainQueuesAndTopics.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/DrainQueuesAndTopics.java 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/DrainQueuesAndTopics.java 2006-07-10 18:03:13 UTC (rev 4968)
@@ -0,0 +1,92 @@
+package org.jboss.soa.esb.tests;
+
+import javax.jms.*;
+import javax.naming.*;
+
+import org.jboss.soa.esb.helpers.*;
+
+public class DrainQueuesAndTopics
+{
+ private static final int MAX_TIMES_NOMSG = 10;
+ private static final String JNDI_URL = "localhost";
+ private static final String JNDI_TYPE
+ = AppServerContext.SERVER_TYPE.jboss.toString();
+
+ private Context m_oCtx;
+
+ public DrainQueuesAndTopics() throws Exception
+ {
+ purgeQueueTopic("queue/A");
+ purgeQueueTopic("queue/B");
+ purgeQueueTopic("topic/testTopic");
+ } //__________________________________
+
+ public int purgeQueueTopic(String p_sName) throws Exception
+ {
+ int iRet = 0;
+ m_oCtx = AppServerContext.getServerContext(JNDI_TYPE,JNDI_URL);
+
+ System.out.println(p_sName);
+ MessageConsumer oCns = null;
+ switch(p_sName.toLowerCase().charAt(0))
+ { case 't' : oCns = getTopic(p_sName); break;
+ case 'q' : oCns = getQueue(p_sName); break;
+ }
+ if (null==oCns)
+ return 0;
+
+ for (int iNoRcv=0; iNoRcv < MAX_TIMES_NOMSG; )
+ { Message oMsg = oCns.receive(200);
+ if (null==oMsg)
+ { iNoRcv++;
+ System.out.print(".");
+ continue;
+ }
+ iRet++;
+ dumpMessage(oMsg);
+ iNoRcv = 0;
+ }
+ System.out.println();
+ return iRet;
+ } //__________________________________
+
+ void dumpMessage(Message pM)
+ {
+ System.out.println(pM);
+ } //__________________________________
+
+ QueueReceiver getQueue(String p_sJndi) throws Exception
+ {
+ QueueConnection oQconn = null;
+ QueueSession oQsess = null;
+ QueueConnectionFactory qcf = (QueueConnectionFactory) m_oCtx
+ .lookup("ConnectionFactory");
+
+ oQconn = qcf.createQueueConnection();
+ oQsess = oQconn.createQueueSession(false
+ ,QueueSession.AUTO_ACKNOWLEDGE);
+ javax.jms.Queue oQueue
+ = (javax.jms.Queue) m_oCtx.lookup(p_sJndi);
+
+ QueueReceiver oRcv = oQsess.createReceiver(oQueue);
+ oQconn.start();
+ return oRcv;
+ } //__________________________________
+
+ TopicSubscriber getTopic(String p_sJndi) throws Exception
+ {
+ TopicConnection oTconn = null;
+ TopicSession oTsess = null;
+ TopicConnectionFactory qcf = (TopicConnectionFactory) m_oCtx
+ .lookup("ConnectionFactory");
+
+ oTconn = qcf.createTopicConnection();
+ oTsess = oTconn.createTopicSession(false
+ ,QueueSession.AUTO_ACKNOWLEDGE);
+ Topic oT = (Topic) m_oCtx.lookup(p_sJndi);
+
+ TopicSubscriber oRcv = oTsess.createSubscriber(oT);
+ oTconn.start();
+ return oRcv;
+ } //__________________________________
+} //____________________________________________________________________________
Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestNotification.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestNotification.java 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestNotification.java 2006-07-10 18:03:13 UTC (rev 4968)
@@ -0,0 +1,201 @@
+/*
+* 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.util.*;
+import java.text.SimpleDateFormat;
+
+import org.jboss.soa.esb.common.EsbSysProps;
+import org.jboss.soa.esb.helpers.*;
+import org.jboss.soa.esb.helpers.persist.SimpleDataSource;
+import org.jboss.soa.esb.notification.*;
+import org.jboss.soa.esb.services.*;
+
+// DON'T FORGET !!
+// The Rosetta Application server has to be up and running
+// (set JNDI_SERVER appropriately)
+// For e-mail notification: System properties for smtp
+// (server, user, password, port) must be set up in app server
+
+public class TestNotification
+{
+ private static InotificationHandler m_oH;
+
+ public TestNotification () throws Exception
+ { performTest(); }
+
+ static void performTest() throws Exception
+ {
+ // get a handle to your business delegate
+ m_oH = NotificationHandlerFactory.getNotifHandler
+ ("remote"
+ ,EsbSysProps.getJndiServerType()
+ ,EsbSysProps.getJndiServerURL()
+ );
+
+ DomElement oEl = new DomElement("MyFileList");
+ oEl.setAttr(NotificationList.TYPE,"OK");
+
+// oEl.addElemChild(fileListTarget());
+// oEl.addElemChild(emailTarget());
+// oEl.addElemChild(jmsQueueTarget());
+// oEl.addElemChild(jmsTopicTarget());
+ oEl.addElemChild(sqlTableTarget());
+
+ NotificationList oNL = new NotificationList(oEl);
+
+ // to see how the XML looks like
+ // this is just a unit test class
+ // Typically the XML is used in a parameter object (DomElement.fromXml())
+ System.out.println(oNL.toString());
+
+ // a simple timestamped message
+ Date oNow = new Date(System.currentTimeMillis());
+ SimpleDateFormat oStamp = new SimpleDateFormat("dd/MMM/yyyy HH:mm:ss.SSS");
+ StringBuilder sb = new StringBuilder(oStamp.format(oNow))
+ .append(" This message from Notification test");
+
+ m_oH.sendNotifications(oNL,sb.toString());
+ } //________________________________
+
+ static DomElement emailTarget() throws Exception
+ {
+ DomElement oTgt = new DomElement(NotificationList.CHILD_TGT);
+ oTgt.setAttr(NotificationTarget.PRM_NOTIF_CLASS,"NotifyEmail");
+ oTgt.setAttr(EsbEmail.FROM,"se...@jb...");
+ oTgt.setAttr(EsbEmail.SENDTO,"rec...@ho...,rec...@jb...");;
+ oTgt.setAttr(EsbEmail.SUBJECT,"TEST from Rosetta");
+ oTgt.setAttr(EsbEmail.MESSAGE,"This is the text of your message");
+
+ // This class does NOT send the e-mails, the app server does
+ // consequently these paths would have to be accessible in the
+ // application server (filesystem / mounts)
+ String[] sa = {"/tmp/tomcat.sh","/tmp/program.js"};
+ for (String sCurr : sa)
+ oTgt.addTextChild(EsbEmail.ATTACH,sCurr);
+
+ return oTgt;
+ } //________________________________
+
+ static DomElement fileListTarget() throws Exception
+ {
+ DomElement oTgt = new DomElement(NotificationList.CHILD_TGT);
+ oTgt.setAttr(NotificationTarget.PRM_NOTIF_CLASS,"NotifyFiles");
+
+ // This class does NOT write the files, the app server does
+ // consequently these paths would have to be accessible in the
+ // application server (filesystem / mounts)
+ String[] sa = {"file:///tmp/file1.notif","file:///tmp/file2.notif"};
+ for (String sCurr : sa)
+ { DomElement oFile = new DomElement(NotifyFiles.CHILD_FILE);
+ oFile.setAttr(NotifyFiles.ATT_URI,sCurr);
+ oFile.setAttr(NotifyFiles.ATT_APPEND,Boolean.toString(true));
+ oTgt.addElemChild(oFile);
+ }
+ return oTgt;
+ } //________________________________
+
+ static DomElement jmsQueueTarget() throws Exception
+ {
+ DomElement oTgt = new DomElement(NotificationList.CHILD_TGT);
+ oTgt.setAttr(NotificationTarget.PRM_NOTIF_CLASS,"NotifyQueues");
+
+ String[] sa = {"queue/A","queue/B"};
+ for (String sCurr : sa)
+ { DomElement oQ = new DomElement(NotifyQueues.CHILD_QUEUE);
+ oQ.setAttr(NotifyJMS.ATT_DEST_NAME,sCurr);
+ for (DomElement oProp : getMessageProperties())
+ oQ.addElemChild(oProp);
+ oTgt.addElemChild(oQ);
+ }
+ return oTgt;
+ } //________________________________
+
+ static DomElement jmsTopicTarget() throws Exception
+ {
+ DomElement oTgt = new DomElement(NotificationList.CHILD_TGT);
+ oTgt.setAttr(NotificationTarget.PRM_NOTIF_CLASS,"NotifyTopics");
+
+ String[] sa = {"topic/testTopic"};
+ for (String sCurr : sa)
+ { DomElement oQ = new DomElement(NotifyTopics.CHILD_TOPIC);
+ oQ.setAttr(NotifyJMS.ATT_DEST_NAME,sCurr);
+ for (DomElement oProp : getMessageProperties())
+ oQ.addElemChild(oProp);
+ oTgt.addElemChild(oQ);
+ }
+ return oTgt;
+ } //________________________________
+
+ static DomElement[] getMessageProperties() throws Exception
+ {
+ KeyValuePair[] oaProps = new KeyValuePair[]
+ {new KeyValuePair("prop1","111")
+ ,new KeyValuePair("prop2","bbb")
+ ,new KeyValuePair("prop3","abc123")
+ };
+ DomElement[] oaRet = new DomElement[oaProps.length];
+ int iCurr = 0;
+ for (KeyValuePair oCurr : oaProps)
+ { DomElement oElem = new DomElement(NotifyJMS.CHILD_MSG_PROP);
+ oElem.setAttr(NotifyJMS.ATT_PROP_NAME,oCurr.getKey());
+ oElem.setAttr(NotifyJMS.ATT_PROP_VALUE,oCurr.getValue());
+ oaRet[iCurr++] = oElem;
+ }
+ return oaRet;
+ } //________________________________
+
+ static DomElement sqlTableTarget() throws Exception
+ {
+ DomElement oTgt = new DomElement(NotificationList.CHILD_TGT);
+ oTgt.setAttr(NotificationTarget.PRM_NOTIF_CLASS,"NotifySqlTable");
+
+ oTgt.setAttr(SimpleDataSource.DRIVER,"org.postgresql.Driver");
+ oTgt.setAttr(SimpleDataSource.URL,"jdbc:postgresql://lavasca:5432/rosetta");
+ oTgt.setAttr(SimpleDataSource.USER,"postgres");
+ oTgt.setAttr(SimpleDataSource.PASSWORD,"");
+
+ // Table name for insert - must exist in database (URL)
+ oTgt.setAttr(NotifySqlTable.ATT_TABLE,"test_notif_table");
+ // Column that will contain the dynamic data generated by the ActionClass
+ // must exist in table (ATT_TABLE above)
+ oTgt.setAttr(NotifySqlTable.ATT_DATA,"msg");
+
+ // constant data that can be also added in the insert
+ // (perhaps needed for queries)
+ // Key = column name (it must exist in the table, same as ATT_DATA column)
+ KeyValuePair[] oaCols = new KeyValuePair[]
+ {new KeyValuePair("src","TestNotification")
+ ,new KeyValuePair("ref","any Ref")
+ ,new KeyValuePair("val1","VVVV 11111")
+ };
+ for (KeyValuePair oCurr : oaCols)
+ { DomElement oElem = new DomElement(NotifySqlTable.CHILD_COLUMN);
+ oElem.setAttr(NotifySqlTable.ATT_NAME,oCurr.getKey());
+ oElem.setAttr(NotifySqlTable.ATT_VALUE,oCurr.getValue());
+ oTgt.addElemChild(oElem);
+ }
+
+
+ return oTgt;
+ } //________________________________
+} //____________________________________________________________________________
Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestObjStore.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestObjStore.java 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestObjStore.java 2006-07-10 18:03:13 UTC (rev 4968)
@@ -0,0 +1,84 @@
+/*
+* 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.EsbSysProps;
+import org.jboss.soa.esb.common.bizclasses.*;
+import org.jboss.soa.esb.services.*;
+
+// DON'T FORGET !!
+// The Rosetta Application server has to be up and running
+// (set JNDI_SERVER appropriately)
+
+public class TestObjStore
+{
+ private static IpersistHandler m_oH;
+
+ public TestObjStore () throws Exception
+ { performTest(); }
+
+ static void performTest() throws Exception
+ {
+ // get a handle to your business delegate
+ m_oH = PersistHandlerFactory.getPersistHandler
+ ("remote"
+ ,EsbSysProps.getJndiServerType()
+ ,EsbSysProps.getJndiServerURL()
+ );
+
+ // request UID chunks for your own use
+ 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
+ {
+ // set up a Person (see TestPersonAddrPhone.class)
+ Person oPrs = TestPersonAddrPhone.getPerson();
+ // timestamp, uid and snap Uid are added just to make it easier
+ // to compare output text
+ oPrs.setStamp(System.currentTimeMillis());
+ long lUid = m_oH.addObject(oPrs);
+ oPrs.setUid(lUid);
+ oPrs.setSnap(lUid);
+
+ // retrieve it from the Object Store
+ Person oP2 = (Person)m_oH.getObject(Person.class,lUid);
+
+ // output in XML format both objects, and compare
+ // timestamps will differ slightly because first object
+ // has a dummy timestamp (just before "store" request)
+ System.out.println(oPrs.toDTO().toXml());
+ System.out.println(oP2.toDTO().toXml());
+
+ // if you used the "ObjStoreExample.xml" that comes with the
+ // standard example, you'll be able to see your objects
+ // in the "object_snap" and "people_index" tables
+
+ } //________________________________
+} //____________________________________________________________________________
Added: labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestParamsRepository.java 2006-07-10 18:03:13 UTC (rev 4968)
@@ -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/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java
===================================================================
--- labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java 2006-07-10 18:01:44 UTC (rev 4967)
+++ labs/jbossesb/branches/refactor/ESBCore/tests/src/org/jboss/soa/esb/tests/TestPersonAddrPhone.java 2006-07-10 18:03:13 UTC (rev 4968)
@@ -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("my...@gm...","home"));
+ oP.addEmail(OneValue.getStringValue("joh...@jb...","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;
+ }
+
+} //____________________________________________________________________________
|