ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1732546 - in /ace/trunk: org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java org.apache.ace.useradmin/src/org/apache/ace/useradmin/repository/Activator.java
Date Fri, 26 Feb 2016 19:28:56 GMT
Author: jawi
Date: Fri Feb 26 19:28:56 2016
New Revision: 1732546

URL: http://svn.apache.org/viewvc?rev=1732546&view=rev
Log:
Test fixes; made test delay configurable.

Modified:
    ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java
    ace/trunk/org.apache.ace.useradmin/src/org/apache/ace/useradmin/repository/Activator.java

Modified: ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java?rev=1732546&r1=1732545&r2=1732546&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java (original)
+++ ace/trunk/org.apache.ace.test/src/org/apache/ace/it/IntegrationTestBase.java Fri Feb 26
19:28:56 2016
@@ -615,7 +615,7 @@ public class IntegrationTestBase extends
 
             // XXX it appears we run into race conditions between the setup and configuration
of our services, use a
             // little delay to get things settled seems to help here...
-            TimeUnit.MILLISECONDS.sleep(300);
+            TimeUnit.MILLISECONDS.sleep(Integer.getInteger("org.apache.ace.it.testDelay",
500));
 
             configureAdditionalServices();
         }

Modified: ace/trunk/org.apache.ace.useradmin/src/org/apache/ace/useradmin/repository/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.useradmin/src/org/apache/ace/useradmin/repository/Activator.java?rev=1732546&r1=1732545&r2=1732546&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.useradmin/src/org/apache/ace/useradmin/repository/Activator.java
(original)
+++ ace/trunk/org.apache.ace.useradmin/src/org/apache/ace/useradmin/repository/Activator.java
Fri Feb 26 19:28:56 2016
@@ -23,12 +23,16 @@ import static org.apache.ace.repository.
 
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
 
 import org.apache.ace.connectionfactory.ConnectionFactory;
 import org.apache.ace.repository.Repository;
 import org.apache.ace.repository.ext.impl.RemoteRepository;
+import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.useradmin.RoleRepositoryStore;
@@ -45,6 +49,8 @@ public class Activator extends Dependenc
     public static final String KEY_REPOSITORY_NAME = "repositoryName";
     public static final String KEY_REPOSITORY_LOCATION = "repositoryLocation";
 
+    private final List<Component> m_components = new ArrayList<>();
+
     private volatile DependencyManager m_manager;
 
     @Override
@@ -56,6 +62,12 @@ public class Activator extends Dependenc
 
     @Override
     public void updated(Dictionary<String, ?> properties) throws ConfigurationException
{
+        removeOldComponents();
+
+        if (properties == null) {
+            return;
+        }
+
         String customer = (String) properties.get(KEY_REPOSITORY_CUSTOMER);
         if ((customer == null) || "".equals(customer.trim())) {
             throw new ConfigurationException(KEY_REPOSITORY_CUSTOMER, "Repository customer
has to be specified.");
@@ -81,11 +93,12 @@ public class Activator extends Dependenc
 
         String repoFilter = String.format("(&(customer=%s)(name=%s)(|(master=true)(remote=true)))",
customer, name);
 
-        m_manager.add(m_manager.createComponent()
+        Component repoComp = null;
+        Component storeComp = m_manager.createComponent()
             .setInterface(new String[] { RoleRepositoryStore.class.getName(), UserAdminListener.class.getName()
}, null)
             .setImplementation(UserAdminRepository.class)
             .add(m_manager.createServiceDependency().setService(Repository.class, repoFilter).setRequired(true))
-            .add(m_manager.createServiceDependency().setService(LogService.class).setRequired(false)));
+            .add(m_manager.createServiceDependency().setService(LogService.class).setRequired(false));
 
         if (repositoryUrl != null) {
             // Remote version...
@@ -94,12 +107,32 @@ public class Activator extends Dependenc
             repoProps.put(REPOSITORY_NAME, name);
             repoProps.put("remote", "true");
 
-            m_manager.add(m_manager.createComponent()
+            repoComp = m_manager.createComponent()
                 .setInterface(Repository.class.getName(), repoProps)
                 .setImplementation(new RemoteRepository(repositoryUrl, customer, name))
                 .add(m_manager.createServiceDependency()
                     .setService(ConnectionFactory.class)
-                    .setRequired(true)));
+                    .setRequired(true));
+        }
+
+        synchronized (m_components) {
+            m_components.add(storeComp);
+            m_manager.add(storeComp);
+
+            if (repoComp != null) {
+                m_components.add(repoComp);
+                m_manager.add(repoComp);
+            }
+        }
+    }
+
+    private void removeOldComponents() {
+        synchronized (m_components) {
+            Iterator<Component> iter = m_components.iterator();
+            while (iter.hasNext()) {
+                m_manager.remove(iter.next());
+                iter.remove();
+            }
         }
     }
 }



Mime
View raw message