mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3845 - make test (and map) work better on slow machines
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1349713 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ccf601e4e4
commit
b067a65444
|
@ -88,7 +88,7 @@ public class CachedLDAPAuthorizationMap extends DefaultAuthorizationMap implemen
|
|||
|
||||
private static String ANY_DESCENDANT = "\\$";
|
||||
|
||||
private DirContext context;
|
||||
protected DirContext context;
|
||||
private EventDirContext eventContext;
|
||||
|
||||
protected HashMap<ActiveMQDestination, AuthorizationEntry> entries =
|
||||
|
@ -106,10 +106,20 @@ public class CachedLDAPAuthorizationMap extends DefaultAuthorizationMap implemen
|
|||
env.put(Context.SECURITY_PROTOCOL, connectionProtocol);
|
||||
env.put(Context.PROVIDER_URL, connectionURL);
|
||||
env.put(Context.SECURITY_AUTHENTICATION, authentication);
|
||||
//env.put("com.sun.jndi.ldap.connect.pool", "true");
|
||||
return new InitialDirContext(env);
|
||||
}
|
||||
|
||||
protected boolean isContextAlive() {
|
||||
boolean alive = false;
|
||||
if (context != null) {
|
||||
try {
|
||||
context.getAttributes("");
|
||||
alive = true;
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
return alive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the existing open context or creates a new one and registers listeners for
|
||||
* push notifications if such an update style is enabled. This implementation should not
|
||||
|
@ -120,17 +130,8 @@ public class CachedLDAPAuthorizationMap extends DefaultAuthorizationMap implemen
|
|||
* @throws NamingException if there is an error setting things up
|
||||
*/
|
||||
protected DirContext open() throws NamingException {
|
||||
if (context != null) {
|
||||
boolean alive = true;
|
||||
try {
|
||||
context.getAttributes("");
|
||||
} catch (Exception e) {
|
||||
LOG.info("LDAP connection failed", e);
|
||||
alive = false;
|
||||
}
|
||||
if (alive) {
|
||||
return context;
|
||||
}
|
||||
if (isContextAlive()) {
|
||||
return context;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -631,7 +632,7 @@ public class CachedLDAPAuthorizationMap extends DefaultAuthorizationMap implemen
|
|||
*/
|
||||
protected void checkForUpdates() {
|
||||
if (context == null || (!refreshDisabled && (refreshInterval != -1 && System.currentTimeMillis() >= lastUpdated + refreshInterval))) {
|
||||
if (context == null) {
|
||||
if (!isContextAlive()) {
|
||||
try {
|
||||
context = createContext();
|
||||
} catch (NamingException ne) {
|
||||
|
|
17
activemq-core/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java
Normal file → Executable file
17
activemq-core/src/test/java/org/apache/activemq/security/AbstractCachedLDAPAuthorizationMapLegacyTest.java
Normal file → Executable file
|
@ -19,6 +19,7 @@ package org.apache.activemq.security;
|
|||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
import org.apache.activemq.jaas.GroupPrincipal;
|
||||
import org.apache.activemq.util.Wait;
|
||||
import org.apache.directory.ldap.client.api.LdapConnection;
|
||||
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
|
||||
import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
|
||||
|
@ -300,16 +301,20 @@ public abstract class AbstractCachedLDAPAuthorizationMapLegacyTest extends Abstr
|
|||
|
||||
getLdapServer().stop();
|
||||
|
||||
Thread.sleep(1000);
|
||||
// wait for the context to be closed
|
||||
// as we can't rely on ldar server isStarted()
|
||||
Wait.waitFor(new Wait.Condition() {
|
||||
public boolean isSatisified() throws Exception {
|
||||
return map.context == null;
|
||||
}
|
||||
});
|
||||
|
||||
if (!sync) {
|
||||
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
|
||||
assertEquals("set size: " + failedACLs, 2, failedACLs.size());
|
||||
}
|
||||
failedACLs = map.getReadACLs(new ActiveMQQueue("TEST.FOO"));
|
||||
assertEquals("set size: " + failedACLs, 2, failedACLs.size());
|
||||
|
||||
getLdapServer().start();
|
||||
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(2000);
|
||||
|
||||
connection = getLdapConnection();
|
||||
|
||||
|
|
|
@ -161,7 +161,6 @@ cn: read
|
|||
member: cn=users,ou=Group,ou=ActiveMQ,ou=system
|
||||
member: cn=admins,ou=Group,ou=ActiveMQ,ou=system
|
||||
member: uid=jdoe,ou=User,ou=ActiveMQ,ou=system
|
||||
member: cn=notthere,ou=Group,ou=ActiveMQ,ou=system
|
||||
objectClass: groupOfNames
|
||||
objectClass: top
|
||||
|
||||
|
|
Loading…
Reference in New Issue