|
From: <jbo...@li...> - 2006-06-28 15:10:56
|
Author: estebanschifman
Date: 2006-06-28 11:10:52 -0400 (Wed, 28 Jun 2006)
New Revision: 4846
Modified:
labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/Controller.java
labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java
Log:
TestNotification has now NotifyQueues and NotifyTopics examples
Modified: 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-28 15:07:54 UTC (rev 4845)
+++ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/Controller.java 2006-06-28 15:10:52 UTC (rev 4846)
@@ -37,9 +37,10 @@
Class[] oaTest =
{
- TestParamsRepository.class
- ,TestPersonAddrPhone.class
- ,TestObjStore.class
+ TestNotification.class
+// TestParamsRepository.class
+// ,TestPersonAddrPhone.class
+// ,TestObjStore.class
};
for (Class oCls : oaTest)
Modified: labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java
===================================================================
--- labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java 2006-06-28 15:07:54 UTC (rev 4845)
+++ labs/jbossesb/trunk/ESBCore/Tests/src/org/jboss/soa/esb/tests/TestNotification.java 2006-06-28 15:10:52 UTC (rev 4846)
@@ -50,11 +50,19 @@
DomElement oEl = new DomElement("MyFileList");
oEl.setAttr(NotificationList.TYPE,"OK");
- oEl.addElemChild(fileListTarget());
+// oEl.addElemChild(fileListTarget());
+// oEl.addElemChild(emailTarget());
+// oEl.addElemChild(jmsQueueTarget());
+ oEl.addElemChild(jmsTopicTarget());
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))
@@ -67,15 +75,15 @@
{
DomElement oTgt = new DomElement(NotificationList.CHILD_TGT);
oTgt.setAttr(NotificationTarget.PRM_NOTIF_CLASS,"NotifyEmail");
- oTgt.setAttr(EsbEmail.FROM,"my...@my...");
- oTgt.setAttr(EsbEmail.SENDTO,"som...@ta...");;
+ 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 = {"C:/tmp/tomcat.sh","E;/tmp/program.js"};
+ String[] sa = {"/tmp/tomcat.sh","/tmp/program.js"};
for (String sCurr : sa)
oTgt.addTextChild(EsbEmail.ATTACH,sCurr);
@@ -90,7 +98,7 @@
// 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:///E:/tmp/file1.notif","file:///E:/tmp/file2.notif"};
+ 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);
@@ -99,4 +107,54 @@
}
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;
+ } //________________________________
} //____________________________________________________________________________
|