[jboss-svn-commits] JBoss Common SVN: r4666 - in arquillian/trunk: examples/domain/src/main/java/com/acme/cdi and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Jul 2 11:37:47 EDT 2010


Author: aslak
Date: 2010-07-02 11:37:46 -0400 (Fri, 02 Jul 2010)
New Revision: 4666

Added:
   arquillian/trunk/examples/domain/src/main/java/com/acme/cdi/conversation/
   arquillian/trunk/examples/domain/src/main/java/com/acme/cdi/conversation/LongRunningBean.java
   arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/conversation/
   arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/conversation/ConversationScopeTestCase.java
   arquillian/trunk/examples/junit/src/test/resources/arquillian.xml
   arquillian/trunk/examples/testng/src/test/java/com/acme/cdi/random/
   arquillian/trunk/examples/testng/src/test/java/com/acme/cdi/random/RandomTestCase.java
Removed:
   arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/RequestLifeCycleController.java
   arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/SessionLifeCycleController.java
Modified:
   arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/WeldSEContainer.java
   arquillian/trunk/examples/junit/pom.xml
   arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java
   arquillian/trunk/examples/testng/pom.xml
Log:
ARQ-185 Removed Session and Request scope from Weld SE Container. Use Weld EE Mock for Session, Request and Conversation scopes. Added Conversation scope examples.


Deleted: arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/RequestLifeCycleController.java
===================================================================
--- arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/RequestLifeCycleController.java	2010-07-02 13:51:59 UTC (rev 4665)
+++ arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/RequestLifeCycleController.java	2010-07-02 15:37:46 UTC (rev 4666)
@@ -1,94 +0,0 @@
-/*
- * 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 org.jboss.arquillian.container.weld.se.embedded_1;
-
-import java.util.UUID;
-
-import org.jboss.arquillian.spi.Context;
-import org.jboss.arquillian.spi.event.Event;
-import org.jboss.arquillian.spi.event.suite.EventHandler;
-import org.jboss.weld.context.ContextLifecycle;
-import org.jboss.weld.context.api.BeanStore;
-import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.weld.manager.api.WeldManager;
-
-/**
- * SessionLifeCycleController
- *
- * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class RequestLifeCycleController implements EventHandler<Event>
-{
-   private Class<? extends Event> endRequestEvent;
-   
-   public RequestLifeCycleController(Class<? extends Event> endRequestEvent) 
-   {
-      if(endRequestEvent == null) 
-      {
-         throw new IllegalArgumentException("EndSessionEvent must be specified");
-      }
-      this.endRequestEvent = endRequestEvent;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.arquillian.spi.EventHandler#callback(org.jboss.arquillian.spi.Context, java.lang.Object)
-    */
-   public void callback(Context context, Event event) throws Exception 
-   {
-      WeldManager manager = context.get(WeldManager.class);
-      if(manager == null)
-      {
-         throw new IllegalStateException("No " + WeldManager.class.getName() + " found in context");
-      }
-      ContextLifecycle lifeCycle = manager.getServices().get(ContextLifecycle.class);
-
-      String requestId = UUID.randomUUID().toString();
-      BeanStore beanStore = new ConcurrentHashMapBeanStore();
-      
-      lifeCycle.beginRequest(requestId, beanStore);
-      
-      context.register(endRequestEvent, new DestoryRequest(requestId, beanStore));
-   }
-   
-   /**
-    * DestorySession
-    *
-    * @author <a href="mailto:aknutsen at redhat.org">Aslak Knutsen</a>
-    * @version $Revision: $
-    */
-   private static class DestoryRequest implements EventHandler<Event> {
-      
-      private String requestId;
-      private BeanStore beanStore;
-      
-      public DestoryRequest(String requestId, BeanStore beanStore)
-      {
-         this.requestId = requestId;
-         this.beanStore = beanStore;
-      }
-      
-      /* (non-Javadoc)
-       * @see org.jboss.arquillian.spi.event.EventHandler#callback(org.jboss.arquillian.spi.Context, java.lang.Object)
-       */
-      public void callback(Context context, Event event) throws Exception
-      {
-         WeldManager manager = context.get(WeldManager.class);
-         manager.getServices().get(ContextLifecycle.class).endRequest(requestId, beanStore);
-      }
-   }
-}

