+ * wait-time = {@link #WAIT_COUNT} * {@value #WAIT_SLEEP} + */ + static final int WAIT_COUNT = 50; + static final int WAIT_SLEEP = 100; + + /** + * Verify UDT client/server connect and disconnect. + */ + @Test + public void connection() throws Exception { + + final String host = "localhost"; + final int port = 1234; + + log.info("Starting server."); + final Server server = new Server(host, port); + final Thread serverTread = new Thread(server, "server-*"); + serverTread.start(); + server.waitForRunning(true); + assertTrue(server.isRunning); + + log.info("Starting client."); + final Client client = new Client(host, port); + final Thread clientThread = new Thread(client, "client-*"); + clientThread.start(); + client.waitForRunning(true); + assertTrue(client.isRunning); + + log.info("Wait till connection is active."); + client.waitForActive(true); + server.waitForActive(true); + + log.info("Verify connection is active."); + assertEquals("group must have one", 1, server.group.size()); + + log.info("Stopping client."); + client.shutdown(); + client.waitForShutdown(); + assertTrue(client.isShutdown); + + log.info("Wait till connection is inactive."); + client.waitForActive(false); + server.waitForActive(false); + + log.info("Verify connection is inactive."); + assertEquals("group must be empty", 0, server.group.size()); + + log.info("Stopping server."); + server.shutdown(); + server.waitForShutdown(); + assertTrue(server.isShutdown); + + log.info("Finished server."); + } + } diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/udt/package-info.java b/testsuite/src/test/java/io/netty/testsuite/transport/udt/package-info.java new file mode 100644 index 0000000000..3345a22a72 --- /dev/null +++ b/testsuite/src/test/java/io/netty/testsuite/transport/udt/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012 The Netty Project + * + * The Netty Project licenses this file to you under the Apache License, + * version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/** + * Test suite classes for UDT. + */ +package io.netty.testsuite.transport.udt; +