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

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Aug 5 09:16:53 EDT 2010


Author: aslak
Date: 2010-08-05 09:16:52 -0400 (Thu, 05 Aug 2010)
New Revision: 6909

Added:
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/Cow.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/ejb/
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/generic/
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/
Removed:
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/Cow.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java
   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/EJBTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/ejb/
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/ejb/
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/ejb/
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/interceptors/hierarchical/
Modified:
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/ejb/EnterpriseBeanInterceptionTest.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/generic/SimpleWeldClassTest.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/InterceptorsWithHierarchyTest.java
   core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/SimpleWeldClassTest.java
Log:
WELD-493 Converted ejb and interceptor tests to Arquillian

Deleted: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/Cow.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/Cow.java	2010-08-05 13:15:53 UTC (rev 6908)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/Cow.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -1,37 +0,0 @@
-/*
- * 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;
-
-import javax.ejb.Stateful;
-
- at Stateful
-public class Cow
-{
-   
-   private boolean pinged;
-   
-   public boolean isPinged()
-   {
-      return pinged;
-   }
-   
-   public void ping()
-   {
-      pinged = true;
-   }
-
-}

Deleted: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java	2010-08-05 13:15:53 UTC (rev 6908)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-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
-{
-   
-   @Test
-   public void testNoInterface()
-   {
-      Cow cow = getReference(Cow.class);
-      cow.ping();
-      assert cow.isPinged();
-   }
-   
-}

Deleted: 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	2010-08-05 13:15:53 UTC (rev 6908)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -1,51 +0,0 @@
-/*
- * 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;
-
-import javax.ejb.MessageDrivenContext;
-import javax.enterprise.context.ApplicationScoped;
-
- at ApplicationScoped
-public class Control
-{
-   private volatile boolean messageDelivered;
-   private volatile boolean contextSet;
-
-   public boolean isMessageDelivered()
-   {
-      return messageDelivered;
-   }
-
-   public void setMessageDelivered(boolean messageDelivered)
-   {
-      this.messageDelivered = messageDelivered;
-   }
-
-   public void setContext(MessageDrivenContext context)
-   {
-      if (context != null)
-      {
-         contextSet = true;
-      }
-   }
-
-   public boolean isContextSet()
-   {
-      return contextSet;
-   }
-
-}

Deleted: 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-08-05 13:15:53 UTC (rev 6908)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -1,59 +0,0 @@
-/*
- * 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;
-
-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;
-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(groups="broken")
-   // TODO Need a way to deploy test-destinations-service.xml to JBoss AS
-   // Port the test as broken
-   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();
-      assert getReference(Control.class).isContextSet();
-   }
-   
-}

Deleted: 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-08-05 13:15:53 UTC (rev 6908)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -1,54 +0,0 @@
-/*
- * 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;
-
-import javax.annotation.Resource;
-import javax.ejb.ActivationConfigProperty;
-import javax.ejb.MessageDriven;
-import javax.ejb.MessageDrivenContext;
-import javax.inject.Inject;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-
- at MessageDriven(activationConfig={
-      @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
-      @ActivationConfigProperty(propertyName="destination",     propertyValue="queue/testQueue")
-  })
-public class MilkMan implements MessageListener
-{
-   
-   @Inject Control control;
-   
-   @Resource
-   private MessageDrivenContext context;
-
-   public void onMessage(Message message)
-   {
-      try
-      {
-         control.setContext(context);
-         control.setMessageDelivered(((TextMessage) message).getText().equals(EJBTest.MESSAGE));
-      }
-      catch (JMSException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-}

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/Cow.java (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/Cow.java)
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/Cow.java	                        (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/Cow.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -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;
+
+import javax.ejb.Stateful;
+
+ at Stateful
+public class Cow
+{
+   
+   private boolean pinged;
+   
+   public boolean isPinged()
+   {
+      return pinged;
+   }
+   
+   public void ping()
+   {
+      pinged = true;
+   }
+
+}

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java)
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java	                        (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/EJBTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+ at Category(Integration.class)
+ at RunWith(Arquillian.class)
+public class EJBTest 
+{
+   @Deployment
+   public static Archive<?> deploy() 
+   {
+      return ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
+         .addModule(
+               ShrinkWrap.create(BeanArchive.class)
+                  .addPackage(EJBTest.class.getPackage())
+         );
+   }
+   
+   @Test
+   public void testNoInterface(Cow cow)
+   {
+      cow.ping();
+      Assert.assertTrue(cow.isPinged());
+   }
+}

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java)
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java	                        (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import javax.ejb.MessageDrivenContext;
+import javax.enterprise.context.ApplicationScoped;
+
+ at ApplicationScoped
+public class Control
+{
+   private volatile boolean messageDelivered;
+   private volatile boolean contextSet;
+
+   public boolean isMessageDelivered()
+   {
+      return messageDelivered;
+   }
+
+   public void setMessageDelivered(boolean messageDelivered)
+   {
+      this.messageDelivered = messageDelivered;
+   }
+
+   public void setContext(MessageDrivenContext context)
+   {
+      if (context != null)
+      {
+         contextSet = true;
+      }
+   }
+
+   public boolean isContextSet()
+   {
+      return contextSet;
+   }
+
+}

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java)
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java	                        (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+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 junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.weld.tests.category.Broken;
+import org.jboss.weld.tests.category.Integration;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+ at Category(Integration.class)
+ at RunWith(Arquillian.class)
+public class EJBTest 
+{
+   public static final String MESSAGE = "Hello!";
+   
+   @Deployment
+   public static Archive<?> deploy() 
+   {
+      return ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
+         .addModule(
+               ShrinkWrap.create(JavaArchive.class)
+                  .addPackage(EJBTest.class.getPackage())
+                  .addManifestResource(EmptyAsset.INSTANCE, "beans.xml")
+                  //.addManifestResource(EJBTest.class.getPackage(), "test-destinations-service.xml", "test-destinations-service.xml")
+         );
+   }
+
+   @Category(Broken.class)
+   @Test
+   // TODO Need a way to deploy test-destinations-service.xml to JBoss AS
+   public void testMdbUsable(Control control) 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));
+      
+      // TODO: rewrite to use CountDownLatch, avoid Thread.sleep in tests
+      Thread.sleep(1000);
+      Assert.assertTrue(control.isMessageDelivered());
+      Assert.assertTrue(control.isContextSet());
+   }
+   
+}

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java)
===================================================================
--- core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java	                        (rev 0)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.MessageDrivenContext;
+import javax.inject.Inject;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+ at MessageDriven(activationConfig={
+      @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+      @ActivationConfigProperty(propertyName="destination",     propertyValue="queue/testQueue")
+  })
+public class MilkMan implements MessageListener
+{
+   
+   @Inject Control control;
+   
+   @Resource
+   private MessageDrivenContext context;
+
+   public void onMessage(Message message)
+   {
+      try
+      {
+         control.setContext(context);
+         control.setMessageDelivered(((TextMessage) message).getText().equals(EJBTest.MESSAGE));
+      }
+      catch (JMSException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+}

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/ejb (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/ejb)

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/ejb/EnterpriseBeanInterceptionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/ejb/EnterpriseBeanInterceptionTest.java	2010-08-05 09:18:23 UTC (rev 6907)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/ejb/EnterpriseBeanInterceptionTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -23,51 +23,66 @@
 
 import javax.ejb.Timer;
 import javax.enterprise.inject.spi.InterceptionType;
+import javax.inject.Inject;
 
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.Packaging;
-import org.jboss.testharness.impl.packaging.PackagingType;
-import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
 import org.jboss.weld.bean.SessionBean;
 import org.jboss.weld.bean.interceptor.InterceptorBindingsAdapter;
 import org.jboss.weld.ejb.spi.InterceptorBindings;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.annotations.Test;
+import org.jboss.weld.manager.BeanManagerImpl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
- at Artifact
- at Packaging(PackagingType.EAR)
- at BeansXml("beans.xml")
-public class EnterpriseBeanInterceptionTest extends AbstractWeldTest
+ at RunWith(Arquillian.class)
+public class EnterpriseBeanInterceptionTest 
 {
+   @Deployment
+   public static Archive<?> deploy() 
+   {
+      return ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
+         .addModule(
+               ShrinkWrap.create(BeanArchive.class)
+                  .intercept(Goalkeeper.class, Defender.class, Referee.class)
+                  .addPackage(EnterpriseBeanInterceptionTest.class.getPackage())
+         );
+   }
+   
+   @Inject 
+   private BeanManagerImpl beanManager;
 
-   @Test(groups = { "interceptors" })
+   @Test
    public void testInterceptors() throws Exception
    {
-      SessionBean<Ball> ballSessionBean = (SessionBean<Ball>)getCurrentManager().getBeans(Ball.class).iterator().next();
-      InterceptorBindings interceptorBindings = new InterceptorBindingsAdapter(getCurrentManager().getCdiInterceptorsRegistry().getInterceptionModel(ballSessionBean.getType()));
+      SessionBean<Ball> ballSessionBean = (SessionBean<Ball>)beanManager.getBeans(Ball.class).iterator().next();
+      InterceptorBindings interceptorBindings = new InterceptorBindingsAdapter(beanManager.getCdiInterceptorsRegistry().getInterceptionModel(ballSessionBean.getType()));
       List<javax.enterprise.inject.spi.Interceptor> interceptors =
             new ArrayList<javax.enterprise.inject.spi.Interceptor>(interceptorBindings.getAllInterceptors());
 
-      assert interceptors.size() == 3;
+      Assert.assertEquals(3, interceptors.size());
       List<Class<?>> expectedInterceptors = Arrays.<Class<?>>asList(Goalkeeper.class, Defender.class, Referee.class);
-      assert expectedInterceptors.contains(interceptors.get(0).getBeanClass());
-      assert expectedInterceptors.contains(interceptors.get(1).getBeanClass());
-      assert expectedInterceptors.contains(interceptors.get(2).getBeanClass());
+      Assert.assertTrue(expectedInterceptors.contains(interceptors.get(0).getBeanClass()));
+      Assert.assertTrue(expectedInterceptors.contains(interceptors.get(1).getBeanClass()));
+      Assert.assertTrue(expectedInterceptors.contains(interceptors.get(2).getBeanClass()));
 
 
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("shoot")).size() == 0;
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).size() == 1;
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).get(0).getBeanClass().equals(Goalkeeper.class);
+      Assert.assertEquals(0, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("shoot")).size());
+      Assert.assertEquals(1, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).size());
+      Assert.assertEquals(Goalkeeper.class, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).get(0).getBeanClass());
       
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("pass")).size() == 0;
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).size() == 1;
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).get(0).getBeanClass().equals(Defender.class);
+      Assert.assertEquals(0, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("pass")).size());
+      Assert.assertEquals(1, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).size());
+      Assert.assertEquals(Defender.class, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).get(0).getBeanClass());
 
       Method finishGameMethod = ballSessionBean.getType().getMethod("finishGame", Timer.class);
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, finishGameMethod).size() == 0;
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, finishGameMethod).size() == 1;
-      assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, finishGameMethod).get(0).getBeanClass().equals(Referee.class);
-
+      Assert.assertEquals(0, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, finishGameMethod).size());
+      Assert.assertEquals(1, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, finishGameMethod).size());
+      Assert.assertEquals(Referee.class, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, finishGameMethod).get(0).getBeanClass());
    }
-
 }

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/generic (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/generic)

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/generic/SimpleWeldClassTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/generic/SimpleWeldClassTest.java	2010-08-05 09:18:23 UTC (rev 6907)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/generic/SimpleWeldClassTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -19,32 +19,49 @@
 import java.util.Collection;
 import java.util.List;
 
-import org.jboss.testharness.impl.packaging.Artifact;
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.weld.introspector.WeldClass;
 import org.jboss.weld.introspector.WeldMethod;
 import org.jboss.weld.introspector.jlr.WeldClassImpl;
 import org.jboss.weld.metadata.TypeStore;
 import org.jboss.weld.resources.ClassTransformer;
-import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.tests.category.Broken;
 import org.jboss.weld.util.Beans;
-import org.testng.annotations.Test;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 /**
  * @author Marius Bogoevici
  */
