Changeset 406 for trunk/openjdk/jdk/test


Ignore:
Timestamp:
Dec 21, 2012, 10:37:13 AM (13 years ago)
Author:
dmik
Message:

trunk: Merged in openjdk6 b27 from branches/vendor/oracle.

Location:
trunk/openjdk
Files:
4 edited
9 copied

Legend:

Unmodified
Added
Removed
  • trunk/openjdk

  • trunk/openjdk/jdk/test/java/net/Socket/setReuseAddress/Basic.java

    r278 r406  
    11/*
    2  * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2424/*
    2525 * @test
    26  * @bug 4476378
     26 * @bug 4476378 7123896
    2727 * @summary Check the specific behaviour of the setReuseAddress(boolean)
    2828 * method.
     29 * @run main Basic
     30 * @run main/othervm -Dsun.net.useExclusiveBind Basic
    2931 */
    3032import java.net.*;
     
    171173            passed();
    172174        } catch (BindException e) {
    173             failed();
     175            if (System.getProperty("sun.net.useExclusiveBind") != null) {
     176                // exclusive bind enabled - expected result
     177                passed();
     178            } else {
     179                failed();
     180            }
    174181        }
    175182        s2.close();
  • trunk/openjdk/jdk/test/java/net/Socket/setReuseAddress/Restart.java

    r278 r406  
    11/*
    2  * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2424/*
    2525 * @test
    26  * @bug 4476378
    27  * @summary Check that SO_REUSEADDR allows a server to restart
     26 * @bug 4476378 7123896
     27 * @summary Check that SO_REUSEADDR allows a server to restart 
    2828 *          after a crash.
     29 * @run main Restart
     30 * @run main/othervm -Dsun.net.useExclusiveBind Restart
    2931 */
    3032import java.net.*;
     
    4042
    4143    public static void main(String args[]) throws Exception {
     44        ServerSocket ss = new ServerSocket(0);
     45        Socket s1 = null, s2 = null;
     46        try {
     47            int port = ss.getLocalPort();
    4248
    43         InetSocketAddress isa = new InetSocketAddress(0);
    44         ServerSocket ss = new ServerSocket();
    45         ss.bind(isa);
     49            s1 = new Socket(InetAddress.getLocalHost(), port);
     50            s2 = ss.accept();
    4651
    47         int port = ss.getLocalPort();
     52            // close server socket and the accepted connection
     53            ss.close();
     54            s2.close();
    4855
    49         Socket s1 = new Socket(InetAddress.getLocalHost(), port);
    50         Socket s2 = ss.accept();
     56            ss = new ServerSocket();
     57            ss.bind( new InetSocketAddress(port) );
     58            ss.close();
    5159
    52         // close server socket and the accepted connection
    53         ss.close();
    54         s2.close();
    55 
    56         boolean failed = false;
    57 
    58         ss = new ServerSocket();
    59         ss.bind( new InetSocketAddress(port) );
    60         ss.close();
    61 
    62         // close the client socket
    63         s1.close();
     60            // close the client socket
     61            s1.close();
     62        } catch (BindException be) {
     63            if (System.getProperty("sun.net.useExclusiveBind") != null) {
     64                // exclusive bind, expected exception
     65            } else {
     66                throw be;
     67            }
     68        } finally {
     69            if (ss != null) ss.close();
     70            if (s1 != null) s1.close();
     71            if (s2 != null) s2.close();
     72        }
    6473    }
    6574}
  • trunk/openjdk/jdk/test/java/util/UUID/UUIDTest.java

    r278 r406  
    11/*
    2  * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    6161        for (int i=0; i<100; i++) {
    6262            UUID u1 = UUID.randomUUID();
     63            if(4 != u1.version())
     64                throw new Exception("bad version");
     65            if(2 != u1.variant())
     66                throw new Exception("bad variant");
    6367            if (list.contains(u1))
    6468                throw new Exception("random UUID collision very unlikely");
     
    7377        for (int i=0; i<100; i++) {
    7478            byteSource.nextBytes(someBytes);
    75             UUID test = UUID.nameUUIDFromBytes(someBytes);
    76             if (list.contains(test))
     79            UUID u1 = UUID.nameUUIDFromBytes(someBytes);
     80            if(3 != u1.version())
     81                throw new Exception("bad version");
     82            if(2 != u1.variant())
     83                throw new Exception("bad variant");
     84            if (list.contains(u1))
    7785                throw new Exception("byte UUID collision very unlikely");
    78             list.add(test);
     86            list.add(u1);
    7987        }
    8088    }
Note: See TracChangeset for help on using the changeset viewer.