package bind; import junit.framework.TestCase; import netscape.ldap.LDAPConnection; import netscape.ldap.LDAPException; /** * Testcase to demonstrate DIRSERVER-632 ("If one tries to connect with an * illegal LDAP protocol version, no error occurs"). */ public class IllegalLDAPVersionBindTest extends TestCase { static final String HOST = "localhost"; static final int PORT = 10389; static final String USER = "uid=admin,ou=system"; static final String PASSWORD = "secret"; private LDAPConnection con = null; public void testConnectWithIllegalLDAPVersion() throws LDAPException { int LDAP_VERSION = 4; // illegal try { con = new LDAPConnection(); con.connect(LDAP_VERSION, HOST, PORT, USER, PASSWORD); fail("try to connect with illegal version number should fail"); } catch (LDAPException e) { assertEquals("statuscode", LDAPException.PROTOCOL_ERROR, e.getLDAPResultCode()); } finally { con.disconnect(); } } }