You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2017/02/24 09:35:21 UTC

svn commit: r1784251 - /jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/AbstractServer.java

Author: mduerig
Date: Fri Feb 24 09:35:20 2017
New Revision: 1784251

URL: http://svn.apache.org/viewvc?rev=1784251&view=rev
Log:
OAK-5542: Test failure: security.authentication.ldap.LdapProviderTest (Address already in use)
OAK-5485: Test failure: LdapDefaultLoginModuleTest address already in use
Ignore tests in the case of a BindException

Modified:
    jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/AbstractServer.java

Modified: jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/AbstractServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/AbstractServer.java?rev=1784251&r1=1784250&r2=1784251&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/AbstractServer.java (original)
+++ jackrabbit/oak/trunk/oak-auth-ldap/src/test/java/org/apache/jackrabbit/oak/security/authentication/ldap/AbstractServer.java Fri Feb 24 09:35:20 2017
@@ -20,10 +20,13 @@
 package org.apache.jackrabbit.oak.security.authentication.ldap;
 
 
+import static org.junit.Assume.assumeFalse;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.BindException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -40,6 +43,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.exception.LdapConfigurationException;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.ldif.LdifEntry;
 import org.apache.directory.api.ldap.model.ldif.LdifReader;
@@ -228,10 +232,28 @@ public abstract class AbstractServer {
 
         directoryService.startup();
         setupExamplePartition();
-        ldapServer.start();
+        startLdapServer();
         setContexts(ServerDNConstants.ADMIN_SYSTEM_DN, "secret");
     }
 
+    /**
+     * Start the LDAP server assuming we can bind to the previously reserved port.
+     * Given that there is a small race between when the port was reserved and when the
+     * socket is actually bound this can still fail. For now we are ignoring this rare
+     * case and skip the test. See OAK-5542.
+     * @throws Exception
+     */
+    private void startLdapServer() throws Exception {
+        try {
+            ldapServer.start();
+        } catch (LdapConfigurationException e) {
+            Throwable cause = e.getCause();
+            assumeFalse("Ignoring this test as the server port is already in use (OAK-5542): " + cause,
+                    cause instanceof BindException);
+            throw e;
+        }
+    }
+
     protected void setupLdapServer() throws Exception {
         ldapServer.setTransports(new TcpTransport(port));
         ldapServer.setDirectoryService(directoryService);