felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1800119 - in /felix/trunk/osgi-r7/configurator: ./ src/main/java/org/apache/felix/configurator/impl/ src/main/java/org/apache/felix/configurator/impl/json/ src/main/java/org/apache/felix/configurator/impl/model/ src/test/java/org/apache/fe...
Date Wed, 28 Jun 2017 06:02:10 GMT
Author: cziegeler
Date: Wed Jun 28 06:02:10 2017
New Revision: 1800119

URL: http://svn.apache.org/viewvc?rev=1800119&view=rev
Log:
Update to latest configurator spec: remove environment handling, change to osgi.extender

Modified:
    felix/trunk/osgi-r7/configurator/pom.xml
    felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java
    felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Util.java
    felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java
    felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/Config.java
    felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/ConfigList.java
    felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/State.java
    felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/ConfiguratorTest.java
    felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/BundleStateTest.java
    felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigListTest.java
    felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigTest.java
    felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/StateTest.java

Modified: felix/trunk/osgi-r7/configurator/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/pom.xml?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/pom.xml (original)
+++ felix/trunk/osgi-r7/configurator/pom.xml Wed Jun 28 06:02:10 2017
@@ -67,7 +67,7 @@
                             org.osgi.service.coordinator
                         </DynamicImport-Package>
                         <Provide-Capability>
-                            osgi.implementation;osgi.implementation="osgi.configurator";version:Version="1.0"
+                            osgi.extender;osgi.extender="osgi.configurator";version:Version="1.0"
                         </Provide-Capability>
                         <Embed-Dependency>geronimo-json_1.0_spec,johnzon-core,org.apache.felix.converter</Embed-Dependency>
                     </instructions>