- at Artifact
-public class SimpleWeldClassTest extends AbstractWeldTest
+ at RunWith(Arquillian.class)
+public class SimpleWeldClassTest
 {
+   @Deployment
+   public static Archive<?> deploy() 
+   {
+      return ShrinkWrap.create(BeanArchive.class)
+         .addPackage(SimpleWeldClassTest.class.getPackage());
+   }
 
-   @Test(groups = "broken")
-   // Aslak Issue is still open, so test can be ported as is
+   /*
+    * description = "WELD-568"
+    */
+   @Category(Broken.class)
+   @Test
    public void testWeldClassForGenericSuperclass()
    {
       WeldClass<StringProcessor> weldClass = WeldClassImpl.of(StringProcessor.class, new ClassTransformer(new TypeStore()));
-      Collection methods = weldClass.getWeldMethods();
+      Collection<WeldMethod<?, ?>> methods = weldClass.getWeldMethods();
       //assert methods.size() == 2;
       List<WeldMethod<?,?>> interceptableMethods = Beans.getInterceptableMethods(weldClass);
-      assert interceptableMethods.size() == 4;
+      Assert.assertEquals(4, interceptableMethods.size());
    }
 
 }

Copied: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical (from rev 6907, core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/hierarchical)

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/InterceptorsWithHierarchyTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/InterceptorsWithHierarchyTest.java	2010-08-05 09:18:23 UTC (rev 6907)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/InterceptorsWithHierarchyTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -16,33 +16,41 @@
  */
 package org.jboss.weld.tests.interceptors.hierarchical;
 
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
-import org.jboss.weld.test.AbstractWeldTest;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.weld.tests.category.Broken;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 /**
  * @author Marius Bogoevici
  */
