diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java index 5e3d14e6f..466da3497 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java @@ -13,14 +13,12 @@ package org.eclipse.equinox.p2.tests.engine; import java.io.File; import java.io.IOException; import java.security.cert.Certificate; -import java.util.Hashtable; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.core.ProvisioningAgent; import org.eclipse.equinox.internal.p2.engine.EngineActivator; +import org.eclipse.equinox.internal.p2.engine.phases.CertificateChecker; import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI; -import org.eclipse.equinox.internal.provisional.p2.engine.CertificateChecker; -import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestData; -import org.osgi.framework.ServiceRegistration; +import org.eclipse.equinox.p2.tests.*; /** * Tests for {@link CertificateChecker}. @@ -46,12 +44,16 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { } CertificateChecker checker; - ServiceRegistration serviceReg; CertificateTestService serviceUI; File unsigned; + private ProvisioningAgent testAgent; protected void setUp() throws Exception { - checker = new CertificateChecker(); + serviceUI = new CertificateTestService(); + testAgent = new ProvisioningAgent(); + testAgent.registerService(IServiceUI.SERVICE_NAME, serviceUI); + testAgent.setBundleContext(TestActivator.getContext()); + checker = new CertificateChecker(testAgent); try { unsigned = TestData.getFile("CertificateChecker", "unsigned.jar"); } catch (IOException e) { @@ -59,17 +61,6 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { } assertTrue("1.0", unsigned != null); assertTrue("1.0", unsigned.exists()); - // We need to ensure the test service has a higher ranking than - // anything registered by the SDK via DS. - serviceUI = new CertificateTestService(); - Hashtable properties = new Hashtable(1); - properties.put(org.osgi.framework.Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE)); - serviceReg = EngineActivator.getContext().registerService(IServiceUI.class.getName(), serviceUI, properties); - } - - protected void tearDown() throws Exception { - if (serviceReg != null) - serviceReg.unregister(); } /** @@ -154,16 +145,10 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { */ public void testBug291049() { try { - - // Intentionally unregister our service so that we get whatever the default (or null) service is - // in an SDK configuration. - if (serviceReg != null) { - serviceReg.unregister(); - serviceReg = null; - } + // Intentionally replace our service with a null service + testAgent.registerService(IServiceUI.SERVICE_NAME, null); checker.add(unsigned); // TODO need to add some untrusted files here, too. To prove that we treated them as trusted temporarily - System.getProperties().setProperty(EngineActivator.PROP_UNSIGNED_POLICY, EngineActivator.UNSIGNED_PROMPT); IStatus result = checker.start(); assertTrue("1.0", result.isOK()); |