Deleted: arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/SessionLifeCycleController.java
===================================================================
--- arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/SessionLifeCycleController.java	2010-07-02 13:51:59 UTC (rev 4665)
+++ arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/SessionLifeCycleController.java	2010-07-02 15:37:46 UTC (rev 4666)
@@ -1,93 +0,0 @@
-/*
- * 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 org.jboss.arquillian.container.weld.se.embedded_1;
-
-import java.util.UUID;
-
-import org.jboss.arquillian.spi.Context;
-import org.jboss.arquillian.spi.event.Event;
-import org.jboss.arquillian.spi.event.suite.EventHandler;
-import org.jboss.weld.context.ContextLifecycle;
-import org.jboss.weld.context.api.BeanStore;
-import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.weld.manager.api.WeldManager;
-
-/**
- * SessionLifeCycleController
- *
- * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class SessionLifeCycleController implements EventHandler<Event>
-{
-   private Class<? extends Event> endSessionEvent;
-   
-   public SessionLifeCycleController(Class<? extends Event> endSessionEvent) 
-   {
-      if(endSessionEvent == null) 
-      {
-         throw new IllegalArgumentException("EndSessionEvent must be specified");
-      }
-      this.endSessionEvent = endSessionEvent;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.arquillian.spi.EventHandler#callback(org.jboss.arquillian.spi.Context, java.lang.Object)
-    */
-   public void callback(Context context, Event event) throws Exception 
-   {
-      WeldManager manager = context.get(WeldManager.class);
-      if(manager == null)
-      {
-         throw new IllegalStateException("No " + WeldManager.class.getName() + " found in context");
-      }
-      ContextLifecycle lifeCycle = manager.getServices().get(ContextLifecycle.class);
-
-      String sessionId = UUID.randomUUID().toString();
-      BeanStore beanStore = new ConcurrentHashMapBeanStore();
-      
-      lifeCycle.restoreSession(sessionId, beanStore);
-      context.register(endSessionEvent, new DestorySession(sessionId, beanStore));
-   }
-   
-   /**
-    * DestorySession
-    *
-    * @author <a href="mailto:aknutsen at redhat.org">Aslak Knutsen</a>
-    * @version $Revision: $
-    */
-   private static class DestorySession implements EventHandler<Event> {
-      
-      private String sessionId;
-      private BeanStore beanStore;
-      
-      public DestorySession(String sessionId, BeanStore beanStore)
-      {
-         this.sessionId = sessionId;
-         this.beanStore = beanStore;
-      }
-      
-      /* (non-Javadoc)
-       * @see org.jboss.arquillian.spi.event.EventHandler#callback(org.jboss.arquillian.spi.Context, java.lang.Object)
-       */
-      public void callback(Context context, Event event) throws Exception
-      {
-         WeldManager manager = context.get(WeldManager.class);
-         manager.getServices().get(ContextLifecycle.class).endSession(sessionId, beanStore);
-      }
-   }
-}

Modified: arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/WeldSEContainer.java
===================================================================
--- arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/WeldSEContainer.java	2010-07-02 13:51:59 UTC (rev 4665)
+++ arquillian/trunk/containers/weld-se-embedded-1/src/main/java/org/jboss/arquillian/container/weld/se/embedded_1/WeldSEContainer.java	2010-07-02 15:37:46 UTC (rev 4666)
@@ -28,10 +28,6 @@
 import org.jboss.arquillian.spi.DeployableContainer;
 import org.jboss.arquillian.spi.DeploymentException;
 import org.jboss.arquillian.spi.LifecycleException;
-import org.jboss.arquillian.spi.event.container.BeforeUnDeploy;
-import org.jboss.arquillian.spi.event.suite.After;
-import org.jboss.arquillian.spi.event.suite.Before;
-import org.jboss.arquillian.spi.event.suite.BeforeClass;
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.weld.bootstrap.WeldBootstrap;
 import org.jboss.weld.bootstrap.api.Environments;
