[weld-commits] Weld SVN: r6489 - in archetypes/branches/prototype: src/main and 12 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Fri Jun 18 20:46:08 EDT 2010


Author: dan.j.allen
Date: 2010-06-18 20:46:07 -0400 (Fri, 18 Jun 2010)
New Revision: 6489

Added:
   archetypes/branches/prototype/archetype.properties
   archetypes/branches/prototype/src/main/java/com/mycompany/JaxRsConfig.java
   archetypes/branches/prototype/src/main/java/com/mycompany/Member.java
   archetypes/branches/prototype/src/main/java/com/mycompany/MemberListProducer.java
   archetypes/branches/prototype/src/main/java/com/mycompany/MemberRegistration.java
   archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepository.java
   archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepositoryProducer.java
   archetypes/branches/prototype/src/main/java/com/mycompany/MemberResource.java
   archetypes/branches/prototype/src/main/java/com/mycompany/Member_.java
   archetypes/branches/prototype/src/main/resources-jbossas/
   archetypes/branches/prototype/src/main/resources-jbossas/default-ds.xml
   archetypes/branches/prototype/src/test/java/com/mycompany/MemberRegistrationTest.java
   archetypes/branches/prototype/src/test/resources-glassfish-embedded/
   archetypes/branches/prototype/src/test/resources-glassfish-embedded/sun-resources.xml
   archetypes/branches/prototype/src/test/resources-glassfish-embedded/test-persistence.xml
   archetypes/branches/prototype/src/test/resources-jbossas/
   archetypes/branches/prototype/src/test/resources-jbossas/jndi.properties
   archetypes/branches/prototype/src/test/resources-jbossas/test-persistence.xml
   archetypes/branches/prototype/src/test/resources/arquillian.xml
Removed:
   archetypes/branches/prototype/src/main/java/com/mycompany/HelloWorld.java
   archetypes/branches/prototype/src/main/java/com/mycompany/Widget.java
   archetypes/branches/prototype/src/main/java/com/mycompany/WidgetListProducer.java
   archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepository.java
   archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepositoryProducer.java
   archetypes/branches/prototype/src/test/java/com/mycompany/HelloWorldTest.java
Modified:
   archetypes/branches/prototype/build.sh
   archetypes/branches/prototype/pom.xml
   archetypes/branches/prototype/readme.txt
   archetypes/branches/prototype/src/main/resources/META-INF/persistence.xml
   archetypes/branches/prototype/src/main/resources/import.sql
   archetypes/branches/prototype/src/main/webapp/WEB-INF/
   archetypes/branches/prototype/src/main/webapp/home.xhtml
   archetypes/branches/prototype/src/main/webapp/resources/css/screen.css
Log:
major refactoring of project
switch from Widget to Member
add Arquillian configuration


Added: archetypes/branches/prototype/archetype.properties
===================================================================
--- archetypes/branches/prototype/archetype.properties	                        (rev 0)
+++ archetypes/branches/prototype/archetype.properties	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,9 @@
+archetype.keepParent=false
+archetype.groupId=org.jboss.weld.archetypes
+archetype.artifactId=weld-basic-javaee6-webapp
+archetype.version=1.0.0-SNAPSHOT
+archetype.package=com.acme.webapp
+archetype.languages=java
+# value of <artifactId> is converted to ${artifactId} expression in filtered files
+archetype.filteredExtensions=java,txt
+name=Java EE 6 project

Modified: archetypes/branches/prototype/build.sh
===================================================================
--- archetypes/branches/prototype/build.sh	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/build.sh	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,6 +1,28 @@
 #!/bin/sh
 
-mvn clean archetype:create-from-project
-mvn -f target/generated-sources/archetype/pom.xml install
+ARCHETYPE_DIR=target/generated-sources/archetype
+ARCHETYPE_RESOURCES_DIR=$ARCHETYPE_DIR/src/main/resources/archetype-resources
 
+echo Generating archetype from project into $ARCHETYPE_DIR...
+mvn clean archetype:create-from-project -Darchetype.properties=archetype.properties
+echo Cleaning generated archetype project...
+mvn -f $ARCHETYPE_DIR/pom.xml clean
+rm -f $ARCHETYPE_RESOURCES_DIR/`basename $0`
+# could also use col -b
+sed -i 's;
+;;' $ARCHETYPE_RESOURCES_DIR/pom.xml
+sed -i 's;
+;;' $ARCHETYPE_RESOURCES_DIR/readme.txt
+sed -i 's;<name>weld-basic-javaee6-webapp</name>;<name>Weld Basic Java EE 6 Webapp</name>;' $ARCHETYPE_DIR/pom.xml
+sed -i 's;<name>weld-basic-javaee6-webapp-src</name>;<name>${name}</name>;' $ARCHETYPE_RESOURCES_DIR/pom.xml
+if [ ! -z $1 ] && [ "$1" = "install" ]; then
+   shift
+   mvn -f $ARCHETYPE_DIR/pom.xml install
+fi
 
+if [ ! -z $1 ] && [ "$1" = "generate" ]; then
+   cd target
+   mvn archetype:generate -B -DarchetypeCatalog=local \
+      -DarchetypeArtifactId=weld-basic-javaee6-webapp -DarchetypeGroupId=org.jboss.weld.archetypes -DarchetypeVersion=1.0.0-SNAPSHOT \
+      -DartifactId=generated-project -DgroupId=com.acme -Dversion=1.0.0-SNAPSHOT -Dname="Java EE 6 Webapp"
+fi

