You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2017/08/22 08:05:57 UTC

[1/2] karaf git commit: Tabs to Spaces, Extract constant

Repository: karaf
Updated Branches:
  refs/heads/master 7afb05828 -> 09c445c38


Tabs to Spaces, Extract constant

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

Branch: refs/heads/master
Commit: 188d35571670b0fab308ca07fd3a5a066bdf82c6
Parents: 7afb058
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Aug 22 09:20:29 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Aug 22 09:20:29 2017 +0200

----------------------------------------------------------------------
 .../apache/karaf/itests/KarafTestSupport.java   | 75 ++++++++++----------
 1 file changed, 38 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/188d3557/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
index 17413bd..57648d7 100644
--- a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
+++ b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
@@ -88,6 +88,7 @@ import org.slf4j.LoggerFactory;
 
 public class KarafTestSupport {
 
+    private static final EnumSet<org.apache.karaf.features.FeaturesService.Option> NO_AUTO_REFRESH = EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles);
     public static final String MIN_RMI_SERVER_PORT = "44444";
     public static final String MAX_RMI_SERVER_PORT = "66666";
     public static final String MIN_HTTP_PORT = "9080";
@@ -534,25 +535,25 @@ public class KarafTestSupport {
         Assert.assertFalse("Should not contain '" + expectedPart + "' but was : " + actual, actual.contains(expectedPart));
     }
 
-	protected void assertBundleInstalled(String name) {
-	    Assert.assertNotNull("Bundle " + name + " should be installed", findBundleByName(name));
-	}
+    protected void assertBundleInstalled(String name) {
+        Assert.assertNotNull("Bundle " + name + " should be installed", findBundleByName(name));
+    }
 
-	protected void assertBundleNotInstalled(String name) {
-	    Assert.assertNull("Bundle " + name + " should not be installed", findBundleByName(name));
-	}
+    protected void assertBundleNotInstalled(String name) {
+        Assert.assertNull("Bundle " + name + " should not be installed", findBundleByName(name));
+    }
 
-	protected Bundle findBundleByName(String symbolicName) {
-	    for (Bundle bundle : bundleContext.getBundles()) {
-	        if (bundle.getSymbolicName().equals(symbolicName)) {
-	            return bundle;
-	        }
-	    }
-	    return null;
-	}
+    protected Bundle findBundleByName(String symbolicName) {
+        for (Bundle bundle : bundleContext.getBundles()) {
+            if (bundle.getSymbolicName().equals(symbolicName)) {
+                return bundle;
+            }
+        }
+        return null;
+    }
 
     protected void installAndAssertFeature(String feature) throws Exception {
-        featureService.installFeature(feature, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
+        featureService.installFeature(feature, NO_AUTO_REFRESH);
         assertFeatureInstalled(feature);
     }
 
@@ -563,23 +564,23 @@ public class KarafTestSupport {
     protected void installAssertAndUninstallFeatures(String... feature) throws Exception {
         boolean success = false;
         Set<String> features = new HashSet<>(Arrays.asList(feature));
-    	try {
+        try {
             System.out.println("Installing " + features);
-            featureService.installFeatures(features, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
-			for (String curFeature : feature) {
-			    assertFeatureInstalled(curFeature);
-			}
+            featureService.installFeatures(features, NO_AUTO_REFRESH);
+            for (String curFeature : feature) {
+                assertFeatureInstalled(curFeature);
+            }
             success = true;
-		} finally {
+        } finally {
             System.out.println("Uninstalling " + features);
             try {
-                featureService.uninstallFeatures(features, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
+                featureService.uninstallFeatures(features, NO_AUTO_REFRESH);
             } catch (Exception e) {
                 if (success) {
                     throw e;
                 }
             }
-		}
+        }
     }
 
     /**
@@ -589,30 +590,30 @@ public class KarafTestSupport {
      * @param featuresBefore
      * @throws Exception
      */
-	protected void uninstallNewFeatures(Set<Feature> featuresBefore) throws Exception {
-		Feature[] features = featureService.listInstalledFeatures();
+    protected void uninstallNewFeatures(Set<Feature> featuresBefore) throws Exception {
+        Feature[] features = featureService.listInstalledFeatures();
         Set<String> uninstall = new HashSet<>();
         for (Feature curFeature : features) {
-			if (!featuresBefore.contains(curFeature)) {
+            if (!featuresBefore.contains(curFeature)) {
                 uninstall.add(curFeature.getId());
-			}
-		}
+            }
+        }
         try {
             System.out.println("Uninstalling " + uninstall);
-            featureService.uninstallFeatures(uninstall, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
+            featureService.uninstallFeatures(uninstall, NO_AUTO_REFRESH);
         } catch (Exception e) {
             LOG.error(e.getMessage(), e);
         }
-	}
+    }
 
     protected void close(Closeable closeAble) {
-    	if (closeAble != null) {
-    		try {
-				closeAble.close();
-			} catch (IOException e) {
-				throw new RuntimeException(e.getMessage(), e);
-			}
-    	}
+        if (closeAble != null) {
+            try {
+                closeAble.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e.getMessage(), e);
+            }
+        }
     }
 
 }

[2/2] karaf git commit: Fix warnings, Remove unnecessary code

Posted by cs...@apache.org.
Fix warnings, Remove unnecessary code

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

Branch: refs/heads/master
Commit: 09c445c38538202bf5f9f767bf49a316ab5fb0e3
Parents: 188d355
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Aug 22 09:24:21 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Aug 22 09:24:21 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/karaf/itests/MavenTest.java  | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/09c445c3/itests/src/test/java/org/apache/karaf/itests/MavenTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/MavenTest.java b/itests/src/test/java/org/apache/karaf/itests/MavenTest.java
index 4ee914c..22eb4fc 100644
--- a/itests/src/test/java/org/apache/karaf/itests/MavenTest.java
+++ b/itests/src/test/java/org/apache/karaf/itests/MavenTest.java
@@ -18,7 +18,7 @@ package org.apache.karaf.itests;
 
 import java.io.File;
 import java.io.IOException;
-import java.net.ServerSocket;
+import java.nio.charset.Charset;
 import java.util.Arrays;
 import java.util.Dictionary;
 import java.util.LinkedList;
@@ -28,6 +28,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
+
 import javax.inject.Inject;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -40,7 +41,6 @@ import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.AbstractHandler;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
@@ -135,17 +135,6 @@ public class MavenTest /*extends KarafTestSupport*/ {
         return probe;
     }
 
-    private int getAvailablePort(int min, int max) {
-        for (int i = min; i <= max; i++) {
-            try {
-                ServerSocket socket = new ServerSocket(i);
-                return socket.getLocalPort();
-            } catch (Exception ignored) {
-            }
-        }
-        throw new IllegalStateException("Can't find available network ports");
-    }
-
     @Configuration
     public Option[] config() {
         MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").versionAsInProject().type("tar.gz");
@@ -228,9 +217,9 @@ public class MavenTest /*extends KarafTestSupport*/ {
 
     private void updateSettings() throws IOException {
         File settingsFile = new File(System.getProperty("karaf.home"), "etc/maven-settings.xml");
-        String settings = FileUtils.readFileToString(settingsFile);
+        String settings = FileUtils.readFileToString(settingsFile, Charset.forName("UTF-8"));
         settings = settings.replace("@@port@@", Integer.toString(port));
-        FileUtils.write(settingsFile, settings);
+        FileUtils.write(settingsFile, settings, Charset.forName("UTF-8"));
     }
 
     /**