Search in sources :

Example 16 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v1NullValue.

@Test
public void v1NullValue() {
    Cookie cookie = new Cookie("foo", null);
    cookie.setVersion(1);
    doTest(cookie, "foo=\"\"; Version=1", "foo=");
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Example 17 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v1ValueContainsBackslash.

@Test
public void v1ValueContainsBackslash() {
    Cookie cookie = new Cookie("foo", "a\\b");
    cookie.setVersion(1);
    doTest(cookie, "foo=\"a\\\\b\"; Version=1", null);
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Example 18 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v1simpleCookie.

@Test
public void v1simpleCookie() {
    Cookie cookie = new Cookie("foo", "bar");
    cookie.setVersion(1);
    doTest(cookie, "foo=bar; Version=1", "foo=bar");
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Example 19 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookies method doTestBug60788.

private void doTestBug60788(boolean useRfc6265) {
    Cookie expected = new Cookie("userId", "foo");
    expected.setVersion(1);
    if (useRfc6265) {
        expected.setDomain("\"www.example.org\"");
        expected.setPath("\"/\"");
    } else {
        // The legacy processor removes the quotes for domain and path
        expected.setDomain("www.example.org");
        expected.setPath("/");
    }
    test(useRfc6265, "$Version=\"1\"; userId=\"foo\";$Path=\"/\";$Domain=\"www.example.org\"", expected);
}
Also used : Cookie(javax.servlet.http.Cookie)

Example 20 with Cookie

use of javax.servlet.http.Cookie in project tomcat by apache.

the class TestCookieProcessorGeneration method v0ValueContainsEquals.

@Test
public void v0ValueContainsEquals() {
    Cookie cookie = new Cookie("foo", "a=b");
    doTestDefaults(cookie, "foo=\"a=b\"; Version=1", "foo=a=b");
    doTestAllowSeparators(cookie, "foo=a=b", "foo=a=b");
}
Also used : Cookie(javax.servlet.http.Cookie) Test(org.junit.Test)

Aggregations

Cookie (javax.servlet.http.Cookie)522 Test (org.junit.Test)207 HttpServletRequest (javax.servlet.http.HttpServletRequest)84 HttpServletResponse (javax.servlet.http.HttpServletResponse)61 IOException (java.io.IOException)45 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)44 ServletException (javax.servlet.ServletException)40 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)32 HashMap (java.util.HashMap)28 HttpSession (javax.servlet.http.HttpSession)26 Locale (java.util.Locale)23 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)23 HttpCookie (java.net.HttpCookie)19 Properties (java.util.Properties)19 Date (java.util.Date)18 PrintWriter (java.io.PrintWriter)17 ArrayList (java.util.ArrayList)17 Map (java.util.Map)16 MvcResult (org.springframework.test.web.servlet.MvcResult)15 ResultMatcher (org.springframework.test.web.servlet.ResultMatcher)15