Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2011-12-12 19:13:13 +0000
committerDJ Houghton2011-12-12 19:13:13 +0000
commit64938edc458a285b88ba3fbb295d6fbfa8f0126e (patch)
tree9a57553c8566c06b28b4ebceb7bfe07b6c06d10a
parentc9761f54ea4d6920475599b1358a65cd232eb160 (diff)
downloadrt.equinox.p2-64938edc458a285b88ba3fbb295d6fbfa8f0126e.tar.gz
rt.equinox.p2-64938edc458a285b88ba3fbb295d6fbfa8f0126e.tar.xz
rt.equinox.p2-64938edc458a285b88ba3fbb295d6fbfa8f0126e.zip
Bug 366425 - Verify end to end tests
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java (renamed from bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java)122
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest35.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest36.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest37.java266
5 files changed, 204 insertions, 335 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java
index 5fa63746f..4d07779aa 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java
@@ -1,25 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 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
+ * Copyright (c) 2011 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
*******************************************************************************/
package org.eclipse.equinox.p2.tests.full;
-import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
-
import java.io.File;
-import java.io.IOException;
import java.net.URI;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
+import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdmin;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.p2.core.*;
import org.eclipse.equinox.p2.engine.*;
@@ -36,17 +34,15 @@ import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
-public class End2EndTest extends AbstractProvisioningTest {
+/**
+ * Abstract parent class for the End-to-End test suites.
+ */
+public abstract class AbstractEnd2EndTest extends AbstractProvisioningTest {
private IMetadataRepositoryManager metadataRepoManager;
-
private IArtifactRepositoryManager artifactRepoManager;
private IDirector director;
-
private ServiceTracker fwAdminTracker;
-
- private static URI repositoryLocation = URI.create("http://download.eclipse.org/eclipse/updates/3.5");
-
private IProvisioningAgent end2endAgent = null;
protected void setUp() throws Exception {
@@ -78,11 +74,12 @@ public class End2EndTest extends AbstractProvisioningTest {
}
}
- public void testInstallSDK35() {
- File installFolder = TestActivator.getContext().getDataFile(End2EndTest.class.getName());
+ public void testInstallSDK() {
+ File installFolder = TestActivator.getContext().getDataFile(AbstractEnd2EndTest.class.getName());
IProfile profile2 = createProfile("End2EndProfile", installFolder.getAbsolutePath());
//Add repository of the release
+ URI repositoryLocation = getRepositoryLocation();
try {
metadataRepoManager.addRepository(repositoryLocation);
metadataRepoManager.setEnabled(repositoryLocation, true);
@@ -93,21 +90,15 @@ public class End2EndTest extends AbstractProvisioningTest {
fail("Exception loading the repository.", e);
}
- installPlatform35(profile2, installFolder);
-
+ installPlatform(profile2, installFolder);
installBogusIU(profile2, installFolder);
-
- installPlatformSource35(profile2, installFolder);
-
- attemptToUninstallRCP35(profile2, installFolder);
-
- rollbackPlatformSource35(profile2, installFolder);
-
+ installPlatformSource(profile2, installFolder);
+ attemptToUninstallRCP(profile2, installFolder);
+ rollbackPlatformSource(profile2, installFolder);
// uninstallPlatform(profile2, installFolder);
-
}
- private void attemptToUninstallRCP35(IProfile profile2, File installFolder) {
+ private void attemptToUninstallRCP(IProfile profile2, File installFolder) {
IQueryResult collect = profile2.query(QueryUtil.createIUQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
assertEquals(1, queryResultSize(collect));
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
@@ -119,7 +110,7 @@ public class End2EndTest extends AbstractProvisioningTest {
protected void uninstallPlatform(IProfile profile2, File installFolder) {
System.out.println("Uninstall the platform");
- IQueryResult collect = profile2.query(QueryUtil.createIUQuery("org.eclipse.platform.ide"), new NullProgressMonitor());
+ IQueryResult collect = profile2.query(QueryUtil.createIUQuery(getPlatform().getId()), new NullProgressMonitor());
assertEquals(1, queryResultSize(collect));
// Collector collect2 = profile2.query(new InstallableUnitQuery("org.eclipse.platform.source.feature.group"), new Collector(), new NullProgressMonitor());
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
@@ -128,7 +119,7 @@ public class End2EndTest extends AbstractProvisioningTest {
assertOK("Can not uninstall platform", s);
}
- private void rollbackPlatformSource35(IProfile profile2, File installFolder) {
+ private void rollbackPlatformSource(IProfile profile2, File installFolder) {
IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME);
long[] timestamps = profileRegistry.listProfileTimestamps(profile2.getProfileId());
assertEquals(3, timestamps.length);
@@ -138,21 +129,19 @@ public class End2EndTest extends AbstractProvisioningTest {
IStatus s = director.revert(profile2, revertProfile, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertTrue(s.isOK());
- validateInstallContentFor35(installFolder);
+ validateInstallContent(installFolder);
assertFalse(new File(installFolder, "configuration/org.eclipse.equinox.source/source.info").exists());
}
- private void installPlatformSource35(IProfile profile2, File installFolder) {
- final String id = "org.eclipse.platform.source.feature.group";
- final Version version = Version.create("3.5.0.v20090611a-9gEeG1HFtQcmRThO4O3aR_fqSMvJR2sJ");
-
- IInstallableUnit toInstall = getIU(id, version);
+ private void installPlatformSource(IProfile profile2, File installFolder) {
+ VersionedId source = getPlatformSource();
+ IInstallableUnit toInstall = getIU(source.getId(), source.getVersion());
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
request.addInstallableUnits(new IInstallableUnit[] {toInstall});
IStatus s = director.provision(request, null, new NullProgressMonitor());
if (!s.isOK())
- fail("Installation of the " + id + " " + version + " failed.");
+ fail("Installation of the " + source.getId() + " " + source.getVersion() + " failed.");
assertProfileContainsAll("Platform source feature", profile2, new IInstallableUnit[] {toInstall});
assertTrue(new File(installFolder, "configuration/org.eclipse.equinox.source").exists());
@@ -174,23 +163,21 @@ public class End2EndTest extends AbstractProvisioningTest {
assertNotOK(s);
}
- private void installPlatform35(IProfile profile2, File installFolder) {
- final String id = "org.eclipse.platform.ide";
- final Version version = Version.create("3.5.0.I20090611-1540");
-
+ private void installPlatform(IProfile profile2, File installFolder) {
+ VersionedId platform = getPlatform();
//First we install the platform
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
- IInstallableUnit platformIU = getIU(id, version);
+ IInstallableUnit platformIU = getIU(platform.getId(), platform.getVersion());
request.addInstallableUnits(new IInstallableUnit[] {platformIU});
IStatus s = director.provision(request, null, new NullProgressMonitor());
if (!s.isOK()) {
LogHelper.log(s);
- fail("Installation of the " + id + " " + version + " failed. " + s.toString());
+ fail("Installation of the " + platform.getId() + " " + platform.getVersion() + " failed. " + s.toString());
}
- assertProfileContainsAll("Platform 3.5 profile", profile2, new IInstallableUnit[] {platformIU});
- validateInstallContentFor35(installFolder);
+ assertProfileContainsAll("Platform profile", profile2, new IInstallableUnit[] {platformIU});
+ validateInstallContent(installFolder);
assertFalse(new File(installFolder, "configuration/org.eclipse.equinox.source").exists());
}
@@ -207,7 +194,7 @@ public class End2EndTest extends AbstractProvisioningTest {
Exception failure = null;
for (int i = 0; i < 3; i++) {
try {
- IMetadataRepository repo = metadataRepoManager.loadRepository(repositoryLocation, null);
+ IMetadataRepository repo = metadataRepoManager.loadRepository(getRepositoryLocation(), null);
it = repo.query(query, null).iterator();
if (it.hasNext())
return (IInstallableUnit) it.next();
@@ -217,42 +204,19 @@ public class End2EndTest extends AbstractProvisioningTest {
}
if (failure == null)
failure = new RuntimeException("IU not found");
- fail("Failed to obtain " + id + " version: " + v + " from: " + repositoryLocation, failure);
+ fail("Failed to obtain " + id + " version: " + v + " from: " + getRepositoryLocation(), failure);
return null;//will never get here
}
- private void validateInstallContentFor35(File installFolder) {
- FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
- Manipulator manipulator = fwkAdmin.getManipulator();
- LauncherData launcherData = manipulator.getLauncherData();
- launcherData.setFwConfigLocation(new File(installFolder, "configuration"));
- launcherData.setLauncher(new File(installFolder, getLauncherName("eclipse", Platform.getOS())));
- try {
- manipulator.load();
- } catch (IllegalStateException e) {
- fail("Error loading the configuration", e);
- } catch (FrameworkAdminRuntimeException e) {
- fail("Error loading the configuration", e);
- } catch (IOException e) {
- fail("Error loading the configuration", e);
- }
-
- assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xms40m");
- assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xmx256m");
+ abstract protected void validateInstallContent(File installFolder);
- String[] programArgs = manipulator.getLauncherData().getProgramArgs();
- assertContains("Can't find program arg", programArgs, "-startup");
- assertContains("Can't find program arg", programArgs, "-showsplash");
- assertContains("Can't find program arg", programArgs, "org.eclipse.platform");
+ abstract protected URI getRepositoryLocation();
- assertTrue(manipulator.getConfigData().getBundles().length > 50);
+ abstract protected VersionedId getPlatform();
- assertTrue(new File(installFolder, "plugins").exists());
- assertTrue(new File(installFolder, "features").exists());
-
- }
+ abstract protected VersionedId getPlatformSource();
- private void assertContains(String message, String[] source, String searched) {
+ protected void assertContains(String message, String[] source, String searched) {
for (int i = 0; i < source.length; i++) {
if (source[i].equals(searched))
return;
@@ -260,7 +224,7 @@ public class End2EndTest extends AbstractProvisioningTest {
fail(message + " " + searched);
}
- private FrameworkAdmin getEquinoxFrameworkAdmin() {
+ protected FrameworkAdmin getEquinoxFrameworkAdmin() {
final String FILTER_OBJECTCLASS = "(" + Constants.OBJECTCLASS + "=" + FrameworkAdmin.class.getName() + ")";
final String filterFwName = "(" + FrameworkAdmin.SERVICE_PROP_KEY_FW_NAME + "=Equinox)";
final String filterLauncherName = "(" + FrameworkAdmin.SERVICE_PROP_KEY_LAUNCHER_NAME + "=Eclipse.exe)";
@@ -289,7 +253,7 @@ public class End2EndTest extends AbstractProvisioningTest {
return (FrameworkAdmin) fwAdminTracker.getService();
}
- private static String getLauncherName(String name, String os) {
+ protected static String getLauncherName(String name, String os) {
if (os == null) {
EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(TestActivator.getContext(), EnvironmentInfo.class.getName());
if (info != null)
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java
index f06db4f90..bf180dfd4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java
@@ -13,17 +13,24 @@ package org.eclipse.equinox.p2.tests.full;
import junit.framework.*;
/**
- * Performs all automated download manager tests.
+ * Performs all automated full end-to-end install/update/rollback tests.
*/
public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
- suite.addTestSuite(End2EndTest.class);
- // suite.addTest(From35to36.suite());
- // suite.addTest(Install36from35.suite());
+
+ suite.addTestSuite(End2EndTest35.class);
+ suite.addTestSuite(End2EndTest36.class);
+ suite.addTestSuite(End2EndTest37.class);
+
+ //suite.addTest(From35to36.suite());
suite.addTest(From36to37.suite());
+ //suite.addTest(From37to38.suite());
+
+ //suite.addTest(Install36from35.suite());
suite.addTest(Install37from36.suite());
+ //suite.addTest(Install38from37.suite());
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest35.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest35.java
new file mode 100644
index 000000000..af7a3e425
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest35.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.full;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
+import org.eclipse.equinox.p2.metadata.VersionedId;
+
+/**
+ * Test installing 3.5.
+ */
+public class End2EndTest35 extends AbstractEnd2EndTest {
+
+ protected void validateInstallContent(File installFolder) {
+ FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
+ Manipulator manipulator = fwkAdmin.getManipulator();
+ LauncherData launcherData = manipulator.getLauncherData();
+ launcherData.setFwConfigLocation(new File(installFolder, "configuration"));
+ launcherData.setLauncher(new File(installFolder, getLauncherName("eclipse", Platform.getOS())));
+ try {
+ manipulator.load();
+ } catch (IllegalStateException e) {
+ fail("Error loading the configuration", e);
+ } catch (FrameworkAdminRuntimeException e) {
+ fail("Error loading the configuration", e);
+ } catch (IOException e) {
+ fail("Error loading the configuration", e);
+ }
+
+ assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xms40m");
+ assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xmx256m");
+
+ String[] programArgs = manipulator.getLauncherData().getProgramArgs();
+ assertContains("Can't find program arg", programArgs, "-startup");
+ assertContains("Can't find program arg", programArgs, "-showsplash");
+ assertContains("Can't find program arg", programArgs, "org.eclipse.platform");
+
+ assertTrue(manipulator.getConfigData().getBundles().length > 50);
+
+ assertTrue(new File(installFolder, "plugins").exists());
+ assertTrue(new File(installFolder, "features").exists());
+
+ }
+
+ protected URI getRepositoryLocation() {
+ return URI.create("http://download.eclipse.org/eclipse/updates/3.5");
+ }
+
+ protected VersionedId getPlatform() {
+ return new VersionedId("org.eclipse.platform.ide", "3.5.0.I20090611-1540");
+ }
+
+ protected VersionedId getPlatformSource() {
+ return new VersionedId("org.eclipse.platform.source.feature.group", "3.5.0.v20090611a-9gEeG1HFtQcmRThO4O3aR_fqSMvJR2sJ");
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest36.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest36.java
new file mode 100644
index 000000000..f65ab416b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest36.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.full;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
+import org.eclipse.equinox.p2.metadata.VersionedId;
+
+/**
+ * Test installing 3.6.
+ */
+public class End2EndTest36 extends AbstractEnd2EndTest {
+
+ protected void validateInstallContent(File installFolder) {
+ FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
+ Manipulator manipulator = fwkAdmin.getManipulator();
+ LauncherData launcherData = manipulator.getLauncherData();
+ launcherData.setFwConfigLocation(new File(installFolder, "configuration"));
+ launcherData.setLauncher(new File(installFolder, getLauncherName("eclipse", Platform.getOS())));
+ try {
+ manipulator.load();
+ } catch (IllegalStateException e) {
+ fail("Error loading the configuration", e);
+ } catch (FrameworkAdminRuntimeException e) {
+ fail("Error loading the configuration", e);
+ } catch (IOException e) {
+ fail("Error loading the configuration", e);
+ }
+
+ assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xms40m");
+ assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xmx384m");
+
+ String[] programArgs = manipulator.getLauncherData().getProgramArgs();
+ assertContains("Can't find program arg", programArgs, "-startup");
+ assertContains("Can't find program arg", programArgs, "-showsplash");
+ assertContains("Can't find program arg", programArgs, "org.eclipse.platform");
+
+ assertTrue(manipulator.getConfigData().getBundles().length > 50);
+
+ assertTrue(new File(installFolder, "plugins").exists());
+ assertTrue(new File(installFolder, "features").exists());
+
+ }
+
+ protected URI getRepositoryLocation() {
+ return URI.create("http://download.eclipse.org/eclipse/updates/3.6");
+ }
+
+ protected VersionedId getPlatform() {
+ return new VersionedId("org.eclipse.platform.ide", "3.6.2.M20110210-1200");
+ }
+
+ protected VersionedId getPlatformSource() {
+ return new VersionedId("org.eclipse.platform.source.feature.group", "3.6.2.r362_v20110210-9gF78Gs1FrIGnHDHWkEcopoN8AmxeZflGDGKQi");
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest37.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest37.java
index c0d644a0e..b28ad2c4d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest37.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest37.java
@@ -13,202 +13,16 @@ package org.eclipse.equinox.p2.tests.full;
import java.io.File;
import java.io.IOException;
import java.net.URI;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
-import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
-import org.eclipse.equinox.p2.core.*;
-import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.query.*;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
-import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-import org.eclipse.equinox.p2.tests.TestActivator;
-import org.eclipse.osgi.service.environment.EnvironmentInfo;
-import org.osgi.framework.*;
-import org.osgi.util.tracker.ServiceTracker;
+import org.eclipse.equinox.p2.metadata.VersionedId;
-public class End2EndTest37 extends AbstractProvisioningTest {
+/**
+ * Test installing 3.7.
+ */
+public class End2EndTest37 extends AbstractEnd2EndTest {
- private static URI repositoryLocation = URI.create("http://download.eclipse.org/eclipse/updates/3.7");
- private IMetadataRepositoryManager metadataRepoManager;
- private IArtifactRepositoryManager artifactRepoManager;
- private IDirector director;
- private ServiceTracker fwAdminTracker;
- private IProvisioningAgent end2endAgent = null;
-
- protected void setUp() throws Exception {
- ServiceReference sr = TestActivator.context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME);
- IProvisioningAgentProvider agentFactory = (IProvisioningAgentProvider) TestActivator.context.getService(sr);
- end2endAgent = agentFactory.createAgent(getTempFolder().toURI());
- metadataRepoManager = (IMetadataRepositoryManager) end2endAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- artifactRepoManager = (IArtifactRepositoryManager) end2endAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
- director = (IDirector) end2endAgent.getService(IDirector.SERVICE_NAME);
- }
-
- protected IProfile createProfile(String profileId, String installFolder) {
- IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME);
- if (profileRegistry == null) {
- throw new RuntimeException("Profile registry service not available");
- }
-
- Map properties = new HashMap();
- properties.put(IProfile.PROP_INSTALL_FOLDER, installFolder);
- EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(TestActivator.getContext(), EnvironmentInfo.class.getName());
- if (info != null)
- properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch());
- properties.put("org.eclipse.update.install.features", "true");
- properties.put(IProfile.PROP_CACHE, installFolder);
- try {
- return profileRegistry.addProfile(profileId, properties);
- } catch (ProvisionException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
- }
-
- public void testInstallSDK37() {
- File installFolder = TestActivator.getContext().getDataFile(End2EndTest37.class.getName());
- IProfile profile2 = createProfile("End2EndProfile", installFolder.getAbsolutePath());
-
- //Add repository of the release
- try {
- metadataRepoManager.addRepository(repositoryLocation);
- metadataRepoManager.setEnabled(repositoryLocation, true);
- metadataRepoManager.loadRepository(repositoryLocation, new NullProgressMonitor());
- artifactRepoManager.addRepository(repositoryLocation);
- artifactRepoManager.setEnabled(repositoryLocation, true);
- } catch (ProvisionException e) {
- fail("Exception loading the repository.", e);
- }
-
- installPlatform37(profile2, installFolder);
- installBogusIU(profile2, installFolder);
- installPlatformSource37(profile2, installFolder);
- attemptToUninstallRCP37(profile2, installFolder);
- rollbackPlatformSource37(profile2, installFolder);
- // uninstallPlatform(profile2, installFolder);
- }
-
- private void attemptToUninstallRCP37(IProfile profile2, File installFolder) {
- IQueryResult collect = profile2.query(QueryUtil.createIUQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
- assertEquals(1, queryResultSize(collect));
- ProfileChangeRequest request = new ProfileChangeRequest(profile2);
- request.removeInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) collect.iterator().next()});
- IStatus s = director.provision(request, null, new NullProgressMonitor());
- assertOK("Can not uninstall RCP", s);
- assertEquals(1, queryResultSize(profile2.query(QueryUtil.createIUQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor())));
- }
-
- protected void uninstallPlatform(IProfile profile2, File installFolder) {
- System.out.println("Uninstall the platform");
- IQueryResult collect = profile2.query(QueryUtil.createIUQuery("org.eclipse.platform.ide"), new NullProgressMonitor());
- assertEquals(1, queryResultSize(collect));
- // Collector collect2 = profile2.query(new InstallableUnitQuery("org.eclipse.platform.source.feature.group"), new Collector(), new NullProgressMonitor());
- ProfileChangeRequest request = new ProfileChangeRequest(profile2);
- request.removeInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) collect.iterator().next()});//, (IInstallableUnit) collect2.iterator().next()});
- IStatus s = director.provision(request, null, new NullProgressMonitor());
- assertOK("Can not uninstall platform", s);
- }
-
- private void rollbackPlatformSource37(IProfile profile2, File installFolder) {
- IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME);
- long[] timestamps = profileRegistry.listProfileTimestamps(profile2.getProfileId());
- assertEquals(3, timestamps.length);
-
- IProfile revertProfile = profileRegistry.getProfile(profile2.getProfileId(), timestamps[1]);
- assertTrue(director.revert(profile2, revertProfile, new ProvisioningContext(getAgent()), new NullProgressMonitor()).isOK());
-
- validateInstallContentFor37(installFolder);
- assertFalse(new File(installFolder, "configuration/org.eclipse.equinox.source/source.info").exists());
- }
-
- private void installPlatformSource37(IProfile profile2, File installFolder) {
- final String id = "org.eclipse.platform.source.feature.group";
- final Version version = Version.create("3.5.0.v20090611a-9gEeG1HFtQcmRThO4O3aR_fqSMvJR2sJ");
-
- IInstallableUnit toInstall = getIU(id, version);
-
- ProfileChangeRequest request = new ProfileChangeRequest(profile2);
- request.addInstallableUnits(new IInstallableUnit[] {toInstall});
- IStatus s = director.provision(request, null, new NullProgressMonitor());
- if (!s.isOK())
- fail("Installation of the " + id + " " + version + " failed.");
-
- assertProfileContainsAll("Platform source feature", profile2, new IInstallableUnit[] {toInstall});
- assertTrue(new File(installFolder, "configuration/org.eclipse.equinox.source").exists());
- }
-
- private void installBogusIU(IProfile profile, File installFolder) {
- InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
- iud.setId("org.eclipse.equinox.p2.tests.bogusIU.end2end");
- iud.setVersion(Version.create("1.0.0"));
- iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.p2.tests.bogusIU.end2end", Version.create("1.0.0"))});
- Map data = new HashMap();
- data.put("install", "org.eclipse.equinox.p2.osgi.removeJvmArg(programArg:-XX:+UnlockDiagnosticVMOptions);");
- iud.addTouchpointData(MetadataFactory.createTouchpointData(data));
- IInstallableUnit bogusIU = MetadataFactory.createInstallableUnit(iud);
- iud.setTouchpointType(MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.osgi", Version.create("1.0.0")));
- ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.addInstallableUnits(new IInstallableUnit[] {bogusIU});
- IStatus s = director.provision(request, null, new NullProgressMonitor());
- assertNotOK(s);
- }
-
- private void installPlatform37(IProfile profile2, File installFolder) {
- final String id = "org.eclipse.platform.ide";
- final Version version = Version.create("3.5.0.I20090611-1540");
-
- //First we install the platform
- ProfileChangeRequest request = new ProfileChangeRequest(profile2);
- IInstallableUnit platformIU = getIU(id, version);
-
- request.addInstallableUnits(new IInstallableUnit[] {platformIU});
- IStatus s = director.provision(request, null, new NullProgressMonitor());
- if (!s.isOK()) {
- LogHelper.log(s);
- fail("Installation of the " + id + " " + version + " failed. " + s.toString());
- }
-
- assertProfileContainsAll("Platform 3.7 profile", profile2, new IInstallableUnit[] {platformIU});
- validateInstallContentFor37(installFolder);
- assertFalse(new File(installFolder, "configuration/org.eclipse.equinox.source").exists());
- }
-
- /**
- * Returns the IU corresponding to the given id and version. Fails if the IU could
- * not be found. Never returns null.
- */
- public IInstallableUnit getIU(String id, Version v) {
- final IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, v);
- Iterator it = metadataRepoManager.query(query, null).iterator();
- if (it.hasNext())
- return (IInstallableUnit) it.next();
- //try the repository location directly - retry because eclipse.org can be flaky
- Exception failure = null;
- for (int i = 0; i < 3; i++) {
- try {
- IMetadataRepository repo = metadataRepoManager.loadRepository(repositoryLocation, null);
- it = repo.query(query, null).iterator();
- if (it.hasNext())
- return (IInstallableUnit) it.next();
- } catch (ProvisionException e) {
- failure = e;
- }
- }
- if (failure == null)
- failure = new RuntimeException("IU not found");
- fail("Failed to obtain " + id + " version: " + v + " from: " + repositoryLocation, failure);
- return null;//will never get here
- }
-
- private void validateInstallContentFor37(File installFolder) {
+ protected void validateInstallContent(File installFolder) {
FrameworkAdmin fwkAdmin = getEquinoxFrameworkAdmin();
Manipulator manipulator = fwkAdmin.getManipulator();
LauncherData launcherData = manipulator.getLauncherData();
@@ -225,7 +39,7 @@ public class End2EndTest37 extends AbstractProvisioningTest {
}
assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xms40m");
- assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xmx256m");
+ assertContains("Can't find VM arg", manipulator.getLauncherData().getJvmArgs(), "-Xmx384m");
String[] programArgs = manipulator.getLauncherData().getProgramArgs();
assertContains("Can't find program arg", programArgs, "-startup");
@@ -239,67 +53,15 @@ public class End2EndTest37 extends AbstractProvisioningTest {
}
- private void assertContains(String message, String[] source, String searched) {
- for (int i = 0; i < source.length; i++) {
- if (source[i].equals(searched))
- return;
- }
- fail(message + " " + searched);
+ protected URI getRepositoryLocation() {
+ return URI.create("http://download.eclipse.org/eclipse/updates/3.7");
}
- private FrameworkAdmin getEquinoxFrameworkAdmin() {
- final String FILTER_OBJECTCLASS = "(" + Constants.OBJECTCLASS + "=" + FrameworkAdmin.class.getName() + ")";
- final String filterFwName = "(" + FrameworkAdmin.SERVICE_PROP_KEY_FW_NAME + "=Equinox)";
- final String filterLauncherName = "(" + FrameworkAdmin.SERVICE_PROP_KEY_LAUNCHER_NAME + "=Eclipse.exe)";
- final String filterFwAdmin = "(&" + FILTER_OBJECTCLASS + filterFwName + filterLauncherName + ")";
-
- String FWK_ADMIN_EQ = "org.eclipse.equinox.frameworkadmin.equinox";
- Bundle b = Platform.getBundle(FWK_ADMIN_EQ);
- if (b == null)
- fail("Bundle: " + FWK_ADMIN_EQ + " is required for this test");
- try {
- b.start();
- } catch (BundleException e) {
- fail("Can't start framework admin");
- }
- if (fwAdminTracker == null) {
- Filter filter;
- try {
- filter = TestActivator.getContext().createFilter(filterFwAdmin);
- fwAdminTracker = new ServiceTracker(TestActivator.getContext(), filter, null);
- fwAdminTracker.open();
- } catch (InvalidSyntaxException e) {
- // never happens
- e.printStackTrace();
- }
- }
- return (FrameworkAdmin) fwAdminTracker.getService();
+ protected VersionedId getPlatform() {
+ return new VersionedId("org.eclipse.platform.ide", "3.7.0.I20110613-1736");
}
- private static String getLauncherName(String name, String os) {
- if (os == null) {
- EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(TestActivator.getContext(), EnvironmentInfo.class.getName());
- if (info != null)
- os = info.getOS();
- }
-
- if (os.equals(org.eclipse.osgi.service.environment.Constants.OS_WIN32)) {
- IPath path = new Path(name);
- if ("exe".equals(path.getFileExtension())) //$NON-NLS-1$
- return name;
- return name + ".exe"; //$NON-NLS-1$
- }
- if (os.equals(org.eclipse.osgi.service.environment.Constants.OS_MACOSX)) {
- IPath path = new Path(name);
- if ("app".equals(path.getFileExtension())) //$NON-NLS-1$
- return name;
- StringBuffer buffer = new StringBuffer();
- buffer.append(name.substring(0, 1).toUpperCase());
- buffer.append(name.substring(1));
- buffer.append(".app/Contents/MacOS/"); //$NON-NLS-1$
- buffer.append(name.toLowerCase());
- return buffer.toString();
- }
- return name;
+ protected VersionedId getPlatformSource() {
+ return new VersionedId("org.eclipse.platform.source.feature.group", "3.7.0.v20110530-9gF7UHNFFt4cwE-pkZDJ7oz-mj4OSEIlu9SEv0f");
}
}

Back to the top