/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4476378
* @summary Check the specific behaviour of the setReuseAddress(boolean)
* method.
* @run main Basic
*/
public class Basic {
testCount++;
}
void passed() {
}
void failed() {
failures++;
}
if (pass) {
passed();
} else {
failed();
}
}
test("Socket should be created with SO_REUSEADDR disabled");
test("Socket.setReuseAddress(true)");
s1.setReuseAddress(true);
test("Socket.setReuseAddress(false)");
s1.setReuseAddress(false);
/* bind to any port */
test("Binding Socket to port already in use should throw " +
"a BindException");
try {
failed();
} catch (BindException e) {
passed();
}
}
test("ServerSocket.setReuseAddress(true)");
s1.setReuseAddress(true);
test("Socket.setReuseAddress(false)");
s1.setReuseAddress(false);
/* bind to any port */
test("Binding ServerSocket to port already in use should throw " +
"a BindException");
try {
failed();
} catch (BindException e) {
passed();
}
}
test("DatagramSocket should be created with SO_REUSEADDR disabled");
test("DatagramSocket.setReuseAddress(true)");
s1.setReuseAddress(true);
test("DatagramSocket.setReuseAddress(false)");
s1.setReuseAddress(false);
/* bind to any port */
test("Binding datagram socket to port already in use should throw " +
"a BindException");
try {
failed();
} catch (BindException e) {
passed();
}
// bind with SO_REUSEADDR enabled
s1.setReuseAddress(true);
test("Bind 2 datagram sockets to the same port - second " +
"bind doesn't have SO_REUSEADDR enabled");
try {
failed();
} catch (BindException e) {
passed();
}
test("Bind 2 datagram sockets to the same port - both have " +
"SO_REUSEADDR enabled");
s2.setReuseAddress(true);
try {
passed();
} catch (BindException e) {
// exclusive bind enabled - expected result
passed();
} else {
failed();
}
}
}
test("Check SO_REUSEADDR is enabled in MulticastSocket()");
test("Check that SO_REUSEADDR is not disabled by " +
"MulticastSocket.bind()");
// bind to specific address
}
SocketTests();
failures + " failure(s).");
if (failures > 0) {
}
}
new Basic();
}
}