@Deployment(testable = false)
public static WebArchive createDeployment() {
return defaultArchive();
}
cd javaee7-samples/jaspic/wrapping/Now we are ready to start testing. You can run all the tests in this sample by executing:
mvn test
Or you can run individual tests by executing one of the following:mvn test -Dtest=WrappingTest
This tests that the wrapped request and response a SAM puts into the MessageInfo structure reaches the Servlet that’s invoked.
@Deployment(testable = false)
public static WebArchive createDeployment() {
return defaultArchive();
}
@Test
public void testRequestWrapping() throws IOException, SAXException {
String response = getFromServerPath("protected/servlet");
// The SAM wrapped a request so that it always contains the request attribute "isWrapped" with value true.
assertTrue("Request wrapped by SAM did not arrive in Servlet.",
response.contains("request isWrapped: true"));
}
@Test
public void testResponseWrapping() throws IOException, SAXException {
String response = getFromServerPath("protected/servlet");
// The SAM wrapped a response so that it always contains the header "isWrapped" with value true.
assertTrue("Response wrapped by SAM did not arrive in Servlet.",
response.contains("response isWrapped: true"));
}
There's a lot more about JavaEE to cover. If you're ready to learn more, check out the other available samples.
git clone git://github.com/javaee-samples/javaee7-samples.git
cd javaee7-samples/jaspic/wrapping/
Do the changes as you see fit and send a pull request!
Good Luck!