[jboss-svn-commits] JBoss Common SVN: r3884 - in arquillian/trunk: demo-testng and 17 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Dec 25 17:51:47 EST 2009


Author: aslak
Date: 2009-12-25 17:51:47 -0500 (Fri, 25 Dec 2009)
New Revision: 3884

Added:
   arquillian/trunk/demo-testng/
   arquillian/trunk/demo-testng/pom.xml
   arquillian/trunk/demo-testng/src/
   arquillian/trunk/demo-testng/src/main/
   arquillian/trunk/demo-testng/src/main/java/
   arquillian/trunk/demo-testng/src/main/java/com/
   arquillian/trunk/demo-testng/src/main/java/com/acme/
   arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/
   arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManager.java
   arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManagerBean.java
   arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/MessageEcho.java
   arquillian/trunk/demo-testng/src/main/java/com/acme/util/
   arquillian/trunk/demo-testng/src/main/java/com/acme/util/jms/
   arquillian/trunk/demo-testng/src/main/java/com/acme/util/jms/QueueRequestor.java
   arquillian/trunk/demo-testng/src/main/resources/
   arquillian/trunk/demo-testng/src/test/
   arquillian/trunk/demo-testng/src/test/java/
   arquillian/trunk/demo-testng/src/test/java/com/
   arquillian/trunk/demo-testng/src/test/java/com/acme/
   arquillian/trunk/demo-testng/src/test/java/com/acme/ejb/
   arquillian/trunk/demo-testng/src/test/java/com/acme/ejb/InjectionTestCase.java
   arquillian/trunk/demo-testng/src/test/java/com/acme/jms/
   arquillian/trunk/demo-testng/src/test/java/com/acme/jms/InjectionTestCase.java
   arquillian/trunk/demo-testng/src/test/java/com/acme/resource/
   arquillian/trunk/demo-testng/src/test/java/com/acme/resource/InjectionTestCase.java
   arquillian/trunk/demo-testng/src/test/java/com/acme/weld/
   arquillian/trunk/demo-testng/src/test/java/com/acme/weld/InjectionTestCase.java
   arquillian/trunk/demo-testng/src/test/resources/
   arquillian/trunk/demo-testng/src/test/resources/jndi.properties
Log:
ARQ-9 Added demo version for TestNG



Property changes on: arquillian/trunk/demo-testng
___________________________________________________________________
Name: svn:ignore
   + .classpath
.project
.settings
target



Added: arquillian/trunk/demo-testng/pom.xml
===================================================================
--- arquillian/trunk/demo-testng/pom.xml	                        (rev 0)
+++ arquillian/trunk/demo-testng/pom.xml	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+   <!-- Parent -->
+   <parent>
+      <groupId>org.jboss.arquillian</groupId>
+      <artifactId>arquillian-build</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+      <relativePath>../build/pom.xml</relativePath>
+   </parent>
+
+   <!-- Model Version -->
+   <modelVersion>4.0.0</modelVersion>
+
+   <!-- Artifact Configuration -->
+   <artifactId>arquillian-demo-testng</artifactId>
+   <name>Arquillian Demo TestNG</name>
+   <description>TestNG Demo of Arquillian Usage</description>
+
+   <!-- Properties -->
+   <properties>
+
+      <!-- Versioning -->
+
+   </properties>
+
+   <profiles>
+      <profile>
+         <id>jboss-embedded</id>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.arquillian</groupId>
+               <artifactId>arquillian-jboss-embedded</artifactId>
+               <version>${project.version}</version>
+            </dependency>
+         </dependencies>
+      </profile>
+      <profile>
+         <id>jboss-remote-51</id>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.arquillian</groupId>
+               <artifactId>arquillian-jboss-remote-51</artifactId>
+               <version>${project.version}</version>
+            </dependency>
+         </dependencies>
+      </profile>
+      <profile>
+         <id>jboss-remote-60</id>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.arquillian</groupId>
+               <artifactId>arquillian-jboss-remote-60</artifactId>
+               <version>${project.version}</version>
+            </dependency>
+         </dependencies>
+      </profile>
+   </profiles>
+
+   <!-- Dependencies -->
+   <dependencies>
+
+      <dependency>
+         <groupId>javax.ejb</groupId>
+         <artifactId>ejb-api</artifactId>
+         <version>3.0</version>
+         <scope>provided</scope>
+      </dependency>
+      <dependency>
+         <groupId>javax.enterprise</groupId> 
+         <artifactId>cdi-api</artifactId>
+         <version>1.0</version>
+         <scope>provided</scope>       
+      </dependency>
+      <dependency>
+         <groupId>javax.mail</groupId> 
+         <artifactId>mail</artifactId>
+         <version>1.4.1</version>
+         <scope>provided</scope>       
+      </dependency>
+      <dependency>
+         <groupId>javax.jms</groupId> 
+         <artifactId>jms</artifactId>
+         <version>1.1</version>
+         <scope>provided</scope>       
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.arquillian</groupId>
+         <artifactId>arquillian-testng</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+
+      <dependency>
+         <groupId>org.testng</groupId>
+         <artifactId>testng</artifactId>
+         <scope>test</scope>
+      </dependency>
+
+   </dependencies>
+
+</project>
+

