Java Code Examples for java.net.HttpCookie#equals()

The following examples show how to use java.net.HttpCookie#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NullUriCookieTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 2
Source File: NullUriCookieTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 3
Source File: NullUriCookieTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 4
Source File: TestHttpCookie.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 5
Source File: NullUriCookieTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 6
Source File: TestHttpCookie.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 7
Source File: NullUriCookieTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 8
Source File: TestHttpCookie.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 9
Source File: NullUriCookieTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 10
Source File: TestHttpCookie.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 11
Source File: NullUriCookieTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 12
Source File: TestHttpCookie.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 13
Source File: NullUriCookieTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 14
Source File: TestHttpCookie.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 15
Source File: NullUriCookieTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 16
Source File: TestHttpCookie.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 17
Source File: NullUriCookieTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 18
Source File: TestHttpCookie.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}
 
Example 19
Source File: NullUriCookieTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
Example 20
Source File: TestHttpCookie.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void eq(HttpCookie ck1, HttpCookie ck2, boolean same) {
    testCount++;
    if (ck1.equals(ck2) != same) {
        raiseError("Comparison inconsistent: " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }

    int h1 = ck1.hashCode();
    int h2 = ck2.hashCode();
    if ((h1 == h2) != same) {
        raiseError("Comparison inconsistent: hashCode for " + ck1 + " " + ck2
                + " should " + (same ? "equal" : "not equal"));
    }
}