author | pconcannon |
Wed, 27 Nov 2019 16:01:34 +0000 | |
changeset 59299 | 17d242844fc9 |
parent 57686 | 70f5cbb711a9 |
child 58679 | 9c3209ff7550 |
permissions | -rw-r--r-- |
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
1 |
/* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
3 |
* |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
4 |
* This code is free software; you can redistribute it and/or modify it |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
6 |
* published by the Free Software Foundation. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
7 |
* |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
8 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
9 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
10 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
11 |
* version 2 for more details (a copy is included in the LICENSE file that |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
12 |
* accompanied this code). |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
13 |
* |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License version |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
15 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
16 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
17 |
* |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
18 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
19 |
* or visit www.oracle.com if you need additional information or have any |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
20 |
* questions. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
21 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
22 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
23 |
import java.io.IOException; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
24 |
import java.net.DatagramSocket; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
25 |
import java.net.InetAddress; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
26 |
import java.net.InetSocketAddress; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
27 |
import java.net.MulticastSocket; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
28 |
import java.net.SocketException; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
29 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
30 |
/* |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
31 |
* @test |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
32 |
* @bug 8153674 |
57686
70f5cbb711a9
8225430: Replace wildcard address with loopback or local host in tests - part 14
aefimov
parents:
55127
diff
changeset
|
33 |
* @key intermittent |
70f5cbb711a9
8225430: Replace wildcard address with loopback or local host in tests - part 14
aefimov
parents:
55127
diff
changeset
|
34 |
* @summary This test might fail intermittently as it needs a UDP socket that |
70f5cbb711a9
8225430: Replace wildcard address with loopback or local host in tests - part 14
aefimov
parents:
55127
diff
changeset
|
35 |
* binds to the wildcard address. |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
36 |
* @summary Expected SocketException not thrown when calling bind() with |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
37 |
* setReuseAddress(false) |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
38 |
* @run main/othervm ReuseAddressTest |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
39 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
40 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
41 |
public class ReuseAddressTest { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
42 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
43 |
String getInfo(DatagramSocket soc) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
44 |
if (soc == null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
45 |
return null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
46 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
47 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
48 |
return "localPort: " + soc.getLocalPort() |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
49 |
+ "; localAddress: " + soc.getLocalAddress() |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
50 |
+ "; remotePort: " + soc.getPort() |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
51 |
+ "; remoteAddress: " + soc.getInetAddress() |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
52 |
+ "; isClosed: " + soc.isClosed() |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
53 |
+ "; isBound: " + soc.isBound(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
54 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
55 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
56 |
static InetSocketAddress createSocketAddress(int testMcastPort) throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
57 |
InetAddress localAddress = InetAddress.getLocalHost(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
58 |
InetSocketAddress localSocketAddress = new InetSocketAddress(localAddress, testMcastPort); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
59 |
return localSocketAddress; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
60 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
61 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
62 |
/* standalone interface */ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
63 |
public static void main(String argv[]) throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
64 |
ReuseAddressTest test = new ReuseAddressTest(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
65 |
test.DatagramSocket0029(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
66 |
test.DatagramSocket0030(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
67 |
test.DatagramSocket0031(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
68 |
test.DatagramSocket0032(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
69 |
test.DatagramSocket0034(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
70 |
test.DatagramSocket0035(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
71 |
test.DatagramSocket2028(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
72 |
test.DatagramSocket2029(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
73 |
test.DatagramSocket2030(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
74 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
75 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
76 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
77 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
78 |
* Equivalence class partitioning with input values orientation for public |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
79 |
* void setReuseAddress(boolean on) throws SocketException, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
80 |
* <br><b>on</b>: false. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
81 |
* <br><b>Expected results</b>: getReuseAddress() will return false |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
82 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
83 |
public void DatagramSocket0029() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
84 |
String testCaseID = "DatagramSocket0029"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
85 |
System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
86 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
87 |
DatagramSocket ds = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
88 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
89 |
ds = new DatagramSocket(null); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
90 |
ds.setReuseAddress(false); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
91 |
if (ds.getReuseAddress() == true) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
92 |
throw new RuntimeException("SO_REUSEADDR is not set to false"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
93 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
94 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
95 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
96 |
throw new RuntimeException("unexpected: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
97 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
98 |
System.out.println("Security restriction"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
99 |
} finally { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
100 |
if (ds != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
101 |
ds.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
102 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
103 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
104 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
105 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
106 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
107 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
108 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
109 |
* Equivalence class partitioning with input values orientation for public |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
110 |
* void setReuseAddress(boolean on) throws SocketException, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
111 |
* <br><b>on</b>: true. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
112 |
* <br><b>Expected results</b>: Allows completely duplicate bindings (same |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
113 |
* address and port) on multicast sockets |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
114 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
115 |
public void DatagramSocket0030() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
116 |
String testCaseID = "DatagramSocket0030"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
117 |
System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
118 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
119 |
MulticastSocket ms1 = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
120 |
MulticastSocket ms2 = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
121 |
try { |
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
122 |
InetSocketAddress addr = createSocketAddress(0); |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
123 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
124 |
ms1 = new MulticastSocket(null); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
125 |
ms1.setReuseAddress(true); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
126 |
if (!ms1.getReuseAddress()) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
127 |
System.out.println("Cannot check: " |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
128 |
+ " safety for SO_REUSEADDR option is not guaranteed"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
129 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
130 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
131 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
132 |
ms1.bind(addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
133 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
134 |
throw new RuntimeException("cannot bind first socket to " + addr |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
135 |
+ " unexpected " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
136 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
137 |
|
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
138 |
addr = createSocketAddress(ms1.getLocalPort()); |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
139 |
ms2 = new MulticastSocket(null); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
140 |
ms2.setReuseAddress(true); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
141 |
if (!ms2.getReuseAddress()) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
142 |
System.out.println("Cannot check: " |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
143 |
+ " safety for SO_REUSEADDR option is not guaranteed"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
144 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
145 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
146 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
147 |
ms2.bind(addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
148 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
149 |
throw new RuntimeException("cannot bind second socket to " + addr |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
150 |
+ " unexpected " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
151 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
152 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
153 |
if (ms1.getLocalPort() != addr.getPort() || !ms1.isBound() |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
154 |
|| ms2.getLocalPort() != addr.getPort() || !ms2.isBound()) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
155 |
System.out.println("bind() fails with: " + addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
156 |
System.out.println(" ms1 [" + getInfo(ms1) + "]"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
157 |
System.out.println(" ms2 [" + getInfo(ms2) + "]"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
158 |
System.out.println(" getReuseAddress(): " + ms2.getReuseAddress()); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
159 |
throw new RuntimeException("bind() fails with: " + addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
160 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
161 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
162 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
163 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
164 |
throw new RuntimeException("unexpected: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
165 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
166 |
System.out.println("Security restriction"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
167 |
} finally { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
168 |
if (ms1 != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
169 |
ms1.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
170 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
171 |
if (ms2 != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
172 |
ms2.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
173 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
174 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
175 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
176 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
177 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
178 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
179 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
180 |
* Equivalence class partitioning with input values orientation for public |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
181 |
* void setReuseAddress(boolean on) throws SocketException, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
182 |
* <br><b>on</b>: false. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
183 |
* <br><b>Expected results</b>: The second bind will throw SocketException, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
184 |
* when SO_REUSEADDR disable |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
185 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
186 |
public void DatagramSocket0031() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
187 |
String testCaseID = "DatagramSocket0031"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
188 |
System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
189 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
190 |
MulticastSocket ms1 = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
191 |
MulticastSocket ms2 = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
192 |
try { |
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
193 |
InetSocketAddress addr = createSocketAddress(0); |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
194 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
195 |
ms1 = new MulticastSocket(null); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
196 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
197 |
ms1.bind(addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
198 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
199 |
throw new RuntimeException("cannot bind first socket to " + addr |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
200 |
+ " unexpected " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
201 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
202 |
|
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
203 |
addr = createSocketAddress(ms1.getLocalPort()); |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
204 |
ms2 = new MulticastSocket(null); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
205 |
ms2.setReuseAddress(false); // method under test |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
206 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
207 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
208 |
ms2.bind(addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
209 |
System.out.println("No exceptions: "); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
210 |
System.out.println(" addr: " + addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
211 |
System.out.println(" ms1 [" + getInfo(ms1) + "]"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
212 |
System.out.println(" ms2 [" + getInfo(ms2) + "]"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
213 |
System.out.println(" getReuseAddress(): " + ms2.getReuseAddress()); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
214 |
throw new RuntimeException("no exceptions from bind() with " + addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
215 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
216 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
217 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
218 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
219 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
220 |
throw new RuntimeException("unexpected: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
221 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
222 |
System.out.println("Security restriction"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
223 |
} finally { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
224 |
if (ms1 != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
225 |
ms1.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
226 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
227 |
if (ms2 != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
228 |
ms2.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
229 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
230 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
231 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
232 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
233 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
234 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
235 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
236 |
* Equivalence class partitioning with input values orientation for public |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
237 |
* void setReuseAddress(boolean on) throws SocketException, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
238 |
* <br><b>on</b>: true. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
239 |
* <br><b>Expected results</b>: Allows a single process to bind the same |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
240 |
* port to multiple sockets as long as each bind specifies a different local |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
241 |
* IP address |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
242 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
243 |
public void DatagramSocket0032() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
244 |
String testCaseID = "DatagramSocket0032"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
245 |
System.out.println(" >> " + testCaseID + ": " + "public void setReuseAddress(boolean on) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
246 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
247 |
DatagramSocket ds1 = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
248 |
DatagramSocket ds2 = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
249 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
250 |
|
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
251 |
InetSocketAddress isa1 = createSocketAddress(0); |
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
252 |
InetAddress addr = isa1.getAddress(); |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
253 |
InetAddress wildcard = InetAddress.getByName("0.0.0.0"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
254 |
if (addr.equals(wildcard) || addr.isLoopbackAddress()) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
255 |
System.out.println("Cannot check: addresses are equal"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
256 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
257 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
258 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
259 |
ds1 = new DatagramSocket(null); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
260 |
ds1.setReuseAddress(true); // method under test |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
261 |
if (!ds1.getReuseAddress()) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
262 |
System.out.println("Cannot check: " |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
263 |
+ " safety for SO_REUSEADDR option is not guaranteed"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
264 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
265 |
ds1.bind(isa1); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
266 |
|
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
267 |
InetSocketAddress isa2 = new InetSocketAddress(wildcard, ds1.getLocalPort()); |
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
268 |
|
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
269 |
ds2 = new DatagramSocket(null); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
270 |
ds2.setReuseAddress(true); // method under test |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
271 |
if (!ds2.getReuseAddress()) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
272 |
System.out.println("Cannot check: " |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
273 |
+ " safety for SO_REUSEADDR option is not guaranteed"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
274 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
275 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
276 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
277 |
ds2.bind(isa2); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
278 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
279 |
throw new RuntimeException("cannot bind second socket to " + isa2 |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
280 |
+ " unexpected " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
281 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
282 |
|
55127
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
283 |
if (ds1.getLocalPort() != ds2.getLocalPort() || !ds1.isBound() |
f0ef081cb15d
8194231: java/net/DatagramSocket/ReuseAddressTest.java failed with java.net.BindException: Address already in use: Cannot bind
azeller
parents:
47216
diff
changeset
|
284 |
|| !ds2.isBound()) { |
41228
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
285 |
System.out.println("bind() fails with: " + addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
286 |
System.out.println(" ds1 [" + getInfo(ds1) + "]"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
287 |
System.out.println(" ds2 [" + getInfo(ds2) + "]"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
288 |
System.out.println(" getReuseAddress(): " + ds2.getReuseAddress()); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
289 |
throw new RuntimeException("bind() fails with: " + addr); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
290 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
291 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
292 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
293 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
294 |
throw new RuntimeException("unexpected: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
295 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
296 |
System.out.println("Security restriction"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
297 |
} finally { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
298 |
if (ds1 != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
299 |
ds1.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
300 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
301 |
if (ds2 != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
302 |
ds2.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
303 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
304 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
305 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
306 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
307 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
308 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
309 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
310 |
* Assertion testing for public int getTrafficClass() throws |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
311 |
* SocketException, will return a number in range from 0 to 255 or throw |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
312 |
* SocketException. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
313 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
314 |
public void DatagramSocket2028() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
315 |
String testCaseID = "DatagramSocket2028"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
316 |
System.out.println(" >> " + testCaseID + ": " + "public int getTrafficClass() throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
317 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
318 |
DatagramSocket ds = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
319 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
320 |
ds = new DatagramSocket(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
321 |
int tc = ds.getTrafficClass(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
322 |
if (tc < 0 || tc > 255) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
323 |
throw new RuntimeException("getTrafficClass() returns: " + tc); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
324 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
325 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
326 |
System.out.println("Security restriction: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
327 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
328 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
329 |
throw new RuntimeException("Unexpected exception : " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
330 |
} finally { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
331 |
if (ds != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
332 |
ds.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
333 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
334 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
335 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
336 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
337 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
338 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
339 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
340 |
* Assertion testing for public void setTrafficClass(int tc) throws |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
341 |
* SocketException, IAE will be thrown with tc less than 0 or greater than |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
342 |
* 255. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
343 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
344 |
public void DatagramSocket2029() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
345 |
String testCaseID = "DatagramSocket2029"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
346 |
System.out.println(" >> " + testCaseID + ": " + "public void setTrafficClass(int tc) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
347 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
348 |
DatagramSocket ds = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
349 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
350 |
ds = new DatagramSocket(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
351 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
352 |
System.out.println("Security restriction: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
353 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
354 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
355 |
throw new RuntimeException("cannot create socket: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
356 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
357 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
358 |
int[] values = { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
359 |
Integer.MIN_VALUE, Integer.MIN_VALUE + 1, -1000, -2, -1, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
360 |
256, 257, 1000, 50000, Integer.MAX_VALUE - 1, Integer.MAX_VALUE |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
361 |
}; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
362 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
363 |
for (int i = 0; i < values.length; i++) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
364 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
365 |
ds.setTrafficClass(values[i]); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
366 |
System.out.println("No exception with: " + values[i]); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
367 |
System.out.println("getTrafficClass() returns: " + ds.getTrafficClass()); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
368 |
ds.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
369 |
throw new RuntimeException("setTrafficClass() fails with : " + values[i]); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
370 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
371 |
ds.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
372 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
373 |
throw new RuntimeException("setTrafficClass() throws : " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
374 |
} catch (IllegalArgumentException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
375 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
376 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
377 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
378 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
379 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
380 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
381 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
382 |
* Assertion testing for public void setTrafficClass(int tc) throws |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
383 |
* SocketException, only SocketException may be thrown with tc in range from |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
384 |
* 0 to 255. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
385 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
386 |
public void DatagramSocket2030() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
387 |
String testCaseID = "DatagramSocket2030"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
388 |
System.out.println(" >> " + testCaseID + ": " + "public void setTrafficClass(int tc) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
389 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
390 |
DatagramSocket ds = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
391 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
392 |
ds = new DatagramSocket(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
393 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
394 |
System.out.println("Security restriction: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
395 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
396 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
397 |
throw new RuntimeException("cannot create socket: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
398 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
399 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
400 |
for (int i = 0; i <= 255; i++) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
401 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
402 |
ds.setTrafficClass(i); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
403 |
} catch (SocketException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
404 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
405 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
406 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
407 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
408 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
409 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
410 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
411 |
* Equivalence class partitioning with input values orientation for public |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
412 |
* void setBroadcast(boolean on) throws SocketException, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
413 |
* <br><b>on</b>: false. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
414 |
* <br><b>Expected results</b>: getBroadcast() will return false |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
415 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
416 |
public void DatagramSocket0034() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
417 |
String testCaseID = "DatagramSocket0034"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
418 |
System.out.println(" >> " + testCaseID + ": " + "public void setBroadcast(boolean on) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
419 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
420 |
DatagramSocket ds = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
421 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
422 |
ds = new DatagramSocket(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
423 |
ds.setBroadcast(false); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
424 |
if (ds.getBroadcast() == true) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
425 |
throw new RuntimeException("SO_BROADCAST is not set to false"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
426 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
427 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
428 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
429 |
throw new RuntimeException("unexpected: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
430 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
431 |
System.out.println("Security restriction"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
432 |
} finally { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
433 |
if (ds != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
434 |
ds.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
435 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
436 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
437 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
438 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
439 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
440 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
441 |
/** |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
442 |
* Equivalence class partitioning with input values orientation for public |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
443 |
* void setBroadcast(boolean on) throws SocketException, |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
444 |
* <br><b>on</b>: true. |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
445 |
* <br><b>Expected results</b>: getBroadcast() will return true |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
446 |
*/ |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
447 |
public void DatagramSocket0035() throws Exception { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
448 |
String testCaseID = "DatagramSocket0035"; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
449 |
System.out.println(" >> " + testCaseID + ": " + "public void setBroadcast(boolean on) throws SocketException"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
450 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
451 |
DatagramSocket ds = null; |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
452 |
try { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
453 |
ds = new DatagramSocket(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
454 |
ds.setBroadcast(true); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
455 |
if (ds.getBroadcast() == false) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
456 |
throw new RuntimeException("SO_BROADCAST is not set to true"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
457 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
458 |
} catch (IOException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
459 |
e.printStackTrace(System.out); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
460 |
throw new RuntimeException("unexpected: " + e); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
461 |
} catch (SecurityException e) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
462 |
System.out.println("Security restriction"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
463 |
} finally { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
464 |
if (ds != null) { |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
465 |
ds.close(); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
466 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
467 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
468 |
|
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
469 |
System.out.println("OKAY"); |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
470 |
} |
bb9385e8c619
8153674: Expected SocketException not thrown when calling bind() with setReuseAddress(false)
vtewari
parents:
diff
changeset
|
471 |
} |