[jboss-svn-commits] JBoss Common SVN: r3804 - in arquillian/trunk/demo: src/main/java/com/acme/ejb and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Nov 27 07:04:28 EST 2009


Author: aslak
Date: 2009-11-27 07:04:27 -0500 (Fri, 27 Nov 2009)
New Revision: 3804

Added:
   arquillian/trunk/demo/src/test/java/com/acme/resource/
   arquillian/trunk/demo/src/test/java/com/acme/resource/ResourcesTest.java
   arquillian/trunk/demo/src/test/java/com/acme/weld/
   arquillian/trunk/demo/src/test/java/com/acme/weld/WeldGreetingsTest.java
   arquillian/trunk/demo/src/test/resources/jndi.properties
Removed:
   arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManager.java
   arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManagerBean.java
   arquillian/trunk/demo/src/test/java/com/acme/ejb/SystemManagerTest.java
Modified:
   arquillian/trunk/demo/pom.xml
Log:
ARQ-17 Extracted container configuration out as Maven profiles. mvn test -P jboss-embedded|jboss-remote-51|jboss-remote-60 . Added demo tests for Resource and CDI injection.

Modified: arquillian/trunk/demo/pom.xml
===================================================================
--- arquillian/trunk/demo/pom.xml	2009-11-27 11:59:31 UTC (rev 3803)
+++ arquillian/trunk/demo/pom.xml	2009-11-27 12:04:27 UTC (rev 3804)
@@ -12,7 +12,6 @@
    <name>Arquillian Demo</name>
    <description>Demo of Arquillian Usage</description>
 
-
    <!-- Properties -->
    <properties>
 
@@ -21,53 +20,95 @@
 
    </properties>
 
+   <profiles>
+      <profile>
+         <id>jboss-embedded</id>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.arquillian</groupId>
+               <artifactId>arquillian-jboss-embedded</artifactId>
+               <version>${version.org.jboss.arquillian_arquillian}</version>
+            </dependency>
+         </dependencies>
+      </profile>
+      <profile>
+         <id>jboss-remote-51</id>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.arquillian</groupId>
+               <artifactId>arquillian-jboss-remote-51</artifactId>
+               <version>${version.org.jboss.arquillian_arquillian}</version>
+            </dependency>
+         </dependencies>
+      </profile>
+      <profile>
+         <id>jboss-remote-60</id>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.arquillian</groupId>
+               <artifactId>arquillian-jboss-remote-60</artifactId>
+               <version>${version.org.jboss.arquillian_arquillian}</version>
+            </dependency>
+         </dependencies>
+      </profile>
+   </profiles>
+
    <!-- Dependencies -->
    <dependencies>
 
       <dependency>
-        <groupId>javax.ejb</groupId>
-        <artifactId>ejb-api</artifactId>
-        <version>3.0</version>      
+         <groupId>javax.ejb</groupId>
+         <artifactId>ejb-api</artifactId>
+         <version>3.0</version>
+         <scope>provided</scope>
       </dependency>
       <dependency>
-         <groupId>org.jboss.arquillian</groupId>
-         <artifactId>arquillian-junit</artifactId>
-         <version>${version.org.jboss.arquillian_arquillian}</version>
+         <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>org.jboss.arquillian</groupId>
-         <artifactId>arquillian-jboss-embedded</artifactId>
+         <artifactId>arquillian-junit</artifactId>
          <version>${version.org.jboss.arquillian_arquillian}</version>
       </dependency>
 
       <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
-	 <version>4.7</version>
+         <version>4.7</version>
          <scope>test</scope>
       </dependency>
 
    </dependencies>
-   
+
    <build>
-   	<plugins>
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <inherited>true</inherited>
-        <configuration>
-          <source>1.6</source>
-          <target>1.6</target>
-          <showDeprecation>false</showDeprecation>
-          <showWarnings>true</showWarnings>
-          <optimize>true</optimize>
-          <compilerVersion>1.6</compilerVersion>
-          <fork>true</fork>
-          <argLine>-Xmx512M</argLine>
-          <executable>${JAVA_HOME}/bin/javac</executable>
-        </configuration>
-      </plugin>
+      <plugins>
+         <plugin>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <inherited>true</inherited>
+            <configuration>
+               <source>1.6</source>
+               <target>1.6</target>
+               <showDeprecation>false</showDeprecation>
+               <showWarnings>true</showWarnings>
+               <optimize>true</optimize>
+               <compilerVersion>1.6</compilerVersion>
+               <fork>true</fork>
+               <argLine>-Xmx512M</argLine>
+               <executable>${JAVA_HOME}/bin/javac</executable>
+            </configuration>
+         </plugin>
 
