You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jg...@apache.org on 2016/04/15 14:57:51 UTC
karaf git commit: [KARAF-4494] FeaturesService Should Support
Variable Interpolation in featuresRepositories property. Patch from James
Carmen.
Repository: karaf
Updated Branches:
refs/heads/karaf-3.0.x 54f01bd92 -> b363d5881
[KARAF-4494] FeaturesService Should Support Variable Interpolation in featuresRepositories property. Patch from James Carmen.
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b363d588
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b363d588
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b363d588
Branch: refs/heads/karaf-3.0.x
Commit: b363d58815eb6a78043b69da0e2ac0f8827bdb97
Parents: 54f01bd
Author: jgoodyear <jg...@apache.org>
Authored: Fri Apr 15 10:27:23 2016 -0230
Committer: jgoodyear <jg...@apache.org>
Committed: Fri Apr 15 10:27:23 2016 -0230
----------------------------------------------------------------------
.../features/internal/FeaturesServiceImpl.java | 10 +++++++
.../karaf/features/FeaturesServiceTest.java | 30 ++++++++++++++++++++
2 files changed, 40 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/b363d588/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
index 4e7a863..4934390 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
@@ -16,6 +16,15 @@
*/
package org.apache.karaf.features.internal;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.felix.utils.properties.InterpolationHelper;
+
import org.apache.felix.utils.version.VersionRange;
import org.apache.felix.utils.version.VersionTable;
import org.apache.karaf.features.BundleInfo;
@@ -148,6 +157,7 @@ public class FeaturesServiceImpl implements FeaturesService {
this.uris = new HashSet<URI>();
for (String value : s) {
value = value.trim();
+ value = InterpolationHelper.substVars(value, "featuresRepositories", null, null);
if (!value.isEmpty()) {
this.uris.add(new URI(value));
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/b363d588/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java b/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
index d23849e..b63ec89 100644
--- a/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/FeaturesServiceTest.java
@@ -435,6 +435,36 @@ public class FeaturesServiceTest extends TestBase {
}
@Test
+ public void testInstallFeatureRepositoryWithSystemPropertyInterpolation() throws Exception {
+
+ URI repo = createTempRepo("<features name='test' xmlns='http://karaf.apache.org/xmlns/features/v1.0.0'></features>");
+
+
+ final String fullPath = repo.toString().substring("file:/".length());
+ final String uri = "file:/${karaf.test.fullPath}";
+ System.setProperty("karaf.test.fullPath", fullPath);
+
+ BundleContext bundleContext = EasyMock.createMock(BundleContext.class);
+ BundleManager bundleManager = new BundleManager(bundleContext);
+ expect(bundleContext.getBundles()).andReturn(new Bundle[0]).anyTimes();
+ File stateFile = new File("target/FeaturesServiceState.properties");
+ try {
+ expect(bundleContext.getDataFile("FeaturesServiceState.properties")).andReturn(stateFile).anyTimes();
+ replay(bundleContext);
+ FeaturesServiceImpl svc = new FeaturesServiceImpl(bundleManager);
+ svc.setUrls(uri);
+ svc.start();
+ Repository repository = svc.getRepository(repo);
+ verify(bundleContext);
+ assertNotNull(repository);
+ svc.stop();
+ } finally {
+ assertTrue("Unable to remove state file, subsequent tests will fail (clean install required).", stateFile.delete());
+ System.getProperties().remove("karaf.test.fullPath");
+ }
+ }
+
+ @Test
public void testInstallBatchFeatureWithoutContinueOnFailureNoClean() throws Exception {
String bundle1Uri = "file:bundle1";
String bundle2Uri = "file:bundle2";