@@ -29,6 +29,12 @@ public static Archive<?> createDeployment() {
2929 );
3030 }
3131
32+ /**
33+ * Tests that the forwarded resource can utilize a CDI bean
34+ *
35+ * @throws IOException
36+ * @throws SAXException
37+ */
3238 @ Test
3339 public void testCDIForwardViaPublicResource () throws IOException , SAXException {
3440
@@ -39,6 +45,12 @@ public void testCDIForwardViaPublicResource() throws IOException, SAXException {
3945 );
4046 }
4147
48+ /**
49+ * Tests that the forwarded resource can utilize a CDI bean
50+ *
51+ * @throws IOException
52+ * @throws SAXException
53+ */
4254 @ Test
4355 public void testCDIForwardViaProtectedResource () throws IOException , SAXException {
4456
@@ -48,5 +60,97 @@ public void testCDIForwardViaProtectedResource() throws IOException, SAXExceptio
4860 response .contains ("response from forwardedServlet - Called from CDI" )
4961 );
5062 }
63+
64+ /**
65+ * Tests that the forwarded resource has the correct servlet path
66+ *
67+ * @throws IOException
68+ * @throws SAXException
69+ */
70+ @ Test
71+ public void testCDIForwardWithRequestPublic () throws IOException , SAXException {
72+
73+ String response = getFromServerPath ("public/servlet" );
74+
75+ assertTrue (
76+ "Servletpath reported by servlet request after forward from SAM not as expected." ,
77+ response .contains ("servletPath via Servlet - /forwardedServlet" )
78+ );
79+ }
80+
81+ /**
82+ * Tests that the forwarded resource has the correct servlet path
83+ *
84+ * @throws IOException
85+ * @throws SAXException
86+ */
87+ @ Test
88+ public void testCDIForwardWithRequestProtected () throws IOException , SAXException {
89+
90+ String response = getFromServerPath ("protected/servlet" );
91+
92+ assertTrue (
93+ "Servletpath reported by servlet request after forward from SAM not as expected." ,
94+ response .contains ("servletPath via Servlet - /forwardedServlet" )
95+ );
96+ }
97+
98+ /**
99+ * Tests that the forwarded resource can utilize an injected HttpServletRequest and that
100+ * the value is correct.
101+ *
102+ * @throws IOException
103+ * @throws SAXException
104+ */
105+ @ Test
106+ public void testCDIForwardWithRequestInjectPublic () throws IOException , SAXException {
107+
108+ String response = getFromServerPath ("public/servlet" );
109+
110+ assertTrue (
111+ "Servletpath reported by servlet request after forward from SAM not as expected." ,
112+ response .contains ("servletPath via Servlet - /forwardedServlet" )
113+ );
114+
115+ assertTrue (
116+ "Response did not contain output from forwarded Servlet using CDI injected request. " +
117+ "Request appears not to be usable." ,
118+ response .contains ("servletPath via CDI" )
119+ );
120+
121+ assertTrue (
122+ "Servletpath reported by injected request after forward from SAM not as expected." ,
123+ response .contains ("servletPath via CDI - /forwardedServlet" )
124+ );
125+ }
126+
127+ /**
128+ * Tests that the forwarded resource can utilize an injected HttpServletRequest and that
129+ * the value is correct.
130+ *
131+ * @throws IOException
132+ * @throws SAXException
133+ */
134+ @ Test
135+ public void testCDIForwardWithRequestInjectProtected () throws IOException , SAXException {
136+
137+ String response = getFromServerPath ("protected/servlet" );
138+
139+ assertTrue (
140+ "Servletpath reported by servlet request after forward from SAM not as expected." ,
141+ response .contains ("servletPath via Servlet - /forwardedServlet" )
142+ );
143+
144+ assertTrue (
145+ "Response did not contain output from forwarded Servlet using CDI injected request. " +
146+ "Request appears not to be usable." ,
147+ response .contains ("servletPath via CDI" )
148+ );
149+
150+ assertTrue (
151+ "Servletpath reported by injected request after forward from SAM not as expected." ,
152+ response .contains ("servletPath via CDI - /forwardedServlet" )
153+ );
154+ }
51155
52156}
0 commit comments