Modified: felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Configurator.java
Wed Jun 28 06:02:10 2017
@@ -64,8 +64,6 @@ public class Configurator {
 
     private final State state;
 
-    private final Set<String> activeEnvironments;
-
     private final org.osgi.util.tracker.BundleTracker<Bundle> tracker;
 
     private volatile boolean active = true;
@@ -86,7 +84,6 @@ public class Configurator {
         this.queue = new WorkerQueue();
         this.bundleContext = bc;
         this.configAdminReferences = configAdminReferences;
-        this.activeEnvironments = Util.getActiveEnvironments(bc);
         State s = null;
         try {
             s = State.createOrReadState(bundleContext.getDataFile(State.FILE_NAME));
@@ -95,7 +92,6 @@ public class Configurator {
             s = new State();
         }
         this.state = s;
-        this.state.changeEnvironments(this.activeEnvironments);
         this.tracker = new org.osgi.util.tracker.BundleTracker<>(this.bundleContext,
                 Bundle.ACTIVE|Bundle.STARTING|Bundle.STOPPING|Bundle.RESOLVED|Bundle.INSTALLED,
 
@@ -251,11 +247,7 @@ public class Configurator {
                 hashes.add(Util.getSHA256(initial.trim()));
                 files.put(ConfiguratorConstants.CONFIGURATOR_INITIAL, initial);
             }
-            if ( state.getInitialHashes() != null && state.getInitialHashes().equals(hashes))
{
-                if ( state.environmentsChanged() ) {
-                    state.checkEnvironments(-1);
-                }
-            } else {
+            if ( state.getInitialHashes() == null || !state.getInitialHashes().equals(hashes))
{
                 if ( state.getInitialHashes() != null ) {
                     processRemoveBundle(-1);
                 }
@@ -304,9 +296,6 @@ public class Configurator {
             final long bundleLastModified = bundle.getLastModified();
             final Long lastModified = state.getLastModified(bundleId);
             if ( lastModified != null && lastModified.longValue() == bundleLastModified
) {
-                if ( state.environmentsChanged() ) {
-                    state.checkEnvironments(bundleId);
-                }
                 // no changes, nothing to do
                 return;
             }
@@ -411,41 +400,30 @@ public class Configurator {
         Config toDeactivate = null;
 
         for(final Config cfg : configList) {
-            final boolean canBeActive = cfg.isActive(activeEnvironments);
-
             switch ( cfg.getState() ) {
-            case INSTALL     : // activate if first found
-                if ( canBeActive && toActivate == null ) {
-                    toActivate = cfg;
-                }
-                break;
-
-            case IGNORED     : // same as installed
-            case INSTALLED   : // check if we have to uninstall
-                if ( canBeActive ) {
+                case INSTALL     : // activate if first found
                     if ( toActivate == null ) {
                         toActivate = cfg;
-                    } else {
-                        cfg.setState(ConfigState.INSTALL);
                     }
-                } else {
-                    if ( toDeactivate == null ) { // this should always be null
-                        cfg.setState(ConfigState.UNINSTALL);
-                        toDeactivate = cfg;
+                    break;
+
+                case IGNORED     : // same as installed
+                case INSTALLED   : // check if we have to uninstall
+                    if ( toActivate == null ) {
+                        toActivate = cfg;
                     } else {
-                        cfg.setState(ConfigState.UNINSTALLED);
+                        cfg.setState(ConfigState.INSTALL);
                     }
-                }
-                break;
+                    break;
 
-            case UNINSTALL   : // deactivate if first found (we should only find one anyway)
-                if ( toDeactivate == null ) {
-                    toDeactivate = cfg;
-                }
-                break;
+                case UNINSTALL   : // deactivate if first found (we should only find one
anyway)
+                    if ( toDeactivate == null ) {
+                       toDeactivate = cfg;
+                    }
+                    break;
 
-            case UNINSTALLED : // nothing to do
-                break;
+                case UNINSTALLED : // nothing to do
+                    break;
             }
 
         }

Modified: felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Util.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Util.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/Util.java
Wed Jun 28 06:02:10 2017
@@ -28,16 +28,13 @@ import java.util.Set;
 
 import org.apache.felix.configurator.impl.logger.SystemLogger;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleWire;
 import org.osgi.framework.wiring.BundleWiring;
 
 public class Util {
 
-    private static final String PROP_ENVIRONMENTS = "configurator.environment";
-
-    public static final String NS_OSGI_IMPL = "osgi.implementation";
+    public static final String NS_OSGI_EXTENDER = "osgi.extender";
 
     public static final String PROP_CONFIGURATIONS = "configurations";
 
@@ -58,12 +55,12 @@ public class Util {
         }
 
         // check for bundle requirement to implementation namespace
-        final List<BundleRequirement> requirements = bundleWiring.getRequirements(NS_OSGI_IMPL);
+        final List<BundleRequirement> requirements = bundleWiring.getRequirements(NS_OSGI_EXTENDER);
         if ( requirements == null || requirements.isEmpty() ) {
             return null;
         }
         // get all wires for the implementation namespace
-        final List<BundleWire> wires = bundleWiring.getRequiredWires(NS_OSGI_IMPL);
+        final List<BundleWire> wires = bundleWiring.getRequiredWires(NS_OSGI_EXTENDER);
         for(final BundleWire wire : wires) {
             // if the wire is to this bundle (configurator), it must be the correct
             // requirement (no need to do additional checks like version etc.)
@@ -92,50 +89,7 @@ public class Util {
         return null;
     }
 
-    /**
-     * Get the set of active environments from the framework property.
-     *
-     * @param bc The bundle context
-     * @return A set with the environments, might be empty
-     */
-    public static Set<String> getActiveEnvironments(final BundleContext bc) {
-        final String value = bc.getProperty(PROP_ENVIRONMENTS);
-        if ( value == null ) {
-            return Collections.emptySet();
-        }
-        final Set<String> envs = new HashSet<>();
-        for(final String name : value.split(",") ) {
-            if ( isValidEnvironmentName(name) ) {
-                envs.add(name.trim());
-            } else {
-                SystemLogger.error("Invalid environment name: " + name);
-            }
-        }
-        return envs;
-    }
-
-    public static boolean isValidEnvironmentName(final String name) {
-        if ( name == null ) {
-            return false;
-        }
-        final String testName = name.trim();
-        boolean isValid = !testName.isEmpty();
-        for(int i=0; i<testName.length(); i++) {
-            final char c = testName.charAt(i);
-            if ( c == '-'
-                 || c == '_'
-                 || (c >= '0' && c <= '9')
-                 || (c >= 'a' && c <= 'z')
-                 || (c >= 'A' && c <= 'Z')) {
-                continue;
-            }
-            isValid = false;
-            break;
-        }
-        return isValid;
-    }
-
-   public static String getSHA256(final String value) {
+    public static String getSHA256(final String value) {
         try {
             StringBuilder builder = new StringBuilder();
             MessageDigest md = MessageDigest.getInstance("SHA-256");

Modified: felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/json/JSONUtil.java
Wed Jun 28 06:02:10 2017
@@ -28,12 +28,10 @@ import java.io.Writer;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -194,23 +192,7 @@ public class JSONUtil {
             } else {
                 @SuppressWarnings("unchecked")
                 final Map<String, ?> mainMap = (Map<String, ?>)entry.getValue();
-                final int envIndex = entry.getKey().indexOf('[');
-                if ( envIndex != -1 && !entry.getKey().endsWith("]") ) {
-                    report.errors.add("Ignoring configuration in '" + identifier + "' (invalid
environments definition) : " + entry.getKey());
-                    continue;
-                }
-                final String pid;
-                final Set<String> environments;
-                if ( envIndex == -1 ) {
-                    pid = entry.getKey();
-                    environments = null;
-                } else {
-                    pid = entry.getKey().substring(0, envIndex);
-                    environments = new HashSet<>(Arrays.asList(entry.getKey().substring(envIndex
+ 1, entry.getKey().length()).split(",")));
-                    if ( environments.isEmpty() ) {
-                        report.warnings.add("Invalid environments for configuration in '"
+ identifier + "' : " + pid);
-                    }
-                }
+                final String pid = entry.getKey();
 
                 int ranking = 0;
                 ConfigPolicy policy = ConfigPolicy.DEFAULT;
@@ -269,7 +251,7 @@ public class JSONUtil {
                 }
 
                 if ( valid ) {
-                    final Config c = new Config(pid, environments, properties, bundleId,
ranking, policy);
+                    final Config c = new Config(pid, properties, bundleId, ranking, policy);
                     c.setFiles(converter.flushFiles());
                     configurations.add(c);
                 }

Modified: felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/Config.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/Config.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/Config.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/Config.java
Wed Jun 28 06:02:10 2017
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.Serializable;
 import java.util.Dictionary;
 import java.util.List;
-import java.util.Set;
 
 public class Config implements Serializable, Comparable<Config> {
 
@@ -47,9 +46,6 @@ public class Config implements Serializa
     /** The configuration properties. */
     private final Dictionary<String, Object> properties;
 
-    /** The environments. */
-    private final Set<String> environments;
-
     /** The index within the list of configurations if several. */
     private volatile int index = 0;
 
@@ -59,13 +55,11 @@ public class Config implements Serializa
     private volatile List<File> files;
 
     public Config(final String pid,
-            final Set<String> environments,
             final Dictionary<String, Object> properties,
             final long bundleId,
             final int ranking,
             final ConfigPolicy policy) {
         this.pid = pid;
-        this.environments = environments;
         this.ranking = ranking;
         this.bundleId = bundleId;
         this.properties = properties;
@@ -84,7 +78,6 @@ public class Config implements Serializa
         out.writeInt(VERSION);
         out.writeObject(pid);
         out.writeObject(properties);
-        out.writeObject(environments);
         out.writeObject(policy.name());
         out.writeLong(bundleId);
         out.writeInt(ranking);
@@ -107,7 +100,6 @@ public class Config implements Serializa
         }
         ReflectionUtil.setField(this, "pid", in.readObject());
         ReflectionUtil.setField(this, "properties", in.readObject());
-        ReflectionUtil.setField(this, "environments", in.readObject());
         ReflectionUtil.setField(this, "policy", ConfigPolicy.valueOf((String)in.readObject()));
         ReflectionUtil.setField(this, "bundleId", in.readLong());
         ReflectionUtil.setField(this, "ranking", in.readInt());
@@ -189,14 +181,6 @@ public class Config implements Serializa
         return this.properties;
     }
 
-    /**
-     * Return the set of environments
-     * @return The set of environments or {@code null}
-     */
-    public Set<String> getEnvironments() {
-        return this.environments;
-    }
-
     public void setFiles(final List<File> f) {
         this.files = f;
     }
@@ -205,28 +189,6 @@ public class Config implements Serializa
         return this.files;
     }
 
-    /**
-     * A configuration is active if
-     * - it has no environments specified
-     * - or if the list of active environments contains at least one of the mentioned envs
-     *
-     * @param activeEnvironments The set of active environments
-     * @return {@code true} if active.
-     */
-    public boolean isActive(final Set<String> activeEnvironments) {
-        boolean result = true;
-        if ( this.environments != null ) {
-            result = false;
-            for(final String env : activeEnvironments) {
-                if ( this.environments.contains(env) ) {
-                    result = true;
-                    break;
-                }
-            }
-        }
-        return result;
-    }
-
     @Override
     public int compareTo(final Config o) {
         // sort by ranking, highest first
@@ -252,7 +214,6 @@ public class Config implements Serializa
                 + ", index=" + index
                 + ", properties=" + properties
                 + ", policy=" + policy
-                + ", state=" + state
-                + ", environments=" + environments + "]";
+                + ", state=" + state + "]";
     }
 }

Modified: felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/ConfigList.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/ConfigList.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/ConfigList.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/ConfigList.java
Wed Jun 28 06:02:10 2017
@@ -115,8 +115,7 @@ public class ConfigList implements Seria
             // search if we already have this configuration
             for(final Config current : this.configurations) {
                 if ( current.getBundleId() == cfg.getBundleId()
-                  && current.getRanking() == cfg.getRanking()
-                  && current.getEnvironments().equals(cfg.getEnvironments()) ) {
+                  && current.getRanking() == cfg.getRanking()) {
                     if ( current.getState() == ConfigState.UNINSTALL ) {
                         cfg.setState(ConfigState.INSTALLED);
                         current.setState(ConfigState.UNINSTALLED);

Modified: felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/State.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/State.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/State.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/main/java/org/apache/felix/configurator/impl/model/State.java
Wed Jun 28 06:02:10 2017
@@ -26,7 +26,6 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -43,12 +42,8 @@ public class State extends AbstractState
 
     private final Map<Long, Long> bundlesConfigAdminBundleId = new HashMap<>();
 
-    private final Set<String> environments = new HashSet<>();
-
     private volatile Set<String> initialHashes;
 
-    private volatile transient boolean envsChanged = true;
-
     /**
      * Serialize the object
      * - write version id
@@ -60,7 +55,6 @@ public class State extends AbstractState
     throws IOException {
         out.writeInt(VERSION);
         out.writeObject(bundlesLastModified);
-        out.writeObject(environments);
         out.writeObject(initialHashes);
     }
 
@@ -77,7 +71,6 @@ public class State extends AbstractState
             throw new ClassNotFoundException(this.getClass().getName());
         }
         ReflectionUtil.setField(this, "bundlesLastModified", in.readObject());
-        ReflectionUtil.setField(this, "environments", in.readObject());
         initialHashes = (Set<String>) in.readObject();
     }
 
@@ -131,21 +124,7 @@ public class State extends AbstractState
         return this.bundlesLastModified.keySet();
     }
 
-    public Set<String> getEnvironments() {
-        return this.environments;
-    }
-
-    public void changeEnvironments(final Set<String> envs) {
-        this.envsChanged = this.environments.equals(envs);
-        this.environments.clear();
-        this.environments.addAll(envs);
-    }
-
-    public boolean environmentsChanged() {
-        return this.envsChanged;
-    }
-
-    public Set<String> getInitialHashes() {
+   public Set<String> getInitialHashes() {
         return this.initialHashes;
     }
 
@@ -188,7 +167,7 @@ public class State extends AbstractState
 
     @Override
     public String toString() {
-        return "State [bundlesLastModified=" + bundlesLastModified + ", environments=" +
environments
-                + ", initialHashes=" + initialHashes + "]";
+        return "State [bundlesLastModified=" + bundlesLastModified +
+                ", initialHashes=" + initialHashes + "]";
     }
 }

Modified: felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/ConfiguratorTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/ConfiguratorTest.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/ConfiguratorTest.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/ConfiguratorTest.java
Wed Jun 28 06:02:10 2017
@@ -84,12 +84,12 @@ public class ConfiguratorTest {
         final BundleWiring wiring = mock(BundleWiring.class);
         when(b.adapt(BundleWiring.class)).thenReturn(wiring);
         final BundleRequirement req = mock(BundleRequirement.class);
-        when(wiring.getRequirements(Util.NS_OSGI_IMPL)).thenReturn(Collections.singletonList(req));
+        when(wiring.getRequirements(Util.NS_OSGI_EXTENDER)).thenReturn(Collections.singletonList(req));
         final BundleWire wire = mock(BundleWire.class);
         when(wire.getProviderWiring()).thenReturn(wiring);
         when(wire.getRequirement()).thenReturn(req);
         when(wiring.getBundle()).thenReturn(bundle);
-        when(wiring.getRequiredWires(Util.NS_OSGI_IMPL)).thenReturn(Collections.singletonList(wire));
+        when(wiring.getRequiredWires(Util.NS_OSGI_EXTENDER)).thenReturn(Collections.singletonList(wire));
         final Vector<URL> urls = new Vector<>();
         urls.add(this.getClass().getResource("/bundles/" + id + ".json"));
         when(b.findEntries("OSGI-INF/configurator", "*.json", false)).thenReturn(urls.elements());

Modified: felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/BundleStateTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/BundleStateTest.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/BundleStateTest.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/BundleStateTest.java
Wed Jun 28 06:02:10 2017
@@ -24,7 +24,6 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.Collections;
 
 import org.junit.Test;
 
@@ -33,8 +32,8 @@ public class BundleStateTest {
     @Test public void testReadWrite() throws Exception {
         final BundleState state = new BundleState();
 
-        final Config c1 = new Config("a", Collections.emptySet(), null, 1,  0, ConfigPolicy.DEFAULT);
-        final Config c2 = new Config("b", Collections.emptySet(), null, 1, 10, ConfigPolicy.DEFAULT);
+        final Config c1 = new Config("a", null, 1,  0, ConfigPolicy.DEFAULT);
+        final Config c2 = new Config("b", null, 1, 10, ConfigPolicy.DEFAULT);
 
         state.add(c1);
         state.add(c2);
@@ -54,8 +53,8 @@ public class BundleStateTest {
 
     @Test public void testDifferentPids() {
         final BundleState state = new BundleState();
-        final Config c1 = new Config("a", Collections.emptySet(), null, 1,  0, ConfigPolicy.DEFAULT);
-        final Config c2 = new Config("b", Collections.emptySet(), null, 1, 10, ConfigPolicy.DEFAULT);
+        final Config c1 = new Config("a", null, 1,  0, ConfigPolicy.DEFAULT);
+        final Config c2 = new Config("b", null, 1, 10, ConfigPolicy.DEFAULT);
 
         state.add(c1);
         state.add(c2);

Modified: felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigListTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigListTest.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigListTest.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigListTest.java
Wed Jun 28 06:02:10 2017
@@ -24,7 +24,6 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.Collections;
 import java.util.Iterator;
 
 import org.junit.Test;
@@ -34,9 +33,9 @@ public class ConfigListTest {
     @Test public void testReadWrite() throws Exception {
         final ConfigList list = new ConfigList();
 
-        final Config c1 = new Config("a", Collections.singleton("e1"),
+        final Config c1 = new Config("a",
                 null, 10, 0, ConfigPolicy.DEFAULT);
-        final Config c2 = new Config("a", Collections.singleton("e1"),
+        final Config c2 = new Config("a",
                 null, 10, 50, ConfigPolicy.DEFAULT);
         list.add(c1);
         list.add(c2);
@@ -55,12 +54,12 @@ public class ConfigListTest {
 
     @Test public void testRanking() {
         final ConfigList list = new ConfigList();
-        final Config c1 = new Config("a", Collections.emptySet(), null, 1,  0, ConfigPolicy.DEFAULT);
-        final Config c2 = new Config("a", Collections.emptySet(), null, 1, 10, ConfigPolicy.DEFAULT);
-        final Config c3 = new Config("a", Collections.emptySet(), null, 1,  0, ConfigPolicy.DEFAULT);
-        final Config c4 = new Config("a", Collections.emptySet(), null, 1, 50, ConfigPolicy.DEFAULT);
-        final Config c5 = new Config("a", Collections.emptySet(), null, 1, 20, ConfigPolicy.DEFAULT);
-        final Config c6 = new Config("a", Collections.emptySet(), null, 1, 10, ConfigPolicy.DEFAULT);
+        final Config c1 = new Config("a", null, 1,  0, ConfigPolicy.DEFAULT);
+        final Config c2 = new Config("a", null, 1, 10, ConfigPolicy.DEFAULT);
+        final Config c3 = new Config("a", null, 1,  0, ConfigPolicy.DEFAULT);
+        final Config c4 = new Config("a", null, 1, 50, ConfigPolicy.DEFAULT);
+        final Config c5 = new Config("a", null, 1, 20, ConfigPolicy.DEFAULT);
+        final Config c6 = new Config("a", null, 1, 10, ConfigPolicy.DEFAULT);
 
         list.add(c1);
         list.add(c2);
@@ -81,8 +80,8 @@ public class ConfigListTest {
 
     @Test public void testDifferentBundleIds() {
         final ConfigList list = new ConfigList();
-        final Config c1 = new Config("a", Collections.emptySet(), null, 2, 10, ConfigPolicy.DEFAULT);
-        final Config c2 = new Config("a", Collections.emptySet(), null, 1, 10, ConfigPolicy.DEFAULT);
+        final Config c1 = new Config("a", null, 2, 10, ConfigPolicy.DEFAULT);
+        final Config c2 = new Config("a", null, 1, 10, ConfigPolicy.DEFAULT);
 
         list.add(c1);
         list.add(c2);

Modified: felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigTest.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigTest.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/ConfigTest.java
Wed Jun 28 06:02:10 2017
@@ -19,57 +19,24 @@
 package org.apache.felix.configurator.impl.model;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.Dictionary;
-import java.util.HashSet;
 import java.util.Hashtable;
 
 import org.junit.Test;
 
 public class ConfigTest {
 
-    @Test public void testActiveNoEnv() {
-        final Config c1 = new Config("a", null, null, 1, 0, ConfigPolicy.DEFAULT);
-
-        assertTrue(c1.isActive(Collections.emptySet()));
-        assertTrue(c1.isActive(Collections.singleton("foo")));
-        assertTrue(c1.isActive(new HashSet<>(Arrays.asList("foo", "bar"))));
-    }
-
-    @Test public void testActiveSingleEnv() {
-        final Config c1 = new Config("a", Collections.singleton("foo"), null, 1, 0, ConfigPolicy.DEFAULT);
-
-        assertFalse(c1.isActive(Collections.emptySet()));
-        assertTrue(c1.isActive(Collections.singleton("foo")));
-        assertTrue(c1.isActive(new HashSet<>(Arrays.asList("foo", "bar"))));
-        assertFalse(c1.isActive(Collections.singleton("bar")));
-        assertFalse(c1.isActive(new HashSet<>(Arrays.asList("you", "bar"))));
-    }
-
-    @Test public void testActiveTwoEnv() {
-        final Config c1 = new Config("a", new HashSet<>(Arrays.asList("x", "y")), null,
1, 0, ConfigPolicy.DEFAULT);
-
-        assertFalse(c1.isActive(Collections.emptySet()));
-        assertTrue(c1.isActive(Collections.singleton("x")));
-        assertTrue(c1.isActive(Collections.singleton("y")));
-        assertTrue(c1.isActive(new HashSet<>(Arrays.asList("x", "y"))));
-        assertFalse(c1.isActive(new HashSet<>(Arrays.asList("a", "b"))));
-    }
-
     @Test public void testReadWrite() throws Exception {
         final Dictionary<String, Object> props = new Hashtable<>();
         props.put("x", "1");
         props.put("y", 1L);
 
-        final Config cfg = new Config("a", Collections.singleton("e1"),
+        final Config cfg = new Config("a",
                 props, 10, 50, ConfigPolicy.DEFAULT);
         cfg.setIndex(70);
         cfg.setState(ConfigState.UNINSTALL);
@@ -93,9 +60,6 @@ public class ConfigTest {
             assertEquals(2, c.getProperties().size());
             assertEquals("1", c.getProperties().get("x"));
             assertEquals(1L, c.getProperties().get("y"));
-
-            assertEquals(1, c.getEnvironments().size());
-            assertEquals("e1", c.getEnvironments().iterator().next());
         }
     }
 }

Modified: felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/StateTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/StateTest.java?rev=1800119&r1=1800118&r2=1800119&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/StateTest.java
(original)
+++ felix/trunk/osgi-r7/configurator/src/test/java/org/apache/felix/configurator/impl/model/StateTest.java
Wed Jun 28 06:02:10 2017
@@ -24,7 +24,6 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.Collections;
 
 import org.junit.Test;
 
@@ -33,8 +32,8 @@ public class StateTest {
     @Test public void testReadWrite() throws Exception {
         final State state = new State();
 
-        final Config c1 = new Config("a", Collections.emptySet(), null, 1,  0, ConfigPolicy.DEFAULT);
-        final Config c2 = new Config("b", Collections.emptySet(), null, 1, 10, ConfigPolicy.DEFAULT);
+        final Config c1 = new Config("a", null, 1,  0, ConfigPolicy.DEFAULT);
+        final Config c2 = new Config("b", null, 1, 10, ConfigPolicy.DEFAULT);
 
         state.add(c1);
         state.add(c2);
@@ -60,8 +59,8 @@ public class StateTest {
 
     @Test public void testDifferentPids() {
         final State state = new State();
-        final Config c1 = new Config("a", Collections.emptySet(), null, 1,  0, ConfigPolicy.DEFAULT);
-        final Config c2 = new Config("b", Collections.emptySet(), null, 1, 10, ConfigPolicy.DEFAULT);
+        final Config c1 = new Config("a", null, 1,  0, ConfigPolicy.DEFAULT);
+        final Config c2 = new Config("b", null, 1, 10, ConfigPolicy.DEFAULT);
 
         state.add(c1);
         state.add(c2);



Mime
View raw message