Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2009-08-10 17:52:58 +0000
committerDJ Houghton2009-08-10 17:52:58 +0000
commit8fc08e6186b7cd11ed29adb4a7dd3794c608323d (patch)
treea8a602a0cfe4335097bbe5b52cc72c15cdcc27d4 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse
parent6fcbaf2e5b81da23fe15d1baf16f3ea8e197b47e (diff)
downloadrt.equinox.p2-8fc08e6186b7cd11ed29adb4a7dd3794c608323d.tar.gz
rt.equinox.p2-8fc08e6186b7cd11ed29adb4a7dd3794c608323d.tar.xz
rt.equinox.p2-8fc08e6186b7cd11ed29adb4a7dd3794c608323d.zip
Bug 286046 - GZipped profile format not understood by 3.5.0
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java80
1 files changed, 78 insertions, 2 deletions
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 8784ca39e..9d95c8a73 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
@@ -10,8 +10,9 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.Properties;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
@@ -19,10 +20,12 @@ import org.eclipse.equinox.internal.p2.engine.Profile;
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
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;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
@@ -541,4 +544,77 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
// }
// }
// }
+
+ public void testPersistenceFormatNotGzipped() {
+ //in a profile with an engine version from 3.5.0 or earlier, we must not gzip the profile registry
+ IInstallableUnit engineIU = createEclipseIU("org.eclipse.equinox.p2.engine", Version.create("1.0.100.v20090605"));
+ 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();
+ } catch (NoSuchMethodException e) {
+ fail();
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ } catch (InvocationTargetException e) {
+ fail();
+ }
+ File profileFolder = new File(folder, getName() + ".profile");
+ File[] filesFound = profileFolder.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.getName().endsWith(".profile");
+ }
+ });
+ assertEquals(1, filesFound.length);
+ filesFound = profileFolder.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.getName().endsWith(".profile.gz");
+ }
+ });
+ assertEquals(0, filesFound.length);
+ }
+
+ 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"));
+ 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();
+ } catch (NoSuchMethodException e) {
+ fail();
+ } catch (IllegalArgumentException e) {
+ fail();
+ } catch (IllegalAccessException e) {
+ fail();
+ } catch (InvocationTargetException e) {
+ fail();
+ }
+ File profileFolder = new File(folder, getName() + ".profile");
+ File[] filesFound = profileFolder.listFiles(new FileFilter() {
+
+ public boolean accept(File pathname) {
+ return pathname.getName().endsWith(".profile.gz");
+ }
+ });
+ assertEquals(1, filesFound.length);
+ }
}

Back to the top