Modified: archetypes/branches/prototype/pom.xml
===================================================================
--- archetypes/branches/prototype/pom.xml	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/pom.xml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -2,16 +2,25 @@
 <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>
+
+   <parent>
+      <groupId>org.jboss.weld</groupId>
+      <artifactId>weld-parent</artifactId>
+      <version>11</version>
+   </parent>
+
    <groupId>org.jboss.weld.archetypes</groupId>
-   <artifactId>javaee6</artifactId>
+   <artifactId>weld-basic-javaee6-webapp-src</artifactId>
+   <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>
-   <name>Java EE 6.0 Archetype</name>
-   <version>1.0.0-SNAPSHOT</version>
 
+   <name>weld-basic-javaee6-webapp-src</name>
+   <description>A basic Java EE 6 webapp project generated from the weld-basic-javaee6-webapp archetype</description>
+
    <properties>
       <!--
-         Explicitly declaring the source encoding eliminates the following message: [WARNING] Using platform encoding
-         (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
+         Explicitly declaring the source encoding eliminates the following message:
+         [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
       -->
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       <!--
@@ -25,12 +34,16 @@
       -->
       <jboss.home>${env.JBOSS_HOME}</jboss.home>
       <jboss.domain>default</jboss.domain>
+      <arquillian.version>1.0.0-SNAPSHOT</arquillian.version>
+      <embedded-glassfish.version>3.0.1-b19</embedded-glassfish.version>
+      <jboss-javaee6-spec.version>1.0.0.Beta5</jboss-javaee6-spec.version>
+      <jboss-as-client.version>6.0.0.20100429-M3</jboss-as-client.version>
    </properties>
 
    <repositories>
-      <!-- Optional Repository.  -->
-      <!-- Soon all required dependencies will be pushed to maven central.  -->
-      <!-- In the mean time, we need to point this archetype to the JBoss Maven Repository  -->
+      <!-- The JBoss public Nexus repository is a composite repository of several major repositories -->
+      <!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
+      <!-- The goal is to get everything you would need into the central, but it's not there yet -->
       <repository>
          <id>jboss-public-repository</id>
          <name>JBoss Repository</name>
@@ -45,24 +58,40 @@
          </snapshots>
       </repository>
    </repositories>
+
    <pluginRepositories>
-      <!-- GlassFish repository required for embedded-glassfish plugin -->
       <pluginRepository>
-         <id>glassfish</id>
-         <name>GlassFish Maven 2 Repository</name>
-         <url>http://download.java.net/maven/glassfish</url>
+         <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>
+            <updatePolicy>daily</updatePolicy>
+         </snapshots>
       </pluginRepository>
    </pluginRepositories>
+
    <dependencies>
+
       <dependency>
-         <groupId>org.jboss.spec</groupId>
-         <artifactId>jboss-javaee-6.0</artifactId>
-         <version>1.0.0-SNAPSHOT</version>
+         <groupId>org.hibernate</groupId>
+         <artifactId>hibernate-jpamodelgen</artifactId>
+         <version>1.0.0.Final</version>
          <scope>provided</scope>
-         <type>pom</type>
+         <exclusions>
+            <exclusion>
+               <groupId>org.hibernate.javax.persistence</groupId>
+               <artifactId>hibernate-jpa-2.0-api</artifactId>
+            </exclusion>
+         </exclusions>
       </dependency>
-      <!-- Bean Validation Implementation -->
-      <!-- Provides portable constraints such as @NotEmpty, @Email and @Url -->
+
+      <!-- JSR-303 (Bean Validation) Implementation -->
+      <!-- Provides portable constraints such as @Email -->
       <!-- Hibernate Validator is the only JSR-303 implementation at the moment, so we can assume it's provided -->
       <dependency>
          <groupId>org.hibernate</groupId>
@@ -71,64 +100,160 @@
          <scope>provided</scope>
       </dependency>
 
-      <!-- Optional, but highly recommended. -->
       <dependency>
-         <groupId>org.testng</groupId>
-         <artifactId>testng</artifactId>
-         <version>5.11</version>
+         <groupId>junit</groupId>
+         <artifactId>junit</artifactId>
+         <version>4.8.1</version>
          <scope>test</scope>
-         <classifier>jdk15</classifier>
       </dependency>
+
+      <dependency>
+         <groupId>org.jboss.arquillian</groupId>
+         <artifactId>arquillian-junit</artifactId>
+         <version>${arquillian.version}</version>
+         <scope>test</scope>
+      </dependency>
+
    </dependencies>
-   <description>Java EE 6.0 Archetype</description>
+
    <build>
-      <finalName>${artifactId}</finalName>
+      <finalName>${project.artifactId}</finalName>
       <plugins>
          <!-- Compiler plugin enforces Java 1.6 compatibility -->
          <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>
+               <!-- Please note you have to compile twice after changing an @Entity class -->
+               <generatedSourcesDirectory>src/main/java</generatedSourcesDirectory>
             </configuration>
          </plugin>
+      </plugins>
+   </build>
 
-         <!-- Eclipse plugin can force download of source and JavaDoc jars -->
-         <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-eclipse-plugin</artifactId>
-            <configuration>
-               <downloadSources>true</downloadSources>
-               <downloadJavadocs>true</downloadJavadocs>
-            </configuration>
-         </plugin>
+   <profiles>
+      <profile>
+         <id>default</id>
+         <activation>
+            <activeByDefault>true</activeByDefault>
+         </activation>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.spec</groupId>
+               <artifactId>jboss-javaee-6.0</artifactId>
+               <version>${jboss-javaee6-spec.version}</version>
+               <type>pom</type>
+               <scope>provided</scope>
+            </dependency>
+         </dependencies>
+         <build>
+            <plugins>
+               <plugin>
+                  <artifactId>maven-surefire-plugin</artifactId>
+                  <version>2.4.3</version>
+                  <configuration>
+                     <skip>true</skip>
+                  </configuration>
+               </plugin>
+               <!-- Configure the JBoss AS Maven deploy plugin -->
+               <plugin>
+                  <groupId>org.codehaus.mojo</groupId>
+                  <artifactId>jboss-maven-plugin</artifactId>
+                  <version>1.4.1-SNAPSHOT</version>
+                  <configuration>
+                     <jbossHome>${jboss.home}</jbossHome>
+                     <serverName>${jboss.domain}</serverName>
+                     <fileNames>
+                        <fileName>src/main/resources-jbossas/default-ds.xml</fileName>
+                        <fileName>${project.build.directory}/${project.build.finalName}.war</fileName>
+                     </fileNames>
+                  </configuration>
+               </plugin>
+            </plugins>
+         </build>
+      </profile>
 
-         <!-- Configure the JBoss AS Maven deploy plugin -->
-         <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>jboss-maven-plugin</artifactId>
-            <configuration>
-               <jbossHome>${jboss.home}</jbossHome>
-               <serverName>${jboss.domain}</serverName>
-               <fileNames>
-                  <fileName>${project.build.directory}/${build.finalName}.war</fileName>
-               </fileNames>
-            </configuration>
-         </plugin>
-                  <!-- Configure the Embedded GlassFish Maven plugin -->
-         <plugin>
-            <groupId>org.glassfish</groupId>
-            <artifactId>maven-embedded-glassfish-plugin</artifactId>
-            <version>3.0</version>
-            <configuration>
-               <app>${expr_start}project.build.directory${expr_end}/${expr_start}build.finalName${expr_end}.war</app>
-               <port>7070</port>
-               <containerType>web</containerType>
-               <instanceRoot>${expr_start}project.build.directory${expr_end}/gfembed${expr_start}maven.build.timestamp${expr_end}</instanceRoot>
-               <autoDelete>true</autoDelete>
-            </configuration>
-         </plugin>
-      </plugins>
-   </build>
+      <profile>
+         <id>glassfish-embedded-30</id>
+         <dependencies>
+            <dependency>
+               <groupId>org.jboss.arquillian.container</groupId>
+               <artifactId>arquillian-glassfish-embedded-30</artifactId>
+               <version>${arquillian.version}</version>
+               <scope>test</scope>
+            </dependency>
+            <dependency>
+               <groupId>org.glassfish.extras</groupId>
+               <artifactId>glassfish-embedded-all</artifactId>
+               <version>3.0.1-b19</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>
+            <plugins>
+               <plugin>
+                  <artifactId>maven-surefire-plugin</artifactId>
+                  <!-- don't use version 2.5 as it creates seperate test suites per class -->
+                  <version>2.4.3</version>
+                  <configuration>
+                     <systemProperties>
+                        <!-- fix an annoyance -->
+                        <property>
+                           <name>derby.stream.error.file</name>
+                           <value>target/derby.log</value>
+                        </property>
+                     </systemProperties>
+                  </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>${arquillian.version}</version>
+               <scope>test</scope>
+            </dependency>
+            <dependency>
+               <groupId>org.jboss.spec</groupId>
+               <artifactId>jboss-javaee-6.0</artifactId>
+               <version>${jboss-javaee6-spec.version}</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>${jboss-as-client.version}</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>
+   </profiles>
 </project>

Modified: archetypes/branches/prototype/readme.txt
===================================================================
--- archetypes/branches/prototype/readme.txt	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/readme.txt	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,7 +1,7 @@
 
-                                 myproject 
+                                 weld-basic-javaee6-webapp-src
 
- Source archetype: weld-jsf-jee
+ Source archetype: weld-basic-javaee6-webapp
 
  What is it?
  ===========
@@ -19,22 +19,20 @@
 
  All you need to run this project is Java 5.0 (Java SDK 1.5) or greator and
  Maven 2.0.10 or greater. This application is setup to be run on a Java EE 6
- certified application server. It has been tested with GlassFish V3 and JBoss
- AS 6.0.
+ application server. We've tested it on GlassFish 3 and JBoss AS 6.0.
 
- If you want to deploy the application to a standalone Servlet Container, then
- you will need to set one up. Alternatively, you can use a Maven command to run
- the application in place on an embedded version of GlassFish V3.
-
- Please note that Maven 2 project needs to use the JBoss Maven repository
+ Please note that Maven 2 project needs to use the JBoss Nexus Maven repository
  because there are certain Java EE API JARs that are not yet publised to the
  Maven Central Repository (see https://jira.jboss.org/jira/browse/WELD-222)
+ The testing framework used by the project, Arquillian, is also only available
+ in the JBoss repository.
 
  Deploying the application
  =========================
 
  To deploy the application to JBoss AS (standalone), first make sure that the
  JBOSS_HOME environment variable points to a JBoss AS 6.0 installation.
+
  Alternatively, you can set the location of JBoss AS using the following
  profile defintion in the .m2/settings.xml file in your home directory:
 
@@ -51,38 +49,42 @@
             <activeByDefault>true</activeByDefault>
          </activation>
          <properties>
-            <jboss.home>/path/to/jboss-as-6.0.0.M1</jboss.home>
+            <jboss.home>/path/to/jboss-as-6.0.0.M3</jboss.home>
          </properties>
       </profile>
    </profiles>
    
 </settings>
 
- You can now deploy to JBoss AS by executing the following command:
+ Once you've set either the JBOSS_HOME environment variable or the jboss.home
+ Maven property, you can deploy to JBoss AS by executing the following command:
 
   mvn package jboss:hard-deploy
 
- Start JBoss AS. The application will be running at the following URL:
+ This will deploy two artifacts, target/weld-basic-javaee6-webapp-src.war and
+ default-ds.xml. The latter installs a data source named jdbc/__default.
 
-  http://localhost:8080/myproject
+ You can also set jboss.home on the commandline:
 
- If you want to deploy to GlassFish V3 (standalone), you first need to change
- the name of the DataSource used by the persistence unit! Open this file:
+  mvn package jboss:hard-deploy -Djboss.home=/path/to/jboss-as-6.0.0.M3
 
-  src/main/resources/META-INF/persistence.xml
+ Start JBoss AS. The application will be running at the following URL:
 
- Change the value of <jta-data-source> to the following:
+  http://localhost:8080/weld-basic-javaee6-webapp-src/home.jsf
 
-  <jta-data-source>jdbc/__default</jta-data-source>
+ Note: If you are using JBoss AS 6.0.0.M3, you may encounter the exception
+ described in https://jira.jboss.org/browse/WELD-448 if you attempt to access
+ to root context path (i.e., /).
+  
+ To undeploy from JBoss AS, run this command:
 
- This configuration uses the built-in default Derby DataSource in GlassFish.
- Optionally, you can use an alternative DataSource of your choice.
- 
- Now, execute the command:
+  mvn jboss:hard-undeploy
 
+ If you want to deploy to GlassFish, first produce the archive to deploy:
+
   mvn package
  
- There are several ways to deploy the archive to GlassFish V3. The recommended
+ There are several ways to deploy the archive to GlassFish. The recommended
  approach is to open the project in NetBeans 6.8, right-click on the project
  and select "Run" from the context menu. That starts JavaDB, GlassFish and
  deploys the application.
@@ -93,10 +95,10 @@
   asadmin start-database
   asadmin start-domain domain1
 
- Now you can either deploy the target/myproject.war through the web-based
+ Now you can either deploy the target/weld-basic-javaee6-webapp-src.war through the web-based
  GlassFish admininstration console, or you can again use asadmin:
 
-  asadmin /path/to/project/target/myproject.war
+  asadmin /path/to/project/target/weld-basic-javaee6-webapp-src.war
 
  Unfortunately, the embedded GlassFish V3 application server does not bootstrap
  the persistence unit(s), so you won't be able to leverage the Maven plugin to
@@ -125,12 +127,23 @@
  Once in the IDE, you can execute the Maven commands through the IDE controls
  to run the application on an embedded Servlet Container.
 
+ Downloading the sources and Javadocs
+ ====================================
+
+ If you want to be able to debug into the source code or look at the Javadocs
+ of any library in the project, you can run either of the following two
+ commands to pull them into your local repository. The IDE should then detect
+ them.
+
+  mvn dependency:sources
+  mvn dependency:resolve -Dclassifier=javadoc
+
  Resources
  =========
 
  Weld archetypes:
  -  Quickstart:        http://seamframework.org/Documentation/WeldQuickstartForMavenUsers
- -  Issue tracker:     https://jira.jboss.org/jira/browse/WELDX
+ -  Issue tracker:     https://jira.jboss.org/jira/browse/WELDRAD
  -  Source code:       http://anonsvn.jboss.org/repos/weld/archetypes
  -  Forums:            http://seamframework.org/Community/WeldUsers
  JSR-299 overview:     http://seamframework.org/Weld

Deleted: archetypes/branches/prototype/src/main/java/com/mycompany/HelloWorld.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/HelloWorld.java	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/HelloWorld.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,74 +0,0 @@
-package com.mycompany;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.inject.Model;
-import javax.validation.constraints.Digits;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
-
-import org.hibernate.validator.constraints.Email;
-import org.hibernate.validator.constraints.NotEmpty;
-
-public @Model class HelloWorld
-{
-   private final String text = "Hello World!";
-
-   private String letters;
-   
-   private String numbers;
-   
-   private String email;
-   
-   public HelloWorld() {}
-
-   @PostConstruct
-   public void initialize()
-   {
-      System.out.println(this.getClass().getSimpleName() + " was constructed");
-   }
-
-   public String getText()
-   {
-      return text;
-   }
-
-   @NotNull
-   @NotEmpty
-   @Pattern(regexp = "[A-Za-z]*", message = "must contain only letters")
-   public String getLetters()
-   {
-      return letters;
-   }
-
-   public void setLetters(String letters)
-   {
-      this.letters = letters;
-   }
-
-   @NotNull
-   @NotEmpty
-   @Digits(fraction = 0, integer = 2)
-   public String getNumbers()
-   {
-      return numbers;
-   }
-
-   public void setNumbers(String numbers)
-   {
-      this.numbers = numbers;
-   }
-
-   @NotNull
-   @NotEmpty
-   @Email
-   public String getEmail()
-   {
-      return email;
-   }
-
-   public void setEmail(String email)
-   {
-      this.email = email;
-   }
-
-}

Added: archetypes/branches/prototype/src/main/java/com/mycompany/JaxRsConfig.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/JaxRsConfig.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/JaxRsConfig.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,7 @@
+package com.mycompany;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+ at ApplicationPath("rest")
+public class JaxRsConfig extends Application {}

Copied: archetypes/branches/prototype/src/main/java/com/mycompany/Member.java (from rev 6481, archetypes/branches/prototype/src/main/java/com/mycompany/Widget.java)
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/Member.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/Member.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,83 @@
+package com.mycompany;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.validation.constraints.Digits;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import org.hibernate.validator.constraints.Email;
+import org.hibernate.validator.constraints.NotEmpty;
+
+ at Entity
+ at XmlRootElement
+ at Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
+public class Member implements Serializable
+{
+   private Long id;
+   private String name;
+   private String email;
+   private String phoneNumber;
+
+   @Id
+   @GeneratedValue
+   public Long getId()
+   {
+      return id;
+   }
+
+   public void setId(Long id)
+   {
+      this.id = id;
+   }
+
+   @NotNull
+   @Size(min = 1, max = 25)
+   @Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   @NotNull
+   @NotEmpty
+   @Email
+   public String getEmail()
+   {
+      return email;
+   }
+
+   public void setEmail(String email)
+   {
+      this.email = email;
+   }
+
+   @NotNull
+   @Size(min = 10, max = 12)
+   @Digits(fraction = 0, integer = 12)
+   @Column(name = "phone_number")
+   public String getPhoneNumber()
+   {
+      return phoneNumber;
+   }
+
+   public void setPhoneNumber(String phoneNumber)
+   {
+      this.phoneNumber = phoneNumber;
+   }
+   
+   /** Default value included to remove warning.  Remove or modify at will.  */  
+   private static final long serialVersionUID = 1L;
+}
\ No newline at end of file

Copied: archetypes/branches/prototype/src/main/java/com/mycompany/MemberListProducer.java (from rev 6481, archetypes/branches/prototype/src/main/java/com/mycompany/WidgetListProducer.java)
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/MemberListProducer.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/MemberListProducer.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,47 @@
+package com.mycompany;
+
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+
+ at RequestScoped
+public class MemberListProducer
+{
+   @Inject
+   @MemberRepository
+   private EntityManager em;
+
+   private List<Member> members;
+
+   @Produces
+   @Named
+   public List<Member> getMembers()
+   {
+      return members;
+   }
+
+   public void onMemberListChanged(@Observes(notifyObserver = Reception.IF_EXISTS) final Member member)
+   {
+      fetch();
+   }
+
+   @PostConstruct
+   public void fetch()
+   {
+      CriteriaBuilder cb = em.getCriteriaBuilder();
+      CriteriaQuery<Member> criteria = cb.createQuery(Member.class);
+      Root<Member> widget = criteria.from(Member.class);
+      criteria.select(widget).orderBy(cb.asc(widget.get(Member_.name)));
+      members = em.createQuery(criteria).getResultList();
+   }
+}

Added: archetypes/branches/prototype/src/main/java/com/mycompany/MemberRegistration.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/MemberRegistration.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/MemberRegistration.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,50 @@
+package com.mycompany;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Model;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.persistence.EntityManager;
+import javax.transaction.UserTransaction;
+
+//@Stateful // enable when JBoss AS M4 is out
+ at Model
+public class MemberRegistration
+{
+   @Inject
+   @MemberRepository
+   private EntityManager em;
+
+   @Inject
+   private UserTransaction utx;
+   
+   private Member newMember;
+
+   @Produces
+   @Named
+   public Member getNewMember()
+   {
+      return newMember;
+   }
+   @Inject
+   private Event<Member> memberEventSrc;
+
+   public void register() throws Exception
+   {
+      System.out.println("Registering " + newMember.getName());
+      utx.begin();
+      em.joinTransaction();
+      em.persist(newMember);
+      utx.commit();
+      memberEventSrc.fire(newMember);
+      initNewMember();
+   }
+
+   @PostConstruct
+   public void initNewMember()
+   {
+      newMember = new Member();
+   }
+}

Copied: archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepository.java (from rev 6481, archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepository.java)
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepository.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepository.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,16 @@
+package com.mycompany;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * A qualifier used to differentiate between multiple data repositories
+ */
+ at Qualifier
+ at Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface MemberRepository {}

Copied: archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepositoryProducer.java (from rev 6481, archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepositoryProducer.java)
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepositoryProducer.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/MemberRepositoryProducer.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,13 @@
+package com.mycompany;
+
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class MemberRepositoryProducer
+{
+   @Produces
+   @MemberRepository
+   @PersistenceContext
+   private EntityManager em;
+}

Added: archetypes/branches/prototype/src/main/java/com/mycompany/MemberResource.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/MemberResource.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/MemberResource.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,30 @@
+package com.mycompany;
+
+import java.util.List;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+ at Path("/members")
+ at RequestScoped
+public class MemberResource
+{
+   @Inject @MemberRepository
+   private EntityManager em;
+
+   @GET
+   public List<Member> getMembers()
+   {
+      return em.createQuery("select m from Member m order by m.name").getResultList();
+   }
+
+   @GET
+   @Path("/{id:[1-9][0-9]*}")
+   public Member getMember(@PathParam("id") long id)
+   {
+      return em.find(Member.class, id);
+   }
+}

Added: archetypes/branches/prototype/src/main/java/com/mycompany/Member_.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/Member_.java	                        (rev 0)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/Member_.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,15 @@
+package com.mycompany;
+
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.StaticMetamodel;
+
+ at StaticMetamodel(Member.class)
+public abstract class Member_ {
+
+	public static volatile SingularAttribute<Member, Long> id;
+	public static volatile SingularAttribute<Member, String> phoneNumber;
+	public static volatile SingularAttribute<Member, String> email;
+	public static volatile SingularAttribute<Member, String> name;
+
+}
+

Deleted: archetypes/branches/prototype/src/main/java/com/mycompany/Widget.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/Widget.java	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/Widget.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,64 +0,0 @@
-package com.mycompany;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
- at Entity
-public class Widget implements Serializable
-{
-   private Long id;
-   private String partNumber;
-   private String name;
-   private String description;
-
-   @Id
-   @GeneratedValue
-   public Long getId()
-   {
-      return id;
-   }
-
-   public void setId(Long id)
-   {
-      this.id = id;
-   }
-
-   // demonstrates a column name override
-   @Column(name = "partno")
-   public String getPartNumber()
-   {
-      return partNumber;
-   }
-
-   public void setPartNumber(String partNumber)
-   {
-      this.partNumber = partNumber;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   public String getDescription()
-   {
-      return description;
-   }
-
-   public void setDescription(String description)
-   {
-      this.description = description;
-   }
-   
-   /** Default value included to remove warning.  Remove or modify at will.  */  
-   private static final long serialVersionUID = 1L;
-}
\ No newline at end of file

Deleted: archetypes/branches/prototype/src/main/java/com/mycompany/WidgetListProducer.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/WidgetListProducer.java	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/WidgetListProducer.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,22 +0,0 @@
-package com.mycompany;
-
-import java.util.List;
-
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.persistence.EntityManager;
-
-public class WidgetListProducer
-{
-   @Inject @WidgetRepository EntityManager widgetRepository;
-   
-   @Produces
-   @Named
-   @RequestScoped
-   @SuppressWarnings("unchecked")
-   List<Widget> getWidgets() {
-      return widgetRepository.createQuery("select w from Widget w order by w.name").getResultList();
-   }
-}

Deleted: archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepository.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepository.java	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepository.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,13 +0,0 @@
-package com.mycompany;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
- at Qualifier
- at Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
- at Retention(RetentionPolicy.RUNTIME)
-public @interface WidgetRepository {}

Deleted: archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepositoryProducer.java
===================================================================
--- archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepositoryProducer.java	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/java/com/mycompany/WidgetRepositoryProducer.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,19 +0,0 @@
-package com.mycompany;
-
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.Disposes;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-public class WidgetRepositoryProducer
-{
-   // NOTE cannot use producer field because Weld attempts to close EntityManager
-   // https://jira.jboss.org/jira/browse/WELD-341
-   @PersistenceContext EntityManager em;
-
-   public @Produces @WidgetRepository EntityManager retrieveEntityManager() {
-      return em;
-   }
-
-   public void disposeEntityManager(@Disposes @WidgetRepository EntityManager em) {}
-}

Modified: archetypes/branches/prototype/src/main/resources/META-INF/persistence.xml
===================================================================
--- archetypes/branches/prototype/src/main/resources/META-INF/persistence.xml	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/resources/META-INF/persistence.xml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,34 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<persistence version="1.0"
+<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_1_0.xsd">
-   <persistence-unit name="widgets">
+      http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+   <persistence-unit name="primary">
       <!-- You can force a non-default JPA provider using one of these declarations -->
       <!--
-      <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+      <provider>org.hibernate.ejb.HibernatePersistence</provider>
       -->
 
-      <!-- Use this data source name for JBoss AS -->
-      <jta-data-source>java:/DefaultDS</jta-data-source>
-      <!-- Use this data source name for Glassfish -->
-      <!--
+      <!-- jdbc/__default is the default data source in GlassFish -->
+      <!-- The same data source is added to JBoss AS by deploying the project file default-ds.xml -->
       <jta-data-source>jdbc/__default</jta-data-source>
-      -->
       <properties>
          <!-- Properties for Hibernate (default provider for JBoss AS) -->
          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
          <property name="hibernate.show_sql" value="true"/>
          <property name="hibernate.format_sql" value="false"/>
-         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
 
          <!-- Properties for EclipseLink (default provider for GlassFish) -->
          <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
          <property name="eclipselink.logging.level" value="FINE"/>
-
       </properties>
    </persistence-unit>
 </persistence>

Modified: archetypes/branches/prototype/src/main/resources/import.sql
===================================================================
--- archetypes/branches/prototype/src/main/resources/import.sql	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/resources/import.sql	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1 +1 @@
-insert into Widget (id, partno, name, description) values (1, 'AAA001', 'Portable Hole', 'A hole for when you need to disappear fast.')
+insert into Member (name, email, phone_number) values ('John Smith', 'john at mailinator.com', '2125551212')

Added: archetypes/branches/prototype/src/main/resources-jbossas/default-ds.xml
===================================================================
--- archetypes/branches/prototype/src/main/resources-jbossas/default-ds.xml	                        (rev 0)
+++ archetypes/branches/prototype/src/main/resources-jbossas/default-ds.xml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE datasources PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+   "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+<datasources>
+   <local-tx-datasource>
+      <jndi-name>jdbc/__default</jndi-name>
+      <use-java-context>false</use-java-context>
+      <connection-url>jdbc:hsqldb:.</connection-url>
+      <driver-class>org.hsqldb.jdbcDriver</driver-class>
+      <user-name>sa</user-name>
+      <password></password>
+      <min-pool-size>5</min-pool-size>
+      <max-pool-size>20</max-pool-size>
+   </local-tx-datasource>
+</datasources>


Property changes on: archetypes/branches/prototype/src/main/webapp/WEB-INF
___________________________________________________________________
Name: svn:ignore
   + sun-web.xml


Modified: archetypes/branches/prototype/src/main/webapp/home.xhtml
===================================================================
--- archetypes/branches/prototype/src/main/webapp/home.xhtml	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/webapp/home.xhtml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -5,63 +5,64 @@
    xmlns:h="http://java.sun.com/jsf/html"
    template="/WEB-INF/templates/default.xhtml">
    <ui:define name="content">
-      <h1>Hello World!</h1>
-      <p>Your CDI bean <code>HelloWorld</code> says <span style="color: blue;">#{helloWorld.text}</span> using the Unified EL.</p>
+      <h1>Welcome to Java EE 6!</h1>
 
-      <h:form id="bv">
-         <h2>Bean Validation examples</h2>
+      <p>You have successfully deployed a Java EE 6 web application.</p>
+
+      <h:form id="reg">
+         <h2>Register (Bean Validation example)</h2>
          <p>Enforces annotation-based constraints defined on the model class.</p>
          <table>
             <tr>
                <th style="text-align: right;">
-                  <h:outputLabel for="letters" value="Letters:"/>
+                  <h:outputLabel for="name" value="Name:"/>
                </th>
                <td>
-                  <h:inputText id="letters" value="#{helloWorld.letters}"/>
-                  <h:message for="letters" errorClass="invalid"/>
+                  <h:inputText id="name" value="#{newMember.name}"/>
+                  <h:message for="name" errorClass="invalid"/>
                </td>
             </tr>
             <tr>
                <th style="text-align: right;">
-                  <h:outputLabel for="numbers" value="Numbers:"/>
+                  <h:outputLabel for="email" value="Email:"/>
                </th>
                <td>
-                  <h:inputText id="numbers" value="#{helloWorld.numbers}"/>
-                  <h:message for="numbers" errorClass="invalid"/>
+                  <h:inputText id="email" value="#{newMember.email}"/>
+                  <h:message for="email" errorClass="invalid"/>
                </td>
             </tr>
             <tr>
                <th style="text-align: right;">
-                  <h:outputLabel for="email" value="Email:"/>
+                  <h:outputLabel for="phoneNumber" value="Phone #:"/>
                </th>
                <td>
-                  <h:inputText id="email" value="#{helloWorld.email}"/>
-                  <h:message for="email" errorClass="invalid"/>
+                  <h:inputText id="phoneNumber" value="#{newMember.phoneNumber}"/>
+                  <h:message for="phoneNumber" errorClass="invalid"/>
                </td>
             </tr>
          </table>
          <p>
-            <h:commandButton id="check" action="check" value="Check values"/>
-            <h:outputText value=" All clear!" rendered="#{facesContext.postback and empty facesContext.messageList}" style="color: green;"/>
+            <h:commandButton id="register" action="#{memberRegistration.register}" value="Register"/>
+            <h:outputText value=" Registered!" rendered="#{facesContext.postback and empty facesContext.messageList}" style="color: green;"/>
          </p>
       </h:form>
-      <h2>Widgets</h2>
-      <h:dataTable var="_widget" value="#{widgets}">
+      <h2>Members</h2>
+      <h:dataTable var="_member" value="#{members}">
          <h:column>
             <f:facet name="header">Id</f:facet>
-            #{_widget.id}
+            #{_member.id}
          </h:column>
          <h:column>
-            <f:facet name="header">Part Number</f:facet>
-            #{_widget.partNumber}
+            <f:facet name="header">Name</f:facet>
+            #{_member.name}
          </h:column>
          <h:column>
-            <f:facet name="header">Name</f:facet>
-            #{_widget.name}
+            <f:facet name="header">Email</f:facet>
+            #{_member.email}
          </h:column>
          <h:column>
-            <f:facet name="header">Description</f:facet>
-            #{_widget.description}
+            <f:facet name="header">Phone #</f:facet>
+            #{_member.phoneNumber}
          </h:column>
       </h:dataTable>
    </ui:define>

Modified: archetypes/branches/prototype/src/main/webapp/resources/css/screen.css
===================================================================
--- archetypes/branches/prototype/src/main/webapp/resources/css/screen.css	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/main/webapp/resources/css/screen.css	2010-06-19 00:46:07 UTC (rev 6489)
@@ -29,6 +29,7 @@
    text-align: center;
    color: #666666;
    font-size: 0.85em;
+   padding: 3em 0 0 0;
 }
 code {
    font-size: 1.1em;
@@ -36,4 +37,4 @@
 span.invalid {
    padding-left: 3px;
    color: red;
-}
\ No newline at end of file
+}

Deleted: archetypes/branches/prototype/src/test/java/com/mycompany/HelloWorldTest.java
===================================================================
--- archetypes/branches/prototype/src/test/java/com/mycompany/HelloWorldTest.java	2010-06-18 18:09:16 UTC (rev 6488)
+++ archetypes/branches/prototype/src/test/java/com/mycompany/HelloWorldTest.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -1,12 +0,0 @@
-package com.mycompany;
-
-import org.testng.annotations.Test;
-
-public class HelloWorldTest
-{
-   @Test
-   public void testGetText() {
-      HelloWorld fixture = new HelloWorld();
-      assert "Hello World!".equals(fixture.getText());
-   }
-}

Added: archetypes/branches/prototype/src/test/java/com/mycompany/MemberRegistrationTest.java
===================================================================
--- archetypes/branches/prototype/src/test/java/com/mycompany/MemberRegistrationTest.java	                        (rev 0)
+++ archetypes/branches/prototype/src/test/java/com/mycompany/MemberRegistrationTest.java	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,38 @@
+package com.mycompany;
+
+import static org.junit.Assert.*;
+import javax.inject.Inject;
+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.WebArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class MemberRegistrationTest
+{
+   @Deployment
+   public static Archive<?> createTestArchive() {
+      return ShrinkWrap.create("test.war", WebArchive.class)
+         .addClasses(Member.class, MemberRegistration.class, MemberRepository.class, MemberRepositoryProducer.class)
+         .addWebResource("test-persistence.xml", "classes/META-INF/persistence.xml")
+         .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+   }
+
+   @Inject MemberRegistration memberRegistration;
+
+   @Test
+   public void testRegister() throws Exception
+   {
+      Member newMember = memberRegistration.getNewMember();
+      newMember.setName("Jane Doe");
+      newMember.setEmail("jane at mailinator.com");
+      newMember.setPhoneNumber("2125551234");
+      memberRegistration.register();
+      assertNotNull(newMember.getId());
+      System.out.println(newMember.getName() + " was persisted with id " + newMember.getId());
+   }
+}

Added: archetypes/branches/prototype/src/test/resources/arquillian.xml
===================================================================
--- archetypes/branches/prototype/src/test/resources/arquillian.xml	                        (rev 0)
+++ archetypes/branches/prototype/src/test/resources/arquillian.xml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -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>

Added: archetypes/branches/prototype/src/test/resources-glassfish-embedded/sun-resources.xml
===================================================================
--- archetypes/branches/prototype/src/test/resources-glassfish-embedded/sun-resources.xml	                        (rev 0)
+++ archetypes/branches/prototype/src/test/resources-glassfish-embedded/sun-resources.xml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,14 @@
+<?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>
+</resources>

Added: archetypes/branches/prototype/src/test/resources-glassfish-embedded/test-persistence.xml
===================================================================
--- archetypes/branches/prototype/src/test/resources-glassfish-embedded/test-persistence.xml	                        (rev 0)
+++ archetypes/branches/prototype/src/test/resources-glassfish-embedded/test-persistence.xml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -0,0 +1,16 @@
+<?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="primary">
+      <jta-data-source>jdbc/arquillian</jta-data-source>
+      <properties>
+         <!-- Properties for EclipseLink (default provider for GlassFish) -->
+         <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+         <property name="eclipselink.logging.level" value="FINE"/>
+      </properties>
+   </persistence-unit>
+</persistence>

Added: archetypes/branches/prototype/src/test/resources-jbossas/jndi.properties
===================================================================
--- archetypes/branches/prototype/src/test/resources-jbossas/jndi.properties	                        (rev 0)
+++ archetypes/branches/prototype/src/test/resources-jbossas/jndi.properties	2010-06-19 00:46:07 UTC (rev 6489)
@@ -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 

Added: archetypes/branches/prototype/src/test/resources-jbossas/test-persistence.xml
===================================================================
--- archetypes/branches/prototype/src/test/resources-jbossas/test-persistence.xml	                        (rev 0)
+++ archetypes/branches/prototype/src/test/resources-jbossas/test-persistence.xml	2010-06-19 00:46:07 UTC (rev 6489)
@@ -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="primary">
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <properties>
+         <!-- Properties for Hibernate (default provider for JBoss AS) -->
+         <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+         <property name="hibernate.show_sql" value="true"/>
+         <property name="hibernate.format_sql" value="false"/>
+      </properties>
+   </persistence-unit>
+</persistence>



More information about the weld-commits mailing list