@@ -54,14 +50,6 @@
     */
    public void setup(Context context, Configuration configuration)
    {
-      //configuration.getContainerConfig(WeldSEConfiguration.class);
-
-        /*
-         *  TODO: make this work ? these handlers will be fired. 
-         *  Not with the needed ClassContext but with the SuiteContext the event was fired from..  
-         */
-//      context.register(AfterDeploy.class, new SessionLifeCycleController(BeforeUnDeploy.class));
-//      context.register(Before.class, new RequestLifeCycleController(After.class));
    }
    
    /* (non-Javadoc)
@@ -120,8 +108,6 @@
       
       context.add(WeldBootstrap.class, bootstrap);
       context.add(WeldManager.class, manager);
-      context.register(BeforeClass.class, new SessionLifeCycleController(BeforeUnDeploy.class));
-      context.register(Before.class, new RequestLifeCycleController(After.class));
       
       return new LocalMethodExecutor();
    }

Added: arquillian/trunk/examples/domain/src/main/java/com/acme/cdi/conversation/LongRunningBean.java
===================================================================
--- arquillian/trunk/examples/domain/src/main/java/com/acme/cdi/conversation/LongRunningBean.java	                        (rev 0)
+++ arquillian/trunk/examples/domain/src/main/java/com/acme/cdi/conversation/LongRunningBean.java	2010-07-02 15:37:46 UTC (rev 4666)
@@ -0,0 +1,51 @@
+/*
+ * 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.cdi.conversation;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.context.ConversationScoped;
+
+/**
+ * LongRunningBean
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at ConversationScoped
+public class LongRunningBean implements Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   private List<String> messages = new ArrayList<String>();
+   
+   public LongRunningBean()
+   {
+   }
+   
+   public void addMessage(String message)
+   {
+      messages.add(message);
+   }
+   
+   public List<String> getMessages()
+   {
+      return messages;
+   }
+}

Modified: arquillian/trunk/examples/junit/pom.xml
===================================================================
--- arquillian/trunk/examples/junit/pom.xml	2010-07-02 13:51:59 UTC (rev 4665)
+++ arquillian/trunk/examples/junit/pom.xml	2010-07-02 15:37:46 UTC (rev 4666)
@@ -118,7 +118,6 @@
 						<artifactId>maven-surefire-plugin</artifactId>
 						<configuration>
 							<includes>
-								<include>com/acme/cdi/payment/*</include>
 								<include>com/acme/cdi/random/*</include>
 							</includes>
 						</configuration>
@@ -131,7 +130,7 @@
 			<dependencies>
 				<dependency>
 					<groupId>org.jboss.arquillian.container</groupId>
-					<artifactId>arquillian-weld-ee-embedded</artifactId>
+					<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
 					<version>${project.version}</version>
 				</dependency>
 				<dependency>
@@ -207,7 +206,8 @@
 						<artifactId>maven-surefire-plugin</artifactId>
 						<configuration>
 							<includes>
-								<include>com/acme/cdi/conversation/*TestCase*</include>
+								<include>com/acme/cdi/payment/*</include>
+								<include>com/acme/cdi/conversation/*</include>
 							</includes>
 						</configuration>
 					</plugin>

Added: arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/conversation/ConversationScopeTestCase.java
===================================================================
--- arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/conversation/ConversationScopeTestCase.java	                        (rev 0)
+++ arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/conversation/ConversationScopeTestCase.java	2010-07-02 15:37:46 UTC (rev 4666)
@@ -0,0 +1,69 @@
+/*
+ * 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.cdi.conversation;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * ConversationScope
+ *
+ * @author <a href="mailto:aslak at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class ConversationScopeTestCase
+{
+   @Deployment
+   public static JavaArchive createDeployment() {
+       return ShrinkWrap.create("test.jar", JavaArchive.class)
+               .addClass(LongRunningBean.class)
+               .addManifestResource(
+                     new ByteArrayAsset("<beans/>".getBytes()), 
+                     ArchivePaths.create("beans.xml"));
+   }
+
+   @Inject 
+   private LongRunningBean bean;
+   
+   @Inject 
+   private Conversation conversation;
+   
+   @Test
+   public void firstCall() throws Exception
+   {
+      bean.addMessage("test1");
+      conversation.begin();
+   }
+
+   @Test
+   public void secondCall() throws Exception
+   {
+      Assert.assertEquals(1, bean.getMessages().size());
+   }
+}

Modified: arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java
===================================================================
--- arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java	2010-07-02 13:51:59 UTC (rev 4665)
+++ arquillian/trunk/examples/junit/src/test/java/com/acme/cdi/payment/SynchronousPaymentProcessorTestCase.java	2010-07-02 15:37:46 UTC (rev 4666)
@@ -32,7 +32,8 @@
  * @version $Revision: $
  */
 @RunWith(Arquillian.class)
