| File was renamed from opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/LDAPDefaultTCPNIOTransportTestCase.java |
| | |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import java.net.Socket; |
| | | import java.util.Random; |
| | | |
| | | import org.forgerock.opendj.ldap.TestCaseUtils; |
| | | import org.glassfish.grizzly.nio.transport.TCPNIOTransport; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import com.forgerock.opendj.ldap.LDAPDefaultTCPNIOTransport; |
| | | import com.forgerock.opendj.ldap.DefaultTCPNIOTransport; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests LDAPDefaultTCPNIOTransport class. |
| | | * Tests DefaultTCPNIOTransport class. |
| | | */ |
| | | public class LDAPDefaultTCPNIOTransportTestCase extends LDAPTestCase |
| | | public class DefaultTCPNIOTransportTestCase extends LDAPTestCase |
| | | { |
| | | /** |
| | | * Tests the default transport. |
| | |
| | | public void testGetInstance() throws Exception |
| | | { |
| | | // Create a transport. |
| | | final TCPNIOTransport transport = LDAPDefaultTCPNIOTransport.getInstance(); |
| | | final Random r = new Random(); |
| | | int port = r.nextInt(10000); |
| | | if (port < 1000) |
| | | { |
| | | port += 1000; |
| | | } |
| | | final TCPNIOTransport transport = DefaultTCPNIOTransport.getInstance(); |
| | | final int port = TestCaseUtils.findFreePort(); |
| | | |
| | | transport.bind(port); |
| | | // Establish a socket connection to see if the transport factory works. |
| | | final Socket socket = new Socket("localhost", port); |