diff --git a/.gitignore b/.gitignore index 95c24606ba..3b0fc8527a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ bin .openshift */.gitignore .gitkeep +/helloworld-jsp diff --git a/kitchensink-jsp/.factorypath b/kitchensink-jsp/.factorypath new file mode 100644 index 0000000000..16e422aead --- /dev/null +++ b/kitchensink-jsp/.factorypath @@ -0,0 +1,5 @@ + + + + + diff --git a/kitchensink-jsp/pom.xml b/kitchensink-jsp/pom.xml new file mode 100644 index 0000000000..ef91f5d561 --- /dev/null +++ b/kitchensink-jsp/pom.xml @@ -0,0 +1,341 @@ + + + 4.0.0 + + org.jboss.as.kitchensink-jsp + 7.1.0-SNAPSHOT + war + JBoss AS Quickstarts: kitchensink JSP + + + + + UTF-8 + + + + 2.0.0.Final + + + + + + + + org.jboss.spec + jboss-javaee-web-6.0 + ${javaee6.web.spec.version} + pom + import + + + + + + + + + + + javax.enterprise + cdi-api + provided + + + + + org.jboss.spec.javax.annotation + jboss-annotations-api_1.1_spec + provided + + + + + org.jboss.spec.javax.servlet + jboss-servlet-api_3.0_spec + provided + + + + + org.jboss.spec.javax.ws.rs + jboss-jaxrs-api_1.1_spec + provided + + + + + org.hibernate.javax.persistence + hibernate-jpa-2.0-api + provided + + + + + org.jboss.spec.javax.ejb + jboss-ejb-api_3.1_spec + provided + + + + + javax.servlet + jstl + 1.2 + runtime + + + + + + + org.hibernate + hibernate-validator + 4.2.0.Final + provided + + + org.slf4j + slf4j-api + + + + + + + + + org.hibernate + hibernate-jpamodelgen + 1.1.1.Final + provided + + + + + junit + junit + 4.10 + test + + + + + + org.jboss.arquillian.junit + arquillian-junit-container + 1.0.0.CR4 + test + + + + org.jboss.arquillian.protocol + arquillian-protocol-servlet + 1.0.0.CR4 + test + + + + + + + ${project.artifactId} + + + + maven-compiler-plugin + 2.3.1 + + 1.6 + 1.6 + + + + maven-war-plugin + 2.1.1 + + + false + + + + + + org.jboss.as.plugins + jboss-as-maven-plugin + 7.1.0.Beta1b + + + + + + + + + default + + true + + + + + maven-surefire-plugin + 2.4.3 + + true + + + + + + + + + + + + + jboss-public-repository + JBoss Repository + http://repository.jboss.org/nexus/content/groups/public + + + + + false + + + + + + + jboss-public-repository + JBoss Repository + http://repository.jboss.org/nexus/content/groups/public + + + + false + + + + + + + + arq-jbossas-managed + + + org.jboss.as + jboss-as-arquillian-container-managed + 7.1.0.Beta1b + test + + + + + + + + + + + jboss-public-repository + JBoss Repository + http://repository.jboss.org/nexus/content/groups/public + + + + + false + + + + + + + jboss-public-repository + JBoss Repository + http://repository.jboss.org/nexus/content/groups/public + + + + false + + + + + + + arq-jbossas-remote + + + org.jboss.as + jboss-as-arquillian-container-remote + 7.1.0.Beta1b + test + + + + + + + + + + openshift + + + + maven-war-plugin + 2.1.1 + + deployments + ROOT + + + + + + + + JBoss AS Quickstarts: kitchensink JSP + http://jboss.org/jbossas + jboss-as-kitchensink-jsp + diff --git a/kitchensink-jsp/readme.md b/kitchensink-jsp/readme.md new file mode 100644 index 0000000000..b36317a983 --- /dev/null +++ b/kitchensink-jsp/readme.md @@ -0,0 +1,99 @@ +jboss-as-kitchensink-jsp +======================== + +What is it? +----------- + +jboss-as-kitchensink-jsp is a deployable Maven 3 project to help you +get your foot in the door developing with Java EE 6 on JBoss AS 7 or EAP 6. This +project is setup to allow you to create a compliant Java EE 6 application +using *JSP 2.0* *EL 2.0* *JSTL 1.2* *CDI 1.0*, *EJB 3.1*, *JPA 2.0* and Bean Validation 1.0. + +This project rebuilds the presentation tier of the kitchensink quickstart app + using JSP and JSTL instead of JSF features. + +It is another app based on JSP that reused all other components from the +Member Registration template. +It reused the persistence unit and some sample persistence and transaction code to help +you get your feet wet with database access in enterprise Java. + +System requirements +------------------- + +All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven +3.0 or better. + +The application this project produces is designed to be run on a JBoss AS 7 or EAP 6. +The following instructions target JBoss AS 7, but they also apply to JBoss EAP 6. + +With the prerequisites out of the way, you're ready to build and deploy. + +Deploying the application +------------------------- + +First you need to start JBoss AS 7 (or EAP 6). To do this, run + + $JBOSS_HOME/bin/standalone.sh + +or if you are using windows + + $JBOSS_HOME/bin/standalone.bat + +To deploy the application, you first need to produce the archive to deploy using +the following Maven goal: + + mvn package + +You can now deploy the artifact to JBoss AS by executing the following command: + + mvn jboss-as:deploy + +This will deploy `target/jboss-as-kitchensink-jsp.war`. + +The application will be running at the following URL . + +To undeploy from JBoss AS, run this command: + + mvn jboss-as:undeploy + +You can also start JBoss AS 7 and deploy the project using Eclipse. See the JBoss AS 7 +Getting Started Guide for Developers for more information. + +Running the Arquillian tests +============================ + +By default, tests are configured to be skipped. The reason is that the sample +test is an Arquillian test, which requires the use of a container. You can +activate this test by selecting one of the container configuration provided +for JBoss AS 7 (remote). + +To run the test in JBoss AS 7, first start a JBoss AS 7 instance. Then, run the +test goal with the following profile activated: + + mvn clean test -Parq-jbossas-remote + +Importing the project into an IDE +================================= + +If you created the project using the Maven archetype wizard in your IDE +(Eclipse, NetBeans or IntelliJ IDEA), then there is nothing to do. You should +already have an IDE project. + +Detailed instructions for using Eclipse with JBoss AS 7 are provided in the +JBoss AS 7 Getting Started Guide for Developers. + +If you created the project from the commandline using archetype:generate, then +you need to import the project into your IDE. If you are using NetBeans 6.8 or +IntelliJ IDEA 9, then all you have to do is open the project as an existing +project. Both of these IDEs recognize Maven projects natively. + +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 diff --git a/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/controller/MemberRegistration.java b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/controller/MemberRegistration.java new file mode 100644 index 0000000000..3909dab20e --- /dev/null +++ b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/controller/MemberRegistration.java @@ -0,0 +1,71 @@ +package org.jboss.as.quickstarts.kitchensinkjsp.controller; + +import java.util.logging.Logger; + +import javax.annotation.PostConstruct; +import javax.ejb.Stateful; +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 org.jboss.as.quickstarts.kitchensinkjsp.model.Member; + +// The @Stateful annotation eliminates the need for manual transaction demarcation +@Stateful +// The @Model stereotype is a convenience mechanism to make this a request-scoped bean that has an +// EL name +// Read more about the @Model stereotype in this FAQ: +// http://sfwk.org/Documentation/WhatIsThePurposeOfTheModelAnnotation +@Model +public class MemberRegistration { + + @Inject + private Logger log; + + @Inject + private EntityManager em; + + @Inject + private Event memberEventSrc; + + private Member newMember; + + @Produces + @Named + public Member getNewMember() { + + log.info("getNewMember: called"+newMember); + return newMember; + + } + + + public void register() throws Exception { + + try{ + + log.info("Registering " + newMember.getName()); + em.persist(newMember); + memberEventSrc.fire(newMember); + initNewMember(); + } + catch (Exception e) { + Throwable t=e; + while((t.getCause())!=null){ t=t.getCause();} + log.info("Exception:"+t.getMessage()); + throw ((Exception)t); + } + + } + + + + @PostConstruct + public void initNewMember() { + newMember = new Member(); + log.info("@PostConstruct:initNewMember called"); + } +} diff --git a/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/data/MemberListProducer.java b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/data/MemberListProducer.java new file mode 100644 index 0000000000..254b421837 --- /dev/null +++ b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/data/MemberListProducer.java @@ -0,0 +1,48 @@ +package org.jboss.as.quickstarts.kitchensinkjsp.data; + +import org.jboss.as.quickstarts.kitchensinkjsp.model.Member; +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; + +@RequestScoped +public class MemberListProducer { + @Inject + private EntityManager em; + + private List members; + + // @Named provides access the return value via the EL variable name "members" in the UI (e.g., + // Facelets or JSP view) + @Produces + @Named + public List getMembers() { + return members; + } + + public void onMemberListChanged(@Observes(notifyObserver = Reception.IF_EXISTS) final Member member) { + retrieveAllMembersOrderedByName(); + } + + @PostConstruct + public void retrieveAllMembersOrderedByName() { + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery criteria = cb.createQuery(Member.class); + Root member = criteria.from(Member.class); + // Swap criteria statements if you would like to try out type-safe criteria queries, a new + // feature in JPA 2.0 + // criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); + criteria.select(member).orderBy(cb.asc(member.get("name"))); + members = em.createQuery(criteria).getResultList(); + } +} diff --git a/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/model/Member.java b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/model/Member.java new file mode 100644 index 0000000000..f78a060c09 --- /dev/null +++ b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/model/Member.java @@ -0,0 +1,84 @@ +package org.jboss.as.quickstarts.kitchensinkjsp.model; + +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; + +@Entity +@XmlRootElement +@Table(name="MemberJSP", uniqueConstraints = @UniqueConstraint(columnNames = "email")) +public class Member implements Serializable { + /** Default value included to remove warning. Remove or modify at will. **/ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue + private Long id; + + @NotNull + @Size(min = 1, max = 25) + @Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces") + private String name; + + @NotNull + @NotEmpty + @Email + private String email; + + @NotNull + @Size(min = 10, max = 12) + @Digits(fraction = 0, integer = 12) + @Column(name = "phone_number") + private String phoneNumber; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + + public String toString(){ + return getName()+":"+getEmail()+":"+getPhoneNumber(); + + } +} \ No newline at end of file diff --git a/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/rest/JaxRsActivator.java b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/rest/JaxRsActivator.java new file mode 100644 index 0000000000..0a7e5f702d --- /dev/null +++ b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/rest/JaxRsActivator.java @@ -0,0 +1,18 @@ +package org.jboss.as.quickstarts.kitchensinkjsp.rest; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +/** + * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 + * "no XML" approach to activating JAX-RS. + * + *