-public class SynchronousPaymentProcessorTestCase {
+public class SynchronousPaymentProcessorTestCase 
+{
 
 	@Deployment
 	public static JavaArchive createDeployment() {

Added: arquillian/trunk/examples/junit/src/test/resources/arquillian.xml
===================================================================
--- arquillian/trunk/examples/junit/src/test/resources/arquillian.xml	                        (rev 0)
+++ arquillian/trunk/examples/junit/src/test/resources/arquillian.xml	2010-07-02 15:37:46 UTC (rev 4666)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+
+<arquillian xmlns="http://jboss.com/arquillian"
+		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		xmlns:weldee="urn:arq:org.jboss.arquillian.container.weld.ee.embedded_1_1">
+
+	<weldee:container>
+		<enableConversationScope>true</enableConversationScope>
+	</weldee:container>	
+
+</arquillian>
\ No newline at end of file

Modified: arquillian/trunk/examples/testng/pom.xml
===================================================================
--- arquillian/trunk/examples/testng/pom.xml	2010-07-02 13:51:59 UTC (rev 4665)
+++ arquillian/trunk/examples/testng/pom.xml	2010-07-02 15:37:46 UTC (rev 4666)
@@ -119,8 +119,97 @@
 						<artifactId>maven-surefire-plugin</artifactId>
 						<configuration>
 							<includes>
-								<include>com/acme/cdi/*</include>
+								<include>com/acme/cdi/random/*</include>
+							</includes>
+						</configuration>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>weld-ee-embedded</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.jboss.arquillian.container</groupId>
+					<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
+					<version>${project.version}</version>
+				</dependency>
+				<dependency>
+					<!--
+						Need on all profiles except Glassfish to compile, api is not 100%
+						up to date with final spec
+					-->
+					<groupId>org.jboss.ejb3</groupId>
+					<artifactId>jboss-ejb3-api</artifactId>
+					<version>3.1.0</version>
+				</dependency>
+				<!-- org.jboss.weld -->
+				<dependency>
+					<groupId>org.jboss.weld</groupId>
+					<artifactId>weld-core</artifactId>
+				</dependency>
+				<dependency>
+					<groupId>org.jboss.weld</groupId>
+					<artifactId>weld-api</artifactId>
+				</dependency>
+				<dependency>
+					<groupId>org.slf4j</groupId>
+					<artifactId>slf4j-simple</artifactId>
+				</dependency>
+				<dependency>
+					<groupId>javax.el</groupId>
+					<artifactId>el-api</artifactId>
+					<version>2.2</version>
+				</dependency>
+				<dependency>
+					<groupId>javax.transaction</groupId>
+					<artifactId>jta</artifactId>
+					<version>1.1</version>
+					<scope>provided</scope>
+				</dependency>
+		
+				<dependency>
+					<groupId>javax.persistence</groupId>
+					<artifactId>persistence-api</artifactId>
+					<version>1.0</version>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>javax.validation</groupId>
+					<artifactId>validation-api</artifactId>
+					<version>1.0.0.GA</version>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>org.jboss.spec.javax.servlet</groupId>
+					<artifactId>jboss-servlet-api_3.0_spec</artifactId>
+					<version>1.0.0.Beta2</version>
+					<scope>provided</scope>
+				</dependency>
+				
+			</dependencies>
+			<dependencyManagement>
+				<dependencies>
+					<!-- org.jboss.weld -->
+					<dependency>
+						<groupId>org.jboss.weld</groupId>
+						<artifactId>weld-core-bom</artifactId>
+						<version>${version.weld_core}</version>
+						<type>pom</type>
+						<scope>import</scope>
+					</dependency>
+				</dependencies>
+			</dependencyManagement>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-surefire-plugin</artifactId>
+						<configuration>
+							<includes>
+								<!-- <include>com/acme/cdi/*</include> -->
 								<include>com/acme/cdi/payment/*</include>
+								<include>com/acme/cdi/translate/*</include>
 							</includes>
 						</configuration>
 					</plugin>

Added: arquillian/trunk/examples/testng/src/test/java/com/acme/cdi/random/RandomTestCase.java
===================================================================
--- arquillian/trunk/examples/testng/src/test/java/com/acme/cdi/random/RandomTestCase.java	                        (rev 0)
+++ arquillian/trunk/examples/testng/src/test/java/com/acme/cdi/random/RandomTestCase.java	2010-07-02 15:37:46 UTC (rev 4666)
@@ -0,0 +1,57 @@
+/*
+ * 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.cdi.random;
+
+import javax.inject.Inject;
+
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class RandomTestCase extends Arquillian {
+
+	@Deployment
+	public static JavaArchive createDeployment() {
+		return ShrinkWrap.create("test.jar", JavaArchive.class)
+				.addPackage(
+						Random.class.getPackage()
+				)
+				.addManifestResource(
+						new ByteArrayAsset("<beans/>".getBytes()),
+						ArchivePaths.create("beans.xml"));
+	}
+
+	@Inject @Random int randomNumber;
+	
+	@Test
+	public void shouldRun() throws Exception 
+	{
+	   Assert.assertTrue(randomNumber < 101);
+	}
+}



More information about the jboss-svn-commits mailing list