Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (Ericsson)2013-01-28 04:41:19 +0000
committerPascal Rapicault2013-01-28 05:08:43 +0000
commitb86b21139a5367412cd51e86d359af33b0c03c3c (patch)
tree1bc01c47dfdcedf7ebc9888aa52002e1d9c809a2 /bundles/org.eclipse.equinox.frameworkadmin.test
parentc847dee6f33950f48ecd1d8eca18729f6ffc470f (diff)
downloadrt.equinox.p2-b86b21139a5367412cd51e86d359af33b0c03c3c.tar.gz
rt.equinox.p2-b86b21139a5367412cd51e86d359af33b0c03c3c.tar.xz
rt.equinox.p2-b86b21139a5367412cd51e86d359af33b0c03c3c.zip
Squashed commit of the following:v20130128-050843
304132 - [shared] upgrading shared base causes loss of user installer plug-ins commit 8461eae803454c36f6a18013c44e37c20810d141 Merge: 23bc40c c847dee Author: Pascal Rapicault <pascal@rapicault.net> Date: Sun Jan 27 22:11:45 2013 -0500 Merge branch 'master' into prapicau/sharedInstall-part1 commit 23bc40c4f85b01f37fb0ac23992524a7c8ccd892 Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Sun Jan 27 21:38:07 2013 -0500 Use constant and fix copyright header commit bc11d565b32b5b5c8bb5c93e5ea666b1d06b43ff Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Sun Jan 27 21:33:32 2013 -0500 Annotate new profile with a base profile timestamp commit ba4e7abda6e44ad47aead2fade320f9be08b27d5 Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Sun Jan 27 21:32:20 2013 -0500 Add constants commit 54c8d356527d1321e25bd837e674b758aa61e248 Author: Krzysztof Daniel <kdaniel@redhat.com> Date: Thu Jan 24 13:23:15 2013 +0100 SimpleConfiguratorImpl refactoring and tests. commit 6177c466083fb7676ebfe5790bc0951043b3b727 Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Thu Jan 24 11:59:45 2013 -0500 detection of change in the reconciler commit f04f46d6d283a6235367872b5eaa7e3e483509ed Merge: 5243d49 c32f111 Author: Pascal Rapicault <pascal@rapicault.net> Date: Thu Jan 24 11:43:01 2013 -0500 Merge branch 'master' into prapicau/sharedInstall-part1 commit 5243d497142b0f2631bcda8b5fed67d7ce0ddbd5 Author: Pascal Rapicault <pascal@rapicault.net> Date: Wed Jan 23 15:26:41 2013 -0500 always use shared install when the ignoreUserConfig property is set commit 12eccdad23420e7ba91f99221c852f7e32eb11de Merge: c68f394 1e9fc23 Author: Pascal Rapicault <pascal@rapicault.net> Date: Wed Jan 23 10:29:56 2013 -0500 Merge branch 'master' into prapicau/sharedInstall-part1 commit c68f394a39c4215ed7ac960495a3c59eb3cf3eee Author: Pascal Rapicault <pascal@rapicault.net> Date: Tue Jan 22 22:24:04 2013 -0500 Bug 398853 - [UI] installed IU shows as update commit aa6d632dea7ff54e9ba7c3c7f9f2ecd30afe5906 Author: Pascal Rapicault <pascal@rapicault.net> Date: Tue Jan 22 13:50:05 2013 -0500 Differentiate initial profile creation from reset. commit 4fb3429ed3fd673d5daf7ca1ce9bf1184a0afcb3 Author: Pascal Rapicault <pascal@rapicault.net> Date: Tue Jan 22 13:49:23 2013 -0500 Only show migration dialog once commit a34eac29e330a41991d003e2dcd2d8b264d77145 Author: Krzysztof Daniel <kdaniel@redhat.com> Date: Mon Jan 21 12:40:36 2013 +0100 397216: [Shared] Better shared configuration change discovery Perform dropins reindexing after master configuration had been changed. https://bugs.eclipse.org/bugs/show_bug.cgi?id=397216 commit 6981ca8bd3c1db9ab2dd9484a1f7c8950fcd1abe Merge: dfec14b 33ca260 Author: Pascal Rapicault <pascal@rapicault.net> Date: Mon Jan 21 15:04:28 2013 -0500 Merge branch 'master' into prapicau/sharedInstall-part1 commit dfec14b67a69b6fa14efb860ef8a986053a58917 Merge: 6067d05 ba5f048 Author: Pascal Rapicault <pascal@rapicault.net> Date: Mon Jan 21 11:34:38 2013 -0500 Merge branch 'master' into prapicau/sharedInstall-part1 commit ba5f048a3ac5563430104adeb173dc4f7dda6eca Author: Pascal Rapicault <pascal@rapicault.net> Date: Mon Jan 21 11:28:20 2013 -0500 Bug 398539 - Got a NPE trying to add a new update site commit 6067d05e402fe796debd9d25604cae7026df5b48 Author: Pascal Rapicault <pascal@rapicault.net> Date: Fri Jan 18 16:16:18 2013 -0500 only write timestamp file for shared install commit 8ab9410d8c797e6a8d2a97e4ba46da3d548440fa Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Fri Jan 18 13:56:46 2013 -0500 Cache the fact that the state.properties is missing commit fefbc5bdec2ce6cdb7fd71b1790bf8abdee8737a Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Fri Jan 18 13:51:54 2013 -0500 Fix bug in change detection logic commit 3de6f8593d5c1b21be3bd21000e34acb945056b1 Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Wed Jan 16 19:50:32 2013 -0500 Detect changes in the bundles.info commit 446649c95063dca689f4d2c886b26975a11f3499 Author: Pascal Rapicault <pascal@rapicault.net> Date: Tue Jan 15 14:04:57 2013 -0500 Simple notification to let the user know that the base has changed. commit e004dc5270abd33a60da9a8d0340409bc8e4a38d Author: Pascal Rapicault <pascal@rapicault.net> Date: Fri Jan 11 14:15:20 2013 +0100 ignore user config.ini if out of sync with base commit a0235c0c95b9047e64d6e24c9d8f6b8588087113 Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Wed Dec 12 09:57:36 2012 -0500 Obtain specific profile state properties without locking commit 1d0f129ca70716e7a181631e1ba0e71f16e35e08 Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Mon Dec 10 16:06:38 2012 -0500 Remember the timestamp of the base config.ini commit 3134caecfd244fd88386f3ce4bd1a6fc71fe8007 Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Wed Dec 5 16:21:50 2012 -0500 Support to ignore the existing profile if the base has changed commit 7f0ba4e643f40bc0143617b93b2238388d38216d Author: Pascal Rapicault (Ericsson) <pascal.rapicault@ericsson.com> Date: Tue Dec 4 11:23:37 2012 -0500 Remove externalization warning
Diffstat (limited to 'bundles/org.eclipse.equinox.frameworkadmin.test')
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/config.ini1
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/user-config.ini3
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java126
3 files changed, 116 insertions, 14 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/config.ini b/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/config.ini
new file mode 100644
index 000000000..cb5fd8609
--- /dev/null
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/config.ini
@@ -0,0 +1 @@
+sharedKey=sharedValue \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/user-config.ini b/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/user-config.ini
new file mode 100644
index 000000000..8797ba532
--- /dev/null
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/dataFile/sharedconfiguration/ignoreUserConfig/user-config.ini
@@ -0,0 +1,3 @@
+osgi.sharedConfiguration.area=file\:configuration/
+userKey=userValue
+
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java
index 134d7bec0..0d0eba503 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * 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
@@ -7,20 +7,29 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Ericsson AB (Pascal Rapicault) - Improve shared install
*******************************************************************************/
package org.eclipse.equinox.frameworkadmin.tests;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
+import java.net.URISyntaxException;
+import java.util.Properties;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.frameworkadmin.BundleInfo;
+import org.eclipse.equinox.internal.frameworkadmin.equinox.Log;
+import org.eclipse.equinox.internal.frameworkadmin.equinox.Messages;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
+import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleException;
+import org.osgi.service.log.LogService;
public class SharedConfigurationTest extends AbstractFwkAdminTest {
public SharedConfigurationTest(String name) {
super(name);
}
-
+
public void testDefaultConfiguration() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException {
startSimpleConfiguratorManipulator();
FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
@@ -30,19 +39,19 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest {
File defaultConfigurationFolder = new File(installFolder, "configuration");
defaultConfigurationFolder.mkdirs();
copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini"));
-
+
String launcherName = "foo";
LauncherData launcherData = manipulator.getLauncherData();
launcherData.setFwConfigLocation(defaultConfigurationFolder);
launcherData.setLauncher(new File(installFolder, launcherName));
-
+
try {
manipulator.load();
} catch (IllegalStateException e) {
//TODO We ignore the framework JAR location not set exception
}
-
+
assertEquals("false", manipulator.getConfigData().getProperty("config.shared"));
assertEquals("true", manipulator.getConfigData().getProperty("from.parent"));
}
@@ -59,23 +68,23 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest {
File userConfigurationFolder = new File(installFolder, "user/configuration");
userConfigurationFolder.mkdirs();
copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-config.ini"), new File(userConfigurationFolder, "config.ini"));
-
+
String launcherName = "foo";
LauncherData launcherData = manipulator.getLauncherData();
launcherData.setFwConfigLocation(userConfigurationFolder);
launcherData.setLauncher(new File(installFolder, launcherName));
-
+
try {
manipulator.load();
} catch (IllegalStateException e) {
//TODO We ignore the framework JAR location not set exception
}
-
+
assertEquals("true", manipulator.getConfigData().getProperty("config.shared"));
assertEquals("true", manipulator.getConfigData().getProperty("from.parent"));
}
-
+
public void testNotSharedConfiguration() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException {
startSimpleConfiguratorManipulator();
FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
@@ -88,20 +97,109 @@ public class SharedConfigurationTest extends AbstractFwkAdminTest {
File userConfigurationFolder = new File(installFolder, "user/configuration");
userConfigurationFolder.mkdirs();
copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-noshare-config.ini"), new File(userConfigurationFolder, "config.ini"));
-
+
String launcherName = "foo";
LauncherData launcherData = manipulator.getLauncherData();
launcherData.setFwConfigLocation(userConfigurationFolder);
launcherData.setLauncher(new File(installFolder, launcherName));
-
+
try {
manipulator.load();
} catch (IllegalStateException e) {
//TODO We ignore the framework JAR location not set exception
}
-
+
assertEquals("false", manipulator.getConfigData().getProperty("config.shared"));
assertEquals(null, manipulator.getConfigData().getProperty("from.parent"));
}
+
+ public void testConfigIniTimestamp() throws BundleException, FrameworkAdminRuntimeException, IOException, URISyntaxException {
+ startSimpleConfiguratorManipulator();
+ FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
+ Manipulator manipulator = fwkAdmin.getManipulator();
+
+ File installFolder = Activator.getContext().getDataFile(SharedConfigurationTest.class.getName());
+ File defaultConfigurationFolder = new File(installFolder, "configuration");
+ defaultConfigurationFolder.mkdirs();
+ copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/config.ini"), new File(defaultConfigurationFolder, "config.ini"));
+ File userConfigurationFolder = new File(installFolder, "user/configuration");
+ userConfigurationFolder.mkdirs();
+ copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/user-config.ini"), new File(userConfigurationFolder, "config.ini"));
+
+ String launcherName = "foo";
+
+ LauncherData launcherData = manipulator.getLauncherData();
+ launcherData.setFwConfigLocation(userConfigurationFolder);
+ launcherData.setLauncher(new File(installFolder, launcherName));
+
+ try {
+ manipulator.load();
+ } catch (IllegalStateException e) {
+ //TODO We ignore the framework JAR location not set exception
+ }
+
+ BundleInfo osgiBi = new BundleInfo("org.eclipse.osgi", "3.3.1", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.osgi.jar"))), 0, true);
+ BundleInfo configuratorBi = new BundleInfo("org.eclipse.equinox.simpleconfigurator", "1.0.0", URIUtil.toURI(FileLocator.resolve(Activator.getContext().getBundle().getEntry("dataFile/org.eclipse.equinox.simpleconfigurator.jar"))), 1, true);
+
+ manipulator.getConfigData().addBundle(osgiBi);
+ manipulator.getConfigData().addBundle(configuratorBi);
+
+ manipulator.save(false);
+ File baseTimestamp = new File(userConfigurationFolder, ".baseTimestamps");
+ assertIsFile(baseTimestamp);
+ assertContent(baseTimestamp, Long.toString(new File(defaultConfigurationFolder, "config.ini").lastModified()));
+ }
+
+ public void testConfigurationIgnoredWhenChanged() throws BundleException, FrameworkAdminRuntimeException, IOException {
+ startSimpleConfiguratorManipulator();
+ FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
+ Manipulator manipulator = fwkAdmin.getManipulator();
+
+ //setup the files
+ File installFolder = Activator.getContext().getDataFile(SharedConfigurationTest.class.getName());
+ File defaultConfigurationFolder = new File(installFolder, "configuration");
+ defaultConfigurationFolder.mkdirs();
+ copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/ignoreUserConfig/config.ini"), new File(defaultConfigurationFolder, "config.ini"));
+ File userConfigurationFolder = new File(installFolder, "user/configuration");
+ userConfigurationFolder.mkdirs();
+ copy("creating shared config.ini", getTestData("", "dataFile/sharedconfiguration/ignoreUserConfig/user-config.ini"), new File(userConfigurationFolder, "config.ini"));
+
+ //setup the timestamp
+ Properties p = new Properties();
+ p.setProperty("configIniTimestamp", Long.toString(new File(defaultConfigurationFolder, "config.ini").lastModified()));
+ saveProperties(new File(userConfigurationFolder, ".baseTimestamps"), p);
+
+ String launcherName = "foo";
+
+ LauncherData launcherData = manipulator.getLauncherData();
+ launcherData.setFwConfigLocation(userConfigurationFolder);
+ launcherData.setLauncher(new File(installFolder, launcherName));
+
+ try {
+ manipulator.load();
+ } catch (IllegalStateException e) {
+ //TODO We ignore the framework JAR location not set exception
+ }
+
+ assertNull(manipulator.getConfigData().getProperty("userKey"));
+ assertEquals("sharedValue", manipulator.getConfigData().getProperty("sharedKey"));
+ }
+
+ private void saveProperties(File outputFile, Properties configProps) throws IOException {
+ String header = "This configuration file was written by: " + this.getClass().getName(); //$NON-NLS-1$
+ FileOutputStream out = null;
+ try {
+ out = new FileOutputStream(outputFile);
+ configProps.store(out, header);
+ Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_propertiesSaved, outputFile));
+ } finally {
+ try {
+ out.flush();
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}

Back to the top