Added: arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManager.java
===================================================================
--- arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManager.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManager.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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 com.acme.ejb;
+
+/**
+ * GreetingManager
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface GreetingManager
+{
+   String greet(String userName);
+}

Added: arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManagerBean.java
===================================================================
--- arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManagerBean.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/GreetingManagerBean.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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 com.acme.ejb;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+/**
+ * GreetingManagerBean
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at Local(GreetingManager.class)
+ at Stateless
+public class GreetingManagerBean implements GreetingManager
+{
+   @Override
+   public String greet(String userName)
+   {
+      return "Hello " + userName;
+   }
+}

Added: arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/MessageEcho.java
===================================================================
--- arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/MessageEcho.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/main/java/com/acme/ejb/MessageEcho.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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 com.acme.ejb;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+/**
+ * MessageEcho
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at MessageDriven(activationConfig = {
+      @ActivationConfigProperty( propertyName = "destination", propertyValue = "queue/DLQ"),
+      @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue")
+})
+public class MessageEcho implements MessageListener
+{
+
+   @Resource(mappedName = "java:/ConnectionFactory")
+   private ConnectionFactory factory;
+   
+   @Override
+   public void onMessage(Message msg)
+   {
+      try 
+      {
+         System.out.println("received " + msg.getJMSMessageID());
+         
+         Connection connection = factory.createConnection();
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer producer = session.createProducer(msg.getJMSReplyTo());
+         producer.send(msg);
+         producer.close();
+         session.close();
+         connection.close();
+      }
+      catch (Exception e) 
+      {
+         throw new RuntimeException("Could not reply to message", e);
+      }
+   }
+}

Added: arquillian/trunk/demo-testng/src/main/java/com/acme/util/jms/QueueRequestor.java
===================================================================
--- arquillian/trunk/demo-testng/src/main/java/com/acme/util/jms/QueueRequestor.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/main/java/com/acme/util/jms/QueueRequestor.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,101 @@
+package com.acme.util.jms;
+
+import javax.jms.InvalidDestinationException;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TemporaryQueue;
+
+public class QueueRequestor {
+
+   QueueSession session; // The queue session the queue belongs to.
+   Queue queue; // The queue to perform the request/reply on.
+   TemporaryQueue tempQueue;
+   QueueSender sender;
+   QueueReceiver receiver;
+
+   /**
+    * Constructor for the <CODE>QueueRequestor</CODE> class.
+    * 
+    * <P>
+    * This implementation assumes the session parameter to be non-transacted,
+    * with a delivery mode of either <CODE>AUTO_ACKNOWLEDGE</CODE> or
+    * <CODE>DUPS_OK_ACKNOWLEDGE</CODE>.
+    * 
+    * @param session
+    *           the <CODE>QueueSession</CODE> the queue belongs to
+    * @param queue
+    *           the queue to perform the request/reply call on
+    * 
+    * @exception JMSException
+    *               if the JMS provider fails to create the
+    *               <CODE>QueueRequestor</CODE> due to some internal error.
+    * @exception InvalidDestinationException
+    *               if an invalid queue is specified.
+    */
+
+   public QueueRequestor(QueueSession session, Queue queue) throws JMSException
+   {
+      this.session = session;
+      this.queue = queue;
+      tempQueue = session.createTemporaryQueue();
+      sender = session.createSender(queue);
+      receiver = session.createReceiver(tempQueue);
+   }
+
+   /**
+    * Sends a request and waits for a reply. The temporary queue is used for the
+    * <CODE>JMSReplyTo</CODE> destination, and only one reply per request is
+    * expected.
+    * 
+    * @param message
+    *           the message to send
+    * 
+    * @return the reply message
+    * 
+    * @exception JMSException
+    *               if the JMS provider fails to complete the request due to
+    *               some internal error.
+    */
+
+   public Message request(Message message) throws JMSException
+   {
+      return request(message, 0);
+   }
+
+   public Message request(Message message, int wait) throws JMSException
+   {
+      message.setJMSReplyTo(tempQueue);
+      sender.send(message);
+      return (receiver.receive(wait));
+   }
+
+   /**
+    * Closes the <CODE>QueueRequestor</CODE> and its session.
+    * 
+    * <P>
+    * Since a provider may allocate some resources on behalf of a
+    * <CODE>QueueRequestor</CODE> outside the Java virtual machine, clients
+    * should close them when they are not needed. Relying on garbage collection
+    * to eventually reclaim these resources may not be timely enough.
+    * 
+    * <P>
+    * Note that this method closes the <CODE>QueueSession</CODE> object passed
+    * to the <CODE>QueueRequestor</CODE> constructor.
+    * 
+    * @exception JMSException
+    *               if the JMS provider fails to close the
+    *               <CODE>QueueRequestor</CODE> due to some internal error.
+    */
+
+   public void close() throws JMSException
+   {
+
+      // publisher and consumer created by constructor are implicitly closed.
+      session.close();
+      tempQueue.delete();
+   }
+ }
\ No newline at end of file

