[jboss-svn-commits] JBL Code SVN: r23621 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule: JBESB_2146 and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 29 13:08:46 EDT 2008


Author: tfennelly
Date: 2008-10-29 13:08:46 -0400 (Wed, 29 Oct 2008)
New Revision: 23621

Added:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_ScheduledEventMessageComposer.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_UnitXTestX.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/config-01.xml
Log:
Added a test for https://jira.jboss.org/jira/browse/JBESB-2146

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_ScheduledEventMessageComposer.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_ScheduledEventMessageComposer.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_ScheduledEventMessageComposer.java	2008-10-29 17:08:46 UTC (rev 23621)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.schedule.JBESB_2146;
+
+import org.jboss.soa.esb.listeners.ScheduledEventMessageComposer;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.schedule.SchedulingException;
+import org.jboss.soa.esb.schedule.MockScheduledEventMessageComposer;
+
+import java.util.*;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JBESB_2146_ScheduledEventMessageComposer implements ScheduledEventMessageComposer {
+
+    public ConfigTree config;
+    public List<Message> composedMessages = Collections.synchronizedList(new ArrayList<Message>());
+    public List<Message> completedMessage = Collections.synchronizedList(new ArrayList<Message>());
+    private static Map<String, JBESB_2146_ScheduledEventMessageComposer> composers = new HashMap<String, JBESB_2146_ScheduledEventMessageComposer>();
+
+    public void reset() {
+        composedMessages.clear();
+        completedMessage.clear();
+    }
+
+    public void initialize(ConfigTree config) {
+        this.config = config;
+        composers.put(config.getAttribute("name"), this);
+    }
+
+    public static JBESB_2146_ScheduledEventMessageComposer getComposer(String name) {
+        return composers.get(name);
+    }
+
+    public void uninitialize() {
+    }
+
+    public Message composeMessage() throws SchedulingException {
+        Message message = org.jboss.soa.esb.message.format.MessageFactory.getInstance().getMessage();
+        composedMessages.add(message);
+        return message;
+    }
+
+    public Message onProcessingComplete(Message message) throws SchedulingException {
+        completedMessage.add(message);
+        return message;
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_ScheduledEventMessageComposer.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_UnitXTestX.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_UnitXTestX.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_UnitXTestX.java	2008-10-29 17:08:46 UTC (rev 23621)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.schedule.JBESB_2146;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.testutils.ESBConfigUtil;
+import org.jboss.soa.esb.testutils.StringUtils;
+import org.jboss.soa.esb.parameters.ParamRepositoryException;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.schedule.MockScheduledEventMessageComposer;
+import org.jboss.soa.esb.schedule.MockScheduledEventListener;
+import org.jboss.soa.esb.mock.MockAction;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.xml.sax.SAXException;
+
+import java.io.UnsupportedEncodingException;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JBESB_2146_UnitXTestX extends TestCase {
+
+    protected void setUp() throws Exception {
+        MockScheduledEventMessageComposer.reset();
+        MockScheduledEventListener.reset();
+        MockAction.message = null;
+    }
+
+    public void test_simple_schedule_01() throws UnsupportedEncodingException, ParamRepositoryException, ConfigurationException, ManagedLifecycleException, SAXException, InterruptedException {
+        runTestConfig("config-01.xml", 10000);
+
+        JBESB_2146_ScheduledEventMessageComposer composer1 = JBESB_2146_ScheduledEventMessageComposer.getComposer("simple-schedule-listener1");
+        JBESB_2146_ScheduledEventMessageComposer composer2 = JBESB_2146_ScheduledEventMessageComposer.getComposer("simple-schedule-listener2");
+
+        System.out.println(composer1.composedMessages.size());
+        System.out.println(composer2.composedMessages.size());
+    }
+
+    private void runTestConfig(String configName, long upTime) throws ParamRepositoryException, ConfigurationException, ManagedLifecycleException, SAXException, InterruptedException {
+        ESBConfigUtil configUtil = null;
+        try {
+            configUtil = new ESBConfigUtil(getClass().getResourceAsStream(configName));
+        } catch (IOException e) {
+            fail(e.getMessage());
+        }
+
+        configUtil.startController();
+        Thread.sleep(upTime);
+        configUtil.stopController();
+    }
+}
\ No newline at end of file


Property changes on: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/JBESB_2146_UnitXTestX.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/config-01.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/config-01.xml	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/config-01.xml	2008-10-29 17:08:46 UTC (rev 23621)
@@ -0,0 +1,34 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+    <providers>
+        <schedule-provider name="schedule">
+            <cron-schedule scheduleid="schedule1" cronExpression="0/2 * * * * ?"/>
+            <cron-schedule scheduleid="schedule2" cronExpression="0/1 * * * * ?"/>
+        </schedule-provider>
+    </providers>
+
+    <services>
+        <service category="ServiceCat" name="ServiceName-01" description="Test Service">
+
+            <listeners>
+                <scheduled-listener name="simple-schedule-listener1" scheduleidref="schedule1" event-processor="org.jboss.soa.esb.schedule.JBESB_2146.JBESB_2146_ScheduledEventMessageComposer" />
+            </listeners>
+
+            <actions>
+                <action name="action" class="org.jboss.soa.esb.mock.MockAction" />
+            </actions>			
+        </service>
+        <service category="ServiceCat" name="ServiceName-02" description="Test Service">
+
+            <listeners>
+                <scheduled-listener name="simple-schedule-listener2" scheduleidref="schedule2" event-processor="org.jboss.soa.esb.schedule.JBESB_2146.JBESB_2146_ScheduledEventMessageComposer" />
+            </listeners>
+
+            <actions>
+                <action name="action" class="org.jboss.soa.esb.mock.MockAction" />
+            </actions>
+        </service>
+    </services>
+
+</jbossesb>
\ No newline at end of file


Property changes on: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/schedule/JBESB_2146/config-01.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list