File tree Expand file tree Collapse file tree 5 files changed +106
-0
lines changed
java/org/javaee7/cdi/nobeans/el/injection
test/java/org/javaee7/cdi/nobeans/el/injection Expand file tree Collapse file tree 5 files changed +106
-0
lines changed Original file line number Diff line number Diff line change 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/xsd/maven-4.0.0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+ <parent >
5+ <groupId >org.javaee7.cdi</groupId >
6+ <artifactId >cdi-samples</artifactId >
7+ <version >1.0-SNAPSHOT</version >
8+ <relativePath >../pom.xml</relativePath >
9+ </parent >
10+
11+ <artifactId >nobeans-el-injection</artifactId >
12+ <packaging >war</packaging >
13+ </project >
Original file line number Diff line number Diff line change 1+ package org .javaee7 .cdi .nobeans .el .injection ;
2+
3+ import javax .enterprise .context .RequestScoped ;
4+ import javax .inject .Named ;
5+
6+ /**
7+ * @author Arun Gupta
8+ */
9+ @ Named
10+ @ RequestScoped
11+ public class ScopedBean {
12+ public String sayHello () {
13+ return "Hello there!" ;
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <web-app version =" 3.1" xmlns =" http://xmlns.jcp.org/xml/ns/javaee" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" >
3+ <context-param >
4+ <param-name >javax.faces.PROJECT_STAGE</param-name >
5+ <param-value >Development</param-value >
6+ </context-param >
7+ <servlet >
8+ <servlet-name >Faces Servlet</servlet-name >
9+ <servlet-class >javax.faces.webapp.FacesServlet</servlet-class >
10+ <load-on-startup >1</load-on-startup >
11+ </servlet >
12+ <servlet-mapping >
13+ <servlet-name >Faces Servlet</servlet-name >
14+ <url-pattern >/faces/*</url-pattern >
15+ </servlet-mapping >
16+ <session-config >
17+ <session-timeout >
18+ 30
19+ </session-timeout >
20+ </session-config >
21+ <welcome-file-list >
22+ <welcome-file >faces/index.xhtml</welcome-file >
23+ </welcome-file-list >
24+ </web-app >
Original file line number Diff line number Diff line change 1+ < ?xml version='1.0' encoding='UTF-8' ?>
2+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+ < html xmlns ="http://www.w3.org/1999/xhtml "
4+ xmlns:h ="http://xmlns.jcp.org/jsf/html ">
5+ < h:head >
6+ < title > Facelet Title</ title >
7+ </ h:head >
8+ < h:body >
9+ #{scopedBean.sayHello()}
10+ </ h:body >
11+ </ html >
12+
Original file line number Diff line number Diff line change 1+ package org .javaee7 .cdi .nobeans .el .injection ;
2+
3+ import com .meterware .httpunit .GetMethodWebRequest ;
4+ import com .meterware .httpunit .WebConversation ;
5+ import java .io .File ;
6+ import java .net .URL ;
7+ import org .jboss .arquillian .container .test .api .Deployment ;
8+ import org .jboss .arquillian .junit .Arquillian ;
9+ import org .jboss .shrinkwrap .api .ShrinkWrap ;
10+ import org .junit .Test ;
11+ import org .junit .runner .RunWith ;
12+
13+ import org .jboss .arquillian .test .api .ArquillianResource ;
14+ import org .jboss .shrinkwrap .api .spec .WebArchive ;
15+
16+ /**
17+ * @author Arun Gupta
18+ */
19+ @ RunWith (Arquillian .class )
20+ public class ScopedBeanTest {
21+
22+ private static final String WEBAPP_SRC = "src/main/webapp" ;
23+
24+ @ ArquillianResource
25+ private URL base ;
26+
27+ @ Deployment (testable =false )
28+ public static WebArchive deploy () {
29+ return ShrinkWrap .create (WebArchive .class )
30+ .addClass (ScopedBean .class )
31+ .addAsWebInfResource ((new File (WEBAPP_SRC + "/WEB-INF" , "web.xml" )))
32+ .addAsWebResource ((new File (WEBAPP_SRC , "index.xhtml" )));
33+ }
34+
35+ @ Test
36+ public void checkRenderedPage () throws Exception {
37+ WebConversation conv = new WebConversation ();
38+ GetMethodWebRequest getRequest = new GetMethodWebRequest (base + "/faces/index.xhtml" );
39+ String responseText = conv .getResponse (getRequest ).getText ();
40+ assert (responseText .contains ("Hello there!" ));
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments