[seam-commits] Seam SVN: r12690 - in modules/jms/trunk/impl/src: test/java/org/jboss/seam/jms/test and 2 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu May 6 21:55:27 EDT 2010


Author: jganoff
Date: 2010-05-06 21:55:26 -0400 (Thu, 06 May 2010)
New Revision: 12690

Added:
   modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/
   modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java
Removed:
   modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/instance/
Modified:
   modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java
   modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
Log:
javax.jms.Connection is not produced @ApplicationScoped as intended.  Simple send message tests added.

Modified: modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java
===================================================================
--- modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java	2010-05-07 00:33:56 UTC (rev 12689)
+++ modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java	2010-05-07 01:55:26 UTC (rev 12690)
@@ -31,15 +31,16 @@
 
 import org.jboss.seam.jms.annotations.Module;
 
-public @ApplicationScoped
-class ConnectionProducer
+public class ConnectionProducer
 {
    @Produces
+   @ApplicationScoped
    @Module
    @Resource(mappedName = "ConnectionFactory")
    private ConnectionFactory cf;
 
    @Produces
+   @ApplicationScoped
    public Connection getConnection() throws Exception
    {
       return cf.createConnection();

Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java	2010-05-07 00:33:56 UTC (rev 12689)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java	2010-05-07 01:55:26 UTC (rev 12690)
@@ -46,6 +46,9 @@
 
    @Inject
    private Instance<Connection> c;
+   
+   @Inject
+   private Instance<Connection> c2;
 
    @Inject
    private Instance<Session> s;
@@ -61,5 +64,11 @@
    {
       Assert.assertNotNull(s.get());
    }
+   
+   @Test
+   public void sameConnection()
+   {
+      Assert.assertEquals(c.get(), c2.get());
+   }
 
 }

Added: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java	                        (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java	2010-05-07 01:55:26 UTC (rev 12690)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.seam.jms.test.transmit;
+
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.jms.test.Util;
+import org.jboss.seam.jms.test.inject.InjectMessageConsumer;
+import org.jboss.seam.jms.test.inject.InjectMessageProducer;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class SimpleTransmitMessageTest
+{
+   @Deployment
+   public static JavaArchive createDeployment()
+   {
+      JavaArchive a = Util.createDeployment(SimpleTransmitMessageTest.class);
+      a.addPackage(InjectMessageConsumer.class.getPackage());
+      return a;
+   }
+
+   @Inject
+   private Connection c;
+   
+   @Inject
+   private Session s;
+  
+   @Inject
+   private Instance<InjectMessageConsumer> imc;
+
+   @Inject
+   private Instance<InjectMessageProducer> imp;
+
+   @Test
+   public void sendMessage_topic() throws JMSException
+   {
+      sendMessage(imp.get().getTp(), imc.get().getTs());
+   }
+   
+   @Test
+   public void sendMessage_queue() throws JMSException
+   {
+      sendMessage(imp.get().getQs(), imc.get().getQr());
+   }
+   
+   private void sendMessage(MessageProducer mp, MessageConsumer mc) throws JMSException
+   {
+      String expected = "test";
+      Message m = s.createTextMessage(expected);
+      c.start();
+      try
+      {
+         mp.send(m);
+         Message received = mc.receive(3000);
+         Assert.assertNotNull(received);
+         Assert.assertTrue(received instanceof TextMessage);
+         TextMessage tm = TextMessage.class.cast(received);
+         Assert.assertEquals(expected, tm.getText());
+      } finally
+      {
+         c.stop();
+      }
+   }
+}



More information about the seam-commits mailing list