Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtended.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtendedConfigured.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtended.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtendedConfigured.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTest.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtended.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java104
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedConfiguredTest.java150
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedTest.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/artifacts.xml22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/content.xml33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_1.0.0/feature.xml30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_2.0.0/feature.xml30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_1.0.0/feature.xml26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_2.0.0/feature.xml26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/directoryBased.jarbin0 -> 871 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/myBundle_2.0.0.jarbin0 -> 361 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_1.0.0.jarbin0 -> 377 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_2.0.0.jarbin0 -> 379 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/zzz_1.0.0.jarbin0 -> 411 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.info1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.profile28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/brokenExtension/.gitignore0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extension2/extension2.info2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension1/extension1.info2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension2.link1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/artifacts.xml24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/content.xml32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/extension3.info1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/plugins/aBundle_1.0.0.jarbin0 -> 319 bytes
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/main/bundles.info2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorTest/extension/extension.info1
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java9
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/Activator.java14
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java21
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java33
-rw-r--r--bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java215
41 files changed, 1033 insertions, 50 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
index 3b61b8e75..fae517eaf 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Red Hat, Inc. - tests
+ * Red Hat, Inc. - fragment support
*******************************************************************************/
package org.eclipse.equinox.p2.tests.simpleconfigurator;
@@ -70,13 +70,14 @@ public abstract class AbstractSimpleConfiguratorTest extends AbstractProvisionin
}
}
+ @SuppressWarnings("deprecation")
protected BundleContext startFramework(File bundleInfo, File[] additionalBundle) {
try {
File simpleConfiguratorBundle = getLocation("org.eclipse.equinox.simpleconfigurator");
File osgiBundleLoc = getLocation("org.eclipse.osgi");
// for test purposes create an install.area and configuration.area located in the local bundle data area.
- File installarea = TestActivator.context.getDataFile(getName() + "/eclipse");
+ File installarea = TestActivator.context.getDataFile(getName() + "/" + System.currentTimeMillis() + "/eclipse");
File configarea = new File(installarea, "configuration");
URL osgiBundle = osgiBundleLoc.toURI().toURL();
//if we have framework in workspace need to add the bin directory
@@ -188,4 +189,13 @@ public abstract class AbstractSimpleConfiguratorTest extends AbstractProvisionin
};
return directory.listFiles(bundleFilter);
}
+
+ public void readOnly(File f, boolean readonly) {
+ if (f.isDirectory()) {
+ for (File f2 : f.listFiles()) {
+ readOnly(f2, readonly);
+ }
+ }
+ f.setWritable(!readonly);
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTest.java
index b5a8f4998..3c3aed777 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Red Hat, Inc. - tests
+ * Red Hat, Inc. - fragment support
*******************************************************************************/
package org.eclipse.equinox.p2.tests.simpleconfigurator;
@@ -21,8 +21,8 @@ public class BundlesTxtTest extends AbstractSimpleConfiguratorTest {
BUNDLE_JAR_DIRECTORY = "simpleConfiguratorTest/bundlesTxt";
}
- private File[] jars = null;
- private File bundleInfo = null;
+ protected File[] jars = null;
+ protected File bundleInfo = null;
protected void setUp() throws Exception {
super.setUp();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtended.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtended.java
new file mode 100644
index 000000000..06d6e8577
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtended.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc. - fragment support
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+
+public class BundlesTxtTestExtended extends BundlesTxtTest {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ // enable extended mode
+ Activator.EXTENDED = true;
+ System.setProperty("p2.fragments", "true");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Activator.EXTENDED = false;
+ System.setProperty("p2.fragments", "false");
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtendedConfigured.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtendedConfigured.java
new file mode 100644
index 000000000..b6a49dc81
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/BundlesTxtTestExtendedConfigured.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc. - fragment support
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import java.io.File;
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+import org.osgi.framework.BundleContext;
+
+public class BundlesTxtTestExtendedConfigured extends BundlesTxtTestExtended {
+
+ private File testData;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ //subdir extension will be loaded
+ testData = getTempFolder();
+ copy("preparing testData", getTestData("simpleconfigurator extensions", "testData/simpleConfiguratorTest"), testData);
+ Activator.EXTENSIONS = testData.toString();
+ System.setProperty("p2.fragments", Activator.EXTENSIONS);
+ readOnly(testData, true);
+ }
+
+ @Override
+ public void testBundlesTxt() throws Exception {
+ BundleContext equinoxContext = startFramework(bundleInfo, null);
+ assertJarsInstalled(jars, equinoxContext.getBundles());
+ /**
+ * 3 = one extension + osgi + simpleconfigurator
+ */
+ assertEquals(jars.length + 3, equinoxContext.getBundles().length);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ Activator.EXTENSIONS = null;
+ readOnly(testData, false);
+ testData.delete();
+ super.tearDown();
+ System.setProperty("p2.fragments", "");
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtended.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtended.java
new file mode 100644
index 000000000..d53531f5b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtended.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc. - fragment support
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+
+public class NonExclusiveModeExtended extends NonExclusiveMode {
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ // enable extended mode
+ Activator.EXTENDED = true;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Activator.EXTENDED = false;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtendedConfigured.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtendedConfigured.java
new file mode 100644
index 000000000..bf411f654
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/NonExclusiveModeExtendedConfigured.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc. - fragment support
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import java.io.File;
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+
+public class NonExclusiveModeExtendedConfigured extends NonExclusiveModeExtended {
+
+ private File testData;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ testData = getTempFolder();
+ copy("preparing testData", getTestData("simpleconfigurator extensions", "testData/simpleConfiguratorExtendedTest/extensions"), testData);
+ Activator.EXTENSIONS = testData.toString();
+ readOnly(testData, true);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ Activator.EXTENSIONS = null;
+ readOnly(testData, false);
+ testData.delete();
+ super.tearDown();
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTest.java
index 120acfc1f..c32dcdb6b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTest.java
@@ -7,6 +7,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
* Ericsson AB - ongoing development
+ * Red Hat, Inc. - fragment support
******************************************************************************/
package org.eclipse.equinox.p2.tests.simpleconfigurator;
@@ -19,12 +20,12 @@ import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class SimpleConfiguratorTest extends AbstractProvisioningTest {
- private URL relativeURL;
- private File userConfiguration;
- private File masterConfguration;
- private URL[] sharedConfiguration = new URL[2];
- private URL[] localConfiguration = new URL[1];
- private SimpleConfiguratorImpl configurator;
+ protected URL relativeURL;
+ protected File userConfiguration;
+ protected File masterConfguration;
+ protected URL[] sharedConfiguration = new URL[2];
+ protected URL[] localConfiguration = new URL[1];
+ protected SimpleConfiguratorImpl configurator;
public void setUp() throws Exception {
relativeURL = new URL("file://bundles.info");
@@ -48,7 +49,7 @@ public class SimpleConfiguratorTest extends AbstractProvisioningTest {
return new SimpleConfiguratorImpl(null, null);
}
- private void storeTimestamp(long timestamp) throws IOException {
+ protected void storeTimestamp(long timestamp) throws IOException {
File f = new File(userConfiguration.getParent(), SimpleConfiguratorImpl.BASE_TIMESTAMP_FILE_BUNDLESINFO);
Properties p = new Properties();
p.put(SimpleConfiguratorImpl.KEY_BUNDLESINFO_TIMESTAMP, "" + timestamp);
@@ -62,7 +63,7 @@ public class SimpleConfiguratorTest extends AbstractProvisioningTest {
super.tearDown();
}
- private void assertIsPropertySet(boolean set) {
+ protected void assertIsPropertySet(boolean set) {
assertEquals(set, Boolean.TRUE.toString().equalsIgnoreCase(System.getProperty(SimpleConfiguratorImpl.PROP_IGNORE_USER_CONFIGURATION)));
}
@@ -95,7 +96,8 @@ public class SimpleConfiguratorTest extends AbstractProvisioningTest {
assertIsPropertySet(true);
}
- //master not modified -> pick user
+ //master not modified -> extension configured
+ //on adding extension master must be selected in order to create new profile with extensions!
public void testSharedConfigurationMasterUnmodified() throws IOException {
storeTimestamp(new File(masterConfguration, relativeURL.getFile()).lastModified());
assertEquals(sharedConfiguration[0], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtended.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtended.java
new file mode 100644
index 000000000..67740c94a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtended.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2012,2013 Red Hat, Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ * Ericsson AB - ongoing development
+ ******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+
+public class SimpleConfiguratorTestExtended extends SimpleConfiguratorTest {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ // enable extended mode
+ Activator.EXTENDED = true;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Activator.EXTENDED = false;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java
new file mode 100644
index 000000000..5de86bea9
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTestExtendedConfigured.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2012,2013 Red Hat, Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ * Ericsson AB - ongoing development
+ ******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils;
+
+public class SimpleConfiguratorTestExtendedConfigured extends SimpleConfiguratorTestExtended {
+
+ private File parentFolder;
+ private File ext1Info;
+ private File ext1Parent;
+ private File ext3Info;
+ private File ext3Parent;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ parentFolder = new File(getTempFolder(), "extension");
+ ext1Parent = new File(parentFolder, "ext1");
+ ext1Parent.mkdirs();
+ ext1Info = new File(ext1Parent, "ext1.info");
+ ext1Info.createNewFile();
+ ext3Parent = new File(parentFolder, "ext3");
+ ext3Parent.mkdirs();
+ ext3Info = new File(ext3Parent, "ext3.info");
+ ext3Info.createNewFile();
+ ext1Info.setLastModified(System.currentTimeMillis() + 1000);
+ ext1Parent.setWritable(false);
+ ext3Info.setLastModified(System.currentTimeMillis() + 1000);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ Activator.EXTENSIONS = null;
+ ext1Parent.setWritable(true);
+ super.tearDown();
+ }
+
+ public void testWriteableExtension() throws FileNotFoundException, IOException, URISyntaxException {
+ Activator.EXTENSIONS = parentFolder.toString();
+ ArrayList<File> infoFiles = SimpleConfiguratorUtils.getInfoFiles();
+ assertEquals("only read-only info file should be considered", 1, infoFiles.size());
+ // ext1 is expected because ext3 is writeable
+ assertEquals(ext1Info.getName(), infoFiles.get(0).getName());
+ }
+
+ public void testExtensionAdded() throws IOException {
+
+ storeTimestamp(new File(masterConfguration, relativeURL.getFile()).lastModified());
+ assertEquals(sharedConfiguration[0], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
+ assertIsPropertySet(false);
+
+ Activator.EXTENSIONS = parentFolder.toString();
+
+ assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
+ assertIsPropertySet(true);
+ }
+
+ public void testExtensionRemoved() throws IOException {
+
+ Activator.EXTENSIONS = parentFolder.toString();
+ storeTimestamp(ext1Info.lastModified());
+ //on adding extension master must be selected in order to create new profile with extensions!
+ assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
+ assertIsPropertySet(true);
+
+ //disable extension
+ Activator.EXTENSIONS = null;
+
+ assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
+ assertIsPropertySet(true);
+ }
+
+ public void testExtensionModified() throws IOException {
+
+ Activator.EXTENSIONS = parentFolder.toString();
+ storeTimestamp(ext1Info.lastModified());
+ //on adding extension master must be selected in order to create new profile with extensions!
+ assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
+ assertIsPropertySet(true);
+
+ //add new extension
+ File ext2Dir = new File(parentFolder, "ext2");
+ ext2Dir.mkdirs();
+ File file = new File(ext2Dir, "ext2.info");
+ file.createNewFile();
+ file.setLastModified(parentFolder.lastModified() + 3000);
+
+ assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
+ assertIsPropertySet(true);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java
index 454f30d8c..4eccacd1f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc. and others. All rights reserved. This
+ * Copyright (c) 2008, 2013 Red Hat, Inc. and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -15,11 +15,25 @@ public class SimpleConfiguratorTests {
public static Test suite() {
TestSuite suite = new TestSuite("Tests for org.eclipse.equinox.simpleconfigurator");
+
//$JUnit-BEGIN$
+
suite.addTestSuite(SimpleConfiguratorTest.class);
+ suite.addTestSuite(SimpleConfiguratorTestExtended.class);
+ suite.addTestSuite(SimpleConfiguratorTestExtendedConfigured.class);
+
suite.addTestSuite(SimpleConfiguratorUtilsTest.class);
+ suite.addTestSuite(SimpleConfiguratorUtilsExtendedTest.class);
+ suite.addTestSuite(SimpleConfiguratorUtilsExtendedConfiguredTest.class);
+
suite.addTestSuite(BundlesTxtTest.class);
+ suite.addTestSuite(BundlesTxtTestExtended.class);
+ suite.addTestSuite(BundlesTxtTestExtendedConfigured.class);
+
suite.addTestSuite(NonExclusiveMode.class);
+ suite.addTestSuite(NonExclusiveModeExtended.class);
+ suite.addTestSuite(NonExclusiveModeExtendedConfigured.class);
+
//$JUnit-END$
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedConfiguredTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedConfiguredTest.java
new file mode 100644
index 000000000..5e9450631
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedConfiguredTest.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc. - fragment support
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.List;
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo;
+import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils;
+
+public class SimpleConfiguratorUtilsExtendedConfiguredTest extends SimpleConfiguratorUtilsExtendedTest {
+
+ private File testData;
+ private File mainBundlesInfo;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ testData = getTempFolder();
+ copy("preparing readonly data", getTestData("simpleconfigurator extensions", "testData/simpleConfiguratorExtendedTest"), testData);
+ testData = new File(testData, "extensions");
+ readonly(testData.getParentFile(), true);
+ Activator.EXTENSIONS = testData.toString();
+
+ mainBundlesInfo = getTestData("simpleconfigurator extensions - main bundles.info", "testData/simpleConfiguratorExtendedTest/main/bundles.info");
+ }
+
+ private void readonly(File f, boolean readonly) {
+ if (f.isDirectory()) {
+ for (File subfile : f.listFiles()) {
+ subfile.setWritable(!readonly);
+ readonly(subfile, readonly);
+ }
+ f.setWritable(!readonly);
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ Activator.EXTENSIONS = null;
+ readonly(testData.getParentFile(), false);
+ testData.getParentFile().delete();
+ super.tearDown();
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testMultipleInfoFiles() throws MalformedURLException, IOException {
+ List<BundleInfo> readConfiguration = SimpleConfiguratorUtils.readConfiguration(mainBundlesInfo.toURL(), mainBundlesInfo.getParentFile().toURI());
+ BundleInfo a = getBundle("a", readConfiguration);
+ assertNotNull("Bundle from the main list not loaded", a);
+ assertEquals("Path not resolved properly for the main bundles.info", new File(mainBundlesInfo.getParentFile(), "plugins/a_1.0.0.jar").toURI(), getLocation(a));
+
+ BundleInfo b = getBundle("b", readConfiguration);
+ assertNotNull("Bundle from the main list not loaded", b);
+ assertEquals("Path not resolved properly for the main bundles.info", new File("/b_1.0.0.jar").toURI(), getLocation(b));
+
+ //check false positive
+ BundleInfo x = getBundle("x", readConfiguration);
+ assertNull("This bundle is not listed anywhere!", x);
+
+ BundleInfo g = getBundle("g", readConfiguration);
+ assertNotNull("Bundle from the direct extension not loaded", g);
+ assertEquals("Path not resolved properly from direct extension", new File(testData, "extension1/plugins/g_1.0.0.jar").toURI(), getLocation(g));
+
+ BundleInfo h = getBundle("h", readConfiguration);
+ assertNotNull("Bundle from the direct extension not loaded", h);
+ assertEquals("Path not resolved properly from direct extension", new File("/h_1.0.0.jar").toURI(), getLocation(h));
+
+ BundleInfo m = getBundle("m", readConfiguration);
+ assertNotNull("Bundle from the linked extension not loaded", m);
+ assertEquals("Path not resolved properly from linked extension", new File(testData.getParentFile(), "extension2/m_1.0.0.jar").toURI(), getLocation(m));
+
+ BundleInfo n = getBundle("n", readConfiguration);
+ assertNotNull("Bundle from the linked extension not loaded", n);
+ assertEquals("Path not resolved properly from linked extension", new File("/n_1.0.0.jar").toURI(), getLocation(n));
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testMultipleLocations() throws MalformedURLException, IOException {
+ Activator.EXTENSIONS = testData.toString() + "," + new File(testData.getParentFile(), "extensionsForReconciler1");
+
+ List<BundleInfo> readConfiguration = SimpleConfiguratorUtils.readConfiguration(mainBundlesInfo.toURL(), mainBundlesInfo.getParentFile().toURI());
+ BundleInfo a = getBundle("a", readConfiguration);
+ assertNotNull("Bundle from the main list not loaded", a);
+ assertEquals("Path not resolved properly for the main bundles.info", new File(mainBundlesInfo.getParentFile(), "plugins/a_1.0.0.jar").toURI(), getLocation(a));
+
+ BundleInfo b = getBundle("b", readConfiguration);
+ assertNotNull("Bundle from the main list not loaded", b);
+ assertEquals("Path not resolved properly for the main bundles.info", new File("/b_1.0.0.jar").toURI(), getLocation(b));
+
+ //check false positive
+ BundleInfo x = getBundle("x", readConfiguration);
+ assertNull("This bundle is not listed anywhere!", x);
+
+ BundleInfo g = getBundle("g", readConfiguration);
+ assertNotNull("Bundle from the direct extension not loaded", g);
+ assertEquals("Path not resolved properly from direct extension", new File(testData, "extension1/plugins/g_1.0.0.jar").toURI(), getLocation(g));
+
+ BundleInfo h = getBundle("h", readConfiguration);
+ assertNotNull("Bundle from the direct extension not loaded", h);
+ assertEquals("Path not resolved properly from direct extension", new File("/h_1.0.0.jar").toURI(), getLocation(h));
+
+ BundleInfo m = getBundle("m", readConfiguration);
+ assertNotNull("Bundle from the linked extension not loaded", m);
+ assertEquals("Path not resolved properly from linked extension", new File(testData.getParentFile(), "extension2/m_1.0.0.jar").toURI(), getLocation(m));
+
+ BundleInfo n = getBundle("n", readConfiguration);
+ assertNotNull("Bundle from the linked extension not loaded", n);
+ assertEquals("Path not resolved properly from linked extension", new File("/n_1.0.0.jar").toURI(), getLocation(n));
+
+ BundleInfo aBundle = getBundle("aBundle", readConfiguration);
+ assertNotNull("Bundle from the linked extension not loaded", aBundle);
+ assertEquals("Path not resolved properly from linked extension", new File("/n_1.0.0.jar").toURI(), getLocation(n));
+ }
+
+ //on adding extension master must be selected in order to create new profile with extensions!
+ public void testSharedConfigurationMasterUnmodified() throws IOException {
+ storeTimestamp(new File(masterConfguration, relativeURL.getFile()).lastModified());
+ assertEquals(sharedConfiguration[1], configurator.chooseConfigurationURL(relativeURL, sharedConfiguration));
+ assertIsPropertySet(true);
+ }
+
+ private BundleInfo getBundle(String name, List<BundleInfo> list) {
+ for (BundleInfo info : list) {
+ if (info.getSymbolicName().equals(name)) {
+ return info;
+ }
+ }
+ return null;
+ }
+
+ private URI getLocation(BundleInfo b) {
+ if (b.getBaseLocation() != null) {
+ return b.getBaseLocation().resolve(b.getLocation());
+ }
+ return b.getLocation();
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedTest.java
new file mode 100644
index 000000000..de63cc2a9
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/SimpleConfiguratorUtilsExtendedTest.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc. - fragment support
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.simpleconfigurator;
+
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
+
+public class SimpleConfiguratorUtilsExtendedTest extends SimpleConfiguratorTest {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ // enable extended mode
+ Activator.EXTENDED = true;
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Activator.EXTENDED = false;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/artifacts.xml b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/artifacts.xml
new file mode 100644
index 000000000..a813bf64f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/artifacts.xml
@@ -0,0 +1,22 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?artifactRepository class='org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository' version='1.0.0'?>
+<repository name='test' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1.0.0'>
+ <properties size='2'>
+ <property name='p2.system' value='true'/>
+ <property name='p2.timestamp' value='1228157270984'/>
+ <property name='p2.runnable' value='true'/>
+ </properties>
+ <mappings size='3'>
+ <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
+ <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
+ <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
+ </mappings>
+ <artifacts size='1'>
+ <artifact classifier='osgi.bundle' id='zzz' version='1.0.0'>
+ <properties size='2'>
+ <property name='artifact.size' value='361'/>
+ <property name='download.size' value='361'/>
+ </properties>
+ </artifact>
+ </artifacts>
+</repository>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/content.xml b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/content.xml
new file mode 100644
index 000000000..498c0c7b7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/content.xml
@@ -0,0 +1,33 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?metadataRepository class='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1.0.0'?>
+<repository name='metadata listener dropins' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1.0.0'>
+ <properties size='2'>
+ <property name='p2.system' value='true'/>
+ <property name='p2.timestamp' value='1228157270968'/>
+ <property name='p2.runnable' value='true'/>
+ </properties>
+ <units size='1'>
+ <unit id='zzz' version='1.0.0' singleton='false'>
+ <update id='zzz' range='[0.0.0,1.0.0)' severity='0'/>
+ <properties size='3'>
+ <property name='org.eclipse.equinox.p2.name' value='ZZZ Plug-in'/>
+ </properties>
+ <provides size='3'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='zzz' version='1.0.0'/>
+ <provided namespace='osgi.bundle' name='zzz' version='1.0.0'/>
+ <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
+ </provides>
+ <artifacts size='1'>
+ <artifact classifier='osgi.bundle' id='zzz' version='1.0.0'/>
+ </artifacts>
+ <touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='1'>
+ <instruction key='manifest'>
+ Bundle-ManifestVersion: 2&#xA;Bundle-RequiredExecutionEnvironment: J2SE-1.5&#xA;Bundle-SymbolicName: zzz&#xA;Bundle-Name: Zzz Plug-in&#xA;Manifest-Version: 1.0&#xA;Bundle-Version: 1.0.0
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ </units>
+</repository>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_1.0.0/feature.xml b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_1.0.0/feature.xml
new file mode 100644
index 000000000..afb647df9
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_1.0.0/feature.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="myFeaturePatch"
+ label="MyFeaturePatch Feature"
+ version="1.0.0">
+
+ <description url="http://www.example.com/description">
+ [Enter Feature Description here.]
+ </description>
+
+ <copyright url="http://www.example.com/copyright">
+ [Enter Copyright Description here.]
+ </copyright>
+
+ <license url="http://www.example.com/license">
+ [Enter License Description here.]
+ </license>
+
+ <requires>
+ <import feature="myFeature" version="1.0.0" patch="true"/>
+ </requires>
+
+ <plugin
+ id="mySingletonBundle"
+ download-size="0"
+ install-size="0"
+ version="1.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_2.0.0/feature.xml b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_2.0.0/feature.xml
new file mode 100644
index 000000000..0e7227e35
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeaturePatch_2.0.0/feature.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="myFeaturePatch"
+ label="MyFeaturePatch Feature"
+ version="2.0.0">
+
+ <description url="http://www.example.com/description">
+ [Enter Feature Description here.]
+ </description>
+
+ <copyright url="http://www.example.com/copyright">
+ [Enter Copyright Description here.]
+ </copyright>
+
+ <license url="http://www.example.com/license">
+ [Enter License Description here.]
+ </license>
+
+ <requires>
+ <import feature="myFeature" version="1.0.0" patch="true"/>
+ </requires>
+
+ <plugin
+ id="myBundle"
+ download-size="0"
+ install-size="0"
+ version="2.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_1.0.0/feature.xml b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_1.0.0/feature.xml
new file mode 100644
index 000000000..e51123811
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_1.0.0/feature.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="myFeature"
+ label="MyFeature Feature"
+ version="1.0.0">
+
+ <description url="http://www.example.com/description">
+ [Enter Feature Description here.]
+ </description>
+
+ <copyright url="http://www.example.com/copyright">
+ [Enter Copyright Description here.]
+ </copyright>
+
+ <license url="http://www.example.com/license">
+ [Enter License Description here.]
+ </license>
+
+ <plugin
+ id="myBundle"
+ download-size="0"
+ install-size="0"
+ version="1.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_2.0.0/feature.xml b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_2.0.0/feature.xml
new file mode 100644
index 000000000..f9b6fa0c8
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/features/myFeature_2.0.0/feature.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="myFeature"
+ label="MyFeature Feature"
+ version="2.0.0">
+
+ <description url="http://www.example.com/description">
+ [Enter Feature Description here.]
+ </description>
+
+ <copyright url="http://www.example.com/copyright">
+ [Enter Copyright Description here.]
+ </copyright>
+
+ <license url="http://www.example.com/license">
+ [Enter License Description here.]
+ </license>
+
+ <plugin
+ id="myBundle"
+ download-size="0"
+ install-size="0"
+ version="2.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..33a5f5977
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: directoryBased
+Bundle-Name: directoryBased
+Bundle-Version: 1.0.0
+Bundle-ClassPath: directoryBased.jar
+
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/directoryBased.jar b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/directoryBased.jar
new file mode 100644
index 000000000..5f5e8021b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/directoryBased_1.0.0/directoryBased.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/myBundle_2.0.0.jar b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/myBundle_2.0.0.jar
new file mode 100644
index 000000000..b7c01a542
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/myBundle_2.0.0.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_1.0.0.jar b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_1.0.0.jar
new file mode 100644
index 000000000..a2eee0aa6
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_1.0.0.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_2.0.0.jar b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_2.0.0.jar
new file mode 100644
index 000000000..8cd275fee
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/mySingletonBundle_2.0.0.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/zzz_1.0.0.jar b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/zzz_1.0.0.jar
new file mode 100644
index 000000000..6dbf3ef76
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/plugins/zzz_1.0.0.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.info b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.info
new file mode 100644
index 000000000..cf78b8848
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.info
@@ -0,0 +1 @@
+zzz,1.0.0,file:plugins/zzz_1.0.0.jar,4,false \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.profile b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.profile
new file mode 100644
index 000000000..df4a68063
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/reconciler/extensions/ext1/simplerepo/simple.profile
@@ -0,0 +1,28 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?profile version='1.0.0'?>
+<profile id='DefaultProfile' timestamp='1386012937274'>
+ <units size='1'>
+ <unit id='zzz' version='1.0.0' singleton='false'>
+ <update id='zzz' range='[0.0.0,1.0.0)' severity='0'/>
+ <properties size='3'>
+ <property name='org.eclipse.equinox.p2.name' value='ZZZ Plug-in'/>
+ </properties>
+ <provides size='3'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='zzz' version='1.0.0'/>
+ <provided namespace='osgi.bundle' name='zzz' version='1.0.0'/>
+ <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
+ </provides>
+ <artifacts size='1'>
+ <artifact classifier='osgi.bundle' id='zzz' version='1.0.0'/>
+ </artifacts>
+ <touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='1'>
+ <instruction key='manifest'>
+ Bundle-ManifestVersion: 2&#xA;Bundle-RequiredExecutionEnvironment: J2SE-1.5&#xA;Bundle-SymbolicName: zzz&#xA;Bundle-Name: Zzz Plug-in&#xA;Manifest-Version: 1.0&#xA;Bundle-Version: 1.0.0
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ </units>
+</profile> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/brokenExtension/.gitignore b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/brokenExtension/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/brokenExtension/.gitignore
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extension2/extension2.info b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extension2/extension2.info
new file mode 100644
index 000000000..cdede9b3d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extension2/extension2.info
@@ -0,0 +1,2 @@
+m,1.0.0,file:m_1.0.0.jar,4,false
+n,1.0.0,file:/n_1.0.0.jar,4,false \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension1/extension1.info b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension1/extension1.info
new file mode 100644
index 000000000..72d88cb72
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension1/extension1.info
@@ -0,0 +1,2 @@
+g,1.0.0,file:plugins/g_1.0.0.jar,4,false
+h,1.0.0,file:/h_1.0.0.jar,4,false \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension2.link b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension2.link
new file mode 100644
index 000000000..b04d6c9bf
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensions/extension2.link
@@ -0,0 +1 @@
+link=../extension2/extension2.info \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/artifacts.xml b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/artifacts.xml
new file mode 100644
index 000000000..0b47417d2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/artifacts.xml
@@ -0,0 +1,24 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?artifactRepository class='org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository' version='1.0.0'?>
+<repository name='Test Artifact Repository' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1232060468755'/>
+ <property name='p2.runnable' value='true'/>
+ </properties>
+ <mappings size='3'>
+ <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
+ <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
+ <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
+ </mappings>
+ <artifacts size='1'>
+ <artifact classifier='osgi.bundle' id='aBundle' version='1.0.0'>
+ <properties size='4'>
+ <property name='artifact.size' value='319'/>
+ <property name='download.size' value='319'/>
+ <property name='download.md5' value='1977e840df1f69b5392120a653ebbcd1'/>
+ <property name='download.contentType' value='application/zip'/>
+ </properties>
+ </artifact>
+ </artifacts>
+</repository>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/content.xml b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/content.xml
new file mode 100644
index 000000000..a6241b0a7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/content.xml
@@ -0,0 +1,32 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?metadataRepository class='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1.0.0'?>
+<repository name='Test Metadata Repository' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1232060468765'/>
+ </properties>
+ <units size='1'>
+ <unit id='aBundle' version='1.0.0' singleton='false'>
+ <update id='aBundle' range='[0.0.0,1.0.0)' severity='0'/>
+ <properties size='1'>
+ <property name='org.eclipse.equinox.p2.name' value='ABundle Plug-in'/>
+ </properties>
+ <provides size='3'>
+ <provided namespace='org.eclipse.equinox.p2.iu' name='aBundle' version='1.0.0'/>
+ <provided namespace='osgi.bundle' name='aBundle' version='1.0.0'/>
+ <provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
+ </provides>
+ <artifacts size='1'>
+ <artifact classifier='osgi.bundle' id='aBundle' version='1.0.0'/>
+ </artifacts>
+ <touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
+ <touchpointData size='1'>
+ <instructions size='1'>
+ <instruction key='manifest'>
+ Bundle-SymbolicName: aBundle&#xA;Bundle-ManifestVersion: 2&#xA;Bundle-Version: 1.0.0&#xA;Bundle-Name: ABundle Plug-in&#xA;Manifest-Version: 1.0&#xA;
+ </instruction>
+ </instructions>
+ </touchpointData>
+ </unit>
+ </units>
+</repository>
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/extension3.info b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/extension3.info
new file mode 100644
index 000000000..e00e5d190
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/extension3.info
@@ -0,0 +1 @@
+aBundle,1.0.0,file:plugins/aBundle_1.0.0.jar,4,false \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/plugins/aBundle_1.0.0.jar b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/plugins/aBundle_1.0.0.jar
new file mode 100644
index 000000000..6050d4ec3
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/extensionsForReconciler1/1/plugins/aBundle_1.0.0.jar
Binary files differ
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/main/bundles.info b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/main/bundles.info
new file mode 100644
index 000000000..728123d08
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorExtendedTest/main/bundles.info
@@ -0,0 +1,2 @@
+a,1.0.0,file:plugins/a_1.0.0.jar,4,false
+b,1.0.0,file:/b_1.0.0.jar,4,false \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorTest/extension/extension.info b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorTest/extension/extension.info
new file mode 100644
index 000000000..7d9ca0f7a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/testData/simpleConfiguratorTest/extension/extension.info
@@ -0,0 +1 @@
+myBundle,1.0.0,file:../myBundle_1.0.0.jar,4,true \ No newline at end of file
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 7db11a125..b4220492c 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
@@ -8,6 +8,10 @@
*
* Ericsson AB (Pascal Rapicault) - Bug 397216 -[Shared] Better shared
* configuration change discovery
+ *
+ * Red Hat, Inc (Krzysztof Daniel) - Bug 421935: Extend simpleconfigurator to
+ * read .info files from many locations
+ *
*******************************************************************************/
package org.eclipse.equinox.internal.simpleconfigurator.manipulator;
@@ -412,6 +416,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
Properties timestampToPersist = new Properties();
timestampToPersist.put(SimpleConfiguratorImpl.KEY_BUNDLESINFO_TIMESTAMP, Long.toString(sharedBundlesInfo.lastModified()));
+ timestampToPersist.put(SimpleConfiguratorImpl.KEY_EXT_TIMESTAMP, Long.toString(SimpleConfiguratorUtils.getExtendedTimeStamp()));
OutputStream os = null;
try {
try {
@@ -577,8 +582,10 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
private boolean hasBaseChanged(URI installArea, File outputFolder) {
String rememberedTimestamp;
+ String extensionTimestsamp;
try {
rememberedTimestamp = (String) loadProperties(new File(outputFolder, SimpleConfiguratorImpl.BASE_TIMESTAMP_FILE_BUNDLESINFO)).get(SimpleConfiguratorImpl.KEY_BUNDLESINFO_TIMESTAMP);
+ extensionTimestsamp = (String) loadProperties(new File(outputFolder, SimpleConfiguratorImpl.BASE_TIMESTAMP_FILE_BUNDLESINFO)).get(SimpleConfiguratorImpl.KEY_EXT_TIMESTAMP);
} catch (IOException e) {
return false;
}
@@ -588,7 +595,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani
File sharedBundlesInfo = new File(URIUtil.append(installArea, SHARED_BUNDLES_INFO));
if (!sharedBundlesInfo.exists())
return true;
- return !String.valueOf(sharedBundlesInfo.lastModified()).equals(rememberedTimestamp);
+ return !(String.valueOf(sharedBundlesInfo.lastModified()).equals(rememberedTimestamp) && String.valueOf(SimpleConfiguratorUtils.getExtendedTimeStamp()).equals(extensionTimestsamp));
}
private boolean isSharedInstallSetup(File installArea, File outputFile) {
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/Activator.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/Activator.java
index 24c24fd8a..3ab096aea 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/Activator.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,8 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Red Hat, Inc (Krzysztof Daniel) - Bug 421935: Extend simpleconfigurator to
+ * read .info files from many locations
*******************************************************************************/
package org.eclipse.equinox.internal.simpleconfigurator;
@@ -40,6 +42,16 @@ import org.osgi.framework.*;
*/
public class Activator implements BundleActivator {
public final static boolean DEBUG = false;
+
+ /**
+ * If this property is set to true, simpleconfigurator will attempt to read
+ * multiple *.info files.
+ *
+ * This field is writable only for test purposes.
+ */
+ public static String EXTENSIONS = System.getProperty("p2.fragments");
+ public static boolean EXTENDED = (EXTENSIONS != null);
+
private ServiceRegistration<?> configuratorRegistration;
private ServiceRegistration<?> commandRegistration;
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java
index 6a1fee881..f4061f188 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java
@@ -4,13 +4,15 @@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc (Krzysztof Daniel) - Bug 421935: Extend simpleconfigurator to
+ * read .info files from many locations
*******************************************************************************/
package org.eclipse.equinox.internal.simpleconfigurator;
import java.io.*;
-import java.net.URI;
-import java.net.URL;
+import java.net.*;
import java.util.*;
import org.eclipse.equinox.internal.simpleconfigurator.utils.*;
import org.osgi.framework.*;
@@ -244,8 +246,17 @@ class ConfigApplier {
try {
try {
destinationStream = new FileOutputStream(lastBundlesTxt);
- sourceStream = url.openStream();
- SimpleConfiguratorUtils.transferStreams(sourceStream, destinationStream);
+ ArrayList<File> sourcesLocation = SimpleConfiguratorUtils.getInfoFiles();
+ List<InputStream> sourceStreams = new ArrayList<InputStream>(sourcesLocation.size() + 1);
+ sourceStreams.add(url.openStream());
+ if (Activator.EXTENDED) {
+ for (int i = 0; i < sourcesLocation.size(); i++) {
+ sourceStreams.add(new FileInputStream(sourcesLocation.get(i)));
+ }
+ }
+ SimpleConfiguratorUtils.transferStreams(sourceStreams, destinationStream);
+ } catch (URISyntaxException e) {
+ // nothing, was discovered when starting framework
} finally {
if (destinationStream != null)
destinationStream.close();
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java
index 70d3b4c93..b888f29b1 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/SimpleConfiguratorImpl.java
@@ -7,7 +7,9 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Ericsson AB (Pascal Rapicault) - Bug 397216 -[Shared] Better shared configuration change discovery
+ * Ericsson AB (Pascal Rapicault) - Bug 397216 -[Shared] Better shared configuration change discovery
+ * Red Hat, Inc (Krzysztof Daniel) - Bug 421935: Extend simpleconfigurator to
+ * read .info files from many locations
*******************************************************************************/
package org.eclipse.equinox.internal.simpleconfigurator;
@@ -47,6 +49,7 @@ public class SimpleConfiguratorImpl implements Configurator {
private static final long NO_TIMESTAMP = -1;
public static final String BASE_TIMESTAMP_FILE_BUNDLESINFO = ".baseBundlesInfoTimestamp"; //$NON-NLS-1$
public static final String KEY_BUNDLESINFO_TIMESTAMP = "bundlesInfoTimestamp";
+ public static final String KEY_EXT_TIMESTAMP = "extTimestamp";
public static final String PROP_IGNORE_USER_CONFIGURATION = "eclipse.ignoreUserConfiguration"; //$NON-NLS-1$
public SimpleConfiguratorImpl(BundleContext context, Bundle bundle) {
@@ -127,10 +130,10 @@ public class SimpleConfiguratorImpl implements Configurator {
if (Boolean.TRUE.toString().equals(System.getProperty(PROP_IGNORE_USER_CONFIGURATION)))
return sharedConfig.toURL();
- long sharedBundlesInfoTimestamp = getCurrentBundlesInfoBaseTimestamp(sharedConfig);
- long lastKnownBaseTimestamp = getLastKnownBundlesInfoBaseTimestamp(userConfig.getParentFile());
+ long[] sharedBundlesInfoTimestamp = getCurrentBundlesInfoBaseTimestamp(sharedConfig);
+ long[] lastKnownBaseTimestamp = getLastKnownBundlesInfoBaseTimestamp(userConfig.getParentFile());
- if (lastKnownBaseTimestamp == sharedBundlesInfoTimestamp || lastKnownBaseTimestamp == NO_TIMESTAMP) {
+ if ((lastKnownBaseTimestamp[0] == sharedBundlesInfoTimestamp[0] && lastKnownBaseTimestamp[1] == sharedBundlesInfoTimestamp[1]) || lastKnownBaseTimestamp[0] == NO_TIMESTAMP) {
return userConfig.toURL();
} else {
System.setProperty(PROP_IGNORE_USER_CONFIGURATION, Boolean.TRUE.toString());
@@ -140,10 +143,11 @@ public class SimpleConfiguratorImpl implements Configurator {
return null;
}
- private long getLastKnownBundlesInfoBaseTimestamp(File configFolder) {
+ private long[] getLastKnownBundlesInfoBaseTimestamp(File configFolder) {
+ long[] result = new long[] {NO_TIMESTAMP, NO_TIMESTAMP};
File storedSharedTimestamp = new File(configFolder, BASE_TIMESTAMP_FILE_BUNDLESINFO);
if (!storedSharedTimestamp.exists())
- return NO_TIMESTAMP;
+ return result;
Properties p = new Properties();
InputStream is = null;
@@ -152,21 +156,26 @@ public class SimpleConfiguratorImpl implements Configurator {
is = new BufferedInputStream(new FileInputStream(storedSharedTimestamp));
p.load(is);
if (p.get(KEY_BUNDLESINFO_TIMESTAMP) != null) {
- return Long.valueOf((String) p.get(KEY_BUNDLESINFO_TIMESTAMP)).longValue();
+ result[0] = Long.valueOf((String) p.get(KEY_BUNDLESINFO_TIMESTAMP)).longValue();
+ }
+ if (p.get(KEY_EXT_TIMESTAMP) != null) {
+ result[1] = Long.valueOf((String) p.get(KEY_EXT_TIMESTAMP)).longValue();
}
} finally {
is.close();
}
} catch (IOException e) {
- return NO_TIMESTAMP;
+ return result;
}
- return NO_TIMESTAMP;
+ return result;
}
- private long getCurrentBundlesInfoBaseTimestamp(File sharedBundlesInfo) {
+ public static long[] getCurrentBundlesInfoBaseTimestamp(File sharedBundlesInfo) {
if (!sharedBundlesInfo.exists())
- return NO_TIMESTAMP;
- return sharedBundlesInfo.lastModified();
+ return new long[] {NO_TIMESTAMP, NO_TIMESTAMP};
+ long lastModified = sharedBundlesInfo.lastModified();
+ long extLastModified = SimpleConfiguratorUtils.getExtendedTimeStamp();
+ return new long[] {lastModified, extLastModified};
}
public void applyConfiguration(URL url) throws IOException {
diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
index 06474ff34..ab69b8856 100644
--- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
+++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java
@@ -1,20 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2007, 2013 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Red Hat, Inc (Krzysztof Daniel) - Bug 421935: Extend simpleconfigurator to
+ * read .info files from many locations
******************************************************************************/
package org.eclipse.equinox.internal.simpleconfigurator.utils;
import java.io.*;
import java.net.*;
import java.util.*;
+import org.eclipse.equinox.internal.simpleconfigurator.Activator;
import org.osgi.framework.Version;
public class SimpleConfiguratorUtils {
+ private static final String LINK_KEY = "link";
+ private static final String LINK_FILE_EXTENSION = ".link";
private static final String UNC_PREFIX = "//";
private static final String VERSION_PREFIX = "#version=";
public static final String ENCODING_UTF8 = "#encoding=UTF-8";
@@ -26,7 +32,149 @@ public class SimpleConfiguratorUtils {
private static final String COMMA = ",";
private static final String ENCODED_COMMA = "%2C";
+ private static final Set<File> reportedExtensions = Collections.synchronizedSet(new HashSet<File>(0));
+
public static List<BundleInfo> readConfiguration(URL url, URI base) throws IOException {
+ List<BundleInfo> result = new ArrayList<BundleInfo>();
+
+ //old behaviour
+ result.addAll(readConfigurationFromFile(url, base));
+
+ if (!Activator.EXTENDED) {
+ return result;
+ }
+ readExtendedConfigurationFiles(result);
+ //dedup - some bundles may be listed more than once
+ removeDuplicates(result);
+ return result;
+ }
+
+ public static void removeDuplicates(List<BundleInfo> result) {
+ if (result.size() > 1) {
+ int index = 0;
+ while (index < result.size()) {
+ String aSymbolicName = result.get(index).getSymbolicName();
+ String aVersion = result.get(index).getVersion();
+
+ for (int i = index + 1; i < result.size();) {
+ String bSymbolicName = result.get(i).getSymbolicName();
+ String bVersion = result.get(i).getVersion();
+ if (aSymbolicName.equals(bSymbolicName) && aVersion.equals(bVersion)) {
+ result.remove(i);
+ } else {
+ i++;
+ }
+ }
+
+ index++;
+ }
+ }
+ }
+
+ public static void readExtendedConfigurationFiles(List<BundleInfo> result) throws IOException, FileNotFoundException, MalformedURLException {
+ //extended behaviour
+ List<File> files;
+ try {
+ files = getInfoFiles();
+ for (File info : files) {
+ List<BundleInfo> list = readConfigurationFromFile(info.toURL(), info.getParentFile().toURI());
+ // extensions are relative to extension root, not to the framework
+ // it is necessary to replace relative locations with absolute ones
+ for (int i = 0; i < list.size(); i++) {
+ BundleInfo singleInfo = list.get(i);
+ if (singleInfo.getBaseLocation() != null) {
+ singleInfo = new BundleInfo(singleInfo.getSymbolicName(), singleInfo.getVersion(), singleInfo.getBaseLocation().resolve(singleInfo.getLocation()), singleInfo.getStartLevel(), singleInfo.isMarkedAsStarted());
+ list.remove(i);
+ list.add(i, singleInfo);
+ }
+ }
+ if (Activator.DEBUG) {
+ System.out.println("List of bundles to be loaded from " + info.toURL());
+ for (BundleInfo b : list) {
+ System.out.println(b.getSymbolicName() + "_" + b.getVersion());
+ }
+ }
+ result.addAll(list);
+ }
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Couldn't parse simpleconfigurator extensions", e);
+ }
+ }
+
+ public static ArrayList<File> getInfoFiles() throws IOException, FileNotFoundException, URISyntaxException {
+ ArrayList<File> files = new ArrayList<File>(1);
+
+ if (Activator.EXTENSIONS != null) {
+ //configured simpleconfigurator extensions location
+ String stringExtenionLocation = Activator.EXTENSIONS;
+ String[] locationToCheck = stringExtenionLocation.split(",");
+ for (String location : locationToCheck) {
+ files.addAll(getInfoFilesFromLocation(location));
+ }
+ }
+ return files;
+ }
+
+ private static ArrayList<File> getInfoFilesFromLocation(String locationToCheck) throws IOException, FileNotFoundException, URISyntaxException {
+ ArrayList<File> result = new ArrayList<File>(1);
+
+ File extensionsLocation = new File(locationToCheck);
+
+ if (extensionsLocation.exists() && extensionsLocation.isDirectory()) {
+ //extension location contains extensions
+ File[] extensions = extensionsLocation.listFiles();
+ for (File extension : extensions) {
+ if (extension.isFile() && extension.getName().endsWith(LINK_FILE_EXTENSION)) {
+ Properties link = new Properties();
+ link.load(new FileInputStream(extension));
+ String newInfoName = link.getProperty(LINK_KEY);
+ URI newInfoURI = new URI(newInfoName);
+ File newInfoFile = null;
+ if (newInfoURI.isAbsolute()) {
+ newInfoFile = new File(newInfoName);
+ } else {
+ newInfoFile = new File(extension.getParentFile(), newInfoName);
+ }
+ if (newInfoFile.exists()) {
+ extension = newInfoFile.getParentFile();
+ }
+ }
+
+ if (extension.isDirectory()) {
+ if (extension.canWrite()) {
+ synchronized (reportedExtensions) {
+ if (!reportedExtensions.contains(extension)) {
+ reportedExtensions.add(extension);
+ System.err.println("Fragment directory should be read only " + extension);
+ }
+ }
+ continue;
+ }
+ File[] listFiles = extension.listFiles();
+ // new magic - multiple info files, f.e.
+ // egit.info (git feature)
+ // cdt.linkĀ (properties file containing link=path) to other info file
+ for (File file : listFiles) {
+ //if it is a info file - load it
+ if (file.getName().endsWith(".info")) {
+ result.add(file);
+ }
+ // if it is a link - dereference it
+ }
+ } else if (Activator.DEBUG) {
+ synchronized (reportedExtensions) {
+ if (!reportedExtensions.contains(extension)) {
+ reportedExtensions.add(extension);
+ System.out.println("Unrecognized fragment " + extension);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ private static List<BundleInfo> readConfigurationFromFile(URL url, URI base) throws IOException {
InputStream stream = null;
try {
stream = url.openStream();
@@ -183,24 +331,29 @@ public class SimpleConfiguratorUtils {
}
}
- public static void transferStreams(InputStream source, OutputStream destination) throws IOException {
- source = new BufferedInputStream(source);
+ public static void transferStreams(List<InputStream> sources, OutputStream destination) throws IOException {
destination = new BufferedOutputStream(destination);
try {
- byte[] buffer = new byte[8192];
- while (true) {
- int bytesRead = -1;
- if ((bytesRead = source.read(buffer)) == -1)
- break;
- destination.write(buffer, 0, bytesRead);
+ for (int i = 0; i < sources.size(); i++) {
+ InputStream source = new BufferedInputStream(sources.get(i));
+ try {
+ byte[] buffer = new byte[8192];
+ while (true) {
+ int bytesRead = -1;
+ if ((bytesRead = source.read(buffer)) == -1)
+ break;
+ destination.write(buffer, 0, bytesRead);
+ }
+ } finally {
+ try {
+ source.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
} finally {
try {
- source.close();
- } catch (IOException e) {
- // ignore
- }
- try {
destination.close();
} catch (IOException e) {
// ignore
@@ -236,4 +389,36 @@ public class SimpleConfiguratorUtils {
bundleLocation = REFERENCE_PREFIX + bundleLocation;
return bundleLocation;
}
+
+ public static long getExtendedTimeStamp() {
+ long regularTimestamp = -1;
+ if (Activator.EXTENDED) {
+ try {
+ ArrayList<File> infoFiles = SimpleConfiguratorUtils.getInfoFiles();
+ for (File f : infoFiles) {
+ long infoFileLastModified = f.lastModified();
+ // pick latest modified always
+ if (infoFileLastModified > regularTimestamp) {
+ regularTimestamp = infoFileLastModified;
+ }
+ }
+ } catch (FileNotFoundException e) {
+ if (Activator.DEBUG) {
+ e.printStackTrace();
+ }
+ } catch (IOException e) {
+ if (Activator.DEBUG) {
+ e.printStackTrace();
+ }
+ } catch (URISyntaxException e) {
+ if (Activator.DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ if (Activator.DEBUG) {
+ System.out.println("Fragments timestamp: " + regularTimestamp);
+ }
+ }
+ return regularTimestamp;
+ }
}

Back to the top