Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2009-08-10 15:20:01 +0000
committerJohn Arthorne2009-08-10 15:20:01 +0000
commita20baba4d5d2c470ea1f55654a3b86f1a59ff4e9 (patch)
tree98259c768b1d71fceb2674ae289bad8ed20ae34e
parent09509ad60e6b3ef0f61967887c194e5dcec41169 (diff)
downloadrt.equinox.p2-a20baba4d5d2c470ea1f55654a3b86f1a59ff4e9.tar.gz
rt.equinox.p2-a20baba4d5d2c470ea1f55654a3b86f1a59ff4e9.tar.xz
rt.equinox.p2-a20baba4d5d2c470ea1f55654a3b86f1a59ff4e9.zip
Bug 285774 p2 director.app is generating compressed profile files by default.R35x_v20090810
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java54
3 files changed, 69 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java
index 2fd1cb5ea..d020c7670 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/EngineActivator.java
@@ -22,6 +22,17 @@ public class EngineActivator implements BundleActivator, ServiceTrackerCustomize
private static BundleContext context;
public static final String ID = "org.eclipse.equinox.p2.engine"; //$NON-NLS-1$
+ /**
+ * System property describing the profile registry file format
+ */
+ public static final String PROP_PROFILE_FORMAT = "eclipse.p2.profileFormat"; //$NON-NLS-1$
+
+ /**
+ * Value for the PROP_PROFILE_FORMAT system property specifying raw XML file
+ * format (used in p2 until and including 3.5.0 release).
+ */
+ public static final String PROFILE_FORMAT_UNCOMPRESSED = "uncompressed"; //$NON-NLS-1$
+
private ServiceRegistration registration;
private ServiceTracker tracker;
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
index 5bd4df26d..406d4c565 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
@@ -34,6 +34,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class SimpleProfileRegistry implements IProfileRegistry {
+
private static final String PROFILE_REGISTRY = "profile registry"; //$NON-NLS-1$
private static final String PROFILE_EXT = ".profile"; //$NON-NLS-1$
@@ -462,6 +463,11 @@ public class SimpleProfileRegistry implements IProfileRegistry {
* Returns whether the profile file for the given profile should be written in gzip format.
*/
private boolean shouldGzipFile(Profile profile) {
+ //check system property controlling compression
+ String format = EngineActivator.getContext().getProperty(EngineActivator.PROP_PROFILE_FORMAT);
+ if (format != null && format.equals(EngineActivator.PROFILE_FORMAT_UNCOMPRESSED))
+ return false;
+
//check whether the profile contains the p2 engine from 3.5.0 or earlier
return profile.available(new InstallableUnitQuery("org.eclipse.equinox.p2.engine", new VersionRange("[0.0.0, 1.0.101)")), new Collector(), null).isEmpty(); //$NON-NLS-1$//$NON-NLS-2$
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java
index 9d95c8a73..eeb0a60b6 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java
@@ -16,8 +16,7 @@ import java.lang.reflect.Method;
import java.util.Properties;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.engine.Profile;
-import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
+import org.eclipse.equinox.internal.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
@@ -584,6 +583,57 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
assertEquals(0, filesFound.length);
}
+ /**
+ * Asserts that the profile registry persistence honours the system property for controlling
+ * the profile format. See bug 285774.
+ */
+ public void testPersistenceFormatOverride() {
+ try {
+ IInstallableUnit engineIU = createEclipseIU("org.eclipse.equinox.p2.engine", Version.create("55.2"));
+ final String[] values = new String[] {"", "blort", null, EngineActivator.PROFILE_FORMAT_UNCOMPRESSED};
+ for (int i = 0; i < values.length; i++) {
+ final String currentValue = values[i];
+ if (currentValue == null)
+ System.getProperties().remove(EngineActivator.PROP_PROFILE_FORMAT);
+ else
+ System.getProperties().put(EngineActivator.PROP_PROFILE_FORMAT, currentValue);
+ File folder = getTempFolder();
+ folder.mkdirs();
+ SimpleProfileRegistry profileRegistry = new SimpleProfileRegistry(folder, null, false);
+ Profile profile = new Profile(getName(), null, null);
+ profile.addInstallableUnit(engineIU);
+ Method saveMethod;
+ try {
+ saveMethod = registry.getClass().getDeclaredMethod("saveProfile", new Class[] {Profile.class});
+ saveMethod.setAccessible(true);
+ saveMethod.invoke(profileRegistry, new Object[] {profile});
+ } catch (SecurityException e) {
+ fail("1.0", e);
+ } catch (NoSuchMethodException e) {
+ fail("1.1", e);
+ } catch (IllegalArgumentException e) {
+ fail("1.2", e);
+ } catch (IllegalAccessException e) {
+ fail("1.3", e);
+ } catch (InvocationTargetException e) {
+ fail("1.4", e);
+ }
+ File profileFolder = new File(folder, getName() + ".profile");
+ profileFolder.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ if (pathname.getName().endsWith(".profile"))
+ assertEquals("2.0." + currentValue, EngineActivator.PROFILE_FORMAT_UNCOMPRESSED, currentValue);
+ else if (pathname.getName().endsWith(".profile.gz"))
+ assertFalse("2.1." + currentValue, EngineActivator.PROFILE_FORMAT_UNCOMPRESSED.equals(currentValue));
+ return false;
+ }
+ });
+ }
+ } finally {
+ System.getProperties().remove(EngineActivator.PROP_PROFILE_FORMAT);
+ }
+ }
+
public void testPersistenceFormatGzipped() {
//in a profile with an engine version from 3.5.1 or later, we gzip the profile registry
IInstallableUnit engineIU = createEclipseIU("org.eclipse.equinox.p2.engine", Version.create("1.0.101"));

Back to the top