* @throws Exception if an error occurs
*/
public void testSimpleRedirect() throws Exception {
// redirect status codes are 301, 302 and 307
HttpServerMock redirectServerMock1 = createServerMock();
HttpServerMock redirectServerMock2 = createServerMock();
HttpServerMock redirectServerMock3 = createServerMock();
String[] redirectContent1 = new String[]{
"HTTP/1.0 301 OK",
"Content-Type: text/plain",
"Content-Length: 99",
"Age: 1",
"Location: " + redirectServerMock1.getURLAsString("/welcome.jsp"),
"Set-Cookie: BROWSER=Netscape; domain=localhost; path=/",
"",
"<p>We will be redirected so should never see this</p>"
};
serverMock.addTransaction(null, redirectContent1);
String[] redirectContent2 = new String[]{
"HTTP/1.0 302 OK",
"Content-Type: text/wml",
"Content-Length: 88",
"Age: 1",
"Location: " + redirectServerMock2.getURLAsString("/hello.jsp"),
"Set-Cookie: DEVICE=PC; domain=localhost; path=/; secure",
"",
"<p>Again we will be redirected so should never see this</p>"
};
redirectServerMock1.addTransaction(null, redirectContent2);
String[] redirectContent3 = new String[]{
"HTTP/1.0 307 OK",
"Content-Type: text/xml",
"Content-Length: 77",
"Age: 1",
"Location: " + redirectServerMock3.getURLAsString("/my.jsp"),
"Set-Cookie: DEVICE=PALM; domain=localhost; path=/",
"",
"<p>Again we will be redirected so should never see this</p>"
};
redirectServerMock2.addTransaction(null, redirectContent3);
String[] finalContent = new String[]{
"HTTP/1.0 200 OK",
"Content-Type: text/html",
"Content-Length: 543",
"Age: 1",
"Set-Cookie: DEVICE=NOKIA; domain=localhost; path=/",
"",
"<html>",
"<p>Should see this</p>",
"<a href=\"fred.jsp\"/>",
"</html>"
};
redirectServerMock3.addTransaction(null, finalContent);
outputServerPort = redirectServerMock3.getServerPort();
XMLPipelineConfiguration config = createPipelineConfiguration();
XMLPipelineContext context =
pipelineFactory.createPipelineContext(config,
createRootEnvironmentInteraction());