From 0473a8003b375856290be2b8f7c993010a9e1afc Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Sat, 27 Oct 2012 17:56:25 +1100 Subject: [PATCH] update to latest http-client api --- .../session/MaxInactiveMigrationTest.java | 6 +- .../nosql/mongodb/SessionSavingValueTest.java | 13 ++-- ...AbstractClientCrossContextSessionTest.java | 8 +-- .../session/AbstractImmortalSessionTest.java | 12 ++-- .../AbstractInvalidationSessionTest.java | 11 ++-- .../session/AbstractLastAccessTimeTest.java | 12 ++-- .../server/session/AbstractLightLoadTest.java | 12 ++-- .../AbstractLocalSessionScavengingTest.java | 12 ++-- .../session/AbstractNewSessionTest.java | 8 +-- .../session/AbstractOrphanedSessionTest.java | 8 +-- .../AbstractReentrantRequestSessionTest.java | 4 +- .../session/AbstractRemoveSessionTest.java | 8 +-- ...AbstractServerCrossContextSessionTest.java | 2 +- .../session/AbstractSessionCookieTest.java | 8 +-- .../session/AbstractSessionExpiryTest.java | 63 ++++++++----------- ...bstractSessionInvalidateAndCreateTest.java | 8 +-- .../session/AbstractSessionMigrationTest.java | 8 +-- .../session/AbstractSessionRenewTest.java | 8 +-- .../AbstractSessionValueSavingTest.java | 18 +++--- .../AbstractWebAppObjectInSessionTest.java | 8 +-- 20 files changed, 102 insertions(+), 135 deletions(-) diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java index 40546ebc83a..15a5102f54b 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/MaxInactiveMigrationTest.java @@ -103,14 +103,14 @@ public class MaxInactiveMigrationTest request.header("Cookie", sessionCookie); Future future = request.send(); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK, response.status()); + assertEquals(HttpServletResponse.SC_OK, response.getStatus()); - sessionCookie = response.headers().getStringField("Set-Cookie"); + sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue( sessionCookie != null ); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - return response.contentAsString(); + return response.getContentAsString(); } diff --git a/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionSavingValueTest.java b/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionSavingValueTest.java index 57306b68e71..8032d17b65f 100644 --- a/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionSavingValueTest.java +++ b/tests/test-sessions/test-mongodb-sessions/src/test/java/org/eclipse/jetty/nosql/mongodb/SessionSavingValueTest.java @@ -42,7 +42,6 @@ import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.nosql.NoSqlSession; import org.eclipse.jetty.server.session.AbstractSessionValueSavingTest; import org.eclipse.jetty.server.session.AbstractTestServer; -import org.junit.Ignore; import org.junit.Test; public class SessionSavingValueTest extends AbstractSessionValueSavingTest @@ -112,14 +111,14 @@ public class SessionSavingValueTest extends AbstractSessionValueSavingTest Request request = client.newRequest("http://localhost:" + port1 + contextPath + servletMapping + "?action=init"); Future future = request.send(); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); - String[] sessionTestResponse = response.contentAsString().split("/"); + String[] sessionTestResponse = response.getContentAsString().split("/"); assertTrue(Long.parseLong(sessionTestValue[0]) < Long.parseLong(sessionTestResponse[0])); sessionTestValue = sessionTestResponse; - String sessionCookie = response.headers().getStringField("Set-Cookie"); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=","$1\\$Path="); @@ -138,16 +137,16 @@ public class SessionSavingValueTest extends AbstractSessionValueSavingTest Future future2 = request2.send(); ContentResponse response2 = future2.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); - sessionTestResponse = response2.contentAsString().split("/"); + sessionTestResponse = response2.getContentAsString().split("/"); assertTrue(Long.parseLong(sessionTestValue[0]) < Long.parseLong(sessionTestResponse[0])); assertTrue(Long.parseLong(sessionTestValue[1]) < Long.parseLong(sessionTestResponse[1])); sessionTestValue = sessionTestResponse; - String setCookie = response2.headers().getStringField("Set-Cookie"); + String setCookie = response2.getHeaders().getStringField("Set-Cookie"); if (setCookie != null) sessionCookie = setCookie.replaceFirst("(\\W)(P|p)ath=","$1\\$Path="); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClientCrossContextSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClientCrossContextSessionTest.java index b68a8fa883a..b1e559f1858 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClientCrossContextSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractClientCrossContextSessionTest.java @@ -32,9 +32,7 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.junit.Test; @@ -76,8 +74,8 @@ public abstract class AbstractClientCrossContextSessionTest Future future = client.GET("http://localhost:" + port + contextA + servletMapping); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); - String sessionCookie = response.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -87,7 +85,7 @@ public abstract class AbstractClientCrossContextSessionTest request.header("Cookie", sessionCookie); future = request.send(); ContentResponse responseB = future.get(); - assertEquals(HttpServletResponse.SC_OK,responseB.status()); + assertEquals(HttpServletResponse.SC_OK,responseB.getStatus()); assertEquals(servletA.sessionId, servletB.sessionId); } finally diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractImmortalSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractImmortalSessionTest.java index 8944431fa28..87842df095b 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractImmortalSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractImmortalSessionTest.java @@ -33,9 +33,7 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.junit.Test; @@ -67,13 +65,13 @@ public abstract class AbstractImmortalSessionTest int value = 42; Future future = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=set&value=" + value); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); - String sessionCookie = response.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); - String resp = response.contentAsString(); + String resp = response.getContentAsString(); assertEquals(resp.trim(),String.valueOf(value)); // Let's wait for the scavenger to run, waiting 2.5 times the scavenger period @@ -84,8 +82,8 @@ public abstract class AbstractImmortalSessionTest request.header("Cookie", sessionCookie); future = request.send(); response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); - resp = response.contentAsString(); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); + resp = response.getContentAsString(); assertEquals(String.valueOf(value),resp.trim()); } finally diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java index ff27fd3a0b0..7b2180ac30e 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractInvalidationSessionTest.java @@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; @@ -80,8 +79,8 @@ public abstract class AbstractInvalidationSessionTest Future future = client.GET(urls[0] + "?action=init"); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response1.status()); - String sessionCookie = response1.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -92,13 +91,13 @@ public abstract class AbstractInvalidationSessionTest request2.header("Cookie", sessionCookie); future = request2.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); // Invalidate on node1 Request request1 = client.newRequest(urls[0] + "?action=invalidate"); request1.header("Cookie", sessionCookie); future = request1.send(); - assertEquals(HttpServletResponse.SC_OK, response1.status()); + assertEquals(HttpServletResponse.SC_OK, response1.getStatus()); pause(); @@ -107,7 +106,7 @@ public abstract class AbstractInvalidationSessionTest request2.header("Cookie", sessionCookie); future = request2.send(); response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java index c878ba60009..1095976342d 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLastAccessTimeTest.java @@ -84,9 +84,9 @@ public abstract class AbstractLastAccessTimeTest // Perform one request to server1 to create a session Future future = client.GET("http://localhost:" + port1 + contextPath + servletMapping + "?action=init"); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK, response1.status()); - assertEquals("test", response1.contentAsString()); - String sessionCookie = response1.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK, response1.getStatus()); + assertEquals("test", response1.getContentAsString()); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue( sessionCookie != null ); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -103,10 +103,10 @@ public abstract class AbstractLastAccessTimeTest request.header("Cookie", sessionCookie); future = request.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK , response2.status()); - assertEquals("test", response2.contentAsString()); + assertEquals(HttpServletResponse.SC_OK , response2.getStatus()); + assertEquals("test", response2.getContentAsString()); - String setCookie = response2.headers().getStringField("Set-Cookie"); + String setCookie = response2.getHeaders().getStringField("Set-Cookie"); if (setCookie!=null) sessionCookie = setCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLightLoadTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLightLoadTest.java index e709dbe02a9..847ec269386 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLightLoadTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLightLoadTest.java @@ -38,9 +38,7 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.junit.Test; @@ -83,8 +81,8 @@ public abstract class AbstractLightLoadTest Future future = client.GET( urls[0] + "?action=init" ); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response1.status()); - String sessionCookie = response1.headers().getStringField( "Set-Cookie" ); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); + String sessionCookie = response1.getHeaders().getStringField( "Set-Cookie" ); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -119,8 +117,8 @@ public abstract class AbstractLightLoadTest request.header("Cookie", sessionCookie); future = request.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); - String response = response2.contentAsString(); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); + String response = response2.getContentAsString(); System.out.println( "get = " + response ); assertEquals(response.trim(), String.valueOf( clientsCount * requestsCount ) ); } @@ -192,7 +190,7 @@ public abstract class AbstractLightLoadTest request.header("Cookie", sessionCookie); Future future = request.send(); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } // Wait for all workers to be done diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLocalSessionScavengingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLocalSessionScavengingTest.java index 4eb77dc5799..3434a6d94b0 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLocalSessionScavengingTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractLocalSessionScavengingTest.java @@ -32,8 +32,6 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; -import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.SessionManager; import org.junit.Test; @@ -87,8 +85,8 @@ public abstract class AbstractLocalSessionScavengingTest // Create the session on node1 Future future = client.GET(urls[0] + "?action=init"); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response1.status()); - String sessionCookie = response1.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -98,7 +96,7 @@ public abstract class AbstractLocalSessionScavengingTest request.header("Cookie", sessionCookie); future = request.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); // Wait for the scavenger to run on node1, waiting 2.5 times the scavenger period @@ -109,7 +107,7 @@ public abstract class AbstractLocalSessionScavengingTest request.header("Cookie", sessionCookie); future = request.send(); response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response1.status()); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); // Wait for the scavenger to run on node2, waiting 2 times the scavenger period @@ -121,7 +119,7 @@ public abstract class AbstractLocalSessionScavengingTest request.header("Cookie", sessionCookie); future = request.send(); response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java index a73d0bec3d4..6b8e5148f3d 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractNewSessionTest.java @@ -32,9 +32,7 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.servlet.ServletContextHandler; import org.junit.Test; @@ -76,8 +74,8 @@ public abstract class AbstractNewSessionTest { Future future = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create"); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); - String sessionCookie = response.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -91,7 +89,7 @@ public abstract class AbstractNewSessionTest request.header("Cookie", sessionCookie); future = request.send(); response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractOrphanedSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractOrphanedSessionTest.java index 997d848058d..9fd4033af55 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractOrphanedSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractOrphanedSessionTest.java @@ -33,9 +33,7 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.junit.Test; /** @@ -77,8 +75,8 @@ public abstract class AbstractOrphanedSessionTest // Connect to server1 to create a session and get its session cookie Future future = client.GET("http://localhost:" + port1 + contextPath + servletMapping + "?action=init"); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response1.status()); - String sessionCookie = response1.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -93,7 +91,7 @@ public abstract class AbstractOrphanedSessionTest request.header("Cookie", sessionCookie); future = request.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractReentrantRequestSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractReentrantRequestSessionTest.java index afa78dba51e..a84b29fa6b5 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractReentrantRequestSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractReentrantRequestSessionTest.java @@ -59,7 +59,7 @@ public abstract class AbstractReentrantRequestSessionTest { Future future = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=reenter&port=" + port + "&path=" + contextPath + servletMapping); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } finally { @@ -104,7 +104,7 @@ public abstract class AbstractReentrantRequestSessionTest { Future future = client.GET("http://localhost:" + port + path + ";jsessionid="+session.getId()+"?action=none"); ContentResponse resp = future.get(); - assertEquals(HttpServletResponse.SC_OK,resp.status()); + assertEquals(HttpServletResponse.SC_OK,resp.getStatus()); assertEquals("true",session.getAttribute("reentrant")); } finally diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java index 0e5f3f04e85..ed9f5f99866 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractRemoveSessionTest.java @@ -68,8 +68,8 @@ public abstract class AbstractRemoveSessionTest { Future future = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create"); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); - String sessionCookie = response.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -81,7 +81,7 @@ public abstract class AbstractRemoveSessionTest request.header("Cookie", sessionCookie); future = request.send(); response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); //ensure sessionDestroyed listener is called assertTrue(testListener.isDestroyed()); @@ -92,7 +92,7 @@ public abstract class AbstractRemoveSessionTest request.header("Cookie", sessionCookie); future = request.send(); response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java index 79d604dbd72..f6d4afc658e 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractServerCrossContextSessionTest.java @@ -68,7 +68,7 @@ public abstract class AbstractServerCrossContextSessionTest // Perform a request, on server side a cross context dispatch will be done Future future = client.GET("http://localhost:" + port + contextA + servletMapping); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java index affd3fd4db9..ea275ae0e5e 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionCookieTest.java @@ -82,9 +82,9 @@ public abstract class AbstractSessionCookieTest Future future = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create"); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); - String sessionCookie = response.headers().getStringField("Set-Cookie"); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. //sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -96,13 +96,13 @@ public abstract class AbstractSessionCookieTest future = request.send(); response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); request = client.newRequest("http://localhost:" + port + contextPath + servletMapping + "?action=null-cookie"); request.header("Cookie", sessionCookie); future = request.send(); response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java index d743225fd26..f548f6c031a 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionExpiryTest.java @@ -18,7 +18,11 @@ package org.eclipse.jetty.server.session; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.io.IOException; +import java.util.concurrent.Future; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -26,16 +30,11 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.eclipse.jetty.client.ContentExchange; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.http.HttpMethods; -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.SessionManager; -import org.eclipse.jetty.server.session.AbstractTestServer; +import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.servlet.ServletHolder; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; @@ -78,18 +77,14 @@ public abstract class AbstractSessionExpiryTest try { HttpClient client = new HttpClient(); - client.setConnectorType(HttpClient.CONNECTOR_SOCKET); client.start(); String url = "http://localhost:" + port1 + contextPath + servletMapping; //make a request to set up a session on the server - ContentExchange exchange1 = new ContentExchange(true); - exchange1.setMethod(HttpMethods.GET); - exchange1.setURL(url + "?action=init"); - client.send(exchange1); - exchange1.waitForDone(); - assertEquals(HttpServletResponse.SC_OK,exchange1.getResponseStatus()); - String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie"); + Future future = client.GET(url + "?action=init"); + ContentResponse response = future.get(); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -102,14 +97,12 @@ public abstract class AbstractSessionExpiryTest port1 = server1.getPort(); url = "http://localhost:" + port1 + contextPath + servletMapping; - //make another request, the session should not have expired - ContentExchange exchange2 = new ContentExchange(true); - exchange2.setMethod(HttpMethods.GET); - exchange2.setURL(url + "?action=notexpired"); - exchange2.getRequestFields().add("Cookie", sessionCookie); - client.send(exchange2); - exchange2.waitForDone(); - assertEquals(HttpServletResponse.SC_OK,exchange2.getResponseStatus()); + //make another request, the session should not have expired + Request request = client.newRequest(url + "?action=notexpired"); + request.getHeaders().add("Cookie", sessionCookie); + future = request.send(); + ContentResponse response2 = future.get(); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } finally @@ -135,18 +128,14 @@ public abstract class AbstractSessionExpiryTest try { HttpClient client = new HttpClient(); - client.setConnectorType(HttpClient.CONNECTOR_SOCKET); client.start(); String url = "http://localhost:" + port1 + contextPath + servletMapping; //make a request to set up a session on the server - ContentExchange exchange1 = new ContentExchange(true); - exchange1.setMethod(HttpMethods.GET); - exchange1.setURL(url + "?action=init"); - client.send(exchange1); - exchange1.waitForDone(); - assertEquals(HttpServletResponse.SC_OK,exchange1.getResponseStatus()); - String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie"); + Future future = client.GET(url + "?action=init"); + ContentResponse response1 = future.get(); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -163,13 +152,11 @@ public abstract class AbstractSessionExpiryTest url = "http://localhost:" + port1 + contextPath + servletMapping; //make another request, the session should have expired - ContentExchange exchange2 = new ContentExchange(true); - exchange2.setMethod(HttpMethods.GET); - exchange2.setURL(url + "?action=test"); - exchange2.getRequestFields().add("Cookie", sessionCookie); - client.send(exchange2); - exchange2.waitForDone(); - assertEquals(HttpServletResponse.SC_OK,exchange2.getResponseStatus()); + Request request = client.newRequest(url + "?action=test"); + request.getHeaders().add("Cookie", sessionCookie); + future = request.send(); + ContentResponse response2 = future.get(); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateAndCreateTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateAndCreateTest.java index 4d593ba9d01..76b1b6ef5c6 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateAndCreateTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionInvalidateAndCreateTest.java @@ -38,9 +38,7 @@ import javax.servlet.http.HttpSessionListener; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.junit.Test; @@ -117,8 +115,8 @@ public abstract class AbstractSessionInvalidateAndCreateTest // Create the session Future future = client.GET(url + "?action=init"); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response1.status()); - String sessionCookie = response1.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -129,7 +127,7 @@ public abstract class AbstractSessionInvalidateAndCreateTest request2.header("Cookie", sessionCookie); future = request2.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); // Wait for the scavenger to run, waiting 2.5 times the scavenger period pause(scavengePeriod); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionMigrationTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionMigrationTest.java index a909133e57c..98e0280bd3a 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionMigrationTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionMigrationTest.java @@ -72,8 +72,8 @@ public abstract class AbstractSessionMigrationTest Request request1 = client.POST("http://localhost:" + port1 + contextPath + servletMapping + "?action=set&value=" + value); Future future = request1.send(); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response1.status()); - String sessionCookie = response1.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,response1.getStatus()); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -84,8 +84,8 @@ public abstract class AbstractSessionMigrationTest request2.header("Cookie", sessionCookie); future = request2.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); - String response = response2.contentAsString(); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); + String response = response2.getContentAsString(); assertEquals(response.trim(),String.valueOf(value)); } finally { diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java index 3faba2334bf..e9d03cb2ca0 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java @@ -63,9 +63,9 @@ public abstract class AbstractSessionRenewTest //make a request to create a session Future future = client.GET("http://localhost:" + port + contextPath + servletMapping + "?action=create"); ContentResponse response = future.get(); - assertEquals(HttpServletResponse.SC_OK,response.status()); + assertEquals(HttpServletResponse.SC_OK,response.getStatus()); - String sessionCookie = response.headers().getStringField("Set-Cookie"); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); //make a request to change the sessionid @@ -73,8 +73,8 @@ public abstract class AbstractSessionRenewTest request.header("Cookie", sessionCookie); future = request.send(); ContentResponse renewResponse = future.get(); - assertEquals(HttpServletResponse.SC_OK,renewResponse.status()); - String renewSessionCookie = renewResponse.headers().getStringField("Set-Cookie"); + assertEquals(HttpServletResponse.SC_OK,renewResponse.getStatus()); + String renewSessionCookie = renewResponse.getHeaders().getStringField("Set-Cookie"); assertNotNull(renewSessionCookie); assertNotSame(sessionCookie, renewSessionCookie); } diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionValueSavingTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionValueSavingTest.java index 5849b42e813..9698a5b8c13 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionValueSavingTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionValueSavingTest.java @@ -33,9 +33,7 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.junit.Test; @@ -70,12 +68,12 @@ public abstract class AbstractSessionValueSavingTest Future future = client.GET("http://localhost:" + port1 + contextPath + servletMapping + "?action=init"); ContentResponse response1 = future.get(); - assertEquals(HttpServletResponse.SC_OK, response1.status()); - assertTrue(sessionTestValue < Long.parseLong(response1.contentAsString())); + assertEquals(HttpServletResponse.SC_OK, response1.getStatus()); + assertTrue(sessionTestValue < Long.parseLong(response1.getContentAsString())); - sessionTestValue = Long.parseLong(response1.contentAsString()); + sessionTestValue = Long.parseLong(response1.getContentAsString()); - String sessionCookie = response1.headers().getStringField("Set-Cookie"); + String sessionCookie = response1.getHeaders().getStringField("Set-Cookie"); assertTrue( sessionCookie != null ); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -95,11 +93,11 @@ public abstract class AbstractSessionValueSavingTest future = request2.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK , response2.status()); - assertTrue(sessionTestValue < Long.parseLong(response2.contentAsString())); - sessionTestValue = Long.parseLong(response2.contentAsString()); + assertEquals(HttpServletResponse.SC_OK , response2.getStatus()); + assertTrue(sessionTestValue < Long.parseLong(response2.getContentAsString())); + sessionTestValue = Long.parseLong(response2.getContentAsString()); - String setCookie = response1.headers().getStringField("Set-Cookie"); + String setCookie = response1.getHeaders().getStringField("Set-Cookie"); if (setCookie!=null) sessionCookie = setCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java index 28e27855cd5..4bb32359ffc 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractWebAppObjectInSessionTest.java @@ -30,9 +30,7 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; -import org.eclipse.jetty.client.api.Destination; import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpCookie; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.resource.Resource; @@ -119,8 +117,8 @@ public abstract class AbstractWebAppObjectInSessionTest Future future = request.send(); ContentResponse response = future.get(); - assertEquals( HttpServletResponse.SC_OK, response.status()); - String sessionCookie = response.headers().getStringField("Set-Cookie"); + assertEquals( HttpServletResponse.SC_OK, response.getStatus()); + String sessionCookie = response.getHeaders().getStringField("Set-Cookie"); assertTrue(sessionCookie != null); // Mangle the cookie, replacing Path with $Path, etc. sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); @@ -132,7 +130,7 @@ public abstract class AbstractWebAppObjectInSessionTest future = request2.send(); ContentResponse response2 = future.get(); - assertEquals(HttpServletResponse.SC_OK,response2.status()); + assertEquals(HttpServletResponse.SC_OK,response2.getStatus()); } finally {