Added: arquillian/trunk/demo-testng/src/test/java/com/acme/ejb/InjectionTestCase.java
===================================================================
--- arquillian/trunk/demo-testng/src/test/java/com/acme/ejb/InjectionTestCase.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/test/java/com/acme/ejb/InjectionTestCase.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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 com.acme.ejb;
+
+import javax.ejb.EJB;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * GreetingManagerTest
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class InjectionTestCase extends Arquillian
+{
+   @Deployment
+   public static JavaArchive createDeployment() {
+      return Archives.create("test.jar", JavaArchive.class)
+               .addClasses(
+                     GreetingManager.class,
+                     GreetingManagerBean.class);
+   }
+   
+   @EJB
+   private GreetingManager greetingManager;
+   
+   @Test
+   public void shouldBeAbleToInjectEJB() throws Exception {
+      
+      String userName = "Devoxx";
+      
+      Assert.assertEquals(
+            greetingManager.greet(userName),
+            "Hello " + userName);
+   }
+}

Added: arquillian/trunk/demo-testng/src/test/java/com/acme/jms/InjectionTestCase.java
===================================================================
--- arquillian/trunk/demo-testng/src/test/java/com/acme/jms/InjectionTestCase.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/test/java/com/acme/jms/InjectionTestCase.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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 com.acme.jms;
+
+import javax.annotation.Resource;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.acme.ejb.MessageEcho;
+import com.acme.util.jms.QueueRequestor;
+
+/**
+ * JmsTest
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class InjectionTestCase extends Arquillian
+{
+   @Deployment
+   public static JavaArchive createDeployment() {
+      return Archives.create("test.jar", JavaArchive.class)
+            .addClasses(
+                  MessageEcho.class, 
+                  QueueRequestor.class);
+   }
+   
+   @Resource(mappedName = "/queue/DLQ") 
+   private Queue dlq;
+   
+   @Resource(mappedName = "/ConnectionFactory") 
+   private ConnectionFactory factory;
+   
+   @Test
+   public void shouldBeAbleToSendMessage() throws Exception {
+      
+      String messageBody = "ping";
+      
+      Connection connection = factory.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      QueueRequestor requestor = new QueueRequestor((QueueSession)session, dlq);
+
+      connection.start();
+      
+      Message request = session.createTextMessage(messageBody);
+      Message response = requestor.request(request, 5000);
+      
+      Assert.assertEquals(
+            ((TextMessage)response).getText(),
+            messageBody,
+            "Should have responded with same message");
+   }
+}

Added: arquillian/trunk/demo-testng/src/test/java/com/acme/resource/InjectionTestCase.java
===================================================================
--- arquillian/trunk/demo-testng/src/test/java/com/acme/resource/InjectionTestCase.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/test/java/com/acme/resource/InjectionTestCase.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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 com.acme.resource;
+
+import javax.annotation.Resource;
+
+import javax.mail.Session;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * ResourcesTest
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class InjectionTestCase extends Arquillian
+{
+   @Deployment
+   public static JavaArchive createDeployment() {
+      return Archives.create("test.jar", JavaArchive.class);
+   }
+   
+   @Resource(mappedName = "java:/Mail") Session mailSession;
+   
+   @Test
+   public void shouldBeAbleToInjectResource() throws Exception {
+      
+      Assert.assertNotNull(mailSession, "Should have been injected");
+   }
+}

Added: arquillian/trunk/demo-testng/src/test/java/com/acme/weld/InjectionTestCase.java
===================================================================
--- arquillian/trunk/demo-testng/src/test/java/com/acme/weld/InjectionTestCase.java	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/test/java/com/acme/weld/InjectionTestCase.java	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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 com.acme.weld;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.Paths;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.acme.ejb.GreetingManager;
+import com.acme.ejb.GreetingManagerBean;
+
+/**
+ * WeldGreetingsTest
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class InjectionTestCase extends Arquillian
+{
+   @Deployment
+   public static JavaArchive createDeployment() {
+      return Archives.create("test.jar", JavaArchive.class)
+               .addClasses(
+                     GreetingManager.class,
+                     GreetingManagerBean.class)
+               .addManifestResource(
+                     new ByteArrayAsset("<beans/>".getBytes()), 
+                     Paths.create("beans.xml"));
+   }
+   
+   @Inject GreetingManager greetingManager;
+   
+   @Inject BeanManager beanManager;
+   
+   @Test
+   public void shouldBeAbleToInjectWeld() throws Exception {
+      
+      String userName = "Devoxx";
+      
+      Assert.assertNotNull(
+            beanManager,
+            "Should have injected manager");
+
+      Assert.assertEquals(
+            greetingManager.greet(userName),
+            "Hello " + userName);
+   }
+}

Added: arquillian/trunk/demo-testng/src/test/resources/jndi.properties
===================================================================
--- arquillian/trunk/demo-testng/src/test/resources/jndi.properties	                        (rev 0)
+++ arquillian/trunk/demo-testng/src/test/resources/jndi.properties	2009-12-25 22:51:47 UTC (rev 3884)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces 
+java.naming.provider.url=jnp://localhost:1099 



More information about the jboss-svn-commits mailing list