-   	</plugins>
+      </plugins>
    </build>
 </project>
 

Deleted: arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManager.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManager.java	2009-11-27 11:59:31 UTC (rev 3803)
+++ arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManager.java	2009-11-27 12:04:27 UTC (rev 3804)
@@ -1,28 +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 com.acme.ejb;
-
-/**
- * SystemManager
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public interface SystemManager
-{
-   String greet(String userName);
-}

Deleted: arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManagerBean.java
===================================================================
--- arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManagerBean.java	2009-11-27 11:59:31 UTC (rev 3803)
+++ arquillian/trunk/demo/src/main/java/com/acme/ejb/SystemManagerBean.java	2009-11-27 12:04:27 UTC (rev 3804)
@@ -1,37 +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 com.acme.ejb;
-
-import javax.ejb.Local;
-import javax.ejb.Stateless;
-
-/**
- * SystemManagerBean
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
- at Local(SystemManager.class)
- at Stateless
-public class SystemManagerBean implements SystemManager
-{
-   @Override
-   public String greet(String userName)
-   {
-      return "System " + userName;
-   }
-}

Deleted: arquillian/trunk/demo/src/test/java/com/acme/ejb/SystemManagerTest.java
===================================================================
--- arquillian/trunk/demo/src/test/java/com/acme/ejb/SystemManagerTest.java	2009-11-27 11:59:31 UTC (rev 3803)
+++ arquillian/trunk/demo/src/test/java/com/acme/ejb/SystemManagerTest.java	2009-11-27 12:04:27 UTC (rev 3804)
@@ -1,59 +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 com.acme.ejb;
-
-import javax.ejb.EJB;
-
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * GreetingManagerTest
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
- at RunWith(Arquillian.class)
-public class SystemManagerTest
-{
-   @Deployment
-   public static JavaArchive createDeployment() {
-      return Archives.create("test.jar", JavaArchive.class)
-               .addClasses(
-                     SystemManager.class,
-                     SystemManagerBean.class);
-   }
-   
-   @EJB
-   private SystemManager systemManager;
-   
-   @Test
-   public void shouldGreetUser() throws Exception {
-      
-      String userName = "Devoxx";
-      
-      Assert.assertEquals(
-            "System " + userName,
-            systemManager.greet(userName));
-   }
-}

Added: arquillian/trunk/demo/src/test/java/com/acme/resource/ResourcesTest.java
===================================================================
--- arquillian/trunk/demo/src/test/java/com/acme/resource/ResourcesTest.java	                        (rev 0)
+++ arquillian/trunk/demo/src/test/java/com/acme/resource/ResourcesTest.java	2009-11-27 12:04:27 UTC (rev 3804)
@@ -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.resource;
+
+import javax.annotation.Resource;
+import javax.mail.Session;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * ResourcesTest
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class ResourcesTest
+{
+   @Deployment
+   public static JavaArchive createDeployment() {
+      return Archives.create("test.jar", JavaArchive.class);
+   }
+   
+   @Resource(mappedName = "java:/Mail") Session mailSession;
+   
+   @Test
+   public void shouldBeAbleToGreet() throws Exception {
+      
+      Assert.assertNotNull(mailSession);
+   }
+}

Added: arquillian/trunk/demo/src/test/java/com/acme/weld/WeldGreetingsTest.java
===================================================================
--- arquillian/trunk/demo/src/test/java/com/acme/weld/WeldGreetingsTest.java	                        (rev 0)
+++ arquillian/trunk/demo/src/test/java/com/acme/weld/WeldGreetingsTest.java	2009-11-27 12:04:27 UTC (rev 3804)
@@ -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.weld;
+
+import javax.inject.Inject;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.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.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.acme.ejb.GreetingManager;
+import com.acme.ejb.GreetingManagerBean;
+
+/**
+ * WeldGreetingsTest
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class WeldGreetingsTest
+{
+   @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;
+   
+   @Test
+   public void shouldBeAbleToGreet() throws Exception {
+      
+      String userName = "Devoxx";
+      
+      Assert.assertEquals(
+            "Hello " + userName,
+            greetingManager.greet(userName));
+   }
+}

Added: arquillian/trunk/demo/src/test/resources/jndi.properties
===================================================================
--- arquillian/trunk/demo/src/test/resources/jndi.properties	                        (rev 0)
+++ arquillian/trunk/demo/src/test/resources/jndi.properties	2009-11-27 12:04:27 UTC (rev 3804)
@@ -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