You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2016/08/22 09:30:24 UTC

[26/50] [abbrv] karaf git commit: [KARAF-4642] featuresBoot order is not honored. Thank you James Carman for the patch.

[KARAF-4642] featuresBoot order is not honored. Thank you James Carman for the patch.


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/e5beeb0a
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/e5beeb0a
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/e5beeb0a

Branch: refs/heads/master
Commit: e5beeb0a8174a4a9ec1d01e1b3ba569ed0675142
Parents: 3bd7a8e
Author: jgoodyear <jg...@apache.org>
Authored: Mon Aug 1 22:23:17 2016 -0230
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Mon Aug 22 11:29:20 2016 +0200

----------------------------------------------------------------------
 .../internal/service/BootFeaturesInstaller.java |  5 +-
 .../service/BootFeaturesInstallerTest.java      | 55 ++++++++++++--------
 2 files changed, 37 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/e5beeb0a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
index 2b3f81b..d0a703f 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/BootFeaturesInstaller.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Matcher;
@@ -58,7 +59,7 @@ public class BootFeaturesInstaller {
      * The system separator character.
      */
     private static final char SYSTEM_SEPARATOR = File.separatorChar;
-
+    
     public BootFeaturesInstaller(BundleContext bundleContext,
                                  FeaturesServiceImpl featuresService,
                                  String repositories,
@@ -138,7 +139,7 @@ public class BootFeaturesInstaller {
     }
 
     protected Set<String> parseFeatureList(String group) {
-        HashSet<String> features = new HashSet<>();
+        HashSet<String> features = new LinkedHashSet<>();
         for (String feature : Arrays.asList(group.trim().split("\\s*,\\s*"))) {
             if (feature.length() > 0) {
                 features.add(feature);

http://git-wip-us.apache.org/repos/asf/karaf/blob/e5beeb0a/features/core/src/test/java/org/apache/karaf/features/internal/service/BootFeaturesInstallerTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/service/BootFeaturesInstallerTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/service/BootFeaturesInstallerTest.java
index 1754e25..1c6b0d5 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/service/BootFeaturesInstallerTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/service/BootFeaturesInstallerTest.java
@@ -16,21 +16,28 @@
  */
 package org.apache.karaf.features.internal.service;
 
-import static java.util.Arrays.asList;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.fail;
-
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
 
-import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.FeaturesService.Option;
 import org.apache.karaf.features.TestBase;
-import org.easymock.EasyMock;
+import org.easymock.Capture;
 import org.junit.Assert;
 import org.junit.Test;
 
+import static java.util.Arrays.asList;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
 public class BootFeaturesInstallerTest extends TestBase {
 
     @Test
@@ -44,51 +51,57 @@ public class BootFeaturesInstallerTest extends TestBase {
     
     @Test
     public void testDefaultBootFeatures() throws Exception  {
-        FeaturesServiceImpl impl = EasyMock.createMock(FeaturesServiceImpl.class);
+        FeaturesServiceImpl impl = createMock(FeaturesServiceImpl.class);
 
-        impl.installFeatures(setOf("config", "standard", "region"), EnumSet.of(Option.NoFailOnFeatureNotFound));
-        EasyMock.expectLastCall();
+        Capture<Set<String>> featuresCapture = newCapture();
+        impl.installFeatures(capture(featuresCapture), eq(EnumSet.of(Option.NoFailOnFeatureNotFound)));
+        expectLastCall();
 
         impl.bootDone();
-        EasyMock.expectLastCall();
+        expectLastCall();
 
         replay(impl);
         BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, impl, "", "config,standard,region", false);
         bootFeatures.installBootFeatures();
-        EasyMock.verify(impl);        
+        verify(impl);
+
+        List<String> features = new ArrayList<String>(featuresCapture.getValue());
+        Assert.assertEquals("config", features.get(0));
+        Assert.assertEquals("standard", features.get(1));
+        Assert.assertEquals("region", features.get(2));
     }
 
     @Test
     public void testStagedBoot() throws Exception  {
-        FeaturesServiceImpl impl = EasyMock.createStrictMock(FeaturesServiceImpl.class);
+        FeaturesServiceImpl impl = createStrictMock(FeaturesServiceImpl.class);
 
         impl.installFeatures(setOf("transaction"), EnumSet.of(Option.NoFailOnFeatureNotFound));
-        EasyMock.expectLastCall();
+        expectLastCall();
         impl.installFeatures(setOf("ssh"), EnumSet.of(Option.NoFailOnFeatureNotFound));
-        EasyMock.expectLastCall();
+        expectLastCall();
 
         impl.bootDone();
-        EasyMock.expectLastCall();
+        expectLastCall();
 
         replay(impl);
         BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, impl , "", "(transaction), ssh", false);
         bootFeatures.installBootFeatures();
-        EasyMock.verify(impl);        
+        verify(impl);
     }
 
     @Test
     public void testStartDoesNotFailWithOneInvalidUri() throws Exception {
-        FeaturesServiceImpl impl = EasyMock.createStrictMock(FeaturesServiceImpl.class);
+        FeaturesServiceImpl impl = createStrictMock(FeaturesServiceImpl.class);
         impl.addRepository(URI.create("mvn:inexistent/features/1.0/xml/features"));
-        EasyMock.expectLastCall().andThrow(new IllegalArgumentException());
+        expectLastCall().andThrow(new IllegalArgumentException());
 
         impl.bootDone();
-        EasyMock.expectLastCall();
+        expectLastCall();
 
         replay(impl);
         BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, impl, "mvn:inexistent/features/1.0/xml/features", "", false);
         bootFeatures.installBootFeatures();
-        EasyMock.verify(impl);
+        verify(impl);
     }
 
 }