+ * Resources are served relative to the servlet path specified in the {@link ApplicationPath} + * annotation. + *

+ */ +@ApplicationPath("/rest") +public class JaxRsActivator extends Application { + /* class body intentionally left blank */ +} diff --git a/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/rest/MemberResourceRESTService.java b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/rest/MemberResourceRESTService.java new file mode 100644 index 0000000000..a92ed40c57 --- /dev/null +++ b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/rest/MemberResourceRESTService.java @@ -0,0 +1,46 @@ +package org.jboss.as.quickstarts.kitchensinkjsp.rest; + +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; +import javax.ws.rs.Produces; + +import org.jboss.as.quickstarts.kitchensinkjsp.model.Member; + +/** + * JAX-RS Example + * + * This class produces a RESTful service to read the contents of the members table. + */ +@Path("/members") +@RequestScoped +public class MemberResourceRESTService { + @Inject + private EntityManager em; + + @GET + @Produces("text/xml") + public List listAllMembers() { + // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of + // this query + @SuppressWarnings("unchecked") + // We recommend centralizing inline queries such as this one into @NamedQuery annotations on + // the @Entity class + // as described in the named query blueprint: + // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html + final List results = em.createQuery("select m from Member m order by m.name").getResultList(); + return results; + } + + @GET + @Path("/{id:[0-9][0-9]*}") + @Produces("text/xml") + public Member lookupMemberById(@PathParam("id") long id) { + return em.find(Member.class, id); + } +} diff --git a/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/servlet/MemberRegistrationServlet.java b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/servlet/MemberRegistrationServlet.java new file mode 100644 index 0000000000..096d707bd9 --- /dev/null +++ b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/servlet/MemberRegistrationServlet.java @@ -0,0 +1,107 @@ +package org.jboss.as.quickstarts.kitchensinkjsp.servlet; + +import java.io.IOException; + +import javax.inject.Inject; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.jboss.as.quickstarts.kitchensinkjsp.controller.MemberRegistration; +import org.jboss.as.quickstarts.kitchensinkjsp.data.MemberListProducer; +import org.jboss.as.quickstarts.kitchensinkjsp.model.Member; + +/** + * Servlet implementation class MemberRegistrationServlet + */ +@WebServlet("/register.do") +public class MemberRegistrationServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + @Inject + MemberRegistration registrationService; + + @Inject + MemberListProducer memberListService; + + /** + * Default constructor. + */ + public MemberRegistrationServlet() { + // TODO Auto-generated constructor stub + } + + + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + StringBuilder errorMessage= new StringBuilder(); + + try { + + System.out.println("EMAIL='"+request.getParameter("email")+"'"); + Member member; + //create a new member, remember :) the memberservice do not + //call the initMethod if an error occur during the previous persist request + + while((member=registrationService.getNewMember())==null) + { registrationService.initNewMember(); + } + + String value; + + if((value=request.getParameter("name")).length()<1) + { + errorMessage.append("Name can not be null\n"); + } + else + { + member.setName(value); + + if((value=request.getParameter("email")).length()<1) + { + errorMessage.append("email required!\n"); + } + else + { + member.setEmail(value); + + if((value=request.getParameter("phoneNumber")).length()<1){ + errorMessage.append("phoneNumber required \n"); + } + else // all parameters are filled, register + { + member.setPhoneNumber(value); + + log("\n*****************Try Registration of Member="+member); + registrationService.register(); + request.setAttribute("infoMessage", member.getName()+" Registered!"); + } + } + } + + } catch (Exception e) { + + + Throwable t=e; + while((t.getCause())!=null){ t=t.getCause();} + + errorMessage.append("Error========>"+t.getMessage()); + request.setAttribute("infoMessage", ""); + e.printStackTrace(); + } + finally + { + request.setAttribute("errorMessage", errorMessage.toString()); + RequestDispatcher resultView = request.getRequestDispatcher("index.jsp"); + resultView.forward(request,response); + } + } + +} diff --git a/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/util/Resources.java b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/util/Resources.java new file mode 100644 index 0000000000..52a02b2127 --- /dev/null +++ b/kitchensink-jsp/src/main/java/org/jboss/as/quickstarts/kitchensinkjsp/util/Resources.java @@ -0,0 +1,33 @@ +package org.jboss.as.quickstarts.kitchensinkjsp.util; + +import java.util.logging.Logger; + +import javax.enterprise.inject.Produces; +import javax.enterprise.inject.spi.InjectionPoint; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +/** + * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans + * + *

+ * Example injection on a managed bean field: + *

+ * + *
+ * @Inject
+ * private EntityManager em;
+ * 
+ */ +public class Resources { + // use @SuppressWarnings to tell IDE to ignore warnings about field not being referenced directly + @SuppressWarnings("unused") + @Produces + @PersistenceContext + private EntityManager em; + + @Produces + public Logger produceLog(InjectionPoint injectionPoint) { + return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); + } +} diff --git a/kitchensink-jsp/src/main/resources/META-INF/persistence.xml b/kitchensink-jsp/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..3ac23a6401 --- /dev/null +++ b/kitchensink-jsp/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,17 @@ + + + + + java:jboss/datasources/ExampleDS + + + + + + + \ No newline at end of file diff --git a/kitchensink-jsp/src/main/resources/import.sql b/kitchensink-jsp/src/main/resources/import.sql new file mode 100644 index 0000000000..4cd4457e40 --- /dev/null +++ b/kitchensink-jsp/src/main/resources/import.sql @@ -0,0 +1,2 @@ +-- You can use this file to load seed data into the database using SQL statements +insert into MemberJSP (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.jsp.com', '2125551212') ; diff --git a/kitchensink-jsp/src/main/webapp/WEB-INF/beans.xml b/kitchensink-jsp/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000000..c782f570a2 --- /dev/null +++ b/kitchensink-jsp/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/kitchensink-jsp/src/main/webapp/index.jsp b/kitchensink-jsp/src/main/webapp/index.jsp new file mode 100644 index 0000000000..b6d0c4205d --- /dev/null +++ b/kitchensink-jsp/src/main/webapp/index.jsp @@ -0,0 +1,94 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1"%> + + + + + Java EE 6 Starter Application + + + + + + +
+
+ + + + + + <%@ include file="registrationForm.jsp" %> + + + + <%@ include file="registrationResult.jsp" %> + +
+ +
+ + diff --git a/kitchensink-jsp/src/main/webapp/registrationForm.jsp b/kitchensink-jsp/src/main/webapp/registrationForm.jsp new file mode 100644 index 0000000000..8bbfaa0d69 --- /dev/null +++ b/kitchensink-jsp/src/main/webapp/registrationForm.jsp @@ -0,0 +1,56 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="ISO-8859-1"%> + + + + +registrationPage.jsp + + +

Welcome to JBoss AS 7!

+ +

You have successfully deployed a Java EE 6 web application + on JBoss AS 7. +

+ +
+

Register (JSP Sample)

+ + + + + + + + + + + + + + +
+ + +
+ + + +
+ + + +
+

+ + + + +

+
+ + + + + + \ No newline at end of file diff --git a/kitchensink-jsp/src/main/webapp/registrationResult.jsp b/kitchensink-jsp/src/main/webapp/registrationResult.jsp new file mode 100644 index 0000000000..f3b9f5daee --- /dev/null +++ b/kitchensink-jsp/src/main/webapp/registrationResult.jsp @@ -0,0 +1,35 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + +RegistrationAction + + + + + + + + + + + + + + + + + + + + + + +
NameEmailPhoneNumber
+ + + \ No newline at end of file diff --git a/kitchensink-jsp/src/main/webapp/resources/css/screen.css b/kitchensink-jsp/src/main/webapp/resources/css/screen.css new file mode 100644 index 0000000000..d0b387f1ee --- /dev/null +++ b/kitchensink-jsp/src/main/webapp/resources/css/screen.css @@ -0,0 +1,40 @@ +body { + margin: 0; + padding: 0; + background-color: #EAECEE; + font-family: Verdana, sans-serif; + font-size: 0.9em; +} +#container { + margin: 0 auto; + padding: 0 20px 10px 20px; + border: 1px solid #666666; + width: 865px; /* subtract 40px from banner width for padding */ + background: #FFFFFF url(../gfx/banner.png) no-repeat; + padding-top: 110px; +} +#sidebar { + font-size: 0.9em; + width: 225px; + float: right; + border: 1px solid #666666; + background: #EAECEE; + padding: 0 15px 5px 15px; +} +#sidebar ul { + padding-left: 30px; +} +#footer { + clear: both; + text-align: center; + color: #666666; + font-size: 0.85em; + padding: 3em 0 0 0; +} +code { + font-size: 1.1em; +} +span.invalid { + padding-left: 3px; + color: red; +} diff --git a/kitchensink-jsp/src/main/webapp/resources/gfx/banner.png b/kitchensink-jsp/src/main/webapp/resources/gfx/banner.png new file mode 100644 index 0000000000..0b178ae699 Binary files /dev/null and b/kitchensink-jsp/src/main/webapp/resources/gfx/banner.png differ diff --git a/kitchensink-jsp/src/main/webapp/resources/gfx/logo.png b/kitchensink-jsp/src/main/webapp/resources/gfx/logo.png new file mode 100644 index 0000000000..b64d397a0d Binary files /dev/null and b/kitchensink-jsp/src/main/webapp/resources/gfx/logo.png differ diff --git a/kitchensink-jsp/src/test/java/org/jboss/as/quickstarts/helloworldjsp/test/MemberRegistrationTest.java b/kitchensink-jsp/src/test/java/org/jboss/as/quickstarts/helloworldjsp/test/MemberRegistrationTest.java new file mode 100644 index 0000000000..40cfa42f73 --- /dev/null +++ b/kitchensink-jsp/src/test/java/org/jboss/as/quickstarts/helloworldjsp/test/MemberRegistrationTest.java @@ -0,0 +1,49 @@ +package org.jboss.as.quickstarts.helloworldjsp.test; + +import static org.junit.Assert.assertNotNull; + +import java.util.logging.Logger; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.jboss.as.quickstarts.kitchensinkjsp.controller.MemberRegistration; +import org.jboss.as.quickstarts.kitchensinkjsp.model.Member; +import org.jboss.as.quickstarts.kitchensinkjsp.util.Resources; + +@RunWith(Arquillian.class) +public class MemberRegistrationTest { + @Deployment + public static Archive createTestArchive() { + return ShrinkWrap.create(WebArchive.class, "test.war") + .addClasses(Member.class, MemberRegistration.class, Resources.class) + .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml") + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Inject + MemberRegistration memberRegistration; + + @Inject + Logger log; + + @Test + public void testRegister() throws Exception { + Member newMember = memberRegistration.getNewMember(); + newMember.setName("Jane Doe"); + newMember.setEmail("jane@mailinator.com"); + newMember.setPhoneNumber("2125551234"); + memberRegistration.register(); + assertNotNull(newMember.getId()); + log.info(newMember.getName() + " was persisted with id " + newMember.getId()); + } + +} diff --git a/kitchensink-jsp/src/test/resources/arquillian.xml b/kitchensink-jsp/src/test/resources/arquillian.xml new file mode 100644 index 0000000000..42e278341d --- /dev/null +++ b/kitchensink-jsp/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + /path/to/jboss/as + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 163b9f3e57..a3d37528c7 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,8 @@ helloworld numberguess greeter + helloworld-jsp + kitchensink-jsp kitchensink html5-mobile kitchensink-ear @@ -35,6 +37,7 @@ servlet-async servlet-filterlistener helloworld-mdb +