[jboss-svn-commits] JBoss Common SVN: r4514 - in arquillian/trunk: archetypes and 18 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Jun 12 14:57:44 EDT 2010
Author: dan.j.allen
Date: 2010-06-12 14:57:44 -0400 (Sat, 12 Jun 2010)
New Revision: 4514
Added:
arquillian/trunk/archetypes/
arquillian/trunk/archetypes/create-archetypes.sh
arquillian/trunk/archetypes/junit-javaee6-archetype.properties
arquillian/trunk/archetypes/junit-javaee6/
arquillian/trunk/archetypes/junit-javaee6/pom.xml
arquillian/trunk/archetypes/junit-javaee6/readme.txt
arquillian/trunk/archetypes/junit-javaee6/src/
arquillian/trunk/archetypes/junit-javaee6/src/main/
arquillian/trunk/archetypes/junit-javaee6/src/main/java/
arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/
arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/
arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/
arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/
arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game.java
arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game_.java
arquillian/trunk/archetypes/junit-javaee6/src/main/resources/
arquillian/trunk/archetypes/junit-javaee6/src/test/
arquillian/trunk/archetypes/junit-javaee6/src/test/java/
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/BeanManagerTest.java
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/GamePersistenceTest.java
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/IncludeAllTestSuite.java
arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/MavenArtifactResolver.java
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/sun-resources.xml
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/test-persistence.xml
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-remote/
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-remote/test-persistence.xml
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/jndi.properties
arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/test-persistence.xml
arquillian/trunk/archetypes/junit-javaee6/src/test/resources/
arquillian/trunk/archetypes/junit-javaee6/src/test/resources/arquillian.xml
Log:
ARQ-177
Added: arquillian/trunk/archetypes/create-archetypes.sh
===================================================================
--- arquillian/trunk/archetypes/create-archetypes.sh (rev 0)
+++ arquillian/trunk/archetypes/create-archetypes.sh 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+mvn -f junit-javaee6/pom.xml clean archetype:create-from-project -Darchetype.properties=../junit-javaee6-archetype.properties
+mvn -f junit-javaee6/target/generated-sources/archetype/pom.xml install
Property changes on: arquillian/trunk/archetypes/create-archetypes.sh
___________________________________________________________________
Name: svn:executable
+ *
Property changes on: arquillian/trunk/archetypes/junit-javaee6
___________________________________________________________________
Name: svn:ignore
+ target
Added: arquillian/trunk/archetypes/junit-javaee6/pom.xml
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/pom.xml (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/pom.xml 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,325 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.arquillian.archetype</groupId>
+ <artifactId>arquillian-junit-javaee</artifactId>
+ <packaging>jar</packaging>
+ <name>${projectName}</name>
+ <description>Arquillian JUnit project for testing Java EE 6 applications</description>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+ <version.arquillian>1.0.0-SNAPSHOT</version.arquillian>
+ <version.glassfish>3.0.1-b19</version.glassfish>
+ <version.jboss-as-client>6.0.0.20100429-M3</version.jboss-as-client>
+ <version.jboss-javaee6-spec>1.0.0.Beta4</version.jboss-javaee6-spec>
+ <version.jboss-server-manager>1.0.3.GA</version.jboss-server-manager>
+ <version.junit>4.8.1</version.junit>
+ <version.weld>1.0.1-Final</version.weld>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository</id>
+ <name>JBoss Repository</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jboss-public-repository</id>
+ <name>JBoss Repository</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ <version>1.0.0.Final</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <defaultGoal>test</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <!-- Uncomment if you want to generate the JPA 2 metamodel -->
+ <!--
+ <compilerArgument>-proc:none</compilerArgument>
+ -->
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.8</version>
+ <configuration>
+ <wtpversion>2.0</wtpversion>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!-- version 2.5 creates seperate test suites per class -->
+ <version>2.4.3</version>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+
+ <profile>
+ <id>weld-embedded</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core-bom</artifactId>
+ <version>${version.weld}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-weld-embedded</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${version.jboss-javaee6-spec}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*PersistenceTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>jbossas-remote-60</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-60</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${version.jboss-javaee6-spec}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ <!-- need for org.jnp.interfaces.NamingContextFactory -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${version.jboss-as-client}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas</directory>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
+
+ <profile>
+ <id>jbossas-managed-60</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-local-60</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${version.jboss-as-client}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ <!-- cdi is missing from jboss-as-client 6.0.0.M3 -->
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.0-SP1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-server-manager</artifactId>
+ <version>${version.jboss-server-manager}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas</directory>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
+
+ <profile>
+ <id>glassfish-embedded-30</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-glassfish-embedded-30</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.extras</groupId>
+ <artifactId>glassfish-embedded-all</artifactId>
+ <version>${version.glassfish}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-glassfish-embedded</directory>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
+
+ <profile>
+ <!-- Sample test requires Hibernate to be installed in GlassFish -->
+ <id>glassfish-remote-30</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-glassfish-remote-30</artifactId>
+ <version>${version.arquillian}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.extras</groupId>
+ <artifactId>glassfish-embedded-all</artifactId>
+ <version>${version.glassfish}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-glassfish-remote</directory>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
+ </profiles>
+</project>
Property changes on: arquillian/trunk/archetypes/junit-javaee6/pom.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: arquillian/trunk/archetypes/junit-javaee6/readme.txt
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/readme.txt (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/readme.txt 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,94 @@
+
+ Arquillian JUnit project
+
+ Source archetype: arquillian-junit-javaee6
+
+ What is it?
+ ===========
+
+ This is your Arquillian sandbox project! It's a sample Maven 2 project to help
+ you get your foot in the door testing Java EE 6 applications with Arquillian.
+
+ The project is setup to allow you to test your application against and Weld
+ embedded container by default and also embedded and remote JBoss AS and
+ GlassFish containers using the matching Maven profile. It also includes
+ several sample tests for reference and convenient prototyping.
+
+ System requirements
+ ===================
+
+ All you need to run this project is Java 5.0 (Java SDK 1.5) or greator and
+ Maven 2.0.10 or greater (though Maven 3 is strongly recommended).
+
+ Running the tests
+ =================
+
+ This project uses Maven profiles to select the tests and the container on
+ which they will be run.
+
+ By default, simple bean tests are run in a Weld embedded container, handled by
+ the weld-embedded profile:
+
+ mvn clean test
+
+ Additional tests are added if you run against a real Java EE 6 container. You
+ have several options, with the prerequisites listed for each.
+
+ = JBoss AS remote 6.0
+
+ Start a JBoss AS 6.0 instance. Then run:
+
+ mvn clean test -Pjbossas-remote-60
+
+ = JBoss AS managed 6.0
+
+ Set the location to a JBoss AS 6 install directory in the configuration file
+ src/test/resources/arquillian.xml. Then run:
+
+ mvn clean test -Pjbossas-managed-60
+
+ = GlassFish embedded 3.0
+
+ No prerequisites.
+
+ mvn clean test -Pglassfish-embedded-30
+
+ = GlassFish remote 3.0
+
+ Start a GlassFish 3.0 instance and the JavaDB. Then run:
+
+ mvn clean test -Pglassfish-remote-30
+
+ You can safely remove the profile of any container you won't be using.
+
+ Importing the project into an IDE
+ =================================
+
+ If you created the project using the Maven 2 archetype wizard in your IDE
+ (Eclipse, NetBeans or IntelliJ IDEA), then there is nothing to do. You should
+ already have an IDE project.
+
+ If you created the project from the commandline using archetype:generate, then
+ you need to bring the project into your IDE. If you are using NetBeans 6.8 or
+ IntelliJ IDEA 9, then all you have to do is open the project as an existing
+ project. Both of these IDEs recognize Maven 2 projects natively.
+
+ To import into Eclipse, you first need to install the m2eclipse plugin. To get
+ started, add the m2eclipse update site (http://m2eclipse.sonatype.org/update/)
+ to Eclipse and install the m2eclipse plugin and required dependencies. Once
+ that is installed, you'll be ready to import the project into Eclipse.
+
+ Select File > Import... and select "Import... > Maven Projects" and select
+ your project directory. m2eclipse should take it from there.
+
+ Once in the IDE, you can execute the Maven commands through the IDE controls
+ to active one of the Maven profiles and execute the tests.
+
+ Arquillian resources
+ ====================
+
+ Project site: http://jboss.org/arquillian
+ User forums: http://community.jboss.org/en/arquillian
+ Development forums: http://community.jboss.org/en/arquillian/dev
+ JIRA: http://jira.jboss.org/browse/ARQ
+
Property changes on: arquillian/trunk/archetypes/junit-javaee6/readme.txt
___________________________________________________________________
Name: svn:executable
+ *
Added: arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game.java
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game.java (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game.java 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.example;
+
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+ at Entity
+public class Game implements Serializable
+{
+ private Long id;
+ private String title;
+
+ public Game()
+ {
+ }
+
+ public Game(String title)
+ {
+ this.title = title;
+ }
+
+ @Id @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @NotNull
+ @Size(min = 3, max = 50)
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String name)
+ {
+ this.title = name;
+ }
+
+ @Override
+ public String toString() {
+ return "Game@" + hashCode() + "[id = " + id + "; title = " + title + "]";
+ }
+}
Added: arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game_.java
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game_.java (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/main/java/org/jboss/arquillian/example/Game_.java 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.example;
+
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+ at StaticMetamodel(Game.class)
+public abstract class Game_ {
+
+ public static volatile SingularAttribute<Game, Long> id;
+ public static volatile SingularAttribute<Game, String> title;
+
+}
+
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/BeanManagerTest.java
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/BeanManagerTest.java (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/BeanManagerTest.java 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.example;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import static org.junit.Assert.*;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class BeanManagerTest
+{
+ @Deployment
+ public static Archive<?> createTestArchive() {
+ return ShrinkWrap.create("test.jar", JavaArchive.class)
+ .addManifestResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ }
+
+ @Inject BeanManager beanManager;
+
+ @Test
+ public void testCdiBootstrap()
+ {
+ assertNotNull(beanManager);
+ assertFalse(beanManager.getBeans(BeanManager.class).isEmpty());
+ }
+}
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/GamePersistenceTest.java
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/GamePersistenceTest.java (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/GamePersistenceTest.java 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.example;
+
+import java.util.List;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+import javax.transaction.UserTransaction;
+import static org.junit.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.spec.WebArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class GamePersistenceTest
+{
+ private static final String[] GAME_TITLES =
+ {
+ "Super Mario Brothers",
+ "Mario Kart",
+ "F-Zero"
+ };
+
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ return ShrinkWrap.create("test.war", WebArchive.class)
+ .addPackage(Game.class.getPackage())
+ .addWebResource("test-persistence.xml", "classes/META-INF/persistence.xml")
+ .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ }
+
+ @PersistenceContext EntityManager em;
+
+ @Inject UserTransaction utx;
+
+ @Test
+ public void testInsert() throws Exception
+ {
+ assertNotNull(utx);
+
+ // flushing database
+ utx.begin();
+ em.joinTransaction();
+ em.createQuery("delete from Game").executeUpdate();
+ utx.commit();
+
+ // insert records
+ utx.begin();
+ em.joinTransaction();
+ System.out.println("Inserting records...");
+ for (String title : GAME_TITLES)
+ {
+ Game game = new Game(title);
+ em.persist(game);
+ }
+ utx.commit();
+
+ List<Game> games;
+
+ // query with JPQL
+ utx.begin();
+ em.joinTransaction();
+ System.out.println("Selecting (using JPQL)...");
+ games = em.createQuery("select g from Game g order by g.id").getResultList();
+ System.out.println("Found " + games.size() + " games (using JPQL)");
+ assertEquals(GAME_TITLES.length, games.size());
+ for (int i = 0; i < GAME_TITLES.length; i++) {
+ assertEquals(GAME_TITLES[i], games.get(i).getTitle());
+ System.out.println(games.get(i));
+ }
+ utx.commit();
+
+ // query with Criteria
+ utx.begin();
+ em.joinTransaction();
+ CriteriaBuilder builder = em.getCriteriaBuilder();
+ CriteriaQuery<Game> criteria = builder.createQuery(Game.class);
+
+ Root<Game> game = criteria.from(Game.class);
+ criteria.select(game);
+ criteria.orderBy(builder.asc(game.get(Game_.id)));
+ System.out.println("Selecting (using Criteria)...");
+ games = em.createQuery(criteria).getResultList();
+ System.out.println("Found " + games.size() + " games (using Criteria)");
+ assertEquals(GAME_TITLES.length, games.size());
+ for (int i = 0; i < GAME_TITLES.length; i++) {
+ assertEquals(GAME_TITLES[i], games.get(i).getTitle());
+ System.out.println(games.get(i));
+ }
+ utx.commit();
+ }
+
+}
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/IncludeAllTestSuite.java
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/IncludeAllTestSuite.java (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/IncludeAllTestSuite.java 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.example;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * An example of a JUnit 4 test suite, which gives
+ * you fine-grained controller over which tests
+ * are selected and the execution order.
+ *
+ * @author Dan Allen
+ */
+ at RunWith(Suite.class)
+ at SuiteClasses({
+ BeanManagerTest.class,
+ GamePersistenceTest.class
+})
+public class IncludeAllTestSuite {}
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/MavenArtifactResolver.java
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/MavenArtifactResolver.java (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/java/org/jboss/arquillian/example/MavenArtifactResolver.java 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.example;
+
+import java.io.File;
+
+/**
+ * A crude resolver that converts a Maven artifact reference
+ * into a {@link java.io.File} object.
+ *
+ * <p>This approach is an interim solution for Maven projects
+ * until the open feature request to add formally add artifacts
+ * to a test (ARQ-66) is implementated.</p>
+ *
+ * <p>The testCompile goal will resolve any test dependencies and
+ * put them in your local Maven repository. By the time the test
+ * executes, you can be sure that the JAR files you need will be
+ * in your local repository.</p>
+ *
+ * <p>Example usage:</p>
+ *
+ * <pre>
+ * WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
+ * .addLibrary(MavenArtifactResolver.resolve("commons-lang:commons-lang:2.5"));
+ * </pre>
+ *
+ * @author Dan Allen
+ */
+public class MavenArtifactResolver
+{
+ private static final String LOCAL_MAVEN_REPO =
+ System.getProperty("user.home") + File.separatorChar +
+ ".m2" + File.separatorChar + "repository";
+
+ public static File resolve(String groupId, String artifactId, String version)
+ {
+ return new File(LOCAL_MAVEN_REPO + File.separatorChar +
+ groupId.replace(".", File.separator) + File.separatorChar +
+ artifactId + File.separatorChar +
+ version + File.separatorChar +
+ artifactId + "-" + version + ".jar");
+ }
+
+ public static File resolve(String qualifiedArtifactId)
+ {
+ String[] segments = qualifiedArtifactId.split(":");
+ return resolve(segments[0], segments[1], segments[2]);
+ }
+}
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/resources/arquillian.xml
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/resources/arquillian.xml (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/resources/arquillian.xml 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns="http://jboss.com/arquillian"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jbasmanaged="urn:arq:org.jboss.arquillian.jbossas.local60"
+ xmlns:gfembed="urn:arq:org.jboss.arquillian.glassfish.embedded30"
+ xmlns:gfremote="urn:arq:org.jboss.arquillian.container.glassfish.remote30">
+
+ <!-- Uncomment to have test archives exported to the file system for inspection -->
+ <!--
+ <engine>
+ <deploymentExportPath>/tmp/</deploymentExportPath>
+ </engine>
+ -->
+
+ <jbasmanaged:container>
+ <jbasmanaged:jbossHome>/home/dallen/opt/jboss-as-tests</jbasmanaged:jbossHome>
+ </jbasmanaged:container>
+
+ <gfembed:container>
+ <gfembed:bindHttpPort>7070</gfembed:bindHttpPort>
+ <gfembed:sunResourcesXml>src/test/resources-glassfish-embedded/sun-resources.xml</gfembed:sunResourcesXml>
+ </gfembed:container>
+
+ <gfremote:container>
+ <gfremote:remoteServerHttpPort>7070</gfremote:remoteServerHttpPort>
+ </gfremote:container>
+
+</arquillian>
Property changes on: arquillian/trunk/archetypes/junit-javaee6/src/test/resources/arquillian.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/sun-resources.xml
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/sun-resources.xml (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/sun-resources.xml 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN"
+ "http://www.sun.com/software/appserver/dtds/sun-resources_1_4.dtd">
+<resources>
+ <jdbc-resource pool-name="ArquillianEmbeddedDerbyPool"
+ jndi-name="jdbc/arquillian"/>
+ <jdbc-connection-pool name="ArquillianEmbeddedDerbyPool"
+ res-type="javax.sql.DataSource"
+ datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"
+ is-isolation-level-guaranteed="false">
+ <property name="databaseName" value="target/databases/derby"/>
+ <property name="createDatabase" value="create"/>
+ </jdbc-connection-pool>
+ <!-- Add a database driver JAR to pom.xml to use here -->
+ <!--
+ <jdbc-resource pool-name="ArquillianEmbeddedH2Pool"
+ jndi-name="jdbc/arquillian"/>
+ <jdbc-connection-pool name="ArquillianEmbeddedH2Pool"
+ res-type="javax.sql.DataSource"
+ datasource-classname="org.h2.jdbcx.JdbcDataSource">
+ <property name="user" value="sa"/>
+ <property name="password" value=""/>
+ <property name="url" value="jdbc:h2:file:target/databases/h2/db"/>
+ </jdbc-connection-pool>
+ -->
+</resources>
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/test-persistence.xml
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/test-persistence.xml (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-embedded/test-persistence.xml 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="test">
+ <jta-data-source>jdbc/arquillian</jta-data-source>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="FINE"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-remote/test-persistence.xml
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-remote/test-persistence.xml (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/resources-glassfish-remote/test-persistence.xml 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="test">
+ <!-- EclipseLink does not startup correctly during JSR 88 deployment; use Hibernate instead -->
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>jdbc/__default</jta-data-source>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="FINE"/>
+
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/jndi.properties
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/jndi.properties (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/jndi.properties 2010-06-12 18:57:44 UTC (rev 4514)
@@ -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
Property changes on: arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/jndi.properties
___________________________________________________________________
Name: svn:executable
+ *
Added: arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/test-persistence.xml
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/test-persistence.xml (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6/src/test/resources-jbossas/test-persistence.xml 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="test">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: arquillian/trunk/archetypes/junit-javaee6-archetype.properties
===================================================================
--- arquillian/trunk/archetypes/junit-javaee6-archetype.properties (rev 0)
+++ arquillian/trunk/archetypes/junit-javaee6-archetype.properties 2010-06-12 18:57:44 UTC (rev 4514)
@@ -0,0 +1,6 @@
+archetype.groupId=org.jboss.arquillian.archetype
+archetype.artifactId=arquillian-junit-javaee
+archetype.version=1.0.0-SNAPSHOT
+archetype.languages=java
+archetype.filteredExtensions=java
+projectName=Arquillian JUnit Project
More information about the jboss-svn-commits
mailing list