|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2008, 2009 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 16-30
Link Here
|
| 16 |
import java.util.Map; |
16 |
import java.util.Map; |
| 17 |
import org.eclipse.core.runtime.IStatus; |
17 |
import org.eclipse.core.runtime.IStatus; |
| 18 |
import org.eclipse.core.runtime.preferences.IPreferencesService; |
18 |
import org.eclipse.core.runtime.preferences.IPreferencesService; |
|
|
19 |
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; |
| 19 |
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; |
20 |
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; |
| 20 |
import org.eclipse.equinox.internal.p2.metadata.TouchpointInstruction; |
21 |
import org.eclipse.equinox.internal.p2.metadata.TouchpointInstruction; |
|
|
22 |
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; |
| 21 |
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddRepositoryAction; |
23 |
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddRepositoryAction; |
|
|
24 |
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; |
| 25 |
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; |
| 22 |
import org.eclipse.equinox.internal.provisional.p2.core.Version; |
26 |
import org.eclipse.equinox.internal.provisional.p2.core.Version; |
| 23 |
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; |
27 |
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; |
| 24 |
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; |
28 |
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; |
| 25 |
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; |
29 |
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; |
| 26 |
import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; |
30 |
import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; |
| 27 |
import org.eclipse.equinox.internal.provisional.p2.metadata.*; |
31 |
import org.eclipse.equinox.internal.provisional.p2.metadata.*; |
|
|
32 |
import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; |
| 33 |
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; |
| 34 |
import org.eclipse.equinox.internal.provisional.p2.query.Collector; |
| 28 |
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; |
35 |
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; |
| 29 |
import org.eclipse.equinox.p2.tests.TestActivator; |
36 |
import org.eclipse.equinox.p2.tests.TestActivator; |
| 30 |
import org.osgi.service.prefs.Preferences; |
37 |
import org.osgi.service.prefs.Preferences; |
|
Lines 176-181
Link Here
|
| 176 |
assertEquals("2.0", value, TEST_LOCATION); |
183 |
assertEquals("2.0", value, TEST_LOCATION); |
| 177 |
} |
184 |
} |
| 178 |
|
185 |
|
|
|
186 |
/** |
| 187 |
* Tests adding a repository during an update (bug 266881). |
| 188 |
*/ |
| 189 |
public void testBug266881() throws ProvisionException { |
| 190 |
//need to install a real bundle with an artifact to check for GC bug |
| 191 |
URI site = getTestData("0.1", "/testData/updatesite/site").toURI(); |
| 192 |
getMetadataRepositoryManager().addRepository(site); |
| 193 |
getArtifactRepositoryManager().addRepository(site); |
| 194 |
|
| 195 |
//install the old IU |
| 196 |
String id = "AddRepositoryActionTest.testUpdate"; |
| 197 |
Version version = new Version(1, 0, 0); |
| 198 |
IInstallableUnit oldIU = createIU(id, version); |
| 199 |
IProfile profile = createProfile(id); |
| 200 |
ProfileChangeRequest request = new ProfileChangeRequest(profile); |
| 201 |
final IInstallableUnit[] oldIUs = new IInstallableUnit[] {oldIU}; |
| 202 |
request.addInstallableUnits(oldIUs); |
| 203 |
IStatus result = createDirector().provision(request, new ProvisioningContext(), getMonitor()); |
| 204 |
assertTrue("1.0", result.isOK()); |
| 205 |
|
| 206 |
assertTrue("1.1", !getArtifactRepositoryManager().contains(locationURI)); |
| 207 |
|
| 208 |
//define new IU |
| 209 |
version = new Version(1, 1, 0); |
| 210 |
Map instructions = new HashMap(); |
| 211 |
instructions.put("configure", TouchpointInstruction.encodeAction("addRepository", getValidArguments())); |
| 212 |
ITouchpointData tpData = MetadataFactory.createTouchpointData(instructions); |
| 213 |
IInstallableUnit newIU = createIU(id, version, null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, TOUCHPOINT_OSGI, tpData, true, createUpdateDescriptor(id, version)); |
| 214 |
|
| 215 |
//perform the update and install an ordinary bundle |
| 216 |
IMetadataRepository repo = getMetadataRepositoryManager().loadRepository(site, getMonitor()); |
| 217 |
IInstallableUnit bundle = (IInstallableUnit) repo.query(new InstallableUnitQuery("test.bundle"), new Collector(), getMonitor()).iterator().next(); |
| 218 |
request = new ProfileChangeRequest(profile); |
| 219 |
final IInstallableUnit[] newIUs = new IInstallableUnit[] {newIU, bundle}; |
| 220 |
request.addInstallableUnits(newIUs); |
| 221 |
request.removeInstallableUnits(oldIUs); |
| 222 |
result = createDirector().provision(request, new ProvisioningContext(), getMonitor()); |
| 223 |
if (!result.isOK()) |
| 224 |
LogHelper.log(result); |
| 225 |
assertTrue("2.0", result.isOK()); |
| 226 |
|
| 227 |
//check that the artifact is still there |
| 228 |
profile = getProfile(id); |
| 229 |
IArtifactRepository artifacts = getArtifactRepositoryManager().loadRepository(Util.getBundlePoolLocation(profile), getMonitor()); |
| 230 |
assertEquals("3.0", 1, artifacts.getArtifactKeys().length); |
| 231 |
|
| 232 |
//check that profile property is set |
| 233 |
assertProfileContains("3.1", profile, newIUs); |
| 234 |
// Get Preference node associated with the profile |
| 235 |
IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); |
| 236 |
Preferences pref = prefService.getRootNode().node("/profile/" + profile.getProfileId() + "/org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(TEST_LOCATION)); //$NON-NLS-1$ //$NON-NLS-2$ |
| 237 |
String value = pref.get(KEY_URI, null); |
| 238 |
|
| 239 |
assertEquals("3.2", value, TEST_LOCATION); |
| 240 |
} |
| 241 |
|
| 179 |
/* |
242 |
/* |
| 180 |
* Modified from AbstractRepositoryManager |
243 |
* Modified from AbstractRepositoryManager |
| 181 |
*/ |
244 |
*/ |