Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2016-08-12 13:14:37 -0400
committerRoland Grunberg2016-08-12 17:06:06 -0400
commit617698558fa305607f1f37b2240b00d69658d709 (patch)
treea2d317e8adccdb4f2a6e12362eb542f6baaf66e2
parent5094f343c57ab282b73213f6f53a4b8e0af971a5 (diff)
downloadrt.equinox.p2-617698558fa305607f1f37b2240b00d69658d709.tar.gz
rt.equinox.p2-617698558fa305607f1f37b2240b00d69658d709.tar.xz
rt.equinox.p2-617698558fa305607f1f37b2240b00d69658d709.zip
Bug 499623 - Support extended configurations in SimpleConfigManipulator.
SimpleConfiguratorManipulatorImpl#loadConfiguration(BundleContext, String) only returns the list of BundleInfo elements from the platform itself. Extend this mechanism to also return extended BundleInfo elements (when p2.fragments property is set). Change-Id: I2230aff75bb20f8e38dd8a7a22c4cba6aefd6df8 Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorTests.java49
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java18
2 files changed, 64 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorTests.java
index 80ef3ce4b..4534acd77 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorTests.java
@@ -14,10 +14,16 @@ package org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator;
import java.io.File;
import java.io.FileInputStream;
import java.net.URI;
+import java.net.URL;
+import java.util.*;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
import org.eclipse.equinox.internal.simpleconfigurator.manipulator.SimpleConfiguratorManipulatorImpl;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.EquinoxUtils;
import org.eclipse.equinox.internal.simpleconfigurator.utils.URIUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.TestActivator;
+import org.eclipse.equinox.p2.tests.reconciler.dropins.SharedInstallTests;
import org.eclipse.equinox.simpleconfigurator.manipulator.SimpleConfiguratorManipulator;
public class SimpleConfiguratorManipulatorTests extends AbstractProvisioningTest {
@@ -79,4 +85,47 @@ public class SimpleConfiguratorManipulatorTests extends AbstractProvisioningTest
bundles = manipulator.loadConfiguration(new FileInputStream(configurationFile), folder.toURI());
assertEquals(bundles[0].getLocation(), new File(folder, "\u0CA0_\u0CA0.jar").toURI());
}
+
+ public void testLoadConfigurationExtended() throws Exception {
+ // installation info
+ URI installArea = EquinoxUtils.getInstallLocationURI(TestActivator.getContext());
+
+ // test info configured through p2.fragments
+ File mainTestData = getTestData("0.0", "testData/simpleConfiguratorExtendedTest/main/bundles.info");
+ URL configURL = EquinoxUtils.getConfigLocation(TestActivator.getContext()).getDataArea(SimpleConfiguratorManipulator.BUNDLES_INFO_PATH);
+ File target = new File(configURL.getPath());
+ target.getParentFile().mkdirs();
+ target.createNewFile();
+ copy("Copying ..", mainTestData, target);
+
+ File fragTestData = getTestData("0.1", "/testData/simpleConfiguratorExtendedTest");
+ File fragDir = getTempFolder();
+ copy("Copying ..", fragTestData, fragDir);
+ SharedInstallTests.setReadOnly(fragDir, true);
+ Activator.EXTENDED = true;
+ Activator.EXTENSIONS = fragDir.getAbsolutePath();
+
+ List<String> expected = Arrays.asList(new String[] {"m,1.0.0", "n,1.0.0", "a,1.0.0", "b,1.0.0"});
+
+ SimpleConfiguratorManipulator manipulator = new SimpleConfiguratorManipulatorImpl();
+ BundleInfo[] installedInfo = manipulator.loadConfiguration(configURL.openStream(), installArea);
+ BundleInfo[] installedAndExtendedInfo = manipulator.loadConfiguration(TestActivator.getContext(), SimpleConfiguratorManipulator.BUNDLES_INFO_PATH);
+
+ List<BundleInfo> installedAndExtendedL = Arrays.asList(installedAndExtendedInfo);
+ List<BundleInfo> installedL = Arrays.asList(installedInfo);
+ List<BundleInfo> extendedL = new ArrayList<BundleInfo>(installedAndExtendedL);
+ extendedL.removeAll(installedL);
+
+ assertTrue(installedAndExtendedL.containsAll(installedL));
+ assertFalse(extendedL.isEmpty());
+
+ for (BundleInfo b : extendedL) {
+ String actual = b.getSymbolicName() + "," + b.getVersion();
+ if (!expected.contains(actual)) {
+ fail(actual + " Could not be found in the list of expected bundle info entries.");
+ }
+ }
+
+ SharedInstallTests.setReadOnly(fragDir, false);
+ }
}
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java
index e684bc90a..397e222e4 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java
@@ -16,8 +16,7 @@
package org.eclipse.equinox.internal.simpleconfigurator.manipulator;
import java.io.*;
-import java.net.URI;
-import java.net.URL;
+import java.net.*;
import java.util.*;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
@@ -340,8 +339,21 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
}
}
+ List<BundleInfo> result = new ArrayList<BundleInfo>();
//stream will be closed
- return loadConfiguration(stream, installArea);
+ result.addAll(Arrays.asList(loadConfiguration(stream, installArea)));
+
+ try {
+ List<File> infoFiles = SimpleConfiguratorUtils.getInfoFiles();
+ for (File infoFile : infoFiles) {
+ BundleInfo[] info = loadConfiguration(infoFile.toURL().openStream(), infoFile.getParentFile().toURI());
+ result.addAll(Arrays.asList(info));
+ }
+ } catch (URISyntaxException e) {
+ // ignore the extended configurations
+ }
+
+ return result.toArray(new BundleInfo[0]);
}
/*

Back to the top