[jboss-svn-commits] JBL Code SVN: r5361 - in labs/jbossesb/trunk/product/core/common: src/org/jboss/soa/esb/notification tests/src/org/jboss/soa/esb/notification
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 31 11:10:33 EDT 2006
Author: tfennelly
Date: 2006-07-31 11:10:23 -0400 (Mon, 31 Jul 2006)
New Revision: 5361
Added:
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest_testfile1.xml
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget1.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget2.java
Modified:
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java
Log:
Added tests for NotificationList and NotificationTarget
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java 2006-07-31 14:41:11 UTC (rev 5360)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationList.java 2006-07-31 15:10:23 UTC (rev 5361)
@@ -76,8 +76,10 @@
private NotificationTarget[] getTargets() throws Exception {
DomElement[] oaTgts = super.getElementChildren(CHILD_TGT);
NotificationTarget[] oaRet = new NotificationTarget[oaTgts.length];
- for (int i1 = 0; i1 < oaRet.length; i1++)
+
+ for (int i1 = 0; i1 < oaRet.length; i1++) {
oaRet[i1] = NotificationTarget.fromParams(oaTgts[i1]);
+ }
return oaRet;
} // __________________________________
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java 2006-07-31 14:41:11 UTC (rev 5360)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/notification/NotificationTarget.java 2006-07-31 15:10:23 UTC (rev 5361)
@@ -45,7 +45,7 @@
*/
public abstract void sendNotification(java.io.Serializable p_o) throws Exception;
- private static final String NOTIF_PFX = "org.jboss.soa.esb.notification";
+ private static final String NOTIF_PFX = NotificationTarget.class.getPackage().getName();
public static final String PRM_NOTIF_CLASS = "class";
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest.java 2006-07-31 14:41:11 UTC (rev 5360)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest.java 2006-07-31 15:10:23 UTC (rev 5361)
@@ -0,0 +1,75 @@
+/*
+ * 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.notification;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.soa.esb.helpers.DomElement;
+
+import junit.framework.TestCase;
+
+/**
+ * NotificationList unit tests.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class NotificationListUnitTest extends TestCase {
+
+ public void test_NotificationList() throws Exception {
+ DomElement domEl = DomElement.fromInputStream(getClass().getResourceAsStream("NotificationListUnitTest_testfile1.xml"));
+ NotificationList nList = new NotificationList(domEl);
+
+ List<String> messageList = new ArrayList<String>();
+ TestNotificationTarget1.messageList = messageList;
+ TestNotificationTarget2.messageList = messageList;
+
+ nList.sendNotification("tom");
+ assertEquals(4, messageList.size());
+ assertEquals("message 1-tom", messageList.get(0));
+ assertEquals("message 2-tom", messageList.get(1));
+ assertEquals("message 3-tom", messageList.get(2));
+ assertEquals("message 4-tom", messageList.get(3));
+ }
+
+ public void test_assertionMethods() throws Exception {
+ DomElement domEl;
+ NotificationList nList;
+
+ domEl = new DomElement("notif");
+ nList = new NotificationList(domEl);
+ assertTrue(nList.isOK());
+ assertTrue(nList.isErr());
+ // REVIEW: Is this behavior OK?? Can be OK and Err at the same time!!
+
+ domEl = new DomElement("notif");
+ domEl.setAttr(NotificationList.TYPE, "ok");
+ nList = new NotificationList(domEl);
+ assertTrue(nList.isOK());
+ assertTrue(!nList.isErr());
+
+ domEl = new DomElement("notif");
+ domEl.setAttr(NotificationList.TYPE, "err");
+ nList = new NotificationList(domEl);
+ assertTrue(!nList.isOK());
+ assertTrue(nList.isErr());
+ }
+}
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest_testfile1.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest_testfile1.xml 2006-07-31 14:41:11 UTC (rev 5360)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/NotificationListUnitTest_testfile1.xml 2006-07-31 15:10:23 UTC (rev 5361)
@@ -0,0 +1,6 @@
+<notif type="ok">
+ <target class="TestNotificationTarget1" message="message 1" />
+ <target class="TestNotificationTarget1" message="message 2" />
+ <target class="TestNotificationTarget2" message="message 3" />
+ <target class="TestNotificationTarget2" message="message 4" />
+</notif>
\ No newline at end of file
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget1.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget1.java 2006-07-31 14:41:11 UTC (rev 5360)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget1.java 2006-07-31 15:10:23 UTC (rev 5361)
@@ -0,0 +1,24 @@
+package org.jboss.soa.esb.notification;
+
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.soa.esb.helpers.DomElement;
+
+public class TestNotificationTarget1 extends NotificationTarget {
+
+ private DomElement config;
+
+ public static List<String> messageList;
+
+ public TestNotificationTarget1(DomElement targetConf) {
+ super(targetConf);
+ config = targetConf;
+ }
+
+ @Override
+ public void sendNotification(Serializable obj) throws Exception {
+ messageList.add(config.getAttr("message") + "-" + obj);
+ }
+}
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget2.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget2.java 2006-07-31 14:41:11 UTC (rev 5360)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/notification/TestNotificationTarget2.java 2006-07-31 15:10:23 UTC (rev 5361)
@@ -0,0 +1,10 @@
+package org.jboss.soa.esb.notification;
+
+import org.jboss.soa.esb.helpers.DomElement;
+
+public class TestNotificationTarget2 extends TestNotificationTarget1 {
+
+ public TestNotificationTarget2(DomElement targetConf) {
+ super(targetConf);
+ }
+}
More information about the jboss-svn-commits
mailing list