diff options
author | Alexander Kurtakov | 2017-06-21 16:10:50 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2017-06-21 20:34:38 +0000 |
commit | eba656968c699f1a9415fad59d2b19e8452f9a0a (patch) | |
tree | b7a6e7742d2c1ff9ee660630a188adb89c3884e8 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine | |
parent | 7f22c5b775e1e0ce90bbf3055fd99b974d1e7414 (diff) | |
download | rt.equinox.p2-eba656968c699f1a9415fad59d2b19e8452f9a0a.tar.gz rt.equinox.p2-eba656968c699f1a9415fad59d2b19e8452f9a0a.tar.xz rt.equinox.p2-eba656968c699f1a9415fad59d2b19e8452f9a0a.zip |
Bug 518587 - Modernize o.e.equinox.p2.testsI20170621-2000
Move to Java 8, enable more warnings and save actions and go through the
codebase to minimize the warnings.
Change-Id: I6283bfeef18e250f5283e80f7bfad38e6ef65415
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine')
20 files changed, 201 insertions, 94 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 24d992b9a..ec4866b73 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 2017 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 *******************************************************************************/ @@ -28,14 +28,17 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { public boolean unsignedReturnValue = true; public boolean wasPrompted = false; + @Override public AuthenticationInfo getUsernamePassword(String location) { return null; } + @Override public AuthenticationInfo getUsernamePassword(String location, AuthenticationInfo previousInfo) { return null; } + @Override public TrustInfo getTrustInfo(Certificate[][] untrustedChain, String[] unsignedDetail) { wasPrompted = true; return new TrustInfo(null, false, unsignedReturnValue); @@ -48,6 +51,7 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { File unsigned; private ProvisioningAgent testAgent; + @Override protected void setUp() throws Exception { serviceUI = new CertificateTestService(); testAgent = new ProvisioningAgent(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java index c6f9133c7..abcc2b71c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DebugHelperTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2015 Mykola Nikishov. + * Copyright (c) 2015, 2017 Mykola Nikishov 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 @@ -18,7 +18,7 @@ import org.junit.Assert; public class DebugHelperTest extends TestCase { public void testFormatParametersContainsNullValue() { - HashMap<String, Object> parameters = new HashMap<String, Object>(); + HashMap<String, Object> parameters = new HashMap<>(); parameters.put("key", null); String result = DebugHelper.formatParameters(parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java index b2da77b33..484c5e809 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 @@ -133,14 +133,17 @@ public class DownloadManagerTest extends AbstractProvisioningTest { private IArtifactRequest createArtifactRequest() { IArtifactRequest request = new IArtifactRequest() { + @Override public IArtifactKey getArtifactKey() { return null; } + @Override public void perform(IArtifactRepository sourceRepository, IProgressMonitor monitor) { //do nothing } + @Override public IStatus getResult() { return Status.OK_STATUS; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java index d96fe7a4f..39cd4820c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 *******************************************************************************/ @@ -26,10 +26,10 @@ import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** * Simple test of the engine API. - * + * * Note: * Currently you MUST have previously generated metadata from a 3.3.1 install. - * There are ordering dependencies for the tests temporarily + * There are ordering dependencies for the tests temporarily */ public class EngineTest extends AbstractProvisioningTest { @@ -45,26 +45,31 @@ public class EngineTest extends AbstractProvisioningTest { this(name, false); } + @Override protected IStatus completeOperand(IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) { operandCount--; return super.completeOperand(profile, operand, parameters, monitor); } + @Override protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { phaseCount--; return super.completePhase(monitor, profile, parameters); } + @Override protected IStatus initializeOperand(IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) { operandCount++; return super.initializeOperand(profile, operand, parameters, monitor); } + @Override protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { phaseCount++; return super.initializePhase(monitor, profile, parameters); } + @Override protected List<ProvisioningAction> getActions(Operand operand) { return null; } @@ -79,11 +84,13 @@ public class EngineTest extends AbstractProvisioningTest { super("NPE"); } + @Override protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { super.completePhase(monitor, profile, parameters); throw new NullPointerException(); } + @Override protected List<ProvisioningAction> getActions(Operand operand) { return null; } @@ -98,13 +105,16 @@ public class EngineTest extends AbstractProvisioningTest { this(false); } + @Override protected List<ProvisioningAction> getActions(Operand operand) { ProvisioningAction action = new ProvisioningAction() { + @Override public IStatus undo(Map parameters) { throw new NullPointerException(); } + @Override public IStatus execute(Map parameters) { throw new NullPointerException(); } @@ -148,6 +158,7 @@ public class EngineTest extends AbstractProvisioningTest { return directory.delete(); } + @Override protected void setUp() throws Exception { engine = getEngine(); testProvisioning = new File(System.getProperty("java.io.tmpdir"), "testProvisioning"); @@ -155,6 +166,7 @@ public class EngineTest extends AbstractProvisioningTest { testProvisioning.mkdir(); } + @Override protected void tearDown() throws Exception { engine = null; deleteDirectory(testProvisioning); @@ -756,40 +768,49 @@ public class EngineTest extends AbstractProvisioningTest { public void testIncompatibleProfile() { IProfile profile = new IProfile() { + @Override public IQueryResult<IInstallableUnit> available(IQuery<IInstallableUnit> query, IProgressMonitor monitor) { - return new Collector<IInstallableUnit>(); + return new Collector<>(); } + @Override public Map getInstallableUnitProperties(IInstallableUnit iu) { return null; } + @Override public String getInstallableUnitProperty(IInstallableUnit iu, String key) { return null; } + @Override public String getProfileId() { return null; } + @Override public Map getProperties() { return null; } + @Override public String getProperty(String key) { return null; } + @Override public IProvisioningAgent getProvisioningAgent() { return getAgent(); } + @Override public long getTimestamp() { return 0; } + @Override public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) { - return new Collector<IInstallableUnit>(); + return new Collector<>(); } }; try { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java index 00147e924..736b2c7dc 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 *******************************************************************************/ @@ -32,6 +32,7 @@ public class InstructionParserTest extends AbstractProvisioningTest { return TOUCHPOINT_TYPE; } + @Override public String qualifyAction(String actionId) { return "instructionparsertest." + actionId; } @@ -39,10 +40,12 @@ public class InstructionParserTest extends AbstractProvisioningTest { } public static class TestAction extends ProvisioningAction { + @Override public IStatus execute(Map parameters) { return null; } + @Override public IStatus undo(Map parameters) { return null; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java index 1fa318d3e..d8053e762 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 *******************************************************************************/ @@ -23,11 +23,13 @@ public class ParameterizedProvisioningActionTest extends AbstractProvisioningTes String value; ProvisioningAction action = new ProvisioningAction() { + @Override public IStatus execute(Map parameters) { value = (String) parameters.get("test"); return null; } + @Override public IStatus undo(Map parameters) { return null; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java index 0baec8e8d..ca53f0864 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 *******************************************************************************/ @@ -35,6 +35,7 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Collect collectPhase = new Collect(1) { + @Override protected boolean isApplicable(InstallableUnitOperand op) { return super.isApplicable(op); } @@ -51,6 +52,7 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Sizing sizingPhase = new Sizing(1) { + @Override protected boolean isApplicable(InstallableUnitOperand op) { return super.isApplicable(op); } @@ -67,6 +69,7 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Unconfigure unconfigurePhase = new Unconfigure(1) { + @Override protected boolean isApplicable(InstallableUnitOperand op) { return super.isApplicable(op); } @@ -83,6 +86,7 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Uninstall uninstallPhase = new Uninstall(1) { + @Override protected boolean isApplicable(InstallableUnitOperand op) { return super.isApplicable(op); } @@ -99,6 +103,7 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Install installPhase = new Install(1) { + @Override protected boolean isApplicable(InstallableUnitOperand op) { return super.isApplicable(op); } @@ -115,6 +120,7 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Configure configurePhase = new Configure(1) { + @Override protected boolean isApplicable(InstallableUnitOperand op) { return super.isApplicable(op); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java index 0117d6c45..9a5898b78 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 *******************************************************************************/ @@ -110,6 +110,7 @@ public class PhaseSetTest extends AbstractProvisioningTest { URI repoLoc = getTestData("Load test data.", "/testData/pausefeature").toURI(); final PhaseSet phaseSet = (PhaseSet) PhaseSetFactory.createDefaultPhaseSet(); pause = new PauseJob("pause") { + @Override protected IStatus run(IProgressMonitor monitor) { if (!phaseSet.pause()) return new Status(IStatus.ERROR, TestActivator.PI_PROV_TESTS, "pause() failed."); @@ -144,6 +145,7 @@ public class PhaseSetTest extends AbstractProvisioningTest { CountDownLatch latch = new CountDownLatch(1); boolean canStart = false; + @Override public void notify(EventObject o) { if (o instanceof BeginOperationEvent) { canStart = true; @@ -242,6 +244,7 @@ public class PhaseSetTest extends AbstractProvisioningTest { } } pause = new PauseJob("pause") { + @Override protected IStatus run(IProgressMonitor monitor) { if (!phaseSet.pause()) return new Status(IStatus.INFO, TestActivator.PI_PROV_TESTS, "pause() failed."); @@ -268,6 +271,7 @@ public class PhaseSetTest extends AbstractProvisioningTest { class ProvListener implements ProvisioningListener { boolean hasDownloadEvent = false; + @Override public void notify(EventObject o) { if (o instanceof DownloadProgressEvent) hasDownloadEvent = true; @@ -279,6 +283,7 @@ public class PhaseSetTest extends AbstractProvisioningTest { try { pause = new PauseJob("pause") { + @Override protected IStatus run(IProgressMonitor monitor) { while (!listener.hasDownloadEvent) { try { @@ -298,7 +303,7 @@ public class PhaseSetTest extends AbstractProvisioningTest { try { Thread.sleep(2000); } catch (InterruptedException e) { - // + // } setPause(true); return Status.OK_STATUS; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java index 0ccdbe100..aec43669a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 *******************************************************************************/ @@ -60,28 +60,33 @@ public class PhaseTest extends AbstractProvisioningTest { super(phaseId, weight); } + @Override protected IStatus completeOperand(IProfile profile, InstallableUnitOperand operand, Map parameters, IProgressMonitor monitor) { completeOperand = true; return super.completeOperand(profile, operand, parameters, monitor); } + @Override protected IStatus initializeOperand(IProfile profile, InstallableUnitOperand operand, Map parameters, IProgressMonitor monitor) { parameters.put("TestPhase.initializeOperand", "true"); initializeOperand = true; return super.initializeOperand(profile, operand, parameters, monitor); } + @Override protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { completePhase = true; return super.completePhase(monitor, profile, parameters); } + @Override protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { parameters.put("TestPhase.initializePhase", "true"); initializePhase = true; return super.initializePhase(monitor, profile, parameters); } + @Override protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { IInstallableUnit unit = operand.second(); List<ProvisioningAction> parsedActions = getActions(unit, phaseId); @@ -111,10 +116,12 @@ public class PhaseTest extends AbstractProvisioningTest { super(""); } + @Override protected void setUp() throws Exception { engine = getEngine(); } + @Override protected void tearDown() throws Exception { super.tearDown(); engine = null; @@ -165,6 +172,7 @@ public class PhaseTest extends AbstractProvisioningTest { public void testInitCompletePhase() { TestPhase phase = new TestPhase() { + @Override protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { assertFalse(parameters.containsKey("TestPhase.initializePhase")); assertFalse(completePhase); @@ -174,6 +182,7 @@ public class PhaseTest extends AbstractProvisioningTest { return null; } + @Override protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { assertTrue(parameters.containsKey("TestPhase.initializePhase")); assertFalse(completePhase); @@ -195,6 +204,7 @@ public class PhaseTest extends AbstractProvisioningTest { public void testInitCompleteOperand() { TestPhase phase = new TestPhase() { + @Override protected IStatus completeOperand(IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) { assertTrue(parameters.containsKey("TestPhase.initializeOperand")); assertFalse(completeOperand); @@ -204,6 +214,7 @@ public class PhaseTest extends AbstractProvisioningTest { return null; } + @Override protected IStatus initializeOperand(IProfile profile, Operand operand, Map parameters, IProgressMonitor monitor) { assertFalse(parameters.containsKey("TestPhase.initializeOperand")); assertFalse(completeOperand); @@ -226,6 +237,7 @@ public class PhaseTest extends AbstractProvisioningTest { public void testGetProfileDataArea() { TestPhase phase = new TestPhase() { + @Override protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { File profileDataArea = (File) parameters.get("profileDataDirectory"); assertTrue(profileDataArea.isDirectory()); @@ -240,6 +252,7 @@ public class PhaseTest extends AbstractProvisioningTest { return super.initializePhase(monitor, profile, parameters); } + @Override protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { File profileDataArea = (File) parameters.get("profileDataDirectory"); assertTrue(profileDataArea.isDirectory()); @@ -263,10 +276,12 @@ public class PhaseTest extends AbstractProvisioningTest { public static class TestAction extends ProvisioningAction { + @Override public IStatus execute(Map parameters) { return null; } + @Override public IStatus undo(Map parameters) { return null; } @@ -275,6 +290,7 @@ public class PhaseTest extends AbstractProvisioningTest { public void testGetAction() { final ArrayList actionsList1 = new ArrayList(); InstallableUnitPhase phase1 = new InstallableUnitPhase("test", 1) { + @Override protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { List<ProvisioningAction> actions = getActions(operand.second(), "test1"); actionsList1.addAll(actions); @@ -283,6 +299,7 @@ public class PhaseTest extends AbstractProvisioningTest { }; final ArrayList actionsList2 = new ArrayList(); InstallableUnitPhase phase2 = new InstallableUnitPhase("test", 1) { + @Override protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { List<ProvisioningAction> actions = getActions(operand.second(), "test2"); actionsList2.addAll(actions); @@ -349,6 +366,7 @@ public class PhaseTest extends AbstractProvisioningTest { class TestListener implements ProvisioningListener { boolean collectEvent = false; + @Override public void notify(EventObject o) { if (o instanceof CollectEvent) collectEvent = true; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java index da9dfd70c..b1ac67366 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation and others. + * Copyright (c) 2009, 2017 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 @@ -32,6 +32,7 @@ import org.osgi.service.prefs.Preferences; public class ProfilePreferencesTest extends AbstractProvisioningTest { private IPreferencesService prefServ; + @Override protected void setUp() throws Exception { super.setUp(); 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 a28eb7e69..9fb913f22 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 *******************************************************************************/ @@ -72,12 +72,14 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { } } + @Override protected void setUp() throws Exception { getServices(); //ensure we start in a clean state registry.removeProfile(PROFILE_NAME); } + @Override protected void tearDown() throws Exception { super.tearDown(); ungetServices(); @@ -107,7 +109,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testPropertyPeristence() throws ProvisionException { assertNull(registry.getProfile(PROFILE_NAME)); - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); assertTrue(profile.getProperties().containsKey("test")); @@ -153,7 +155,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { } public void testIUPropertyPeristence() throws ProvisionException { - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("test", "test"); assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); @@ -186,7 +188,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testTimestampedProfiles() throws ProvisionException { assertNull(registry.getProfile(PROFILE_NAME)); - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); long oldtimestamp = profile.getTimestamp(); @@ -213,7 +215,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testIsCurrent() throws Exception { assertNull(registry.getProfile(PROFILE_NAME)); - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); @@ -300,11 +302,11 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { simpleRgy.lockProfile(simpleProfile); simpleRgy.unlockProfile(simpleProfile); // Create a lock file to confirm locking - + File lockDirectory = new File(getResourceAsBundleRelFile("testData/engineTest/SimpleRegistry/"), SIMPLE_PROFILE + ".profile"); File lockFile = new File(lockDirectory, ".lock"); assertTrue("Lock file does not exist", lockFile.exists()); - + ProfileLock profileLock = new ProfileLock(lockDirectory); boolean locked = profileLock.lock(); try { @@ -341,6 +343,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { simpleRgy.lockProfile(simpleProfile); final Object lock = new Object(); Thread t1 = new Thread() { + @Override public void run() { try { simpleRgy.unlockProfile(simpleProfile); @@ -362,6 +365,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { } } Thread t2 = new Thread() { + @Override public void run() { try { simpleRgy.lockProfile(simpleProfile); @@ -556,12 +560,14 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { } File profileFolder = new File(folder, getName() + ".profile"); File[] filesFound = profileFolder.listFiles(new FileFilter() { + @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".profile"); } }); assertEquals(1, filesFound.length); filesFound = profileFolder.listFiles(new FileFilter() { + @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".profile.gz"); } @@ -606,6 +612,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { } File profileFolder = new File(folder, getName() + ".profile"); profileFolder.listFiles(new FileFilter() { + @Override public boolean accept(File pathname) { if (pathname.getName().endsWith(".profile")) assertEquals("2.0." + currentValue, EngineActivator.PROFILE_FORMAT_UNCOMPRESSED, currentValue); @@ -647,6 +654,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { File profileFolder = new File(folder, getName() + ".profile"); File[] filesFound = profileFolder.listFiles(new FileFilter() { + @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".profile.gz"); } @@ -656,7 +664,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testRemoveProfileTimestamps() throws ProvisionException { assertNull(registry.getProfile(PROFILE_NAME)); - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); assertTrue(profile.getProperties().containsKey("test")); @@ -697,7 +705,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { long[] states = registry.listProfileTimestamps(profile.getProfileId()); long goodTimestamp = states[0]; long badTimestamp = goodTimestamp + 1; - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("foo", "bar"); // Test invalid arguments handled as per contract @@ -786,7 +794,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); - Map<String, String> profileProperties = new HashMap<String, String>(); + Map<String, String> profileProperties = new HashMap<>(); profileProperties.put("profileFoo", "profileBar"); profile.addProperties(profileProperties); @@ -796,8 +804,8 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { long[] states = registry.listProfileTimestamps(profile.getProfileId()); assertEquals(2, registry.listProfileTimestamps(profile.getProfileId()).length); - Map<String, String> stateProperties1 = new HashMap<String, String>(); - Map<String, String> stateProperties2 = new HashMap<String, String>(); + Map<String, String> stateProperties1 = new HashMap<>(); + Map<String, String> stateProperties2 = new HashMap<>(); stateProperties1.put("one", "two"); stateProperties1.put("a", "b"); @@ -844,7 +852,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { assertEquals(0, result.size()); // Force the states to be pruned by causing a new state to be written. - Map<String, String> stateProperties3 = new HashMap<String, String>(); + Map<String, String> stateProperties3 = new HashMap<>(); stateProperties3.put("AmIPruned", "yes"); registry.setProfileStateProperties(profile.getProfileId(), states[1], stateProperties3); @@ -868,7 +876,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); - Map<String, String> profileProperties = new HashMap<String, String>(); + Map<String, String> profileProperties = new HashMap<>(); profileProperties.put("profileFoo", "profileBar"); profile.addProperties(profileProperties); @@ -877,8 +885,8 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { long[] states = registry.listProfileTimestamps(profile.getProfileId()); - Map<String, String> stateProperties1 = new HashMap<String, String>(); - Map<String, String> stateProperties2 = new HashMap<String, String>(); + Map<String, String> stateProperties1 = new HashMap<>(); + Map<String, String> stateProperties2 = new HashMap<>(); stateProperties1.put("one", "two"); stateProperties1.put("a", "b"); @@ -923,7 +931,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { assertNull(registry.getProfile(getName())); Profile profile = (Profile) registry.addProfile(getName()); - Map<String, String> profileProperties = new HashMap<String, String>(); + Map<String, String> profileProperties = new HashMap<>(); profileProperties.put("profileFoo", "profileBar"); profile.addProperties(profileProperties); @@ -932,8 +940,8 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { long[] states = registry.listProfileTimestamps(profile.getProfileId()); - Map<String, String> stateProperties1 = new HashMap<String, String>(); - Map<String, String> stateProperties2 = new HashMap<String, String>(); + Map<String, String> stateProperties1 = new HashMap<>(); + Map<String, String> stateProperties2 = new HashMap<>(); stateProperties1.put("one", "two"); stateProperties1.put("a", "b"); @@ -991,7 +999,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { assertNull(registry.getProfile(getName())); Profile profile = (Profile) registry.addProfile(getName()); - Map<String, String> profileProperties = new HashMap<String, String>(); + Map<String, String> profileProperties = new HashMap<>(); profileProperties.put("profileFoo", "profileBar"); profile.addProperties(profileProperties); @@ -1000,8 +1008,8 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { long[] states = registry.listProfileTimestamps(profile.getProfileId()); - Map<String, String> stateProperties1 = new HashMap<String, String>(); - Map<String, String> stateProperties2 = new HashMap<String, String>(); + Map<String, String> stateProperties1 = new HashMap<>(); + Map<String, String> stateProperties2 = new HashMap<>(); stateProperties1.put("one", "two"); stateProperties1.put("a", "b"); @@ -1044,7 +1052,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { assertNull(registry.getProfile(getName())); Profile profile = (Profile) registry.addProfile(getName()); - Map<String, String> profileProperties = new HashMap<String, String>(); + Map<String, String> profileProperties = new HashMap<>(); profileProperties.put("profileFoo", "profileBar"); profile.addProperties(profileProperties); @@ -1053,8 +1061,8 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { long[] states = registry.listProfileTimestamps(profile.getProfileId()); - Map<String, String> stateProperties1 = new HashMap<String, String>(); - Map<String, String> stateProperties2 = new HashMap<String, String>(); + Map<String, String> stateProperties1 = new HashMap<>(); + Map<String, String> stateProperties2 = new HashMap<>(); stateProperties1.put("one", "two"); stateProperties1.put("a", "b"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java index d7ff11bbc..425fbec3c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 *******************************************************************************/ @@ -62,7 +62,7 @@ public class ProfileTest extends AbstractProvisioningTest { public void testAddRemoveProperty() throws ProvisionException { IProfileRegistry registry = getProfileRegistry(); assertNull(registry.getProfile(PROFILE_NAME)); - Map<String, String> properties = new HashMap<String, String>(); + Map<String, String> properties = new HashMap<>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); assertTrue(profile.getProperties().containsKey("test")); @@ -111,7 +111,7 @@ public class ProfileTest extends AbstractProvisioningTest { profile.addInstallableUnit(createIU("test")); assertNull(profile.getInstallableUnitProperty(createIU("test"), "test")); assertNull(profile.removeInstallableUnitProperty(createIU("test"), "test")); - Map<String, String> iuProperties = new HashMap<String, String>(); + Map<String, String> iuProperties = new HashMap<>(); iuProperties.put("test", "test"); profile.addInstallableUnitProperties(createIU("test"), iuProperties); assertEquals("test", profile.getInstallableUnitProperty(createIU("test"), "test")); @@ -130,14 +130,17 @@ public class ProfileTest extends AbstractProvisioningTest { profile.addInstallableUnit(createIU("test")); assertEquals(1, queryResultSize(profile.available(QueryUtil.createIUAnyQuery(), null))); profile.setSurrogateProfileHandler(new ISurrogateProfileHandler() { + @Override public IProfile createProfile(String id) { return null; } + @Override public boolean isSurrogate(IProfile profile) { return false; } + @Override public IQueryResult queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor) { return new Collector(); } @@ -211,6 +214,7 @@ public class ProfileTest extends AbstractProvisioningTest { super(rootName, rootHandler); } + @Override public void processingInstruction(String target, String data) throws SAXException { if (PROFILE_TEST_TARGET.equals(target)) { Version profileTestVersion = extractPIVersion(target, data); @@ -226,9 +230,11 @@ public class ProfileTest extends AbstractProvisioningTest { private ProfilesHandler profilesHandler; IProfile[] profiles; + @Override protected void handleRootAttributes(Attributes attributes) { } + @Override public void startElement(String name, Attributes attributes) { if (PROFILES_ELEMENT.equals(name)) { if (profilesHandler == null) { @@ -241,6 +247,7 @@ public class ProfileTest extends AbstractProvisioningTest { } } + @Override protected void finished() { if (isValidXML()) { if (profilesHandler != null) { @@ -308,6 +315,7 @@ public class ProfileTest extends AbstractProvisioningTest { profileMap.put(profileId, profile); } + @Override public void startElement(String name, Attributes attributes) { if (name.equals(PROFILE_ELEMENT)) { new ProfilesProfileHandler(this, attributes, profileHandlers); @@ -327,6 +335,7 @@ public class ProfileTest extends AbstractProvisioningTest { handleRootAttributes(attributes); } + @Override protected void finished() { if (isValidXML()) { profileHandlers.put(getProfileId(), this); @@ -334,10 +343,12 @@ public class ProfileTest extends AbstractProvisioningTest { } } + @Override protected String getErrorMessage() { return "Error parsing profile string"; } + @Override protected Object getRootObject() { Map result = new HashMap(); for (int i = 0; i < profiles.length; i++) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java index f0c242b5a..a85eb2093 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java @@ -1,20 +1,19 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2017 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 * Code 9 - ongoing development *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; - import java.net.URI; import java.util.Collections; +import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; import org.eclipse.equinox.p2.engine.IProvisioningPlan; import org.eclipse.equinox.p2.engine.ProvisioningContext; import org.eclipse.equinox.p2.metadata.IInstallableUnit; @@ -38,6 +37,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { protected IMetadataRepository repoA, repoB, repoC; URI uriA, uriB, uriC; + @Override protected void setUp() throws Exception { super.setUp(); uriA = getTestData("A", testDataFileLocation + "A").toURI(); @@ -59,6 +59,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { repoB.addReferences(Collections.singletonList(new RepositoryReference(repoC.getLocation(), null, IRepository.TYPE_METADATA, IRepository.ENABLED))); } + @Override protected void tearDown() throws Exception { getArtifactRepositoryManager().removeRepository(uriA); getArtifactRepositoryManager().removeRepository(uriB); @@ -74,7 +75,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { context.setArtifactRepositories(new URI[0]); IQueryable<IInstallableUnit> queryable = context.getMetadata(getMonitor()); assertEquals("Only IUs from A", A_UNITCOUNT, queryable.query(QueryUtil.ALL_UNITS, getMonitor()).toUnmodifiableSet().size()); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); // The immediate artifact repo reference was followed assertEquals("1 separately located artifact repos", 1, followed.length); @@ -91,7 +92,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { assertTrue("should find B", units.length > 0); units = queryable.query(QueryUtil.createIUQuery("C"), getMonitor()).toArray(IInstallableUnit.class); assertTrue("should find C", units.length > 0); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); // The artifact repo reference was followed assertEquals("3 artifact repos", 3, followed.length); @@ -107,7 +108,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { assertTrue("should find B", units.length > 0); units = queryable.query(QueryUtil.createIUQuery("C"), getMonitor()).toArray(IInstallableUnit.class); assertFalse("should not find C", units.length > 0); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); assertEquals("two artifact repos", 2, followed.length); @@ -124,7 +125,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { assertTrue("should find B", units.length > 0); units = queryable.query(QueryUtil.createIUQuery("C"), getMonitor()).toArray(IInstallableUnit.class); assertTrue("should find C", units.length > 0); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); assertEquals("three artifact repos", 3, followed.length); @@ -140,7 +141,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { assertTrue("should find B", units.length > 0); units = queryable.query(QueryUtil.createIUQuery("C"), getMonitor()).toArray(IInstallableUnit.class); assertTrue("should find C", units.length > 0); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); assertEquals("three artifact repos", 3, followed.length); @@ -157,7 +158,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { assertTrue("should find B", units.length > 0); units = queryable.query(QueryUtil.createIUQuery("C"), getMonitor()).toArray(IInstallableUnit.class); assertTrue("should find C", units.length > 0); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); assertEquals("three artifact repos", 3, followed.length); @@ -168,7 +169,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { context.setArtifactRepositories(new URI[0]); context.setMetadataRepositories(new URI[0]); context.getMetadata(getMonitor()); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); assertEquals("1.1", 0, followed.length); } @@ -179,7 +180,7 @@ public class ProvisioningContextTest extends AbstractProvisioningTest { context.setArtifactRepositories(new URI[0]); context.setMetadataRepositories(new URI[0]); context.getMetadata(getMonitor()); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<IArtifactRepository>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); IArtifactRepository[] followed = context.getArtifactRepositories(getMonitor()).query(all, getMonitor()).toArray(IArtifactRepository.class); assertEquals("1.1", 0, followed.length); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest.java index 963a5c0cb..7a0b3fb72 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River and others. + * Copyright (c) 2012, 2017 Wind River 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: * Wind River - initial API and implementation *******************************************************************************/ @@ -44,6 +44,7 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { private IEngine engine; private File testProvisioning; + @Override @Before public void setUp() throws Exception { engine = getEngine(); @@ -52,6 +53,7 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { testProvisioning.mkdir(); } + @Override @After public void tearDown() throws Exception { engine = null; @@ -66,6 +68,7 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { boolean mirrorEevent = false; CountDownLatch latch = new CountDownLatch(1); + @Override public void notify(EventObject o) { if (o instanceof CollectEvent) { if (((CollectEvent) o).getType() == CollectEvent.TYPE_OVERALL_START && ((CollectEvent) o).getRepository() == null) { @@ -115,10 +118,11 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { class ProvTestListener implements ProvisioningListener { String publishUnWantedPhaseEvent = null; int publishUnWantedPhaseType = 0; - List<String> phaseStartEventToBePublised = new ArrayList<String>(Arrays.asList(phaseSets)); - List<String> phaseEndEventToBePublised = new ArrayList<String>(Arrays.asList(phaseSets)); + List<String> phaseStartEventToBePublised = new ArrayList<>(Arrays.asList(phaseSets)); + List<String> phaseEndEventToBePublised = new ArrayList<>(Arrays.asList(phaseSets)); CountDownLatch latch = new CountDownLatch(1); + @Override public void notify(EventObject o) { if (o instanceof PhaseEvent) { PhaseEvent event = (PhaseEvent) o; @@ -170,6 +174,7 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { int postUnConfigureEvent = 0; CountDownLatch latch = new CountDownLatch(2); + @Override public void notify(EventObject o) { if (o instanceof InstallableUnitEvent) { InstallableUnitEvent event = (InstallableUnitEvent) o; @@ -204,8 +209,8 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { args.put("enabled", "true"); new RemoveRepositoryAction().execute(args); - Map<String, ITouchpointInstruction> data = new HashMap<String, ITouchpointInstruction>(); - Map<String, String> parameters = new HashMap<String, String>(); + Map<String, ITouchpointInstruction> data = new HashMap<>(); + Map<String, String> parameters = new HashMap<>(); parameters.put("location", testLocation); parameters.put("type", Integer.toString(IRepository.TYPE_ARTIFACT)); parameters.put("name", "Juno"); @@ -260,6 +265,7 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { int postUnConfigureEventForUndo = 0; CountDownLatch latch = new CountDownLatch(1); + @Override public void notify(EventObject o) { if (o instanceof InstallableUnitEvent) { InstallableUnitEvent event = (InstallableUnitEvent) o; @@ -297,11 +303,11 @@ public class ProvisioningEventTest extends AbstractProvisioningTest { IProfile profile = createProfile("testConfigureEvent"); IProvisioningPlan plan = engine.createPlan(profile, null); - Map<String, ITouchpointInstruction> data = new HashMap<String, ITouchpointInstruction>(); + Map<String, ITouchpointInstruction> data = new HashMap<>(); data.put(PhaseSetFactory.PHASE_CONFIGURE, MetadataFactory.createTouchpointInstruction("instructionparsertest.goodAction()", null)); IInstallableUnit testIU = createResolvedIU(createIU(iuId, Version.create("1.0.0"), null, new IRequirement[0], BUNDLE_CAPABILITY, NO_PROPERTIES, ITouchpointType.NONE, new TouchpointData(data), false)); plan.addInstallableUnit(testIU); - data = new HashMap<String, ITouchpointInstruction>(1); + data = new HashMap<>(1); data.put(PhaseSetFactory.PHASE_CONFIGURE, new TouchpointInstruction("alwaysFail();", null)); plan.addInstallableUnit(createResolvedIU(createEclipseIU(failureIU, Version.create("1.0.0"), new IRequirement[0], new TouchpointData(data)))); IStatus result = engine.perform(plan, PhaseSetFactory.createDefaultPhaseSet(), new NullProgressMonitor()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest2.java index 3e8d6bc98..fc061cd04 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningEventTest2.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River and others. + * Copyright (c) 2012, 2017 Wind River 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: * Wind River - initial API and implementation *******************************************************************************/ @@ -44,6 +44,7 @@ public class ProvisioningEventTest2 extends AbstractTestServerClientCase { boolean notifiedDownloadProgressEvent = false; CountDownLatch latch = new CountDownLatch(1); + @Override public void notify(EventObject o) { if (o instanceof DownloadProgressEvent) { notifiedDownloadProgressEvent = true; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java index e546302ca..3aff7348a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 *******************************************************************************/ @@ -51,6 +51,7 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest { registry = null; } + @Override protected void setUp() throws Exception { getServices(); //ensure we start in a clean state @@ -61,6 +62,7 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest { registryField.set(handler, registry); } + @Override protected void tearDown() throws Exception { super.tearDown(); ungetServices(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java index a7cd0616b..86eae8e42 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 @@ -37,21 +37,25 @@ public class TouchpointTest extends AbstractProvisioningTest { testTouchpoint = this; } + @Override public IStatus completeOperand(IProfile profile, Map parameters) { completeOperand++; return super.completeOperand(profile, parameters); } + @Override public IStatus completePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) { completePhase++; return super.completePhase(monitor, profile, phaseId, touchpointParameters); } + @Override public IStatus initializeOperand(IProfile profile, Map parameters) { initializeOperand++; return super.initializeOperand(profile, parameters); } + @Override public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) { initializePhase++; return super.initializePhase(monitor, profile, phaseId, touchpointParameters); @@ -66,6 +70,7 @@ public class TouchpointTest extends AbstractProvisioningTest { } public static class OperandTestTouchpoint extends TestTouchpoint { + @Override public IStatus completeOperand(IProfile profile, Map parameters) { assertEquals(1, initializeOperand); assertEquals(0, completeOperand); @@ -75,6 +80,7 @@ public class TouchpointTest extends AbstractProvisioningTest { return null; } + @Override public IStatus initializeOperand(IProfile profile, Map parameters) { assertEquals(0, initializeOperand); assertEquals(0, completeOperand); @@ -85,12 +91,14 @@ public class TouchpointTest extends AbstractProvisioningTest { return null; } + @Override public String qualifyAction(String actionId) { return "operandtest." + actionId; } } public static class PhaseTestTouchpoint extends TestTouchpoint { + @Override public IStatus completePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map parameters) { assertEquals(1, initializePhase); assertEquals(0, completePhase); @@ -100,6 +108,7 @@ public class TouchpointTest extends AbstractProvisioningTest { return null; } + @Override public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map parameters) { assertEquals(0, initializePhase); assertEquals(0, completePhase); @@ -110,6 +119,7 @@ public class TouchpointTest extends AbstractProvisioningTest { return null; } + @Override public String qualifyAction(String actionId) { return "phasetest." + actionId; } @@ -125,10 +135,12 @@ public class TouchpointTest extends AbstractProvisioningTest { super(""); } + @Override protected void setUp() throws Exception { engine = getEngine(); } + @Override protected void tearDown() throws Exception { engine = null; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java index 9df16a597..69af5a8a7 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2012 Landmark Graphics Corporation + * Copyright (c) 2012, 2017 Landmark Graphics Corporation * 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: * Landmark Graphics Corporation - initial API and implementation *******************************************************************************/ @@ -78,12 +78,12 @@ public class VariableTest extends AbstractProvisioningTest { private static int count = 0; private static final int failAt = 3; - public static ArrayList<String> inputValues = new ArrayList<String>(); - public static ArrayList<String> undoValues = new ArrayList<String>(); + public static ArrayList<String> inputValues = new ArrayList<>(); + public static ArrayList<String> undoValues = new ArrayList<>(); public static void reinitForNextTest() { - inputValues = new ArrayList<String>(); - undoValues = new ArrayList<String>(); + inputValues = new ArrayList<>(); + undoValues = new ArrayList<>(); failMode = false; count = 0; } @@ -108,8 +108,9 @@ public class VariableTest extends AbstractProvisioningTest { return Status.OK_STATUS; } + @Override public Value<String> getResult() { - return new Value<String>(result); + return new Value<>(result); } } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest2.java index 940c174ca..ddf6e0611 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest2.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2013 Landmark Graphics Corporation + * Copyright (c) 2013, 2017 Landmark Graphics Corporation * 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: * Landmark Graphics Corporation - initial API and implementation *******************************************************************************/ @@ -53,7 +53,7 @@ public class VariableTest2 extends AbstractProvisioningTest { public static class Action extends ProvisioningAction { public static Object result; - public static ArrayList<Object> inputValues = new ArrayList<Object>(); + public static ArrayList<Object> inputValues = new ArrayList<>(); @Override public IStatus execute(Map<String, Object> parameters) { @@ -62,8 +62,9 @@ public class VariableTest2 extends AbstractProvisioningTest { return Status.OK_STATUS; } + @Override public Value<Object> getResult() { - return new Value<Object>(result); + return new Value<>(result); } @Override diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest3.java index a7913c879..a00a3063e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/VariableTest3.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2013 Landmark Graphics Corporation + * Copyright (c) 2013, 2017 Landmark Graphics Corporation * 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: * Landmark Graphics Corporation - initial API and implementation *******************************************************************************/ @@ -59,8 +59,8 @@ public class VariableTest3 extends AbstractProvisioningTest { public static class Action extends ProvisioningAction { public static Object result; - public static ArrayList<Object> expectedInputValues = new ArrayList<Object>(); - public static ArrayList<Object> expectedReturnValues = new ArrayList<Object>(); + public static ArrayList<Object> expectedInputValues = new ArrayList<>(); + public static ArrayList<Object> expectedReturnValues = new ArrayList<>(); public static int invocationCounter = 0; @Override @@ -71,10 +71,11 @@ public class VariableTest3 extends AbstractProvisioningTest { return Status.OK_STATUS; } + @Override public Value<Object> getResult() { if (Value.NO_VALUE == result) return Value.NO_VALUE; - return new Value<Object>(result); + return new Value<>(result); } @Override |