- at Artifact
- at BeansXml("beans.xml")
-public class InterceptorsWithHierarchyTest extends AbstractWeldTest
+ at RunWith(Arquillian.class)
+public class InterceptorsWithHierarchyTest
 {
-   @BeforeClass
-   public static void initialize()
+   @Deployment
+   public static Archive<?> deploy() 
    {
-      Defender.invocationsCount = 0;
+      return ShrinkWrap.create(BeanArchive.class)
+         .intercept(Defender.class)
+         .addPackage(InterceptorsWithHierarchyTest.class.getPackage());
    }
 
-   @Test(groups = "broken")
-   // Aslak Issue is still open, so test can be ported as is
-   public void testInterceptorsWithHierarchy()
+   /*
+    * description = "WELD-568"
+    */
+   @Category(Broken.class)
+   @Test
+   public void testInterceptorsWithHierarchy(Attacker player)
    {
-      Attacker player = this.getReference(Attacker.class);
+      Defender.invocationsCount = 0;
       player.cloneMe();
-      Assert.assertEquals(Defender.invocationsCount, 1);
+      Assert.assertEquals(1, Defender.invocationsCount);
    }
 
 }

Modified: core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/SimpleWeldClassTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/SimpleWeldClassTest.java	2010-08-05 09:18:23 UTC (rev 6907)
+++ core/trunk/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/hierarchical/SimpleWeldClassTest.java	2010-08-05 13:16:52 UTC (rev 6909)
@@ -19,32 +19,48 @@
 import java.util.Collection;
 import java.util.List;
 
