1414
1515/**
1616 * This tests that the wrapped request and response a SAM puts into the MessageInfo structure reaches the Servlet that's
17- * invoked.
17+ * invoked as well as all filters executed before that .
1818 *
1919 * @author Arjan Tijms
2020 *
@@ -26,6 +26,46 @@ public class WrappingTest extends ArquillianBase {
2626 public static Archive <?> createDeployment () {
2727 return defaultArchive ();
2828 }
29+
30+ @ Test
31+ public void testProgrammaticFilterRequestWrapping () throws IOException , SAXException {
32+
33+ String response = getFromServerPath ("protected/servlet" );
34+
35+ // The SAM wrapped a request so that it always contains the request attribute "isWrapped" with value true.
36+ assertTrue ("Request wrapped by SAM did not arrive in programmatic Filter." ,
37+ response .contains ("programmatic filter request isWrapped: true" ));
38+ }
39+
40+ @ Test
41+ public void testProgrammaticFilterResponseWrapping () throws IOException , SAXException {
42+
43+ String response = getFromServerPath ("protected/servlet" );
44+
45+ // The SAM wrapped a response so that it always contains the header "isWrapped" with value true.
46+ assertTrue ("Response wrapped by SAM did not arrive in programmatic Filter." ,
47+ response .contains ("programmatic filter response isWrapped: true" ));
48+ }
49+
50+ @ Test
51+ public void testDeclaredFilterRequestWrapping () throws IOException , SAXException {
52+
53+ String response = getFromServerPath ("protected/servlet" );
54+
55+ // The SAM wrapped a request so that it always contains the request attribute "isWrapped" with value true.
56+ assertTrue ("Request wrapped by SAM did not arrive in declared Filter." ,
57+ response .contains ("declared filter request isWrapped: true" ));
58+ }
59+
60+ @ Test
61+ public void testDeclaredFilterResponseWrapping () throws IOException , SAXException {
62+
63+ String response = getFromServerPath ("protected/servlet" );
64+
65+ // The SAM wrapped a response so that it always contains the header "isWrapped" with value true.
66+ assertTrue ("Response wrapped by SAM did not arrive in declared Filter." ,
67+ response .contains ("declared filter response isWrapped: true" ));
68+ }
2969
3070 @ Test
3171 public void testRequestWrapping () throws IOException , SAXException {
@@ -34,7 +74,7 @@ public void testRequestWrapping() throws IOException, SAXException {
3474
3575 // The SAM wrapped a request so that it always contains the request attribute "isWrapped" with value true.
3676 assertTrue ("Request wrapped by SAM did not arrive in Servlet." ,
37- response .contains ("request isWrapped: true" ));
77+ response .contains ("servlet request isWrapped: true" ));
3878 }
3979
4080 @ Test
@@ -44,7 +84,7 @@ public void testResponseWrapping() throws IOException, SAXException {
4484
4585 // The SAM wrapped a response so that it always contains the header "isWrapped" with value true.
4686 assertTrue ("Response wrapped by SAM did not arrive in Servlet." ,
47- response .contains ("response isWrapped: true" ));
87+ response .contains ("servlet response isWrapped: true" ));
4888 }
4989
5090}
0 commit comments