• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

group of test apps


Commit MetaInfo

Revisionc5fd1f674a28ff13decaa4334fcd17ac4e6d4ca4 (tree)
Time2014-01-29 12:16:59
Authorastoria-d <astoria-d@mail...>
Commiterastoria-d

Log Message

added maven test projects

Change Summary

Incremental Difference

--- /dev/null
+++ b/jboss-mvn-test3/.factorypath
@@ -0,0 +1,5 @@
1+<factorypath>
2+ <factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="true" runInBatchMode="false"/>
3+ <factorypathentry kind="VARJAR" id="M2_REPO/org/hibernate/hibernate-jpamodelgen/1.1.1.Final/hibernate-jpamodelgen-1.1.1.Final.jar" enabled="true" runInBatchMode="false"/>
4+ <factorypathentry kind="VARJAR" id="M2_REPO/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0.Final/hibernate-jpa-2.0-api-1.0.0.Final.jar" enabled="true" runInBatchMode="false"/>
5+</factorypath>
--- /dev/null
+++ b/jboss-mvn-test3/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,4 @@
1+eclipse.preferences.version=1
2+org.eclipse.jdt.apt.aptEnabled=false
3+org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations
4+org.eclipse.jdt.apt.reconcileEnabled=true
--- /dev/null
+++ b/jboss-mvn-test3/pom.xml
@@ -0,0 +1,300 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<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">
3+ <modelVersion>4.0.0</modelVersion>
4+
5+ <groupId>com.mastertheboss</groupId>
6+ <artifactId>jboss-mvn-test3</artifactId>
7+ <version>1.0-SNAPSHOT</version>
8+ <packaging>war</packaging>
9+
10+ <name>Java EE 6 webapp project</name>
11+ <description>A starter Java EE 6 webapp project for use on JBoss AS 7, generated from the jboss-javaee6-webapp archetype</description>
12+
13+ <properties>
14+ <!-- Explicitly declaring the source encoding eliminates the following
15+ message: -->
16+ <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
17+ resources, i.e. build is platform dependent! -->
18+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+ <!-- Timestamp format for the maven.build.timestamp property -->
20+ <!-- You can reference property in pom.xml or filtered resources (must
21+ enable third-party plugin if using Maven < 2.1) -->
22+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
23+ <!-- Specify the JBoss AS directory to be the JBOSS_HOME environment
24+ variable -->
25+ <jboss.home>${env.JBOSS_HOME}</jboss.home>
26+ </properties>
27+
28+ <dependencyManagement>
29+ <dependencies>
30+ <!-- Define the version of JBoss' Java EE 6 APIs we want to import.
31+ Any dependencies from org.jboss.spec will have their version defined by this
32+ BOM -->
33+ <!-- JBoss distributes a complete set of Java EE 6 APIs including
34+ a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or
35+ a collection) of artifacts. We use this here so that we always get the correct
36+ versions of artifacts. Here we use the jboss-javaee-web-6.0 stack (you can
37+ read this as the JBoss stack of the Java EE Web Profile 6 APIs), and we use
38+ version 2.0.0.Beta1 which is the latest release of the stack. You can actually
39+ use this stack with any version of JBoss AS that implements Java EE 6, not
40+ just JBoss AS 7! -->
41+ <dependency>
42+ <groupId>org.jboss.spec</groupId>
43+ <artifactId>jboss-javaee-web-6.0</artifactId>
44+ <version>2.0.0.Final</version>
45+ <type>pom</type>
46+ <scope>import</scope>
47+ </dependency>
48+ </dependencies>
49+ </dependencyManagement>
50+
51+ <dependencies>
52+
53+ <!-- First declare the APIs we depend on and need for compilation.
54+ All of them are provided by JBoss AS 7 -->
55+
56+ <!-- Import the CDI API, we use provided scope as the API is included
57+ in JBoss AS 7 -->
58+ <dependency>
59+ <groupId>javax.enterprise</groupId>
60+ <artifactId>cdi-api</artifactId>
61+ <scope>provided</scope>
62+ </dependency>
63+
64+ <!-- Import the Common Annotations API (JSR-250), we use provided scope
65+ as the API is included in JBoss AS 7 -->
66+ <dependency>
67+ <groupId>org.jboss.spec.javax.annotation</groupId>
68+ <artifactId>jboss-annotations-api_1.1_spec</artifactId>
69+ <scope>provided</scope>
70+ </dependency>
71+
72+ <!-- Import the JAX-RS API, we use provided scope as the API is included
73+ in JBoss AS 7 -->
74+ <dependency>
75+ <groupId>org.jboss.spec.javax.ws.rs</groupId>
76+ <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
77+ <scope>provided</scope>
78+ </dependency>
79+
80+ <!-- Import the JPA API, we use provided scope as the API is included
81+ in JBoss AS 7 -->
82+ <dependency>
83+ <groupId>org.hibernate.javax.persistence</groupId>
84+ <artifactId>hibernate-jpa-2.0-api</artifactId>
85+ <scope>provided</scope>
86+ </dependency>
87+
88+ <!-- Import the EJB API, we use provided scope as the API is included
89+ in JBoss AS 7 -->
90+ <dependency>
91+ <groupId>org.jboss.spec.javax.ejb</groupId>
92+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
93+ <scope>provided</scope>
94+ </dependency>
95+
96+ <!-- JSR-303 (Bean Validation) Implementation -->
97+ <!-- Provides portable constraints such as @Email -->
98+ <!-- Hibernate Validator is shipped in JBoss AS 7 -->
99+ <dependency>
100+ <groupId>org.hibernate</groupId>
101+ <artifactId>hibernate-validator</artifactId>
102+ <version>4.2.0.Final</version>
103+ <scope>provided</scope>
104+ <exclusions>
105+ <exclusion>
106+ <groupId>org.slf4j</groupId>
107+ <artifactId>slf4j-api</artifactId>
108+ </exclusion>
109+ </exclusions>
110+ </dependency>
111+
112+ <!-- Now we declare any tools needed -->
113+
114+ <!-- Annotation processor to generate the JPA 2.0 metamodel classes
115+ for typesafe criteria queries -->
116+ <dependency>
117+ <groupId>org.hibernate</groupId>
118+ <artifactId>hibernate-jpamodelgen</artifactId>
119+ <version>1.1.1.Final</version>
120+ <scope>provided</scope>
121+ </dependency>
122+
123+ <!-- Needed for running tests (you may also use TestNG) -->
124+ <dependency>
125+ <groupId>junit</groupId>
126+ <artifactId>junit</artifactId>
127+ <version>4.10</version>
128+ <scope>test</scope>
129+ </dependency>
130+
131+ <!-- Optional, but highly recommended -->
132+ <!-- Arquillian allows you to test enterprise code such as EJBs and
133+ Transactional(JTA) JPA from JUnit/TestNG -->
134+ <dependency>
135+ <groupId>org.jboss.arquillian.junit</groupId>
136+ <artifactId>arquillian-junit-container</artifactId>
137+ <version>1.0.0.CR4</version>
138+ <scope>test</scope>
139+ </dependency>
140+
141+ </dependencies>
142+
143+ <build>
144+ <!-- Maven will append the version to the finalName (which is the name
145+ given to the generated war, and hence the context root) -->
146+ <finalName>${project.artifactId}</finalName>
147+ <plugins>
148+ <!-- Compiler plugin enforces Java 1.6 compatibility and activates
149+ annotation processors -->
150+ <plugin>
151+ <artifactId>maven-compiler-plugin</artifactId>
152+ <version>2.3.1</version>
153+ <configuration>
154+ <source>1.6</source>
155+ <target>1.6</target>
156+ </configuration>
157+ </plugin>
158+ <plugin>
159+ <artifactId>maven-war-plugin</artifactId>
160+ <version>2.1.1</version>
161+ <configuration>
162+ <!-- Java EE 6 doesn't require web.xml, Maven needs to catch
163+ up! -->
164+ <failOnMissingWebXml>false</failOnMissingWebXml>
165+ </configuration>
166+ </plugin>
167+ <!-- The JBoss AS plugin deploys your war to a local JBoss AS container -->
168+ <!-- To use, set the JBOSS_HOME environment variable and run: mvn
169+ package jboss-as:deploy -->
170+ <plugin>
171+ <groupId>org.jboss.as.plugins</groupId>
172+ <artifactId>jboss-as-maven-plugin</artifactId>
173+ <version>7.1.0.Final</version>
174+ </plugin>
175+ </plugins>
176+ </build>
177+
178+ <profiles>
179+ <profile>
180+ <!-- The default profile skips all tests, though you can tune it
181+ to run just unit tests based on a custom pattern -->
182+ <!-- Seperate profiles are provided for running all tests, including
183+ Arquillian tests that execute in the specified container -->
184+ <id>default</id>
185+ <activation>
186+ <activeByDefault>true</activeByDefault>
187+ </activation>
188+ <build>
189+ <plugins>
190+ <plugin>
191+ <artifactId>maven-surefire-plugin</artifactId>
192+ <version>2.4.3</version>
193+ <configuration>
194+ <skip>true</skip>
195+ </configuration>
196+ </plugin>
197+ </plugins>
198+ </build>
199+ </profile>
200+
201+ <profile>
202+ <!-- We add the JBoss repository as we need the JBoss AS connectors
203+ for Arquillian -->
204+ <repositories>
205+ <!-- The JBoss Community public repository is a composite repository
206+ of several major repositories -->
207+ <!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
208+ <repository>
209+ <id>jboss-public-repository</id>
210+ <name>JBoss Repository</name>
211+ <url>http://repository.jboss.org/nexus/content/groups/public</url>
212+ <!-- These optional flags are designed to speed up your builds
213+ by reducing remote server calls -->
214+ <releases>
215+ </releases>
216+ <snapshots>
217+ <enabled>false</enabled>
218+ </snapshots>
219+ </repository>
220+ </repositories>
221+
222+ <pluginRepositories>
223+ <pluginRepository>
224+ <id>jboss-public-repository</id>
225+ <name>JBoss Repository</name>
226+ <url>http://repository.jboss.org/nexus/content/groups/public</url>
227+ <releases>
228+ </releases>
229+ <snapshots>
230+ <enabled>false</enabled>
231+ </snapshots>
232+ </pluginRepository>
233+ </pluginRepositories>
234+
235+ <!-- An optional Arquillian testing profile that executes tests
236+ in your JBoss AS instance -->
237+ <!-- This profile will start a new JBoss AS instance, and execute
238+ the test, shutting it down when done -->
239+ <!-- Run with: mvn clean test -Parq-jbossas-managed -->
240+ <id>arq-jbossas-managed</id>
241+ <dependencies>
242+ <dependency>
243+ <groupId>org.jboss.as</groupId>
244+ <artifactId>jboss-as-arquillian-container-managed</artifactId>
245+ <version>7.0.2.Final</version>
246+ <scope>test</scope>
247+ </dependency>
248+ </dependencies>
249+ </profile>
250+
251+ <profile>
252+ <!-- We add the JBoss repository as we need the JBoss AS connectors
253+ for Arquillian -->
254+ <repositories>
255+ <!-- The JBoss Community public repository is a composite repository
256+ of several major repositories -->
257+ <!-- see http://community.jboss.org/wiki/MavenGettingStarted-Users -->
258+ <repository>
259+ <id>jboss-public-repository</id>
260+ <name>JBoss Repository</name>
261+ <url>http://repository.jboss.org/nexus/content/groups/public</url>
262+ <!-- These optional flags are designed to speed up your builds
263+ by reducing remote server calls -->
264+ <releases>
265+ </releases>
266+ <snapshots>
267+ <enabled>false</enabled>
268+ </snapshots>
269+ </repository>
270+ </repositories>
271+
272+ <pluginRepositories>
273+ <pluginRepository>
274+ <id>jboss-public-repository</id>
275+ <name>JBoss Repository</name>
276+ <url>http://repository.jboss.org/nexus/content/groups/public</url>
277+ <releases>
278+ </releases>
279+ <snapshots>
280+ <enabled>false</enabled>
281+ </snapshots>
282+ </pluginRepository>
283+ </pluginRepositories>
284+
285+ <!-- An optional Arquillian testing profile that executes tests
286+ in a remote JBoss AS instance -->
287+ <!-- Run with: mvn clean test -Parq-jbossas-remote -->
288+ <id>arq-jbossas-remote</id>
289+ <dependencies>
290+ <dependency>
291+ <groupId>org.jboss.as</groupId>
292+ <artifactId>jboss-as-arquillian-container-remote</artifactId>
293+ <version>7.0.2.Final</version>
294+ <scope>test</scope>
295+ </dependency>
296+ </dependencies>
297+ </profile>
298+
299+ </profiles>
300+</project>
--- /dev/null
+++ b/jboss-mvn-test3/readme.html
@@ -0,0 +1,63 @@
1+<h1>jboss-mvn-test3</h1>
2+<h2>What is it?</h2>
3+<p>This is your project! It's a sample, deployable Maven 3 project to help you
4+get your foot in the door developing with Java EE 6 on JBoss AS 7. This
5+project is setup to allow you to create a compliant Java EE 6 application
6+using JSF 2.0, CDI 1.0, EJB 3.1, JPA 2.0 and Bean Validation 1.0. It includes
7+a persistence unit and some sample persistence and transaction code to help
8+you get your feet wet with database access in enterprise Java. </p>
9+<h2>System requirements</h2>
10+<p>All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven
11+3.0 or better.</p>
12+<p>The application this project produces is designed to be run on a JBoss AS 7. </p>
13+<p>NOTE:
14+This project retrieves some artifacts from the JBoss Community Maven repository.</p>
15+<p>With the prerequisites out of the way, you're ready to build and deploy.</p>
16+<h2>Deploying the application</h2>
17+<p>First you need to start JBoss AS 7. To do this, run</p>
18+<pre><code>$JBOSS_HOME/bin/standalone.sh
19+</code></pre>
20+<p>or if you are using windows</p>
21+<pre><code>$JBOSS_HOME/bin/standalone.bat
22+</code></pre>
23+<p>To deploy the application, you first need to produce the archive to deploy using
24+the following Maven goal:</p>
25+<pre><code>mvn package
26+</code></pre>
27+<p>You can now deploy the artifact to JBoss AS by executing the following command:</p>
28+<pre><code>mvn jboss-as:deploy
29+</code></pre>
30+<p>This will deploy <code>target/jboss-mvn-test3.war</code>.</p>
31+<p>The application will be running at the following URL <a href="http://localhost:8080/jboss-mvn-test3/">http://localhost:8080/jboss-mvn-test3/</a>.</p>
32+<p>To undeploy from JBoss AS, run this command:</p>
33+<pre><code>mvn jboss-as:undeploy
34+</code></pre>
35+<p>You can also start JBoss AS 7 and deploy the project using Eclipse. See the JBoss AS 7
36+Getting Started Guide for Developers for more information.</p>
37+<h1>Running the Arquillian tests</h1>
38+<p>By default, tests are configured to be skipped. The reason is that the sample
39+test is an Arquillian test, which requires the use of a container. You can
40+activate this test by selecting one of the container configuration provided
41+for JBoss AS 7 (remote).</p>
42+<p>To run the test in JBoss AS 7, first start a JBoss AS 7 instance. Then, run the
43+test goal with the following profile activated:</p>
44+<pre><code>mvn clean test -Parq-jbossas-remote
45+</code></pre>
46+<h1>Importing the project into an IDE</h1>
47+<p>If you created the project using the Maven archetype wizard in your IDE
48+(Eclipse, NetBeans or IntelliJ IDEA), then there is nothing to do. You should
49+already have an IDE project.</p>
50+<p>If you created the project from the commandline using archetype:generate, then
51+you need to import the project into your IDE. If you are using NetBeans 6.8 or
52+IntelliJ IDEA 9, then all you have to do is open the project as an existing
53+project. Both of these IDEs recognize Maven projects natively.</p>
54+<p>Detailed instructions for using Eclipse with JBoss AS 7 are provided in the
55+JBoss AS 7 Getting Started Guide for Developers.</p>
56+<h1>Downloading the sources and Javadocs</h1>
57+<p>If you want to be able to debug into the source code or look at the Javadocs
58+of any library in the project, you can run either of the following two
59+commands to pull them into your local repository. The IDE should then detect
60+them.</p>
61+<pre><code>mvn dependency:sources
62+mvn dependency:resolve -Dclassifier=javadoc
63+</code></pre>
\ No newline at end of file
--- /dev/null
+++ b/jboss-mvn-test3/src/main/java/com/mastertheboss/controller/MemberRegistration.java
@@ -0,0 +1,53 @@
1+package com.mastertheboss.controller;
2+
3+import java.util.logging.Logger;
4+
5+import javax.annotation.PostConstruct;
6+import javax.ejb.Stateful;
7+import javax.enterprise.event.Event;
8+import javax.enterprise.inject.Model;
9+import javax.enterprise.inject.Produces;
10+import javax.inject.Inject;
11+import javax.inject.Named;
12+import javax.persistence.EntityManager;
13+
14+import com.mastertheboss.model.Member;
15+
16+// The @Stateful annotation eliminates the need for manual transaction demarcation
17+@Stateful
18+// The @Model stereotype is a convenience mechanism to make this a request-scoped bean that has an
19+// EL name
20+// Read more about the @Model stereotype in this FAQ:
21+// http://sfwk.org/Documentation/WhatIsThePurposeOfTheModelAnnotation
22+@Model
23+public class MemberRegistration {
24+
25+ @Inject
26+ private Logger log;
27+
28+ @Inject
29+ private EntityManager em;
30+
31+ @Inject
32+ private Event<Member> memberEventSrc;
33+
34+ private Member newMember;
35+
36+ @Produces
37+ @Named
38+ public Member getNewMember() {
39+ return newMember;
40+ }
41+
42+ public void register() throws Exception {
43+ log.info("Registering " + newMember.getName());
44+ em.persist(newMember);
45+ memberEventSrc.fire(newMember);
46+ initNewMember();
47+ }
48+
49+ @PostConstruct
50+ public void initNewMember() {
51+ newMember = new Member();
52+ }
53+}
--- /dev/null
+++ b/jboss-mvn-test3/src/main/java/com/mastertheboss/data/MemberListProducer.java
@@ -0,0 +1,48 @@
1+package com.mastertheboss.data;
2+
3+import com.mastertheboss.model.Member;
4+import java.util.List;
5+import javax.annotation.PostConstruct;
6+import javax.enterprise.context.RequestScoped;
7+import javax.enterprise.event.Observes;
8+import javax.enterprise.event.Reception;
9+
10+import javax.enterprise.inject.Produces;
11+import javax.inject.Inject;
12+import javax.inject.Named;
13+import javax.persistence.EntityManager;
14+import javax.persistence.criteria.CriteriaBuilder;
15+import javax.persistence.criteria.CriteriaQuery;
16+import javax.persistence.criteria.Root;
17+
18+@RequestScoped
19+public class MemberListProducer {
20+ @Inject
21+ private EntityManager em;
22+
23+ private List<Member> members;
24+
25+ // @Named provides access the return value via the EL variable name "members" in the UI (e.g.,
26+ // Facelets or JSP view)
27+ @Produces
28+ @Named
29+ public List<Member> getMembers() {
30+ return members;
31+ }
32+
33+ public void onMemberListChanged(@Observes(notifyObserver = Reception.IF_EXISTS) final Member member) {
34+ retrieveAllMembersOrderedByName();
35+ }
36+
37+ @PostConstruct
38+ public void retrieveAllMembersOrderedByName() {
39+ CriteriaBuilder cb = em.getCriteriaBuilder();
40+ CriteriaQuery<Member> criteria = cb.createQuery(Member.class);
41+ Root<Member> member = criteria.from(Member.class);
42+ // Swap criteria statements if you would like to try out type-safe criteria queries, a new
43+ // feature in JPA 2.0
44+ // criteria.select(member).orderBy(cb.asc(member.get(Member_.name)));
45+ criteria.select(member).orderBy(cb.asc(member.get("name")));
46+ members = em.createQuery(criteria).getResultList();
47+ }
48+}
--- /dev/null
+++ b/jboss-mvn-test3/src/main/java/com/mastertheboss/model/Member.java
@@ -0,0 +1,78 @@
1+package com.mastertheboss.model;
2+
3+import java.io.Serializable;
4+
5+import javax.persistence.Column;
6+import javax.persistence.Entity;
7+import javax.persistence.GeneratedValue;
8+import javax.persistence.Id;
9+import javax.persistence.Table;
10+import javax.persistence.UniqueConstraint;
11+import javax.validation.constraints.Digits;
12+import javax.validation.constraints.NotNull;
13+import javax.validation.constraints.Pattern;
14+import javax.validation.constraints.Size;
15+import javax.xml.bind.annotation.XmlRootElement;
16+
17+import org.hibernate.validator.constraints.Email;
18+import org.hibernate.validator.constraints.NotEmpty;
19+
20+@Entity
21+@XmlRootElement
22+@Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
23+public class Member implements Serializable {
24+ /** Default value included to remove warning. Remove or modify at will. **/
25+ private static final long serialVersionUID = 1L;
26+
27+ @Id
28+ @GeneratedValue
29+ private Long id;
30+
31+ @NotNull
32+ @Size(min = 1, max = 25)
33+ @Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")
34+ private String name;
35+
36+ @NotNull
37+ @NotEmpty
38+ @Email
39+ private String email;
40+
41+ @NotNull
42+ @Size(min = 10, max = 12)
43+ @Digits(fraction = 0, integer = 12)
44+ @Column(name = "phone_number")
45+ private String phoneNumber;
46+
47+ public Long getId() {
48+ return id;
49+ }
50+
51+ public void setId(Long id) {
52+ this.id = id;
53+ }
54+
55+ public String getName() {
56+ return name;
57+ }
58+
59+ public void setName(String name) {
60+ this.name = name;
61+ }
62+
63+ public String getEmail() {
64+ return email;
65+ }
66+
67+ public void setEmail(String email) {
68+ this.email = email;
69+ }
70+
71+ public String getPhoneNumber() {
72+ return phoneNumber;
73+ }
74+
75+ public void setPhoneNumber(String phoneNumber) {
76+ this.phoneNumber = phoneNumber;
77+ }
78+}
\ No newline at end of file
--- /dev/null
+++ b/jboss-mvn-test3/src/main/java/com/mastertheboss/rest/JaxRsActivator.java
@@ -0,0 +1,18 @@
1+package com.mastertheboss.rest;
2+
3+import javax.ws.rs.ApplicationPath;
4+import javax.ws.rs.core.Application;
5+
6+/**
7+ * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6
8+ * "no XML" approach to activating JAX-RS.
9+ *
10+ * <p>
11+ * Resources are served relative to the servlet path specified in the {@link ApplicationPath}
12+ * annotation.
13+ * </p>
14+ */
15+@ApplicationPath("/rest")
16+public class JaxRsActivator extends Application {
17+ /* class body intentionally left blank */
18+}
--- /dev/null
+++ b/jboss-mvn-test3/src/main/java/com/mastertheboss/rest/MemberResourceRESTService.java
@@ -0,0 +1,46 @@
1+package com.mastertheboss.rest;
2+
3+import java.util.List;
4+
5+import javax.enterprise.context.RequestScoped;
6+import javax.inject.Inject;
7+import javax.persistence.EntityManager;
8+import javax.ws.rs.GET;
9+import javax.ws.rs.Path;
10+import javax.ws.rs.PathParam;
11+import javax.ws.rs.Produces;
12+
13+import com.mastertheboss.model.Member;
14+
15+/**
16+ * JAX-RS Example
17+ *
18+ * This class produces a RESTful service to read the contents of the members table.
19+ */
20+@Path("/members")
21+@RequestScoped
22+public class MemberResourceRESTService {
23+ @Inject
24+ private EntityManager em;
25+
26+ @GET
27+ @Produces("text/xml")
28+ public List<Member> listAllMembers() {
29+ // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of
30+ // this query
31+ @SuppressWarnings("unchecked")
32+ // We recommend centralizing inline queries such as this one into @NamedQuery annotations on
33+ // the @Entity class
34+ // as described in the named query blueprint:
35+ // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html
36+ final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList();
37+ return results;
38+ }
39+
40+ @GET
41+ @Path("/{id:[0-9][0-9]*}")
42+ @Produces("text/xml")
43+ public Member lookupMemberById(@PathParam("id") long id) {
44+ return em.find(Member.class, id);
45+ }
46+}
--- /dev/null
+++ b/jboss-mvn-test3/src/main/java/com/mastertheboss/util/Resources.java
@@ -0,0 +1,33 @@
1+package com.mastertheboss.util;
2+
3+import java.util.logging.Logger;
4+
5+import javax.enterprise.inject.Produces;
6+import javax.enterprise.inject.spi.InjectionPoint;
7+import javax.persistence.EntityManager;
8+import javax.persistence.PersistenceContext;
9+
10+/**
11+ * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans
12+ *
13+ * <p>
14+ * Example injection on a managed bean field:
15+ * </p>
16+ *
17+ * <pre>
18+ * &#064;Inject
19+ * private EntityManager em;
20+ * </pre>
21+ */
22+public class Resources {
23+ // use @SuppressWarnings to tell IDE to ignore warnings about field not being referenced directly
24+ @SuppressWarnings("unused")
25+ @Produces
26+ @PersistenceContext
27+ private EntityManager em;
28+
29+ @Produces
30+ public Logger produceLog(InjectionPoint injectionPoint) {
31+ return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
32+ }
33+}
--- /dev/null
+++ b/jboss-mvn-test3/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,17 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<persistence version="2.0"
3+ xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+ xsi:schemaLocation="
5+ http://java.sun.com/xml/ns/persistence
6+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
7+ <persistence-unit name="primary">
8+ <!-- If you are running in a production environment, add a managed
9+ data source, the example data source is just for proofs of concept! -->
10+ <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
11+ <properties>
12+ <!-- Properties for Hibernate -->
13+ <property name="hibernate.hbm2ddl.auto" value="create-drop" />
14+ <property name="hibernate.show_sql" value="false" />
15+ </properties>
16+ </persistence-unit>
17+</persistence>
\ No newline at end of file
--- /dev/null
+++ b/jboss-mvn-test3/src/main/resources/import.sql
@@ -0,0 +1,2 @@
1+-- You can use this file to load seed data into the database using SQL statements
2+insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.com', '2125551212')
\ No newline at end of file
--- /dev/null
+++ b/jboss-mvn-test3/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,9 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!-- This file can be an empty text file (0 bytes) -->
3+<!-- We're declaring the schema to save you time if you do have to configure
4+ this in the future -->
5+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+ xsi:schemaLocation="
7+ http://java.sun.com/xml/ns/javaee
8+ http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
9+</beans>
--- /dev/null
+++ b/jboss-mvn-test3/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,14 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!-- This file is not required if you don't need any extra configuration. -->
3+<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
4+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+ xsi:schemaLocation="
6+ http://java.sun.com/xml/ns/javaee
7+ http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
8+
9+ <!-- This descriptor activates the JSF 2.0 Servlet -->
10+
11+ <!-- Write your navigation rules here. You are encouraged to use CDI for
12+ creating @Named managed beans. -->
13+
14+</faces-config>
--- /dev/null
+++ b/jboss-mvn-test3/src/main/webapp/WEB-INF/templates/default.xhtml
@@ -0,0 +1,84 @@
1+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+<html xmlns="http://www.w3.org/1999/xhtml"
4+ xmlns:h="http://java.sun.com/jsf/html"
5+ xmlns:ui="http://java.sun.com/jsf/facelets">
6+<h:head>
7+ <title>Java EE 6 Starter Application</title>
8+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9+ <h:outputStylesheet name="css/screen.css" />
10+</h:head>
11+<h:body>
12+ <div id="container">
13+ <div id="content">
14+ <div id="sidebar">
15+ <h3>Find out more</h3>
16+ <p>Learn about JBoss AS 7.</p>
17+ <ul>
18+ <li><a
19+ href="https://docs.jboss.org/author/display/AS7/Getting+Started+Developing+Applications+Guide">JBoss
20+ AS 7 Getting Started Developing Applications Guide</a></li>
21+ <li><a href="jboss.org/jbossas">JBoss AS 7 project
22+ site</a></li>
23+ </ul>
24+ <p>Learn about the Java EE 6 platform and the component
25+ model it provides.</p>
26+ <ul>
27+ <li><a
28+ href="http://download.oracle.com/javaee/6/tutorial/doc">Java
29+ EE 6 tutorial</a></li>
30+ <li><a
31+ href="http://docs.jboss.org/cdi/spec/1.0/html">JSR-299:
32+ CDI specification</a></li>
33+ <li><a
34+ href="https://sites.google.com/site/cdipojo/get-started">CDI
35+ Source</a></li>
36+ </ul>
37+ <p>Dive into Weld, the CDI reference implementation, and
38+ discover portable extensions Seam 3 offers.</p>
39+ <ul>
40+ <li><a
41+ href="http://docs.jboss.org/weld/reference/latest/en-US/html">Weld
42+ reference guide</a></li>
43+ <li><a href="http://seamframework.org/Weld">Weld
44+ project</a></li>
45+ <li><a href="http://seamframework.org/Seam3">Seam
46+ 3 project</a></li>
47+ <li><a
48+ href="http://seamframework.org/Community/Forums">User
49+ forums</a></li>
50+ <li><a
51+ href="http://seamframework.org/Community/MailingLists">Mailing
52+ lists</a></li>
53+ <li><a
54+ href="https://issues.jboss.org/browse/WELDRAD">Archetype
55+ issue tracker</a></li>
56+ </ul>
57+ <p>Explore JavaServer Faces, the component-oriented UI
58+ framework in Java EE 6.</p>
59+ <ul>
60+ <li><a href="http://www.javaserverfaces.org">JSF
61+ community site</a></li>
62+ </ul>
63+ <p>
64+ If you have an add-on, please <a
65+ href="http://seamframework.org/Community/Forums">let
66+ us know</a> and consider <a
67+ href="http://seamframework.org/Seam3/GetInvolved">contributing</a>
68+ it back to the community!
69+ </p>
70+ </div>
71+ <ui:insert name="content">
72+ [Template content will be inserted here]
73+ </ui:insert>
74+ </div>
75+ <div id="footer">
76+ <h:graphicImage value="/resources/gfx/logo.png" alt="Weld logo" />
77+ <p>
78+ This project was generated from a Maven archetype from
79+ JBoss.<br />
80+ </p>
81+ </div>
82+ </div>
83+</h:body>
84+</html>
--- /dev/null
+++ b/jboss-mvn-test3/src/main/webapp/index.html
@@ -0,0 +1,7 @@
1+<!-- Plain HTML page that kicks us into the app -->
2+
3+<html>
4+<head>
5+<meta http-equiv="Refresh" content="0; URL=index.jsf">
6+</head>
7+</html>
\ No newline at end of file
--- /dev/null
+++ b/jboss-mvn-test3/src/main/webapp/index.xhtml
@@ -0,0 +1,79 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
3+ xmlns:ui="http://java.sun.com/jsf/facelets"
4+ xmlns:f="http://java.sun.com/jsf/core"
5+ xmlns:h="http://java.sun.com/jsf/html"
6+ template="/WEB-INF/templates/default.xhtml">
7+ <ui:define name="content">
8+ <h1>Welcome to JBoss AS 7!</h1>
9+
10+ <p>You have successfully deployed a Java EE 6 web application
11+ on JBoss AS 7.</p>
12+
13+ <h:form id="reg">
14+ <h2>Register (Bean Validation example)</h2>
15+ <p>Enforces annotation-based constraints defined on the
16+ model class.</p>
17+ <table>
18+ <tr>
19+ <th style="text-align: right;"><h:outputLabel
20+ for="name" value="Name:" /></th>
21+ <td><h:inputText id="name" value="#{newMember.name}" />
22+ <h:message for="name" errorClass="invalid" /></td>
23+ </tr>
24+ <tr>
25+ <th style="text-align: right;"><h:outputLabel
26+ for="email" value="Email:" /></th>
27+ <td><h:inputText id="email"
28+ value="#{newMember.email}" /> <h:message
29+ for="email" errorClass="invalid" /></td>
30+ </tr>
31+ <tr>
32+ <th style="text-align: right;"><h:outputLabel
33+ for="phoneNumber" value="Phone #:" /></th>
34+ <td><h:inputText id="phoneNumber"
35+ value="#{newMember.phoneNumber}" /> <h:message
36+ for="phoneNumber" errorClass="invalid" /></td>
37+ </tr>
38+ </table>
39+ <p>
40+ <h:commandButton id="register"
41+ action="#{memberRegistration.register}" value="Register" />
42+ <h:outputText value=" Registered!"
43+ rendered="#{facesContext.postback and empty facesContext.messageList}"
44+ style="color: green;" />
45+ </p>
46+ </h:form>
47+ <h2>Members</h2>
48+ <h:panelGroup rendered="#{empty members}">
49+ <em>No registered members.</em>
50+ </h:panelGroup>
51+ <h:dataTable var="_member" value="#{members}"
52+ rendered="#{not empty members}">
53+ <h:column>
54+ <f:facet name="header">Id</f:facet>
55+ #{_member.id}
56+ </h:column>
57+ <h:column>
58+ <f:facet name="header">Name</f:facet>
59+ #{_member.name}
60+ </h:column>
61+ <h:column>
62+ <f:facet name="header">Email</f:facet>
63+ #{_member.email}
64+ </h:column>
65+ <h:column>
66+ <f:facet name="header">Phone #</f:facet>
67+ #{_member.phoneNumber}
68+ </h:column>
69+ <h:column>
70+ <f:facet name="header">REST URL</f:facet>
71+ <a href="#{request.contextPath}/rest/members/#{_member.id}">/rest/members/#{_member.id}</a>
72+ </h:column>
73+ <f:facet name="footer">
74+ REST URL for all members: <a
75+ href="#{request.contextPath}/rest/members">/rest/members</a>
76+ </f:facet>
77+ </h:dataTable>
78+ </ui:define>
79+</ui:composition>
--- /dev/null
+++ b/jboss-mvn-test3/src/main/webapp/resources/css/screen.css
@@ -0,0 +1,40 @@
1+body {
2+ margin: 0;
3+ padding: 0;
4+ background-color: #EAECEE;
5+ font-family: Verdana, sans-serif;
6+ font-size: 0.9em;
7+}
8+#container {
9+ margin: 0 auto;
10+ padding: 0 20px 10px 20px;
11+ border: 1px solid #666666;
12+ width: 865px; /* subtract 40px from banner width for padding */
13+ background: #FFFFFF url(#{request.contextPath}/resources/gfx/banner.png) no-repeat;
14+ padding-top: 110px;
15+}
16+#sidebar {
17+ font-size: 0.9em;
18+ width: 225px;
19+ float: right;
20+ border: 1px solid #666666;
21+ background: #EAECEE;
22+ padding: 0 15px 5px 15px;
23+}
24+#sidebar ul {
25+ padding-left: 30px;
26+}
27+#footer {
28+ clear: both;
29+ text-align: center;
30+ color: #666666;
31+ font-size: 0.85em;
32+ padding: 3em 0 0 0;
33+}
34+code {
35+ font-size: 1.1em;
36+}
37+span.invalid {
38+ padding-left: 3px;
39+ color: red;
40+}
Binary files /dev/null and b/jboss-mvn-test3/src/main/webapp/resources/gfx/banner.png differ
Binary files /dev/null and b/jboss-mvn-test3/src/main/webapp/resources/gfx/logo.png differ
--- /dev/null
+++ b/jboss-mvn-test3/src/test/java/com/mastertheboss/test/MemberRegistrationTest.java
@@ -0,0 +1,49 @@
1+package com.mastertheboss.test;
2+
3+import static org.junit.Assert.assertNotNull;
4+
5+import java.util.logging.Logger;
6+
7+import javax.inject.Inject;
8+
9+import org.jboss.arquillian.container.test.api.Deployment;
10+import org.jboss.arquillian.junit.Arquillian;
11+import org.jboss.shrinkwrap.api.Archive;
12+import org.jboss.shrinkwrap.api.ShrinkWrap;
13+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
14+import org.jboss.shrinkwrap.api.spec.WebArchive;
15+import org.junit.Test;
16+import org.junit.runner.RunWith;
17+
18+import com.mastertheboss.controller.MemberRegistration;
19+import com.mastertheboss.model.Member;
20+import com.mastertheboss.util.Resources;
21+
22+@RunWith(Arquillian.class)
23+public class MemberRegistrationTest {
24+ @Deployment
25+ public static Archive<?> createTestArchive() {
26+ return ShrinkWrap.create(WebArchive.class, "test.war")
27+ .addClasses(Member.class, MemberRegistration.class, Resources.class)
28+ .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml")
29+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
30+ }
31+
32+ @Inject
33+ MemberRegistration memberRegistration;
34+
35+ @Inject
36+ Logger log;
37+
38+ @Test
39+ public void testRegister() throws Exception {
40+ Member newMember = memberRegistration.getNewMember();
41+ newMember.setName("Jane Doe");
42+ newMember.setEmail("jane@mailinator.com");
43+ newMember.setPhoneNumber("2125551234");
44+ memberRegistration.register();
45+ assertNotNull(newMember.getId());
46+ log.info(newMember.getName() + " was persisted with id " + newMember.getId());
47+ }
48+
49+}
--- /dev/null
+++ b/jboss-mvn-test3/src/test/resources/arquillian.xml
@@ -0,0 +1,22 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<arquillian xmlns="http://jboss.org/schema/arquillian"
3+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+ xsi:schemaLocation="http://jboss.org/schema/arquillian
5+ http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
6+
7+ <!-- Uncomment to have test archives exported to the file system for inspection -->
8+<!-- <engine> -->
9+<!-- <property name="deploymentExportPath">target/</property> -->
10+<!-- </engine> -->
11+
12+ <!-- Example configuration for a remote JBoss AS 7 instance -->
13+ <container qualifier="jboss" default="true">
14+ <protocol type="jmx-as7">
15+ <property name="executionType">REMOTE</property>
16+ </protocol>
17+ <configuration>
18+ <property name="jbossHome">/path/to/jboss/as</property>
19+ </configuration>
20+ </container>
21+
22+</arquillian>
\ No newline at end of file
--- /dev/null
+++ b/mvn-test1/pom.xml
@@ -0,0 +1,25 @@
1+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+ <modelVersion>4.0.0</modelVersion>
4+
5+ <groupId>com.mycompany.app</groupId>
6+ <artifactId>mvn-test1</artifactId>
7+ <version>1.0-SNAPSHOT</version>
8+ <packaging>jar</packaging>
9+
10+ <name>mvn-test1</name>
11+ <url>http://maven.apache.org</url>
12+
13+ <properties>
14+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+ </properties>
16+
17+ <dependencies>
18+ <dependency>
19+ <groupId>junit</groupId>
20+ <artifactId>junit</artifactId>
21+ <version>3.8.1</version>
22+ <scope>test</scope>
23+ </dependency>
24+ </dependencies>
25+</project>
--- /dev/null
+++ b/mvn-test1/src/main/java/com/mycompany/app/App.java
@@ -0,0 +1,13 @@
1+package com.mycompany.app;
2+
3+/**
4+ * Hello world!
5+ *
6+ */
7+public class App
8+{
9+ public static void main( String[] args )
10+ {
11+ System.out.println( "Hello World!" );
12+ }
13+}
--- /dev/null
+++ b/mvn-test1/src/test/java/com/mycompany/app/AppTest.java
@@ -0,0 +1,38 @@
1+package com.mycompany.app;
2+
3+import junit.framework.Test;
4+import junit.framework.TestCase;
5+import junit.framework.TestSuite;
6+
7+/**
8+ * Unit test for simple App.
9+ */
10+public class AppTest
11+ extends TestCase
12+{
13+ /**
14+ * Create the test case
15+ *
16+ * @param testName name of the test case
17+ */
18+ public AppTest( String testName )
19+ {
20+ super( testName );
21+ }
22+
23+ /**
24+ * @return the suite of tests being tested
25+ */
26+ public static Test suite()
27+ {
28+ return new TestSuite( AppTest.class );
29+ }
30+
31+ /**
32+ * Rigourous Test :-)
33+ */
34+ public void testApp()
35+ {
36+ assertTrue( true );
37+ }
38+}