-import org.jboss.testharness.impl.packaging.Artifact;
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.BeanArchive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.weld.introspector.WeldClass;
 import org.jboss.weld.introspector.WeldMethod;
 import org.jboss.weld.introspector.jlr.WeldClassImpl;
 import org.jboss.weld.metadata.TypeStore;
 import org.jboss.weld.resources.ClassTransformer;
-import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.tests.category.Broken;
 import org.jboss.weld.util.Beans;
-import org.testng.annotations.Test;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 /**
  * @author Marius Bogoevici
  */
- at Artifact
-public class SimpleWeldClassTest extends AbstractWeldTest
+ at RunWith(Arquillian.class)
+public class SimpleWeldClassTest
 {
+   @Deployment
+   public static Archive<?> deploy() 
+   {
+      return ShrinkWrap.create(BeanArchive.class)
+         .addPackage(InterceptorsWithHierarchyTest.class.getPackage());
+   }
 
-   @Test(groups = "broken")
-   // Aslak Issue is still open, so test can be ported as is
+   /*
+    * description = "WELD-568"
+    */
+   @Category(Broken.class)
+   @Test
    public void testWeldClassForCovariantReturnType()
    {
       WeldClass<Attacker> weldClass = WeldClassImpl.of(Attacker.class, new ClassTransformer(new TypeStore()));
-      Collection methods = weldClass.getWeldMethods();
-      assert methods.size() == 4;
+      Collection<WeldMethod<?, ?>> methods = weldClass.getWeldMethods();
+      Assert.assertEquals(4, methods.size());
       List<WeldMethod<?, ?>> interceptableMethods = Beans.getInterceptableMethods(weldClass);
-      assert interceptableMethods.size() == 4;
+      Assert.assertEquals(4, interceptableMethods.size());
    }
-
 }



More information about the weld-commits mailing list