[jboss-cvs] JBossAS SVN: r112230 - in branches/JBPAPP_5_1/testsuite: src/main/org/jboss/test/ejb3 and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 13 06:54:13 EDT 2011
Author: jaikiran
Date: 2011-09-13 06:54:13 -0400 (Tue, 13 Sep 2011)
New Revision: 112230
Added:
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/SimpleMDBWithAUnSupportedActivationConfigProp.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/unit/
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/unit/MDBActivationConfigPropTestCase.java
branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbpapp6855/
branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbpapp6855/META-INF/
branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbpapp6855/META-INF/jboss.xml
Modified:
branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml
Log:
JBPAPP-6855 Testcase added to ensure that a MDB referencing a unsupported activation config property does not run into deployment errors
Modified: branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml 2011-09-12 20:18:55 UTC (rev 112229)
+++ branches/JBPAPP_5_1/testsuite/imports/sections/ejb3.xml 2011-09-13 10:54:13 UTC (rev 112230)
@@ -222,6 +222,18 @@
</jar>
</target>
+ <target name="jbpapp-6855" depends="compile">
+ <mkdir dir="${build.lib}" />
+
+ <jar destfile="${build.lib}/jbpapp-6855.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/ejb3/jbpapp6855/**" />
+ </fileset>
+ <fileset dir="${build.resources}/ejb3/jbpapp6855" includes="**"/>
+ </jar>
+ </target>
+
+
<target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,ejbthree1597,jbas5713,
jbas7883,
ejb3iiop,
@@ -230,7 +242,8 @@
jbpapp2473,
jbpapp3026,
jbpapp4681,
- jboss51xsd">
+ jboss51xsd,
+ jbpapp-6855">
<mkdir dir="${build.lib}" />
<!-- A jar with a simple ejb3 session -->
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/SimpleMDBWithAUnSupportedActivationConfigProp.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/SimpleMDBWithAUnSupportedActivationConfigProp.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/SimpleMDBWithAUnSupportedActivationConfigProp.java 2011-09-13 10:54:13 UTC (rev 112230)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbpapp6855;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+
+import org.jboss.logging.Logger;
+
+/**
+ * User: Jaikiran Pai
+ */
+ at MessageDriven(activationConfig =
+ {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = SimpleMDBWithAUnSupportedActivationConfigProp.QUEUE_JNDI_NAME),
+ // Unsupported activation config property. Should *not* result in deployment failure
+ @ActivationConfigProperty(propertyName = "foo", propertyValue = "bar")
+ })
+public class SimpleMDBWithAUnSupportedActivationConfigProp implements MessageListener
+{
+ public static final String QUEUE_JNDI_NAME = "queue/auto-create/jbpapp-6855";
+
+ private static Logger logger = Logger.getLogger(SimpleMDBWithAUnSupportedActivationConfigProp.class);
+
+ public static final String REPLY = "You have successfully established contact with the MDB";
+
+ @Resource(mappedName="java:/ConnectionFactory")
+ private QueueConnectionFactory qFactory;
+
+ @Override
+ public void onMessage(Message message)
+ {
+ // do nothing
+ logger.info("Received message " + message);
+ try
+ {
+ sendReply((Queue) message.getJMSReplyTo(), message.getJMSMessageID());
+ }
+ catch (JMSException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sendReply(Queue destination, String jmsMessageID) throws JMSException
+ {
+ if (destination == null) {
+ return;
+ }
+ QueueConnection conn = qFactory.createQueueConnection();
+ try
+ {
+ QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ QueueSender sender = session.createSender(destination);
+ TextMessage message = session.createTextMessage(REPLY);
+ message.setJMSCorrelationID(jmsMessageID);
+ sender.send(message);
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/unit/MDBActivationConfigPropTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/unit/MDBActivationConfigPropTestCase.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/ejb3/jbpapp6855/unit/MDBActivationConfigPropTestCase.java 2011-09-13 10:54:13 UTC (rev 112230)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbpapp6855.unit;
+
+import junit.framework.Test;
+import org.jboss.test.JBossJMSTestCase;
+import org.jboss.test.ejb3.jbpapp6855.SimpleMDBWithAUnSupportedActivationConfigProp;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import javax.jms.TextMessage;
+
+/**
+ * Tests activation config properties on MDBs.
+ * <p/>
+ * User: Jaikiran Pai
+ */
+public class MDBActivationConfigPropTestCase extends JBossJMSTestCase
+{
+
+ public MDBActivationConfigPropTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(MDBActivationConfigPropTestCase.class, "jbpapp-6855.jar");
+
+ }
+
+ /**
+ * Tests that a MDB referencing a unsupported activation config property does not run into
+ * deployment failures
+ *
+ * @throws Exception
+ * @see https://issues.jboss.org/browse/JBPAPP-6855
+ */
+ public void testUnsupportedActivationConfigProp() throws Exception
+ {
+ ConnectionFactory connFactory = null;
+ Connection conn = null;
+ Session session = null;
+ MessageProducer producer = null;
+ MessageConsumer consumer = null;
+ try
+ {
+ connFactory = lookup("ConnectionFactory", ConnectionFactory.class);
+ conn = connFactory.createConnection();
+ conn.start();
+ session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TemporaryQueue replyQueue = session.createTemporaryQueue();
+ // Create and send a message to the queue on which the MDB is listening
+ TextMessage msg = session.createTextMessage("Hello world");
+ msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ msg.setJMSReplyTo(replyQueue);
+ Queue queue = lookup(SimpleMDBWithAUnSupportedActivationConfigProp.QUEUE_JNDI_NAME, Queue.class);
+ producer = session.createProducer(queue);
+ // send the message
+ producer.send(msg);
+ // wait for the reply on the reply queue
+ consumer = session.createConsumer(replyQueue);
+ Message replyMsg = consumer.receive(5000);
+ assertNotNull("No reply received from MDB", replyMsg);
+ assertInstanceOf(replyMsg, TextMessage.class);
+ String actual = ((TextMessage) replyMsg).getText();
+ assertEquals("Unexpected reply from MDB", SimpleMDBWithAUnSupportedActivationConfigProp.REPLY, actual);
+
+ }
+ finally
+ {
+ if (consumer != null)
+ {
+ consumer.close();
+ }
+ if (producer != null)
+ {
+ producer.close();
+ }
+ if (session != null)
+ {
+ session.close();
+ }
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ protected <T> T lookup(String name, Class<T> cls) throws Exception
+ {
+ return cls.cast(getInitialContext().lookup(name));
+ }
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbpapp6855/META-INF/jboss.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbpapp6855/META-INF/jboss.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/ejb3/jbpapp6855/META-INF/jboss.xml 2011-09-13 10:54:13 UTC (rev 112230)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<jboss
+ xmlns="http://www.jboss.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
+ http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+ version="3.0">
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>SimpleMDBWithAUnSupportedActivationConfigProp</ejb-name>
+ <create-destination>true</create-destination>
+ </message-driven>
+ </enterprise-beans>
+</jboss>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list