jdk/test/java/net/CookieHandler/B6791927.java
author amurillo
Fri, 20 Apr 2012 16:23:48 -0700
changeset 12384 55ac5f20c7bf
parent 10138 b7572da25d15
child 14787 54eb3f090934
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1945
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     1
/*
10138
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
     2
 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
1945
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     4
 *
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     7
 * published by the Free Software Foundation.
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     8
 *
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    13
 * accompanied this code).
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    14
 *
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1945
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1945
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1945
diff changeset
    21
 * questions.
1945
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    22
 */
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    23
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    24
/**
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    25
 * @test
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    26
 * @bug 6791927
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    27
 * @summary Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    28
 */
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    29
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    30
import java.net.*;
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    31
import java.util.List;
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    32
import java.util.Locale;
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    33
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    34
public class B6791927 {
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    35
    public static final void main( String[] aaParamters ) throws Exception{
10138
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    36
        Locale reservedLocale = Locale.getDefault();
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    37
        try {
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    38
            // Forces a non US locale
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    39
            Locale.setDefault(Locale.FRANCE);
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    40
            List<HttpCookie> cookies = HttpCookie.parse("set-cookie: CUSTOMER=WILE_E_COYOTE; expires=Wednesday, 09-Nov-2019 23:12:40 GMT");
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    41
            if (cookies == null || cookies.isEmpty()) {
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    42
                throw new RuntimeException("No cookie found");
1945
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    43
            }
10138
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    44
            for (HttpCookie c : cookies) {
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    45
                if (c.getMaxAge() == 0) {
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    46
                    throw new RuntimeException(
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    47
                        "Expiration date shouldn't be 0");
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    48
                }
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    49
            }
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    50
        } finally {
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    51
            // restore the reserved locale
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
    52
            Locale.setDefault(reservedLocale);
1945
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    53
        }
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    54
    }
95b9d549a3b4 6791927: Wrong Locale in HttpCookie::expiryDate2DeltaSeconds
jccollet
parents:
diff changeset
    55
}