/*
* 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 4927640
* @summary Tests the SCTP protocol implementation
* @author chegar
*/
/**
* Tests bind, bindAddress, unbindAddress, getLocalAddress, and
* getAllLocalAddresses.
*/
public class Bind {
if (!Util.isSCTPSupported()) {
return;
}
/* Simply bind tests */
testBind();
/* Test unconnected */
testBindUnbind(false);
/* Test connected */
* This test can be run on systems that support dynamic address
* reconfiguration */
//testBindUnbind(true);
}
void testBind() {
try {
/* TEST 1: empty set if channel is not bound */
"getAllLocalAddresses returned non empty set for unbound channel");
/* TEST 2: null to bind the channel to an automatically assigned
* socket address */
/* TEST 3: non empty set if the channel is bound */
"getAllLocalAddresses returned empty set for bound channel");
debug("getAllLocalAddresses on channel bound to the wildcard:\n"
+ channel.getAllLocalAddresses());
/* TEST 4: AlreadyBoundException if this channel is already bound */
/* TEST 5: UnsupportedAddressTypeException */
try {
fail("UnsupportedSocketAddress expected");
/* TEST 6: AlreadyConnectedException */
try {
fail("AlreadyConnectedException expected");
/* TEST 7: ClosedChannelException - If this channel is closed */
try {
fail("ClosedChannelException expected");
/* TEST 8: ClosedChannelException if channel is closed */
try {
fail("should have thrown ClosedChannelException");
} catch (ClosedChannelException cce) {
pass();
}
} catch (IOException ioe) {
} finally {
}
}
try {
}
if (connected) {
/* Test with connected channel */
}
/* TEST 1: bind/unbindAddresses on the system addresses */
debug("bind/unbindAddresses on the system addresses");
try {
} catch (IOException ioe) {
}
}
/* TEST 2: bindAddress - already bound address. */
try {
} catch (AlreadyBoundException unused) {
debug("Caught AlreadyBoundException - OK");
pass();
} catch (IOException ioe) {
}
/* TEST 3: bind non local address */
try {
} catch (IOException ioe) {
}
/* TEST 4: unbind address that is not bound */
try {
/* remove address first then again */
} catch (IllegalUnbindException unused) {
debug("Caught IllegalUnbindException - OK");
pass();
} catch (IOException ioe) {
}
/* TEST 5: unbind address that is not bound */
try {
} catch (IllegalUnbindException unused) {
debug("Caught IllegalUnbindException - OK");
pass();
} catch (IOException ioe) {
}
if (connected) {
debug("peerChannel Reached EOF");
break;
}
}
}
debug("channel Reached EOF");
break;
}
}
}
}
} catch (IOException ioe) {
} finally {
}
}
throws IOException {
return true;
}
return false;
}
throws IOException {
debug("connecting channel...");
try {
debug("connected");
return peerChannel;
} catch (IOException ioe) {
debug("Cannot connect channel");
throw ioe;
}
}
{
{
return HandlerResult.CONTINUE;
}
{
return HandlerResult.CONTINUE;
}
{
return HandlerResult.CONTINUE;
}
}
//--------------------- Infrastructure ---------------------------
boolean debug = true;
}