diff options
author | Alexander Kurtakov | 2019-07-01 18:26:41 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-07-01 18:26:41 +0000 |
commit | 2fd352be53bd1c745eea9199c35b68a3c1d47103 (patch) | |
tree | c8f4a260873e8c0cc0f76712f4f46a43b87a7948 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse | |
parent | b2afb3f9cb8c98633ecac8340a370a84cc12c6e9 (diff) | |
download | rt.equinox.p2-2fd352be53bd1c745eea9199c35b68a3c1d47103.tar.gz rt.equinox.p2-2fd352be53bd1c745eea9199c35b68a3c1d47103.tar.xz rt.equinox.p2-2fd352be53bd1c745eea9199c35b68a3c1d47103.zip |
Convert to the generic IProvisioningAgent.getService()Y20190705-0620Y20190704-0900I20190704-1800I20190704-0245I20190703-1800I20190703-0640I20190702-1800I20190702-0930I20190702-0610I20190701-1805
Take 2.
Change-Id: Ia6b32d8b27efbf30d7d7bd620c84e0b9e48f843a
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse')
4 files changed, 24 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestAgentProvider.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestAgentProvider.java index 11c87de6b..cc12d18da 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestAgentProvider.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestAgentProvider.java @@ -25,7 +25,8 @@ import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; /** - * Provides {@link IProvisioningAgent} instances for tests. Use as JUnit 4 {@link Rule}. + * Provides {@link IProvisioningAgent} instances for tests. Use as JUnit 4 + * {@link Rule}. */ public final class TestAgentProvider extends ExternalResource { private final TemporaryFolder tempManager; @@ -49,8 +50,9 @@ public final class TestAgentProvider extends ExternalResource { } /** - * Returns an instance of an {@link IProvisioningAgent}. If this class is used as a JUnit method - * {@link Rule}, a separate instance is returned per test method. + * Returns an instance of an {@link IProvisioningAgent}. If this class is used + * as a JUnit method {@link Rule}, a separate instance is returned per test + * method. */ public IProvisioningAgent getAgent() throws ProvisionException { if (agent == null) { @@ -65,7 +67,8 @@ public final class TestAgentProvider extends ExternalResource { private IProvisioningAgent createProvisioningAgent(File location) throws ProvisionException { BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - ServiceReference<IProvisioningAgentProvider> serviceReference = bundleContext.getServiceReference(IProvisioningAgentProvider.class); + ServiceReference<IProvisioningAgentProvider> serviceReference = bundleContext + .getServiceReference(IProvisioningAgentProvider.class); IProvisioningAgentProvider agentFactory = bundleContext.getService(serviceReference); try { return agentFactory.createAgent(location.toURI()); @@ -80,7 +83,7 @@ public final class TestAgentProvider extends ExternalResource { * @see #getAgent() */ public <T> T getService(Class<T> type) throws ProvisionException { - return type.cast(getAgent().getService(type.getName())); + return getAgent().getService(type); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java index c0021b750..a664baebf 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java @@ -145,7 +145,7 @@ public abstract class AbstractEnd2EndTest extends AbstractProvisioningTest { } private void rollbackPlatformSource(IProfile profile2, File installFolder) { - IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME); + IProfileRegistry profileRegistry = end2endAgent.getService(IProfileRegistry.class); long[] timestamps = profileRegistry.listProfileTimestamps(profile2.getProfileId()); assertEquals(3, timestamps.length); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug306279f.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug306279f.java index 9cc2bc279..b4517cd52 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug306279f.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug306279f.java @@ -7,15 +7,20 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Sonatype, Inc. - initial API and implementation *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.p2.core.*; -import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.core.IProvisioningAgentProvider; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfileRegistry; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.engine.ProvisioningContext; import org.eclipse.equinox.p2.planner.IPlanner; import org.eclipse.equinox.p2.planner.IProfileChangeRequest; import org.eclipse.equinox.p2.query.QueryUtil; @@ -26,12 +31,12 @@ public class Bug306279f extends AbstractProvisioningTest { public void testInstallBabel() throws ProvisionException { IProvisioningAgentProvider provider = getAgentProvider(); IProvisioningAgent agent = provider.createAgent(getTestData("bug306279f data", "testData/bug306279f/p2").toURI()); - IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager repoMgr = agent.getService(IMetadataRepositoryManager.class); repoMgr.addRepository(getTestData("bug306279f data", "testData/bug306279f/repo/helios/").toURI()); repoMgr.addRepository(getTestData("bug306279f data", "testData/bug306279f/repo/babel").toURI()); - IPlanner planner = (IPlanner) agent.getService(IPlanner.SERVICE_NAME); - IProfile sdkProfile = ((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME)).getProfile("SDKProfile"); + IPlanner planner = agent.getService(IPlanner.class); + IProfile sdkProfile = agent.getService(IProfileRegistry.class).getProfile("SDKProfile"); IProfileChangeRequest request = planner.createChangeRequest(sdkProfile); request.add(repoMgr.query(QueryUtil.createIUQuery("org.eclipse.babel.nls_rt.rap_en_AA.feature.group"), null).iterator().next()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AgentFromInstallTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AgentFromInstallTests.java index 66aa794bd..a7e3418a1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AgentFromInstallTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AgentFromInstallTests.java @@ -13,9 +13,8 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; -import org.eclipse.equinox.internal.p2.touchpoint.eclipse.AgentFromInstall; - import java.io.File; +import org.eclipse.equinox.internal.p2.touchpoint.eclipse.AgentFromInstall; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.engine.IProfileRegistry; @@ -27,7 +26,7 @@ public class AgentFromInstallTests extends AbstractProvisioningTest { File installFolder = getTestData("normalEclipse", "testData/configAreaToAgent/normalEclipse"); IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), installFolder, null, null); assertNotNull(agent); - IProfile profile = ((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME)).getProfile(IProfileRegistry.SELF); + IProfile profile = agent.getService(IProfileRegistry.class).getProfile(IProfileRegistry.SELF); assertNotNull(profile); assertEquals("SDKProfile", profile.getProfileId()); } @@ -36,7 +35,7 @@ public class AgentFromInstallTests extends AbstractProvisioningTest { File configurationFolder = getTestData("normalEclipse", "testData/configAreaToAgent/normalEclipse/configuration"); IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), null, configurationFolder, null); assertNotNull(agent); - IProfile profile = ((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME)).getProfile(IProfileRegistry.SELF); + IProfile profile = agent.getService(IProfileRegistry.class).getProfile(IProfileRegistry.SELF); assertNotNull(profile); assertEquals("SDKProfile", profile.getProfileId()); } @@ -45,7 +44,7 @@ public class AgentFromInstallTests extends AbstractProvisioningTest { File configurationFolder = getTestData("sharedWithoutBaseAvailable", "testData/configAreaToAgent/sharedWithoutBaseAvailable"); IProvisioningAgent agent = AgentFromInstall.createAgentFrom(getAgentProvider(), null, configurationFolder, null); assertNotNull(agent); - IProfile profile = ((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME)).getProfile(IProfileRegistry.SELF); + IProfile profile = agent.getService(IProfileRegistry.class).getProfile(IProfileRegistry.SELF); assertNotNull(profile); assertEquals("SDKProfile", profile.getProfileId()); } |