/*
* 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
*/
public class Receive {
/* Latches used to synchronize between the client and server so that
* connections without any IO may not be closed without being accepted */
/* Used to verify that the ppid is being sent and received correctly */
if (!Util.isSCTPSupported()) {
return;
}
/* requested to connecct to a specific address */
try {
} catch (NumberFormatException nfe) {
}
} else {
/* start server on local machine, default */
try {
} catch (IOException ioe) {
return;
}
}
}
try {
/* TEST 1: Verify NotYetConnectedException thrown */
try {
fail("should have thrown NotYetConnectedException");
} catch (NotYetConnectedException unused) {
pass();
} catch (IOException ioe) {
}
/* TEST 2: receive small message */
do {
debug("Test 2: invoking receive");
fail("unexpected null from receive");
return;
}
} while (!info.isComplete());
"message should not be unordered");
length, "bytes received not equal to message length");
"received message not the same as sent message");
/* TEST 3: receive large message */
do {
debug("Test 3: invoking receive");
fail("unexpected null from receive");
return;
}
} while (!info.isComplete());
"message should not be unordered");
length, "bytes received not equal to message length");
"received message not the same as sent message");
/* TEST 4: EOF */
/* TEST 5: ClosedChannelException */
try {
fail("should have thrown ClosedChannelException");
} catch (ClosedChannelException cce) {
pass();
} catch (IOException ioe) {
}
/* TEST 6: handler returns RETURN after handling a notification */
/* TEST 7: Non blocking channel return null if no data */
channel.configureBlocking(false);
} catch (IOException ioe) {
} finally {
catch (IOException e) { unexpected (e);}
}
}
}
{
debug("addrs should not be empty");
}
public void start() {
}
return serverAddr;
}
public void run() {
try {
/* send a small message */
/* send a large message */
debug("shutdown");
new ReceiveNotificationHandler(sc);
/* accept another socket for the TEST 6 */
} catch (IOException ioe) {
} catch (InterruptedException ie) {
unexpected(ie);
}
}
}
{
}
public boolean receivedCommUp() {
return receivedCommUp;
}
fail("Unknown notification type");
return HandlerResult.CONTINUE;
}
debug("AssociationChangeNotification");
receivedCommUp = true;
return HandlerResult.RETURN;
/* TEST 4: IllegalReceiveException - If the given handler invokes
* the receive method of this channel*/
try {
fail("IllegalReceiveException expected");
} catch (IllegalReceiveException unused) {
pass();
} catch (IOException ioe) {
}
return HandlerResult.CONTINUE;
}
debug("ShutdownNotification");
return HandlerResult.CONTINUE;
}
}
//--------------------- Infrastructure ---------------------------
boolean debug = true;
}