Changeset 406 for trunk/openjdk/jdk/test
- Timestamp:
- Dec 21, 2012, 10:37:13 AM (13 years ago)
- Location:
- trunk/openjdk
- Files:
-
- 4 edited
- 9 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/openjdk
- Property svn:mergeinfo changed
/branches/vendor/oracle/openjdk6/b27 (added) merged: 405 /branches/vendor/oracle/openjdk6/current merged: 404
- Property svn:mergeinfo changed
-
trunk/openjdk/jdk/test/java/net/Socket/setReuseAddress/Basic.java
r278 r406 1 1 /* 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. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 24 24 /* 25 25 * @test 26 * @bug 4476378 26 * @bug 4476378 7123896 27 27 * @summary Check the specific behaviour of the setReuseAddress(boolean) 28 28 * method. 29 * @run main Basic 30 * @run main/othervm -Dsun.net.useExclusiveBind Basic 29 31 */ 30 32 import java.net.*; … … 171 173 passed(); 172 174 } 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 } 174 181 } 175 182 s2.close(); -
trunk/openjdk/jdk/test/java/net/Socket/setReuseAddress/Restart.java
r278 r406 1 1 /* 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. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 24 24 /* 25 25 * @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 28 28 * after a crash. 29 * @run main Restart 30 * @run main/othervm -Dsun.net.useExclusiveBind Restart 29 31 */ 30 32 import java.net.*; … … 40 42 41 43 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(); 42 48 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(); 46 51 47 int port = ss.getLocalPort(); 52 // close server socket and the accepted connection 53 ss.close(); 54 s2.close(); 48 55 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(); 51 59 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 } 64 73 } 65 74 } -
trunk/openjdk/jdk/test/java/util/UUID/UUIDTest.java
r278 r406 1 1 /* 2 * Copyright (c) 2003, 20 04, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 61 61 for (int i=0; i<100; i++) { 62 62 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"); 63 67 if (list.contains(u1)) 64 68 throw new Exception("random UUID collision very unlikely"); … … 73 77 for (int i=0; i<100; i++) { 74 78 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)) 77 85 throw new Exception("byte UUID collision very unlikely"); 78 list.add( test);86 list.add(u1); 79 87 } 80 88 }
Note:
See TracChangeset
for help on using the changeset viewer.