[weld-commits] Weld SVN: r5907 - in core/trunk: tests/src/test/java/org/jboss/weld/tests/ejb/mdb and 2 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sat Feb 20 17:45:15 EST 2010


Author: pete.muir at jboss.org
Date: 2010-02-20 17:45:14 -0500 (Sat, 20 Feb 2010)
New Revision: 5907

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/EJBTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/MilkMan.java
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/ejb/mdb/test-destinations-service.xml
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java
Log:
WELD-444

Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-02-20 21:48:43 UTC (rev 5906)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-02-20 22:45:14 UTC (rev 5907)
@@ -1027,7 +1027,14 @@
    
    public <T> InjectionTarget<T> createInjectionTarget(EjbDescriptor<T> descriptor)
    {
-      return getBean(descriptor).getInjectionTarget();
+      if (descriptor.isMessageDriven())
+      {
+         return createInjectionTarget(createAnnotatedType(descriptor.getBeanClass()));
+      }
+      else
+      {
+         return getBean(descriptor).getInjectionTarget();
+      }
    }
 
    public <X> Bean<? extends X> getMostSpecializedBean(Bean<X> bean)

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java	2010-02-20 22:45:14 UTC (rev 5907)
@@ -0,0 +1,21 @@
+package org.jboss.weld.tests.ejb.mdb;
+
+import javax.enterprise.context.ApplicationScoped;
+
+ at ApplicationScoped
+public class Control
+{
+   
+   private volatile boolean messageDelivered;
+
+   public boolean isMessageDelivered()
+   {
+      return messageDelivered;
+   }
+
+   public void setMessageDelivered(boolean messageDelivered)
+   {
+      this.messageDelivered = messageDelivered;
+   }
+
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java	2010-02-20 21:48:43 UTC (rev 5906)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java	2010-02-20 22:45:14 UTC (rev 5907)
@@ -16,7 +16,16 @@
  */
 package org.jboss.weld.tests.ejb.mdb;
 
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+
 import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
 import org.jboss.testharness.impl.packaging.Packaging;
 import org.jboss.testharness.impl.packaging.PackagingType;
 import org.jboss.weld.test.AbstractWeldTest;
@@ -24,12 +33,25 @@
 
 @Artifact
 @Packaging(PackagingType.EAR)
+ at IntegrationTest
 public class EJBTest extends AbstractWeldTest
 {
    
-   @Test
-   public void testMdbDeploys()
+   public static final String MESSAGE = "Hello!";
+   
+   @Test(groups="broken")
+   // TODO Need a way to deploy test-destinations-service.xml to JBoss AS
+   public void testMdbUsable() throws Exception
    {
+      InitialContext ctx = new InitialContext();
+      QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
+      QueueConnection connection = factory.createQueueConnection();
+      QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+      Queue queue = (Queue) ctx.lookup("queue/testQueue");
+      QueueSender sender = session.createSender(queue);
+      sender.send(session.createTextMessage(MESSAGE));
+      Thread.sleep(1000);
+      assert getReference(Control.class).isMessageDelivered();
    }
    
 }

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java	2010-02-20 21:48:43 UTC (rev 5906)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java	2010-02-20 22:45:14 UTC (rev 5907)
@@ -18,19 +18,31 @@
 
 import javax.ejb.ActivationConfigProperty;
 import javax.ejb.MessageDriven;
+import javax.inject.Inject;
+import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
+import javax.jms.TextMessage;
 
 @MessageDriven(activationConfig={
       @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
-      @ActivationConfigProperty(propertyName="destination",     propertyValue="queue/DLQ")
+      @ActivationConfigProperty(propertyName="destination",     propertyValue="queue/testQueue")
   })
 public class MilkMan implements MessageListener
 {
+   
+   @Inject Control control;
 
    public void onMessage(Message message)
    {
-      
+      try
+      {
+         control.setMessageDelivered(((TextMessage) message).getText().equals(EJBTest.MESSAGE));
+      }
+      catch (JMSException e)
+      {
+         throw new RuntimeException(e);
+      }
    }
 
 }

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/EJBTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/EJBTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/EJBTest.java	2010-02-20 22:45:14 UTC (rev 5907)
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+package org.jboss.weld.tests.ejb.mdb.dummy;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+ at Artifact
+ at Packaging(PackagingType.EAR)
+ at IntegrationTest
+public class EJBTest extends AbstractWeldTest
+{
+   
+   public static final String MESSAGE = "Hello!";
+   
+   @Test
+   public void testMdbDeploys()
+   {
+   }
+   
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/EJBTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/MilkMan.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/MilkMan.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/MilkMan.java	2010-02-20 22:45:14 UTC (rev 5907)
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+package org.jboss.weld.tests.ejb.mdb.dummy;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+ at MessageDriven(activationConfig={
+      @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+      @ActivationConfigProperty(propertyName="destination",     propertyValue="queue/DLQ")
+  })
+public class MilkMan implements MessageListener
+{
+   
+
+   public void onMessage(Message message)
+   {
+   
+   }
+
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/dummy/MilkMan.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/ejb/mdb/test-destinations-service.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/ejb/mdb/test-destinations-service.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/ejb/mdb/test-destinations-service.xml	2010-02-20 22:45:14 UTC (rev 5907)
@@ -0,0 +1,17 @@
+<server>
+	<mbean code="org.jboss.mq.server.jmx.Topic"
+		   name="jboss.mq.destination:service=Topic,name=testTopic">
+		<depends optional-attribute-name="ServerPeer">
+			jboss.messaging:service=ServerPeer
+		</depends>
+		<depends>jboss.messaging:service=PostOffice</depends>
+	</mbean>
+	
+	<mbean code="org.jboss.mq.server.jmx.Queue"
+		   name="jboss.mq.destination:service=Queue,name=testQueue">
+		<depends optional-attribute-name="ServerPeer">
+			jboss.messaging:service=ServerPeer
+		</depends>
+		<depends>jboss.messaging:service=PostOffice</depends>
+	</mbean>
+</server>


Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/ejb/mdb/test-destinations-service.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the weld-commits mailing list