You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2005/11/28 18:23:05 UTC
svn commit: r349438 [2/2] - in /beehive/trunk: ant/ system-controls/ant/
system-controls/test/ejb/ system-controls/test/ejb/src/assemblyTests/
system-controls/test/ejb/src/assemblyTests/org/
system-controls/test/ejb/src/assemblyTests/org/apache/ system...
Added: beehive/trunk/system-controls/test/jms/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/build.xml?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/build.xml (added)
+++ beehive/trunk/system-controls/test/jms/build.xml Mon Nov 28 09:22:12 2005
@@ -0,0 +1,224 @@
+<?xml version="1.0" ?>
+
+<!--
+ Copyright 2005 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+-->
+<project name="Beehive/JMSControlDRT" default="test" basedir=".">
+
+ <property environment="os"/>
+ <property name="servlet.runtime" value="geronimo"/>
+ <import file="../../systemcontrols-imports.xml"/>
+ <import file="../../ant/geronimo-imports.xml"/>
+
+ <path id="test.classpath">
+ <path refid="controls.dependency.path"/>
+ <path refid="ejb.dependency.path"/>
+ <path refid="velocity.dependency.path"/>
+ <path refid="tools.dependency.path"/>
+ <pathelement location="${beehive.home}/system-controls/build/jars/beehive-ejb-control.jar"/>
+ </path>
+
+ <target name="clean">
+ <delete dir="build"/>
+ </target>
+
+ <!-- ***************************************************************** -->
+ <!-- CACTUS SETTINGS -->
+ <!-- ***************************************************************** -->
+
+ <property name="cactus.home" location="${os.CACTUS_HOME}"/>
+ <property name="geronimo.home" location="${os.GERONIMO_HOME}"/>
+
+
+ <property name="controls.build.dir" location="build/controls"/>
+ <property name="controls.gen.dir" location="build/controls-gen"/>
+ <property name="controls.src.dir" location="src/controls"/>
+ <property name="cactus.build.dir" location="build/cactus"/>
+ <property name="cactus.gen.dir" location="build/cactus-gen"/>
+ <property name="cactus.src.dir" location="src/tests"/>
+ <property name="cactus.log.dir" location="build/logs"/>
+ <property name="jars.dir" location="build/jars"/>
+ <property name="webapp.src.dir" location="src/webapp"/>
+ <property name="webapp.build.dir" location="build/webapp"/>
+
+
+ <property name="waitfor.url" value="http://localhost:8080/jmsTest"/>
+ <property name="target.module.id" value="testJms-cactified"/>
+
+ <!-- Libraries required for the jms controls -->
+ <path id="controls.classpath">
+ <pathelement location="${beehive.home}/system-controls/build/jars/beehive-jms-control.jar"/>
+ <path refid="controls.dependency.path"/>
+ <path refid="ejb.dependency.path"/>
+ <path refid="velocity.dependency.path"/>
+ <path refid="tools.dependency.path"/>
+ </path>
+
+ <!-- Libraries required for the Cactus tests (runtime) -->
+ <path id="cactus.classpath">
+ <pathelement location="${cactus.home}/lib/aspectjrt-1.2.1.jar"/>
+ <pathelement location="${cactus.home}/lib/cactus-1.7.1.jar"/>
+ <pathelement location="${cactus.home}/lib/cactus-ant-1.7.1.jar"/>
+ <pathelement location="${cactus.home}/lib/cargo-0.5.jar"/>
+ <pathelement location="${cactus.home}/lib/commons-httpclient-2.0.2.jar"/>
+ <pathelement location="${cactus.home}/lib/commons-logging-1.0.4.jar"/>
+ <pathelement location="${cactus.home}/lib/junit-3.8.1.jar"/>
+ </path>
+
+ <!-- Libraries required for the Cactus tests (build time) -->
+ <path id="cactus.build.classpath">
+ <pathelement location="${jars.dir}/jmsControls.jar"/>
+ <path refid="controls.classpath"/>
+ <path refid="ejb.dependency.path"/>
+ <path refid="cactus.classpath"/>
+ </path>
+
+ <taskdef resource="cactus.tasks" classpathref="cactus.classpath"/>
+
+ <!-- create the directories necessary for the cactus build -->
+ <target name="init.dirs">
+ <mkdir dir="${controls.build.dir}"/>
+ <mkdir dir="${controls.gen.dir}"/>
+ <mkdir dir="${jars.dir}"/>
+ <mkdir dir="${cactus.build.dir}"/>
+ <mkdir dir="${cactus.gen.dir}"/>
+ <mkdir dir="${cactus.log.dir}"/>
+ <mkdir dir="${webapp.build.dir}"/>
+ <mkdir dir="${webapp.build.dir}/WEB-INF/lib"/>
+ </target>
+
+ <!--
+ -->
+ <target name="build.controls" depends="init.dirs"
+ description="Build the jms controls for the cactus tests.">
+
+ <build-controls srcdir="${controls.src.dir}"
+ destdir="${controls.build.dir}"
+ tempdir="${controls.gen.dir}"
+ classpathref="controls.classpath"/>
+
+ <control-jar destfile="${jars.dir}/jmsControls.jar" basedir="${controls.build.dir}"/>
+ </target>
+
+ <!--
+ -->
+ <target name="build.tests" depends="build.controls" description="Build the cactus tests.">
+
+ <build-controls srcdir="${cactus.src.dir}"
+ destdir="${cactus.build.dir}"
+ tempdir="${cactus.gen.dir}"
+ classpathref="cactus.build.classpath"/>
+ </target>
+
+ <!--
+ -->
+ <target name="build.webapp" description="Assemble the webapp dir for the cactus tests">
+
+ <copy todir="${webapp.build.dir}">
+ <fileset dir="${webapp.src.dir}">
+ <include name="**/*.xml"/>
+ </fileset>
+ </copy>
+
+ <deploy-controls destDir="${webapp.build.dir}/WEB-INF/lib"/>
+
+ <copy file="${beehive.home}/system-controls/build/jars/beehive-jms-control.jar"
+ todir="${webapp.build.dir}/WEB-INF/lib"/>
+ <copy file="${jars.dir}/jmsControls.jar" todir="${webapp.build.dir}/WEB-INF/lib"/>
+ <!-- todo: mq -->
+ <copy file="/usr/local/apps/geronimo-1.0-M5/repository/activemq/jars/activemq-core-3.2-M1.jar"
+ todir="${webapp.build.dir}/WEB-INF/lib"/>
+ </target>
+
+ <!--
+ Build the cactified ear for testing. Steps necessary:
+ 1) Build a war file for the webapp
+ 2) Cactify the webapp war file
+ 3) Build a cactified ear file
+ -->
+ <target name="build.cactus.ear" depends="build.tests, build.webapp"
+ description="Create the ear file that will hold the cactus tests.">
+
+ <war warfile="${jars.dir}/cactusTests.war" webxml="${webapp.build.dir}/WEB-INF/web.xml">
+ <lib dir="${webapp.build.dir}/WEB-INF/lib"/>
+ </war>
+
+ <cactifywar srcfile="${jars.dir}/cactusTests.war" destfile="${jars.dir}/cactusTests-cactified.war"
+ mergewebxml="${webapp.build.dir}/WEB-INF/cactus-web.xml">
+ <classes dir="${cactus.build.dir}"/>
+ <lib file="${clover.jar}"/>
+ </cactifywar>
+
+ <ear earfile="${jars.dir}/testJms-cactified.ear" appxml="${webapp.build.dir}/application.xml">
+ <fileset file="${jars.dir}/cactusTests-cactified.war"/>
+ </ear>
+ </target>
+
+ <!--
+ -->
+ <target name="test.prepare" depends="clean, init.dirs, build.cactus.ear"/>
+
+ <!--
+ -->
+ <target name="cactus.tests" depends="check.cactus, check.geronimo, test.prepare"
+ description="Run the cactus tests.">
+
+ <!-- configure the JMS broker for the tests -->
+ <antcall target="deploy.jms.configuration">
+ <param name="target.module.id" value="weather/Topics"/>
+ <param name="broker.config.file" value="src/test-activemq.xml"/>
+ <param name="broker.rar" value="${geronimo.home}/repository/activemq/rars/activemq-ra-3.2-M1.rar"/>
+ <param name="geronimo.username" value="system"/>
+ <param name="geronimo.password" value="manager"/>
+ </antcall>
+
+ <antcall target="deploy.ear">
+ <param name="ear.to.deploy" value="${jars.dir}/testJms-cactified.ear"/>
+ </antcall>
+
+ <cactus earfile="build/jars/testJms-cactified.ear" fork="yes" failureproperty="tests.failed">
+
+ <classpath>
+ <pathelement location="${cactus.build.dir}"/>
+ <pathelement location="${cactus.home}/lib/aspectjrt-1.2.1.jar"/>
+ <pathelement location="${geronimo.home}/repository/activemq/jars/activemq-core-3.2-M1.jar"/>
+ <pathelement location="${geronimo.home}/repository/concurrent/jars/concurrent-1.3.4.jar"/>
+ <path refid="controls.classpath"/>
+ <path refid="ejb.test.dependency.path"/>
+ </classpath>
+ <containerset>
+ <generic name="Geronimo_M5" port="8080"/>
+ </containerset>
+ <formatter type="brief" usefile="false"/>
+ <formatter type="xml"/>
+
+ <batchtest todir="${cactus.log.dir}">
+ <fileset dir="${cactus.src.dir}">
+ <include name="**/Test*.java"/>
+ <exclude name="**/TestContextInitializer.java"/>
+ </fileset>
+ </batchtest>
+ </cactus>
+
+ <junitreport todir="${cactus.log.dir}">
+ <fileset dir="${cactus.log.dir}" includes="TEST-*.xml"/>
+ <report todir="${cactus.log.dir}" format="frames"/>
+ </junitreport>
+
+ <fail if="tests.failed">At least one test failed!</fail>
+ </target>
+</project>
\ No newline at end of file
Propchange: beehive/trunk/system-controls/test/jms/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderQueueControl.jcx
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderQueueControl.jcx?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderQueueControl.jcx (added)
+++ beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderQueueControl.jcx Mon Nov 28 09:22:12 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.test.controls.system.controls;
+
+import org.apache.beehive.controls.api.bean.ControlExtension;
+import org.apache.beehive.controls.system.jms.JMSControl;
+
+import java.util.Map;
+
+
+@ControlExtension
+@JMSControl.Destination(sendJndiName = "java:/comp/env/xtestQueue",
+ jndiContextFactory="org.openejb.client.RemoteInitialContextFactory",
+ jndiUsername = "system",
+ jndiPassword = "manager",
+ jndiProviderURL = "localhost:4201",
+ transacted = false,
+ jndiConnectionFactory = "java:/comp/env/DefaultActiveMQConnectionFactory")
+public interface OrderQueueControl extends JMSControl
+{
+ /**
+ * Represents a simple order.
+ */
+ public class Order implements java.io.Serializable
+ {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 8951994251593378324L;
+
+ public Order() {
+
+ }
+
+ public Order(int buyer, String[] list) {
+ buyerId = buyer;
+ itemList = list;
+
+ }
+
+ private int buyerId;
+ private String[] itemList;
+
+ public int getBuyerId() { return buyerId; }
+ public String[] getItemList() { return itemList; }
+ }
+
+ public javax.jms.Message submitOrder(Order order, @Property(name = "DeliverBy") long deliverBy);
+
+ @Priority(3)
+ public javax.jms.Message submitOrderWithPriority(Order order);
+
+ @CorrelationId("666")
+ public javax.jms.Message submitOrderWithCorrelationId(Order order);
+
+ @Type("ORDER_TEST")
+ public javax.jms.Message submitOrderWithType(Order order);
+
+ @Delivery(JMSControl.DeliveryMode.NonPersistent)
+ public javax.jms.Message submitOrderWithDeliveryMode(Order order);
+
+ //
+ // message types
+ //
+ @JMSControl.Message(JMSControl.MessageType.Text)
+ public javax.jms.Message sendTextMessage(String messageText);
+
+ @JMSControl.Message(JMSControl.MessageType.Map)
+ public javax.jms.Message sendMapMessage(Map messageMap);
+
+ @JMSControl.Message(JMSControl.MessageType.Bytes)
+ public javax.jms.Message sendBytesMessage(byte[] messageBytes);
+
+ @JMSControl.Message(JMSControl.MessageType.JMSMessage)
+ public javax.jms.Message sendMessageMessage(javax.jms.Message messageMessage);
+}
Added: beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderTopicControl.jcx
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderTopicControl.jcx?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderTopicControl.jcx (added)
+++ beehive/trunk/system-controls/test/jms/src/controls/org/apache/beehive/test/controls/system/controls/OrderTopicControl.jcx Mon Nov 28 09:22:12 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.test.controls.system.controls;
+
+import org.apache.beehive.controls.api.bean.ControlExtension;
+import org.apache.beehive.controls.system.jms.JMSControl;
+
+import java.util.Map;
+
+
+@ControlExtension
+@JMSControl.Destination(sendJndiName = "java:/comp/env/testTopic",
+ sendType = JMSControl.DestinationType.Topic,
+ jndiContextFactory="org.openejb.client.RemoteInitialContextFactory",
+ jndiUsername = "system",
+ jndiPassword = "manager",
+ jndiProviderURL = "localhost:4201",
+ transacted = false,
+ jndiConnectionFactory = "java:/comp/env/DefaultActiveMQConnectionFactory")
+public interface OrderTopicControl extends JMSControl
+{
+ /**
+ * Represents a simple order.
+ */
+ public class Order implements java.io.Serializable
+ {
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 8951994251593378324L;
+
+ public Order() {
+
+ }
+
+ public Order(int buyer, String[] list) {
+ buyerId = buyer;
+ itemList = list;
+
+ }
+
+ private int buyerId;
+ private String[] itemList;
+
+ public int getBuyerId() { return buyerId; }
+ public String[] getItemList() { return itemList; }
+ }
+
+ public javax.jms.Message submitOrder(Order order, @Property(name = "DeliverBy") long deliverBy);
+
+ @Priority(3)
+ public javax.jms.Message submitOrderWithPriority(Order order);
+
+ @CorrelationId("666")
+ public javax.jms.Message submitOrderWithCorrelationId(Order order);
+
+ @Type("ORDER_TEST")
+ public javax.jms.Message submitOrderWithType(Order order);
+
+ @Delivery(DeliveryMode.NonPersistent)
+ public javax.jms.Message submitOrderWithDeliveryMode(Order order);
+
+ //
+ // message types
+ //
+ @JMSControl.Message(JMSControl.MessageType.Text)
+ public javax.jms.Message sendTextMessage(String messageText);
+
+ @JMSControl.Message(JMSControl.MessageType.Map)
+ public javax.jms.Message sendMapMessage(Map messageMap);
+
+ @JMSControl.Message(JMSControl.MessageType.Bytes)
+ public javax.jms.Message sendBytesMessage(byte[] messageBytes);
+
+ @JMSControl.Message(JMSControl.MessageType.JMSMessage)
+ public javax.jms.Message sendMessageMessage(javax.jms.Message messageMessage);
+}
Added: beehive/trunk/system-controls/test/jms/src/test-activemq.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/test-activemq.xml?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/test-activemq.xml (added)
+++ beehive/trunk/system-controls/test/jms/src/test-activemq.xml Mon Nov 28 09:22:12 2005
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector"
+ version="1.5"
+ configId="weather/Topics"
+ parentId="org/apache/geronimo/SystemJMS">
+
+ <resourceadapter>
+ <resourceadapter-instance>
+ <resourceadapter-name>ActiveMQ RA</resourceadapter-name>
+ <config-property-setting name="ServerUrl">tcp://localhost:61616</config-property-setting>
+ <config-property-setting name="UserName">system</config-property-setting>
+ <config-property-setting name="Password">manager</config-property-setting>
+ <workmanager>
+ <gbean-link>DefaultWorkManager</gbean-link>
+ </workmanager>
+ </resourceadapter-instance>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-interface>
+ <connectiondefinition-instance>
+ <name>ConnectionFactory</name>
+ <implemented-interface>javax.jms.QueueConnectionFactory</implemented-interface>
+ <implemented-interface>javax.jms.TopicConnectionFactory</implemented-interface>
+ <connectionmanager>
+ <xa-transaction>
+ <transaction-caching/>
+ </xa-transaction>
+ <single-pool>
+ <max-size>10</max-size>
+ <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
+ <match-one/>
+ </single-pool>
+ </connectionmanager>
+ <global-jndi-name>ConnectionFactory</global-jndi-name>
+ </connectiondefinition-instance>
+ </connection-definition>
+ </outbound-resourceadapter>
+
+ </resourceadapter>
+
+ <adminobject>
+
+ <adminobject-interface>javax.jms.Topic</adminobject-interface>
+ <adminobject-class>org.codehaus.activemq.message.ActiveMQTopic</adminobject-class>
+ <adminobject-instance>
+ <message-destination-name>testTopic</message-destination-name>
+ <config-property-setting
+ name="PhysicalName">testTopic</config-property-setting>
+ </adminobject-instance>
+ </adminobject>
+<!--
+ <adminobject>
+ <adminobject-interface>javax.jms.Topic</adminobject-interface>
+ <adminobject-class>org.codehaus.activemq.message.ActiveMQTopic</adminobject-class>
+ <adminobject-instance>
+ <message-destination-name>weatherRequestsTopic</message-destination-name>
+ <config-property-setting
+ name="PhysicalName">weatherRequestsTopic</config-property-setting>
+ </adminobject-instance>
+ </adminobject>
+ -->
+
+ <adminobject>
+ <adminobject-interface>javax.jms.Queue</adminobject-interface>
+ <adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</adminobject-class>
+ <adminobject-instance>
+ <message-destination-name>testQueue2</message-destination-name>
+ <config-property-setting
+ name="PhysicalName">testJMSControlCQueue2</config-property-setting>
+ </adminobject-instance>
+ </adminobject>
+
+</connector>
\ No newline at end of file
Propchange: beehive/trunk/system-controls/test/jms/src/test-activemq.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestContextInitializer.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestContextInitializer.java?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestContextInitializer.java (added)
+++ beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestContextInitializer.java Mon Nov 28 09:22:12 2005
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.test.controls.system.test;
+
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.runtime.bean.ControlContainerContext;
+
+import java.lang.reflect.Method;
+
+public class TestContextInitializer {
+
+
+ public static ControlContainerContext initContext(Object caller)
+ throws Exception {
+ ControlContainerContext context = new ControlContainerContext();
+ final Class forClass = caller.getClass();
+
+ context.beginContext();
+ Class init = forClass.getClassLoader().loadClass(forClass.getName() + "ClientInitializer");
+
+ Method m = init.getMethod("initialize",
+ new Class[]
+ {
+ ControlBeanContext.class,
+ forClass
+ });
+
+ m.invoke(null, new Object[]{context, caller});
+ return context;
+ }
+}
Propchange: beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestContextInitializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestQueueJmsControl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestQueueJmsControl.java?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestQueueJmsControl.java (added)
+++ beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestQueueJmsControl.java Mon Nov 28 09:22:12 2005
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.test.controls.system.test;
+
+import org.apache.beehive.test.controls.system.controls.OrderQueueControl;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.context.ControlThreadContext;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+import org.apache.beehive.controls.system.jms.JMSControl;
+import org.apache.cactus.ServletTestCase;
+
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.DeliveryMode;
+import javax.jms.TextMessage;
+import javax.jms.JMSException;
+import javax.jms.QueueSession;
+import javax.jms.Queue;
+import javax.jms.MapMessage;
+import javax.jms.BytesMessage;
+import java.util.Date;
+import java.util.HashMap;
+import java.io.Serializable;
+
+/**
+ */
+public class TestQueueJmsControl extends ServletTestCase
+{
+
+ @Control
+ private OrderQueueControl _jmsControl;
+
+ private ControlContainerContext _controlContext = null;
+
+ /**
+ */
+ public void setUp() throws Exception {
+
+ _controlContext = ControlThreadContext.getContext();
+ if (_controlContext == null) {
+ _controlContext = TestContextInitializer.initContext(this);
+ } else {
+ TestQueueJmsControlClientInitializer.initialize(_controlContext, this);
+ }
+ }
+
+ public void tearDown() throws Exception {
+ _controlContext.endContext();
+ super.tearDown();
+ }
+
+ /* empty the message queue */
+ public void testAAA() throws Exception {
+
+ while (true) {
+ if (getMessage(_jmsControl) == null)
+ break;
+ }
+ }
+
+ public void testSendOrderMessage() throws Exception {
+
+ OrderQueueControl.Order o = new OrderQueueControl.Order(1234, new String[] {"heee","haw"});
+ long now = new Date().getTime();
+ Message m = _jmsControl.submitOrder(o, now);
+ assertNotNull(m);
+ }
+
+ public void testRecieveOrderMessage() throws Exception {
+ Message qmess = getMessage(_jmsControl);
+
+ OrderQueueControl.Order o = new OrderQueueControl.Order(1234, new String[] {"heee","haw"});
+ ObjectMessage om = (ObjectMessage)qmess;
+ Serializable s = om.getObject();
+ assertNotNull(s);
+
+ OrderQueueControl.Order out = (OrderQueueControl.Order)s;
+ assertNotNull(out);
+ assertEquals(o.getBuyerId(), out.getBuyerId());
+ assertEquals(o.getItemList()[0], out.getItemList()[0]);
+ assertEquals(o.getItemList()[1], out.getItemList()[1]);
+ }
+
+ public void testSendOrderWithPriority() throws Exception {
+ OrderQueueControl.Order o = new OrderQueueControl.Order(333, new String[] {"hee","haw"});
+ Message m = _jmsControl.submitOrderWithPriority(o);
+ assertNotNull(m);
+ }
+
+ public void testReceiveOrderWithPriority() throws Exception {
+ Message qmess = getMessage(_jmsControl);
+ assertEquals(3, qmess.getJMSPriority());
+ }
+
+ public void testSendOrderWithCorrelationId() throws Exception {
+ OrderQueueControl.Order o = new OrderQueueControl.Order(444, new String[] {"hee","haw"});
+ Message m = _jmsControl.submitOrderWithCorrelationId(o);
+ assertNotNull(m);
+ }
+
+ public void testReceiveOrderWithCorrelationId() throws Exception {
+ Message qmess = getMessage(_jmsControl);
+ assertEquals("666", qmess.getJMSCorrelationID());
+ }
+
+ public void testSendOrderWithDeliveryMode() throws Exception {
+ OrderQueueControl.Order o = new OrderQueueControl.Order(555, new String[] {"hee","haw"});
+ Message m = _jmsControl.submitOrderWithDeliveryMode(o);
+ assertNotNull(m);
+ }
+
+ public void testReceiveOrderWithDeliveryMode() throws Exception {
+ Message qmess = getMessage(_jmsControl);
+ assertEquals(DeliveryMode.NON_PERSISTENT, qmess.getJMSDeliveryMode());
+ }
+
+ public void testSendTextMessage() throws Exception {
+ Message m = _jmsControl.sendTextMessage("Hello There!");
+ assertNotNull(m);
+ }
+
+ public void testReceiveTextMessage() throws Exception {
+ Message qmess = getMessage(_jmsControl);
+ TextMessage tm = (TextMessage)qmess;
+ assertEquals("Hello There!", tm.getText());
+ }
+
+ public void testSendMapMessage() throws Exception {
+ HashMap map = new HashMap();
+ map.put("key1", "hello");
+ map.put("key2", "there");
+ Message m = _jmsControl.sendMapMessage(map);
+ assertNotNull(m);
+ }
+
+ public void testReceiveMapMessage() throws Exception {
+ MapMessage qmess = (MapMessage)getMessage(_jmsControl);
+ assertEquals("hello", qmess.getString("key1"));
+ assertEquals("there", qmess.getString("key2"));
+ }
+
+ public void testSendBytesMessage() throws Exception {
+ byte[] bytes = new byte[] {Byte.MAX_VALUE, Byte.MIN_VALUE, Byte.MAX_VALUE};
+ Message m = _jmsControl.sendBytesMessage(bytes);
+ assertNotNull(m);
+ }
+
+ public void testReceiveBytesMessage() throws Exception {
+ BytesMessage qmess = (BytesMessage)getMessage(_jmsControl);
+ assertEquals(Byte.MAX_VALUE, qmess.readByte());
+ assertEquals(Byte.MIN_VALUE, qmess.readByte());
+ assertEquals(Byte.MAX_VALUE, qmess.readByte());
+ }
+
+
+
+
+
+
+ private static Message getMessage(JMSControl jmsControl) throws JMSException {
+
+ QueueSession sess = (QueueSession)jmsControl.getSession();
+
+ jmsControl.getConnection().start();
+ javax.jms.QueueReceiver consumer = sess.createReceiver((Queue)jmsControl.getDestination());
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+ return qmess;
+ }
+}
Propchange: beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestQueueJmsControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestTopicJmsControl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestTopicJmsControl.java?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestTopicJmsControl.java (added)
+++ beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestTopicJmsControl.java Mon Nov 28 09:22:12 2005
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.test.controls.system.test;
+
+import org.apache.beehive.test.controls.system.controls.OrderTopicControl;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.context.ControlThreadContext;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
+import org.apache.cactus.ServletTestCase;
+
+import javax.jms.Message;
+import javax.jms.TextMessage;
+import javax.jms.TopicSession;
+import javax.jms.TopicSubscriber;
+import javax.jms.Topic;
+import javax.jms.DeliveryMode;
+import javax.jms.ObjectMessage;
+import javax.jms.BytesMessage;
+import javax.jms.MapMessage;
+import java.util.Date;
+import java.util.HashMap;
+import java.io.Serializable;
+
+/**
+ */
+public class TestTopicJmsControl extends ServletTestCase
+{
+
+ @Control
+ private OrderTopicControl _jmsControl;
+
+ private ControlContainerContext _controlContext = null;
+
+ /**
+ */
+ public void setUp() throws Exception {
+
+ _controlContext = ControlThreadContext.getContext();
+ if (_controlContext == null) {
+ _controlContext = TestContextInitializer.initContext(this);
+ } else {
+ TestTopicJmsControlClientInitializer.initialize(_controlContext, this);
+ }
+ }
+
+ public void tearDown() throws Exception {
+ _controlContext.endContext();
+ super.tearDown();
+ }
+
+ public void testSendOrderMessage() throws Exception {
+ // create a subscription to the topic
+ TopicSession sess = (TopicSession)_jmsControl.getSession();
+ _jmsControl.getConnection().start();
+ TopicSubscriber consumer = sess.createSubscriber((Topic)_jmsControl.getDestination());
+
+ OrderTopicControl.Order o = new OrderTopicControl.Order(1234, new String[] {"heee","haw"});
+ long now = new Date().getTime();
+ Message m = _jmsControl.submitOrder(o, now);
+ assertNotNull(m);
+
+ // get the message from the topic
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+
+ ObjectMessage om = (ObjectMessage)qmess;
+ Serializable s = om.getObject();
+ assertNotNull(s);
+
+ OrderTopicControl.Order out = (OrderTopicControl.Order)s;
+ assertNotNull(out);
+ assertEquals(o.getBuyerId(), out.getBuyerId());
+ assertEquals(o.getItemList()[0], out.getItemList()[0]);
+ assertEquals(o.getItemList()[1], out.getItemList()[1]);
+ }
+
+ public void testSendOrderWithPriority() throws Exception {
+ // create a subscription to the topic
+ TopicSession sess = (TopicSession)_jmsControl.getSession();
+ _jmsControl.getConnection().start();
+ TopicSubscriber consumer = sess.createSubscriber((Topic)_jmsControl.getDestination());
+
+ // send the message
+ OrderTopicControl.Order o = new OrderTopicControl.Order(333, new String[] {"hee","haw"});
+ Message m = _jmsControl.submitOrderWithPriority(o);
+ assertNotNull(m);
+
+ // get the message from the topic
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+ assertEquals(3, qmess.getJMSPriority());
+ }
+
+ public void testSendOrderWithCorrelationId() throws Exception {
+ // create a subscription to the topic
+ TopicSession sess = (TopicSession)_jmsControl.getSession();
+ _jmsControl.getConnection().start();
+ TopicSubscriber consumer = sess.createSubscriber((Topic)_jmsControl.getDestination());
+
+ // send the message
+ OrderTopicControl.Order o = new OrderTopicControl.Order(444, new String[] {"hee","haw"});
+ Message m = _jmsControl.submitOrderWithCorrelationId(o);
+ assertNotNull(m);
+
+ // get the message from the topic
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+ assertEquals("666", qmess.getJMSCorrelationID());
+ }
+
+ public void testSendOrderWithDeliveryMode() throws Exception {
+ // create a subscription to the topic
+ TopicSession sess = (TopicSession)_jmsControl.getSession();
+ _jmsControl.getConnection().start();
+ TopicSubscriber consumer = sess.createSubscriber((Topic)_jmsControl.getDestination());
+
+ // send the message
+ OrderTopicControl.Order o = new OrderTopicControl.Order(555, new String[] {"hee","haw"});
+ Message m = _jmsControl.submitOrderWithDeliveryMode(o);
+ assertNotNull(m);
+
+ // get the message from the topic
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+ assertEquals(DeliveryMode.NON_PERSISTENT, qmess.getJMSDeliveryMode());
+ }
+
+ public void testSendTextMessage() throws Exception {
+
+ // create a subscription to the topic
+ TopicSession sess = (TopicSession)_jmsControl.getSession();
+ _jmsControl.getConnection().start();
+ TopicSubscriber consumer = sess.createSubscriber((Topic)_jmsControl.getDestination());
+
+ // send the message
+ Message m = _jmsControl.sendTextMessage("Hello There!");
+ assertNotNull(m);
+
+ // get the message from the topic
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+
+
+ TextMessage tm = (TextMessage)qmess;
+ assertEquals("Hello There!", tm.getText());
+ }
+
+ public void testSendBytesMessage() throws Exception {
+
+ // create a subscription to the topic
+ TopicSession sess = (TopicSession)_jmsControl.getSession();
+ _jmsControl.getConnection().start();
+ TopicSubscriber consumer = sess.createSubscriber((Topic)_jmsControl.getDestination());
+
+ // send the message
+ byte[] bytes = new byte[] {Byte.MAX_VALUE, Byte.MIN_VALUE, Byte.MAX_VALUE};
+ Message m = _jmsControl.sendBytesMessage(bytes);
+ assertNotNull(m);
+
+ // get the message from the topic
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+
+
+ BytesMessage bm = (BytesMessage)qmess;
+ assertEquals(Byte.MAX_VALUE, bm.readByte());
+ assertEquals(Byte.MIN_VALUE, bm.readByte());
+ assertEquals(Byte.MAX_VALUE, bm.readByte());
+ }
+
+ public void testSendMapMessage() throws Exception {
+
+ // create a subscription to the topic
+ TopicSession sess = (TopicSession)_jmsControl.getSession();
+ _jmsControl.getConnection().start();
+ TopicSubscriber consumer = sess.createSubscriber((Topic)_jmsControl.getDestination());
+
+ // send the message
+ HashMap map = new HashMap();
+ map.put("key1", "hello");
+ map.put("key2", "there");
+ Message m = _jmsControl.sendMapMessage(map);
+ assertNotNull(m);
+
+ // get the message from the topic
+ Message qmess = consumer.receive(5000);
+ consumer.close();
+
+
+ MapMessage mp = (MapMessage)qmess;
+ assertEquals("hello", mp.getString("key1"));
+ assertEquals("there", mp.getString("key2"));
+ }
+}
Propchange: beehive/trunk/system-controls/test/jms/src/tests/org/apache/beehive/test/controls/system/test/TestTopicJmsControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/cactus-web.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/cactus-web.xml?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/cactus-web.xml (added)
+++ beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/cactus-web.xml Mon Nov 28 09:22:12 2005
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+
+ <!-- Put Cactus specific definitions here. Note that by default
+ the <cactifywar> Ant task automatically adds Servlet, Filter
+ and JSP redirector definitions and mappings. You only need
+ to edit this file if you want to change these defaults or
+ add other definitions required for Cactus testing. -->
+
+</web-app>
Propchange: beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/cactus-web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/web.xml?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/web.xml (added)
+++ beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/web.xml Mon Nov 28 09:22:12 2005
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <resource-ref>
+ <res-ref-name>DefaultActiveMQConnectionFactory</res-ref-name>
+ <res-type>javax.jms.QueueConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <message-destination-ref>
+ <message-destination-ref-name>xtestQueue</message-destination-ref-name>
+ <message-destination-type>javax.jms.Queue</message-destination-type>
+ <message-destination-usage>ConsumesProduces</message-destination-usage>
+ <message-destination-link>testQueue2</message-destination-link>
+ </message-destination-ref>
+
+ <message-destination-ref>
+ <message-destination-ref-name>testTopic</message-destination-ref-name>
+ <message-destination-type>javax.jms.Topic</message-destination-type>
+ <message-destination-usage>ConsumesProduces</message-destination-usage>
+ <message-destination-link>testTopic</message-destination-link>
+ </message-destination-ref>
+
+</web-app>
Propchange: beehive/trunk/system-controls/test/jms/src/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/system-controls/test/jms/src/webapp/application.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/system-controls/test/jms/src/webapp/application.xml?rev=349438&view=auto
==============================================================================
--- beehive/trunk/system-controls/test/jms/src/webapp/application.xml (added)
+++ beehive/trunk/system-controls/test/jms/src/webapp/application.xml Mon Nov 28 09:22:12 2005
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE application
+ PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN'
+ 'http://java.sun.com/j2ee/dtds/application_1_3.dtd'>
+
+<!-- TODO: In the future you won't have to create a specific
+ application.xml in which you have to declare a Cactus test
+ war if you don't have a war in your EAR -->
+
+<application>
+ <display-name>test-jms</display-name>
+ <description>Cactus JMS Sample for J2EE 1.3</description>
+ <!--
+ <module>
+ <ejb>testEjbs.jar</ejb>
+ </module>
+ -->
+ <module>
+ <web>
+ <web-uri>cactusTests-cactified.war</web-uri>
+ <context-root>/jmsTest</context-root>
+ </web>
+ </module>
+</application>
Propchange: beehive/trunk/system-controls/test/jms/src/webapp/application.xml
------------------------------------------------------------------------------
svn:eol-style = native