java.net.HttpCookie#equals ( )源码实例Demo

下面列出了java.net.HttpCookie#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: NullUriCookieTest.java
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");
}
 
源代码2 项目: jdk8u_jdk   文件: TestHttpCookie.java
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"));
    }
}
 
源代码3 项目: TencentKona-8   文件: NullUriCookieTest.java
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");
}
 
源代码4 项目: TencentKona-8   文件: TestHttpCookie.java
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"));
    }
}
 
源代码5 项目: jdk8u60   文件: NullUriCookieTest.java
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");
}
 
源代码6 项目: jdk8u60   文件: TestHttpCookie.java
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"));
    }
}
 
源代码7 项目: openjdk-jdk8u   文件: NullUriCookieTest.java
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");
}
 
源代码8 项目: openjdk-jdk8u   文件: TestHttpCookie.java
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"));
    }
}
 
源代码9 项目: jdk8u_jdk   文件: NullUriCookieTest.java
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");
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: TestHttpCookie.java
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"));
    }
}
 
源代码11 项目: openjdk-jdk9   文件: NullUriCookieTest.java
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");
}
 
源代码12 项目: openjdk-jdk9   文件: TestHttpCookie.java
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"));
    }
}
 
源代码13 项目: jdk8u-jdk   文件: NullUriCookieTest.java
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");
}
 
源代码14 项目: jdk8u-jdk   文件: TestHttpCookie.java
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"));
    }
}
 
源代码15 项目: hottub   文件: NullUriCookieTest.java
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");
}
 
源代码16 项目: hottub   文件: TestHttpCookie.java
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"));
    }
}
 
源代码17 项目: openjdk-8-source   文件: NullUriCookieTest.java
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");
}
 
源代码18 项目: openjdk-8-source   文件: TestHttpCookie.java
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"));
    }
}
 
源代码19 项目: openjdk-8   文件: NullUriCookieTest.java
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");
}
 
源代码20 项目: jdk8u-dev-jdk   文件: NullUriCookieTest.java
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");
}