Repository: karaf
Updated Branches:
  refs/heads/master f1001666e -> b9ae8bfdd


Suppress test exception in log, extract addRepositories


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

Branch: refs/heads/master
Commit: b9ae8bfddb83c252a39b5207a1af8d5a26d068cb
Parents: f100166
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Thu Aug 10 15:53:05 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Thu Aug 10 15:53:05 2017 +0200

----------------------------------------------------------------------
 .../internal/service/BootFeaturesInstaller.java | 26 +++++++++++---------
 .../service/BootFeaturesInstallerTest.java      | 14 ++++++++---
 2 files changed, 26 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/b9ae8bfd/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 c04192c..2969df0 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
@@ -90,17 +90,7 @@ public class BootFeaturesInstaller {
 
     protected void installBootFeatures() {
         try {
-            for (String repo : repositories) {
-                repo = repo.trim();
-                if (!repo.isEmpty()) {
-                    repo = separatorsToUnix(repo);
-                    try {
-                        featuresService.addRepository(URI.create(repo));
-                    } catch (Exception e) {
-                        LOGGER.error("Error installing boot feature repository 
" + repo, e);
-                    }
-                }
-            }
+            addRepositories();
 
             List<Set<String>> stagedFeatures = parseBootFeatures(features);
             for (Set<String> features : stagedFeatures) {
@@ -124,6 +114,20 @@ public class BootFeaturesInstaller {
         }
     }
 
+    private void addRepositories() {
+        for (String repo : repositories) {
+            repo = repo.trim();
+            if (!repo.isEmpty()) {
+                repo = separatorsToUnix(repo);
+                try {
+                    featuresService.addRepository(URI.create(repo));
+                } catch (Exception e) {
+                    LOGGER.error("Error installing boot feature repository " + 
repo, e);
+                }
+            }
+        }
+    }
+
     protected List<Set<String>> parseBootFeatures(String bootFeatures) {
         List<Set<String>> stages = new ArrayList<>();
         StringTokenizer tokenizer = new StringTokenizer(bootFeatures, " 
\t\r\n,()", true);

http://git-wip-us.apache.org/repos/asf/karaf/blob/b9ae8bfd/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 f4a3cea..ee6d553 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
@@ -22,6 +22,8 @@ import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.karaf.features.FeaturesService.Option;
 import org.apache.karaf.features.TestBase;
@@ -41,6 +43,8 @@ import static org.easymock.EasyMock.verify;
 
 public class BootFeaturesInstallerTest extends TestBase {
 
+    private static final String INEXISTANT_REPO = 
"mvn:inexistent/features/1.0/xml/features";
+
     @Test
     public void testParser() {
         BootFeaturesInstaller installer = new BootFeaturesInstaller(null, 
null, new String[0], "", false);
@@ -92,15 +96,19 @@ public class BootFeaturesInstallerTest extends TestBase {
     @Test
     public void testStartDoesNotFailWithOneInvalidUri() throws Exception {
         FeaturesServiceImpl impl = createStrictMock(FeaturesServiceImpl.class);
-        
impl.addRepository(URI.create("mvn:inexistent/features/1.0/xml/features"));
-        expectLastCall().andThrow(new IllegalArgumentException());
+        impl.addRepository(URI.create(INEXISTANT_REPO));
+        expectLastCall().andThrow(new IllegalArgumentException("Part of the 
test. Can be ignored."));
 
         impl.bootDone();
         expectLastCall();
 
         replay(impl);
-        BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, 
impl, new String[] { "mvn:inexistent/features/1.0/xml/features" }, "", false);
+        String[] repositories = new String[] { INEXISTANT_REPO };
+        BootFeaturesInstaller bootFeatures = new BootFeaturesInstaller(null, 
impl, repositories, "", false);
+        Logger logger = 
Logger.getLogger(BootFeaturesInstaller.class.getName());
+        logger.setLevel(Level.OFF); // Switch off to suppress logging of 
IllegalArgumentException
         bootFeatures.installBootFeatures();
+        logger.setLevel(Level.INFO);
         verify(impl);
     }
 

Reply via email to