/*
* 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 connect, finishConnect, isConnectionPending,
* getRemoteAddresses and association.
*/
public class Connect {
if (!Util.isSCTPSupported()) {
return;
}
doTest();
}
void doTest() {
try {
/* Create a server channel to connect to */
debug("addrs should not be empty");
/* TEST 0.5 Verify default values for new/unconnected channel */
"non empty set for unconnected channel");
"non-null association for unconnected channel");
"should not have a connection pending");
/* TEST 1: non-blocking connect */
channel.configureBlocking(false);
debug("non-blocking connect did not immediately succeed");
"should return true for isConnectionPending");
try {
fail("should have thrown ConnectionPendingException");
} catch (ConnectionPendingException cpe) {
pass();
} catch (IOException ioe) {
}
channel.configureBlocking(true);
"finishConnect should have returned true");
}
/* TEST 1.5 Verify after connect */
"empty set for connected channel");
"null association for connected channel");
"pending connection for connected channel");
/* TEST 2: Verify AlreadyConnectedException thrown */
try {
fail("should have thrown AlreadyConnectedException");
} catch (AlreadyConnectedException unused) {
pass();
} catch (IOException ioe) {
}
/* TEST 2.5: Verify AlreadyConnectedException thrown */
try {
fail("should have thrown AlreadyConnectedException");
} catch (AlreadyConnectedException unused) {
pass();
} catch (IOException ioe) {
}
/* TEST 3: UnresolvedAddressException */
try {
fail("should have thrown UnresolvedAddressException");
} catch (UnresolvedAddressException unused) {
pass();
} catch (IOException ioe) {
}
/* TEST 4: UnsupportedAddressTypeException */
try {
fail("should have thrown UnsupportedAddressTypeException");
} catch (UnsupportedAddressTypeException unused) {
pass();
} catch (IOException ioe) {
}
/* TEST 5: ClosedChannelException */
/* TEST 5.5 getRemoteAddresses */
"pending connection for closed channel");
/* Run some more finishConnect tests */
/* TEST 6: NoConnectionPendingException */
try {
fail("should have thrown NoConnectionPendingException");
} catch (NoConnectionPendingException unused) {
pass();
} catch (IOException ioe) {
}
/* TEST 7: ClosedChannelException */
/* TEST 8: IOException: Connection refused. Exercises handleSocketError.
* Assumption: no sctp socket listening on 3456 */
try {
fail("should have thrown ConnectException: Connection refused");
} catch (IOException ioe) {
pass();
}
} catch (IOException ioe) {
} finally {
catch (IOException unused) {}
catch (IOException unused) {}
}
}
try {
fail("should have thrown ClosedChannelException");
} catch (ClosedChannelException cce) {
pass();
}
}
//--------------------- Infrastructure ---------------------------
boolean debug = true;
}