Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-09-25 16:04:49 -0400
committerAlexander Kurtakov2019-10-27 05:12:49 -0400
commit6862bac5b2c881540e8ee99020975a89cb997684 (patch)
treef329286fab97aeb4cc57d418ae3d310f0b9e6611
parent3d0b351e0d3f340bcc26f7a651f4eebfc817b722 (diff)
downloadrt.equinox.p2-6862bac5b2c881540e8ee99020975a89cb997684.tar.gz
rt.equinox.p2-6862bac5b2c881540e8ee99020975a89cb997684.tar.xz
rt.equinox.p2-6862bac5b2c881540e8ee99020975a89cb997684.zip
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. toString() on array toString() implementation for arrays does not convert array contents to String, rather it will print array's type and hash code (defined as identity hash code). To get string representation of contents of the array, the array could be for example wrapped into Arrays.asList(), as Collections produce content representation in their toString(). Change-Id: I5db7c1cb516f25cb8410278d1d687862de471c6a Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java125
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IULoader.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/StatsTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AbstractEnd2EndTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AllServerTests.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/RepositorManagerDifferentAgentTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java47
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbstractPlannerTest.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300572.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug301446.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug302580.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug309530.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractSharedBundleProductTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest2.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/testserver/helper/TestServerController.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java8
57 files changed, 359 insertions, 289 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index 37777c0a9..84d42a057 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -192,8 +192,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
// print out the children if we have any
IStatus children[] = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus child = children[i];
+ for (IStatus child : children) {
if (!child.isOK())
new CoreException(child).printStackTrace();
}
@@ -246,8 +245,9 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (!target.exists())
target.mkdirs();
File[] children = source.listFiles(filter);
- for (int i = 0; i < children.length; i++)
- copy(message, children[i], new File(target, children[i].getName()));
+ for (File child : children) {
+ copy(message, child, new File(target, child.getName()));
+ }
return;
}
try (InputStream input = new BufferedInputStream(new FileInputStream(source)); OutputStream output = new BufferedOutputStream(new FileOutputStream(target));) {
@@ -281,8 +281,9 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (!target.exists())
target.mkdirs();
File[] children = source.listFiles(filter);
- for (int i = 0; i < children.length; i++)
- move(message, children[i], new File(target, children[i].getName()), filter);
+ for (File child : children) {
+ move(message, child, new File(target, child.getName()), filter);
+ }
return;
}
@@ -527,8 +528,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
for (int i = 0; i < additionalProvides.length; i++) {
provides[i + 1] = additionalProvides[i];
}
- for (Iterator<String> iter = properties.keySet().iterator(); iter.hasNext();) {
- String nextKey = iter.next();
+ for (String nextKey : properties.keySet()) {
String nextValue = properties.get(nextKey);
iu.setProperty(nextKey, nextValue);
}
@@ -660,8 +660,9 @@ public abstract class AbstractProvisioningTest extends TestCase {
file.setReadable(true);
file.setExecutable(true);
File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++)
- delete(children[i]);
+ for (File child : children) {
+ delete(child);
+ }
}
if (!file.delete()) {
file.setWritable(true);
@@ -799,8 +800,9 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (status.isMultiStatus()) {
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++)
- write(children[i], indent + 1, output);
+ for (IStatus child : children) {
+ write(child, indent + 1, output);
+ }
}
}
@@ -816,7 +818,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (expected == null && actual == null)
return;
if (expected == null)
- fail(message + " expected null but was: " + actual);
+ fail(message + " expected null but was: " + Arrays.toString(actual));
if (actual == null)
fail(message + " array is unexpectedly null");
if (expected.length != actual.length)
@@ -829,7 +831,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (expected == null && actual == null)
return;
if (expected == null)
- fail(message + " expected null but was: " + actual);
+ fail(message + " expected null but was: " + Arrays.toString(actual));
if (actual == null)
fail(message + " array is unexpectedly null");
if (expected.length != actual.length)
@@ -1011,18 +1013,18 @@ public abstract class AbstractProvisioningTest extends TestCase {
metadataRepos.clear();
}
URI[] urls = repoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < urls.length; i++) {
+ for (URI url : urls) {
try {
- if (urls[i].toString().contains("cache") || urls[i].toString().contains("rollback"))
- repoMan.loadRepository(urls[i], null).removeAll();
- } catch (ProvisionException e) {
+ if (url.toString().contains("cache") || url.toString().contains("rollback")) {
+ repoMan.loadRepository(url, null).removeAll();
+ }
+ }catch (ProvisionException e) {
//if the repository didn't load, then it doesn't exist and we don't need to clear it up
}
}
//remove all profiles created by this test
IProfileRegistry profileRegistry = getProfileRegistry();
- for (Iterator<String> it = profilesToRemove.iterator(); it.hasNext();) {
- String toRemove = it.next();
+ for (String toRemove : profilesToRemove) {
profileRegistry.removeProfile(toRemove);
}
profilesToRemove.clear();
@@ -1070,17 +1072,17 @@ public abstract class AbstractProvisioningTest extends TestCase {
super.setUp();
IMetadataRepositoryManager repoMan = getMetadataRepositoryManager();
URI[] repos = repoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < repos.length; i++) {
- repoMan.removeRepository(repos[i]);
+ for (URI repo : repos) {
+ repoMan.removeRepository(repo);
}
}
protected IStatus installAsRoots(IProfile profile, IInstallableUnit[] ius, boolean strict, IPlanner planner, IEngine engine) {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
- for (int i = 0; i < ius.length; i++) {
- req.add(ius[i]);
- req.setInstallableUnitInclusionRules(ius[i], strict ? ProfileInclusionRules.createStrictInclusionRule(ius[i]) : ProfileInclusionRules.createOptionalInclusionRule(ius[i]));
- req.setInstallableUnitProfileProperty(ius[i], IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
+ for (IInstallableUnit iu : ius) {
+ req.add(iu);
+ req.setInstallableUnitInclusionRules(iu, strict ? ProfileInclusionRules.createStrictInclusionRule(iu) : ProfileInclusionRules.createOptionalInclusionRule(iu));
+ req.setInstallableUnitProfileProperty(iu, IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
}
return install(req, planner, engine);
@@ -1088,11 +1090,11 @@ public abstract class AbstractProvisioningTest extends TestCase {
protected IStatus installAsRootsAndFlaggedAsBase(IProfile profile, IInstallableUnit[] ius, boolean strict, IPlanner planner, IEngine engine) {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
- for (int i = 0; i < ius.length; i++) {
- req.add(ius[i]);
- req.setInstallableUnitInclusionRules(ius[i], strict ? ProfileInclusionRules.createStrictInclusionRule(ius[i]) : ProfileInclusionRules.createOptionalInclusionRule(ius[i]));
- req.setInstallableUnitProfileProperty(ius[i], IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
- req.setInstallableUnitProfileProperty(ius[i], "org.eclipse.equinox.p2.base", Boolean.TRUE.toString());
+ for (IInstallableUnit iu : ius) {
+ req.add(iu);
+ req.setInstallableUnitInclusionRules(iu, strict ? ProfileInclusionRules.createStrictInclusionRule(iu) : ProfileInclusionRules.createOptionalInclusionRule(iu));
+ req.setInstallableUnitProfileProperty(iu, IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString());
+ req.setInstallableUnitProfileProperty(iu, "org.eclipse.equinox.p2.base", Boolean.TRUE.toString());
}
return install(req, planner, engine);
@@ -1100,9 +1102,9 @@ public abstract class AbstractProvisioningTest extends TestCase {
protected IStatus install(IProfile profile, IInstallableUnit[] ius, boolean strict, IPlanner planner, IEngine engine) {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
- for (int i = 0; i < ius.length; i++) {
- req.add(ius[i]);
- req.setInstallableUnitInclusionRules(ius[i], strict ? ProfileInclusionRules.createStrictInclusionRule(ius[i]) : ProfileInclusionRules.createOptionalInclusionRule(ius[i]));
+ for (IInstallableUnit iu : ius) {
+ req.add(iu);
+ req.setInstallableUnitInclusionRules(iu, strict ? ProfileInclusionRules.createStrictInclusionRule(iu) : ProfileInclusionRules.createOptionalInclusionRule(iu));
}
return install(req, planner, engine);
@@ -1139,10 +1141,11 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (expected.length != actual.length)
assertTrue(message + ".2", false);
boolean[] found = new boolean[expected.length];
- for (int i = 0; i < expected.length; i++) {
+ for (Object expectedelement : expected) {
for (int j = 0; j < expected.length; j++) {
- if (!found[j] && expected[i].equals(actual[j]))
+ if (!found[j] && expectedelement.equals(actual[j])) {
found[j] = true;
+ }
}
}
for (int i = 0; i < found.length; i++)
@@ -1222,15 +1225,14 @@ public abstract class AbstractProvisioningTest extends TestCase {
*/
protected static void assertEquals(String message, IInstallableUnitFragment[] fragments1, IInstallableUnitFragment[] fragments2) throws AssertionFailedError {
Map map = new HashMap(fragments2.length);
- for (int i = 0; i < fragments2.length; i++) {
- map.put(fragments2[i], fragments2[i]);
+ for (IInstallableUnitFragment fragments2element : fragments2) {
+ map.put(fragments2element, fragments2element);
}
-
- for (int i = 0; i < fragments1.length; i++) {
- if (!map.containsKey(fragments1))
- fail(message + " Expected fragment '" + fragments1[i] + "' not present.");
- else {
- assertEquals(message, fragments1[i], map.remove(fragments1[i]));
+ for (IInstallableUnitFragment fragments1element : fragments1) {
+ if (!map.containsKey(fragments1)) {
+ fail(message + " Expected fragment '" + fragments1element + "' not present.");
+ } else {
+ assertEquals(message, fragments1element, map.remove(fragments1element));
}
}
@@ -1272,22 +1274,22 @@ public abstract class AbstractProvisioningTest extends TestCase {
TreeSet set = new TreeSet((o1, o2) -> o1.toString().compareTo(o2.toString()));
set.addAll(Arrays.asList(ius2));
- for (int i = 0; i < ius1.length; i++) {
+ for (IInstallableUnit ius1unit : ius1) {
// + "\0" is a successor for strings
- SortedSet subset = set.subSet(ius1[i], ius1[i].toString() + "\0");
+ SortedSet subset = set.subSet(ius1unit, ius1unit.toString() + "\0");
if (subset.size() == 1) {
IInstallableUnit candidate = (IInstallableUnit) subset.first();
try {
- assertEquals(message, ius1[i], candidate);
+ assertEquals(message, ius1unit, candidate);
} catch (AssertionFailedError e) {
- fail(message + " IUs '" + ius1[i] + "' are unequal : " + e.getMessage());
+ fail(message + " IUs '" + ius1unit + "' are unequal : " + e.getMessage());
}
subset.remove(candidate);
} else if (subset.size() > 1) {
//should not happen
fail(message + " ERROR: Unexpected failure.");
} else {
- fail(message + " Expected IU " + ius1[i] + " not found.");
+ fail(message + " Expected IU " + ius1unit + " not found.");
}
}
if (set.size() > 0)
@@ -1453,10 +1455,11 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (expected == null || actual == null)
fail(message);
Object[] expectedArray = expected.keySet().toArray();
- for (int i = 0; i < expectedArray.length; i++) {
- assertTrue(message, actual.containsKey(expectedArray[i])); //Ensure the key exists
- if (!expectedArray[i].equals("p2.timestamp")) //time stamp value is expected to change
- assertEquals(message, expected.get(expectedArray[i]), actual.get(expectedArray[i]));
+ for (Object expectedelement : expectedArray) {
+ assertTrue(message, actual.containsKey(expectedelement)); //Ensure the key exists
+ if (!expectedelement.equals("p2.timestamp")) {
+ assertEquals(message, expected.get(expectedelement), actual.get(expectedelement));
+ }
}
}
@@ -1473,8 +1476,8 @@ public abstract class AbstractProvisioningTest extends TestCase {
while (reader.ready()) {
String line = reader.readLine();
boolean found = true;
- for (int i = 0; i < parts.length; i++) {
- found = found && line.contains(parts[i]);
+ for (String part : parts) {
+ found = found && line.contains(part);
}
if (found)
return;
@@ -1687,11 +1690,11 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (!(expectedDescriptors == null && actualDescriptors == null))
fail(message + " missing key " + key);
- top: for (int j = 0; j < expectedDescriptors.length; j++) {
- for (int k = 0; k < actualDescriptors.length; k++) {
- if (Arrays.equals(expectedDescriptors[j].getProcessingSteps(), actualDescriptors[k].getProcessingSteps())) {
- File expectedFile = expected.getArtifactFile(expectedDescriptors[j]);
- File actualFile = actual.getArtifactFile(actualDescriptors[k]);
+ top: for (IArtifactDescriptor expectedDescriptor : expectedDescriptors) {
+ for (IArtifactDescriptor actualDescriptor : actualDescriptors) {
+ if (Arrays.equals(expectedDescriptor.getProcessingSteps(), actualDescriptor.getProcessingSteps())) {
+ File expectedFile = expected.getArtifactFile(expectedDescriptor);
+ File actualFile = actual.getArtifactFile(actualDescriptor);
if (expectedFile == null || actualFile == null)
fail(message + " descriptor mismatch");
if (!(expectedFile.exists() && actualFile.exists()))
@@ -1706,7 +1709,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
continue top;
}
}
- fail(message + "Missing expected descriptor" + expectedDescriptors[j]);
+ fail(message + "Missing expected descriptor" + expectedDescriptor);
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IULoader.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IULoader.java
index 12960a377..a710f2ff5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IULoader.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IULoader.java
@@ -13,7 +13,9 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
@@ -24,25 +26,25 @@ public class IULoader {
public static void loadIUs(Object o) {
Class<? extends Object> classWithIUs = o.getClass();
annos = classWithIUs.getAnnotations();
- for (int i = 0; i < annos.length; i++) {
- System.out.println(annos[i]);
+ for (Annotation anno : annos) {
+ System.out.println(anno);
}
Field[] fields = classWithIUs.getFields();
- for (int i = 0; i < fields.length; i++) {
- Annotation[] a = fields[i].getAnnotations();
- for (int j = 0; j < a.length; j++) {
- if (a[j] instanceof IUDescription) {
- IUDescription ml = (IUDescription) a[j]; // here it is !!!
+ for (Field field : fields) {
+ Annotation[] a = field.getAnnotations();
+ for (Annotation a1 : a) {
+ if (a1 instanceof IUDescription) {
+ IUDescription ml = (IUDescription) a1; // here it is !!!
ReducedCUDFParser parser = new ReducedCUDFParser();
- try (InputStream is = new ByteArrayInputStream(ml.content().getBytes())) {
+ try (final InputStream is = new ByteArrayInputStream(ml.content().getBytes())) {
parser.parse(is, false, null);
- fields[i].set(o, parser.getIU());
- } catch (IllegalArgumentException e) {
+ field.set(o, parser.getIU());
+ }catch (IllegalArgumentException e) {
throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
+ }catch (IllegalAccessException e) {
throw new RuntimeException(e);
- } catch (IOException e) {
+ }catch (IOException e) {
throw new RuntimeException(e);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java
index d323ac013..31ee0716e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java
@@ -74,9 +74,9 @@ public class TestActivator implements BundleActivator {
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < bundles.length; i++) {
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return bundles[i];
+ for (Bundle bundle : bundles) {
+ if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+ return bundle;
}
}
return null;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java
index fbf56c796..515f56c73 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java
@@ -150,8 +150,8 @@ public class TestArtifactRepository extends AbstractArtifactRepository {
SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length);
try {
MultiStatus overallStatus = new MultiStatus(TestActivator.PI_PROV_TESTS, IStatus.OK, null, null);
- for (int i = 0; i < requests.length; i++) {
- overallStatus.add(getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1)));
+ for (IArtifactRequest request : requests) {
+ overallStatus.add(getArtifact((ArtifactRequest) request, subMonitor.newChild(1)));
}
return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus);
} finally {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
index 3ec31922a..f43eb6ada 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
@@ -469,8 +469,9 @@ public class CompositeRepositoryTaskTest extends AbstractAntProvisioningTest {
*/
protected AntTaskElement createRemoveElement(String type, URI[] addresses) {
AntTaskElement add = new AntTaskElement(REMOVE_ELEMENT);
- for (int i = 0; i < addresses.length; i++)
- add.addElement(getRepositoryElement(addresses[i], type));
+ for (URI address : addresses) {
+ add.addElement(getRepositoryElement(address, type));
+ }
return add;
}
@@ -479,8 +480,9 @@ public class CompositeRepositoryTaskTest extends AbstractAntProvisioningTest {
*/
protected AntTaskElement createAddElement(String type, URI[] addresses) {
AntTaskElement add = new AntTaskElement(ADD_ELEMENT);
- for (int i = 0; i < addresses.length; i++)
- add.addElement(getRepositoryElement(addresses[i], type));
+ for (URI address : addresses) {
+ add.addElement(getRepositoryElement(address, type));
+ }
return add;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
index cbbed07ae..b372c211e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
@@ -142,8 +142,7 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
for (Iterator<IArtifactKey> iterator = keys.iterator(); iterator.hasNext();) {
IArtifactKey key = iterator.next();
IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors(key);
- for (int n = 0; n < descriptors.length; n++) {
- IArtifactDescriptor desc = descriptors[n];
+ for (IArtifactDescriptor desc : descriptors) {
// Features should be unzipped, others should not be.
boolean isFolder = desc.getProperty("artifact.folder") != null ? Boolean.valueOf(desc.getProperty("artifact.folder")) : false;
if (key.getClassifier().equals(""))
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java
index 16b9ed323..877159e62 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java
@@ -63,9 +63,10 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
*/
private boolean managerContains(URI location) {
URI[] locations = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < locations.length; i++) {
- if (locations[i].equals(location))
+ for (URI uri : locations) {
+ if (uri.equals(location)) {
return true;
+ }
}
return false;
}
@@ -131,8 +132,9 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
Preferences prefs = prefService.getRootNode().node("/profile/" + locationString + "/_SELF_/" + REPO_BUNDLE + "/repositories"); //$NON-NLS-1$ //$NON-NLS-2$
try {
String[] children = prefs.childrenNames();
- for (int i = 0; i < children.length; i++)
- prefs.node(children[i]).removeNode();
+ for (String child : children) {
+ prefs.node(child).removeNode();
+ }
prefs.flush();
} catch (BackingStoreException e) {
fail("0.99", e);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java
index 49f78b0d8..583bf1de6 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java
@@ -80,8 +80,7 @@ public class FoldersRepositoryTest extends TestCase {
File[] fileList = pluginsFolder.listFiles(filter);
assertEquals(2, fileList.length);
IProgressMonitor monitor = new NullProgressMonitor();
- for (int i = 0; i < fileList.length; i++) {
- File file = fileList[i];
+ for (File file : fileList) {
String fileName = file.getName();
if (fileName.endsWith(".jar"))
fileName = fileName.substring(0, fileName.length() - 4);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
index df7ed61a4..aafa526ce 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
@@ -295,9 +295,11 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
return false;
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++)
- if (statusContains(children[i], statusString))
+ for (IStatus child : children) {
+ if (statusContains(child, statusString)) {
return true;
+ }
+ }
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
index e8eaee4a8..6c1d4f87a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
@@ -111,11 +111,11 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
File files[] = repositoryFile.listFiles();
boolean jarFilePresent = false;
boolean artifactFilePresent = false;
- for (int i = 0; i < files.length; i++) {
- if ("artifacts.jar".equalsIgnoreCase(files[i].getName())) {
+ for (File file : files) {
+ if ("artifacts.jar".equalsIgnoreCase(file.getName())) {
jarFilePresent = true;
}
- if ("artifacts.xml".equalsIgnoreCase(files[i].getName())) {
+ if ("artifacts.xml".equalsIgnoreCase(file.getName())) {
artifactFilePresent = false;
}
}
@@ -144,11 +144,11 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
File files[] = repositoryFile.listFiles();
boolean jarFilePresent = false;
boolean artifactFilePresent = false;
- for (int i = 0; i < files.length; i++) {
- if ("artifacts.jar".equalsIgnoreCase(files[i].getName())) {
+ for (File file : files) {
+ if ("artifacts.jar".equalsIgnoreCase(file.getName())) {
jarFilePresent = true;
}
- if ("artifacts.xml".equalsIgnoreCase(files[i].getName())) {
+ if ("artifacts.xml".equalsIgnoreCase(file.getName())) {
artifactFilePresent = true;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/StatsTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/StatsTest.java
index 8a6b009f1..e469fe42c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/StatsTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/StatsTest.java
@@ -109,8 +109,8 @@ public class StatsTest extends AbstractTestServerClientCase {
IInstallableUnit iu = MetadataFactory.createInstallableUnit(descriptor);
metaRepo.addInstallableUnits(Arrays.asList(iu));
- for (int i = 0; i < descriptors.length; i++) {
- File artifactFile = new File(sourceRepo.getLocation(descriptors[i]));
+ for (IArtifactDescriptor desc : descriptors) {
+ File artifactFile = new File(sourceRepo.getLocation(desc));
artifactFile.getParentFile().mkdirs();
assertTrue("Failed to create binary artifact file.", artifactFile.createNewFile());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java
index e444f3ea3..daf3a5020 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/BackupTest.java
@@ -97,9 +97,11 @@ public class BackupTest extends AbstractProvisioningTest {
return true;
if (file.isDirectory()) {
File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++)
- if (!fullyDelete(new File(file, children[i].getName())))
+ for (File child : children) {
+ if (!fullyDelete(new File(file, child.getName()))) {
return false;
+ }
+ }
}
return file.delete();
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java
index 7fc0fb0fd..84d30c9fb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java
@@ -13,12 +13,23 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
import org.eclipse.equinox.internal.p2.director.OperationGenerator;
-import org.eclipse.equinox.internal.p2.engine.*;
+import org.eclipse.equinox.internal.p2.engine.InstallableUnitOperand;
+import org.eclipse.equinox.internal.p2.engine.Operand;
+import org.eclipse.equinox.internal.p2.engine.ProvisioningPlan;
import org.eclipse.equinox.internal.p2.metadata.ResolvedInstallableUnit;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
+import org.eclipse.equinox.p2.metadata.ITouchpointType;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class OperationGenerationTest extends AbstractProvisioningTest {
@@ -485,9 +496,10 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
}
public void assertContains(String message, Object[] searched, Object expected) {
- for (int i = 0; i < searched.length; i++) {
- if (searched[i].equals(expected))
+ for (Object search : searched) {
+ if (search.equals(expected)) {
return;
+ }
}
fail(message + "Can't find " + expected);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java
index f44fe8862..7cc944367 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java
@@ -52,12 +52,12 @@ public class ProfileSynchronizerTest extends AbstractDirectoryWatcherTest {
String base = "/testData/profileSynchronizer/";
String[] extensions = new String[] {"bbb_1.0.0.jar", "bbb.linux_1.0.0.jar", "bbb.win32_1.0.0.jar"};
Set<File> jars = new HashSet<>();
- for (int i = 0; i < extensions.length; i++)
- jars.add(getTestData("0.99", base + extensions[i]));
+ for (String extension : extensions) {
+ jars.add(getTestData("0.99", base + extension));
+ }
File folder = getTempFolder();
toRemove.add(folder);
- for (Iterator<File> iter = jars.iterator(); iter.hasNext();) {
- File next = iter.next();
+ for (File next : jars) {
copy("1.0 " + next.getAbsolutePath(), next, new File(folder, next.getName()));
}
@@ -80,8 +80,9 @@ public class ProfileSynchronizerTest extends AbstractDirectoryWatcherTest {
IInstallableUnit[] ius = watcher.getInstallableUnits();
assertEquals("3.0", expected.size(), ius.length);
- for (int i = 0; i < ius.length; i++)
- assertTrue("3.1 " + ius[i].getId(), expected.contains(ius[i].getId()));
+ for (IInstallableUnit iu : ius) {
+ assertTrue("3.1 " + iu.getId(), expected.contains(iu.getId()));
+ }
assertEquals("3.2", expected.size(), watcher.getArtifactKeys().length);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
index 6ebcbc219..3f2cc7076 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
@@ -53,9 +53,11 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest {
private void removeContents(File source, File target) {
if (source.exists() && source.isDirectory() && target.exists() && target.isDirectory()) {
File[] files = source.listFiles();
- for (int i = 0; i < files.length; i++)
- if (files[i] != null)
- delete(new File(target, files[i].getName()));
+ for (File file : files) {
+ if (file != null) {
+ delete(new File(target, file.getName()));
+ }
+ }
}
}
@@ -79,8 +81,8 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest {
copy("2.0", baseFolder, folder);
watcher.poll();
IArtifactKey[] keys = watcher.getArtifactKeys();
- for (int i = 0; i < keys.length; i++) {
- String file = watcher.getArtifactFile(keys[i]).getAbsolutePath();
+ for (IArtifactKey key : keys) {
+ String file = watcher.getArtifactFile(key).getAbsolutePath();
assertTrue("2.1." + file, file.startsWith(folder.getAbsolutePath()));
}
assertEquals("3.0", 2, watcher.getInstallableUnits().length);
@@ -118,8 +120,7 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest {
IInstallableUnit directoryIU = null;
IInstallableUnit[] ius = watcher.getInstallableUnits();
assertEquals("3.0", 2, ius.length);
- for (int i = 0; i < ius.length; i++) {
- IInstallableUnit iu = ius[i];
+ for (IInstallableUnit iu : ius) {
if (isZipped(iu.getTouchpointData())) {
assertNull("4.0", jaredIU);
jaredIU = iu;
@@ -135,8 +136,7 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest {
IArtifactDescriptor directoryDescriptor = null;
IArtifactKey[] keys = watcher.getArtifactKeys();
assertEquals("7.0", 2, keys.length);
- for (int i = 0; i < keys.length; i++) {
- IArtifactKey key = keys[i];
+ for (IArtifactKey key : keys) {
IArtifactDescriptor[] descriptors = watcher.getArtifactDescriptors(key);
assertEquals("8.0", 1, descriptors.length);
SimpleArtifactDescriptor descriptor = (SimpleArtifactDescriptor) descriptors[0];
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 63afed789..bba21fa57 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
@@ -150,11 +150,11 @@ public class EngineTest extends AbstractProvisioningTest {
private static boolean deleteDirectory(File directory) {
if (directory.exists() && directory.isDirectory()) {
File[] files = directory.listFiles();
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- deleteDirectory(files[i]);
+ for (File file : files) {
+ if (file.isDirectory()) {
+ deleteDirectory(file);
} else {
- files[i].delete();
+ file.delete();
}
}
}
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 c336097c9..1cf77c6a7 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
@@ -583,8 +583,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
try {
IInstallableUnit engineIU = createEclipseIU("org.eclipse.equinox.p2.engine", Version.create("55.2"));
final String[] values = new String[] {"", "blort", null, EngineActivator.PROFILE_FORMAT_UNCOMPRESSED};
- for (int i = 0; i < values.length; i++) {
- final String currentValue = values[i];
+ for (String currentValue : values) {
if (currentValue == null)
System.getProperties().remove(EngineActivator.PROP_PROFILE_FORMAT);
else
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 f839fe839..205318b5f 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
@@ -242,9 +242,10 @@ public abstract class AbstractEnd2EndTest extends AbstractProvisioningTest {
abstract protected VersionedId getPlatformSource();
protected void assertContains(String message, String[] source, String searched) {
- for (int i = 0; i < source.length; i++) {
- if (source[i].equals(searched))
+ for (String element : source) {
+ if (element.equals(searched)) {
return;
+ }
}
fail(message + " " + searched);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java
index af633cf60..afb71ab55 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java
@@ -51,8 +51,8 @@ public class JarProcessorTests extends AbstractProvisioningTest {
return true;
return false;
};
- for (int i = 0; i < input.length; i++) {
- File inputFile = new File(input[i]);
+ for (String filename : input) {
+ File inputFile = new File(filename);
if (inputFile.exists()) {
try {
process(inputFile, filter, true, processor, null);
@@ -99,8 +99,8 @@ public class JarProcessorTests extends AbstractProvisioningTest {
});
input.mkdirs();
- for (int i = 0; i < files.length; i++) {
- copy("Setup input", files[i], new File(input, files[i].getName()));
+ for (File file : files) {
+ copy("Setup input", file, new File(input, file.getName()));
}
Options options = new Options();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
index 5609ae01e..a99eedd75 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
@@ -164,9 +164,10 @@ public class FragmentTest extends AbstractProvisioningTest {
}
public static void assertContains(Object[] objects, Object searched) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] == searched)
+ for (Object object : objects) {
+ if (object == searched) {
return;
+ }
}
throw new AssertionFailedError("The array does not contain the searched element");
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
index 09df59967..c777ddccb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
@@ -223,8 +223,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
private static Map<String, String> createProperties(String[][] keyValuePairs) {
OrderedProperties props = new OrderedProperties(keyValuePairs.length);
- for (int i = 0; i < keyValuePairs.length; i++) {
- String[] nextPair = keyValuePairs[i];
+ for (String[] nextPair : keyValuePairs) {
props.put(nextPair[0], nextPair[1]);
}
return props;
@@ -251,8 +250,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
private static ITouchpointData createTouchpointData(String[][] instructionData) {
Map<String, Object> map = new LinkedHashMap<>(instructionData.length);
- for (int i = 0; i < instructionData.length; i++) {
- String[] nextInstruction = instructionData[i];
+ for (String[] nextInstruction : instructionData) {
map.put(nextInstruction[0], nextInstruction[1]);
}
return MetadataFactory.createTouchpointData(map);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
index 1f9bc46f1..b25134d86 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
@@ -240,8 +240,7 @@ public class FilterTest {
}
this.dictionary = dictionary;
List<String> keyList = new ArrayList<>(dictionary.size());
- for (Iterator<String> e = dictionary.keySet().iterator(); e.hasNext();) {
- String key = e.next();
+ for (String key : dictionary.keySet()) {
for (Iterator<String> i = keyList.iterator(); i.hasNext();) {
if (key.equalsIgnoreCase(i.next())) {
throw new IllegalArgumentException();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AllServerTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AllServerTests.java
index a2e209ff1..ec07e7c33 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AllServerTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AllServerTests.java
@@ -71,8 +71,7 @@ public class AllServerTests extends TestCase {
Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
if (bundles == null)
return null;
- for (int i = 0; i < bundles.length; i++) {
- Bundle bundle = bundles[i];
+ for (Bundle bundle : bundles) {
if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0)
return bundle;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
index 9a069b833..d7f71e4c5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
@@ -63,11 +63,11 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
boolean jarFilePresent = false;
boolean xmlFilePresent = false;
// one of the files in the repository should be the content.xml.jar
- for (int i = 0; i < files.length; i++) {
- if ("compositeContent.jar".equalsIgnoreCase(files[i].getName())) {
+ for (File file : files) {
+ if ("compositeContent.jar".equalsIgnoreCase(file.getName())) {
jarFilePresent = true;
}
- if ("compositeContent.xml".equalsIgnoreCase(files[i].getName())) {
+ if ("compositeContent.xml".equalsIgnoreCase(file.getName())) {
xmlFilePresent = true;
}
}
@@ -85,8 +85,8 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
File[] files = repoLocation.listFiles();
boolean jarFilePresent = false;
// none of the files in the repository should be the content.xml.jar
- for (int i = 0; i < files.length; i++) {
- if ("compositeContent.jar".equalsIgnoreCase(files[i].getName())) {
+ for (File file : files) {
+ if ("compositeContent.jar".equalsIgnoreCase(file.getName())) {
jarFilePresent = true;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/RepositorManagerDifferentAgentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/RepositorManagerDifferentAgentTest.java
index 5bef4d418..2e5ce17ef 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/RepositorManagerDifferentAgentTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/RepositorManagerDifferentAgentTest.java
@@ -18,6 +18,7 @@ package org.eclipse.equinox.p2.tests.metadata.repository;
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import java.util.Arrays;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
@@ -37,7 +38,7 @@ public class RepositorManagerDifferentAgentTest extends AbstractProvisioningTest
IMetadataRepositoryManager mgr = agent.getService(IMetadataRepositoryManager.class);
URI[] repositories = mgr.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
//HERE WE SHOULD GET MUCH MORE REPOSITORIES THAN THIS.
- System.out.println(repositories);
+ System.out.println(Arrays.toString(repositories));
fail();
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java
index 3de879e7a..321e5b4e9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java
@@ -16,11 +16,24 @@ package org.eclipse.equinox.p2.tests.mirror;
import static org.junit.Assert.assertNotEquals;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.artifact.repository.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
+import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryManager;
+import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
@@ -33,9 +46,15 @@ import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactDescriptorQuery;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
-import org.eclipse.equinox.p2.tests.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.StringBufferStream;
+import org.eclipse.equinox.p2.tests.TestActivator;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.util.NLS;
@@ -880,16 +899,15 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest {
IArtifactKey key = iterator.next();
IArtifactDescriptor[] srcDescriptors = packedRepo.getArtifactDescriptors(key);
- for (int j = 0; j < srcDescriptors.length; j++) {
- if (!(srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT).equals(IArtifactDescriptor.FORMAT_PACKED)) {
+ for (IArtifactDescriptor srcDescriptor : srcDescriptors) {
+ if (!(srcDescriptor.getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptor.getProperty(IArtifactDescriptor.FORMAT).equals(IArtifactDescriptor.FORMAT_PACKED)) {
//if we have a packed artifact
IArtifactDescriptor newDescriptor = new ArtifactDescriptor(key);
Map<String, String> properties = new OrderedProperties();
- properties.putAll(srcDescriptors[j].getProperties());
+ properties.putAll(srcDescriptor.getProperties());
properties.remove(IArtifactDescriptor.FORMAT);
((ArtifactDescriptor) newDescriptor).addProperties(properties);
//create appropriate descriptor
-
try (OutputStream repositoryStream = destinationRepo.getOutputStream(newDescriptor)) {
//System.out.println("Mirroring: " + srcDescriptors[j].getArtifactKey() + " (Descriptor: " + srcDescriptors[j] + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -897,10 +915,10 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest {
return;
// TODO Is that ok to ignore the result?
//TODO MAKE THIS WORK PROPERLY
- packedRepo.getArtifact(srcDescriptors[j], repositoryStream, new NullProgressMonitor());
- } catch (ProvisionException e) {
+ packedRepo.getArtifact(srcDescriptor, repositoryStream, new NullProgressMonitor());
+ }catch (ProvisionException e) {
fail("27.1", e);
- } catch (IOException e) {
+ }catch (IOException e) {
fail("27.2", e);
}
//corresponding key should now be in the destination
@@ -913,7 +931,6 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest {
}
if (!canonicalFound)
fail("27.3 no canonical found for " + key.toString());
-
//ensure the canonical matches that in the expected
assertEqualArtifacts("27.3", (SimpleArtifactRepository) destinationRepo, (SimpleArtifactRepository) packedRepo);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java
index 5db3462fe..004b5db20 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java
@@ -114,11 +114,12 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest {
//initialize to the size of both query results
int numKeys = repo1.length + repo2.length;
- for (int i = 0; i < repo1.length; i++) {
- for (int j = 0; j < repo2.length; j++) {
- if (isEqual(repo1[i], repo2[j]))
+ for (IInstallableUnit repo1unit : repo1) {
+ for (IInstallableUnit repo2unit : repo2) {
+ if (isEqual(repo1unit, repo2unit)) {
numKeys--;
- //identical keys has bee found, therefore the number of unique keys is one less than previously thought
+ //identical keys has bee found, therefore the number of unique keys is one less than previously thought
+ }
}
}
return numKeys;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java
index 9b54143bf..4a9719f50 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java
@@ -16,11 +16,22 @@ package org.eclipse.equinox.p2.tests.mirror;
import static org.junit.Assert.assertNotEquals;
-import java.io.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URI;
-import java.util.*;
-import org.eclipse.core.runtime.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryManager;
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
@@ -37,14 +48,24 @@ import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactDescriptorQuery;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
-import org.eclipse.equinox.p2.tests.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.StringBufferStream;
+import org.eclipse.equinox.p2.tests.TestActivator;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.util.NLS;
-import org.junit.*;
-import org.junit.experimental.theories.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.theories.DataPoints;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
/*
@@ -938,26 +959,25 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest {
IArtifactKey key = iterator.next();
IArtifactDescriptor[] srcDescriptors = packedRepo.getArtifactDescriptors(key);
- for (int j = 0; j < srcDescriptors.length; j++) {
- if (!(srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT).equals(IArtifactDescriptor.FORMAT_PACKED)) {
+ for (IArtifactDescriptor srcDescriptor : srcDescriptors) {
+ if (!(srcDescriptor.getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptor.getProperty(IArtifactDescriptor.FORMAT).equals(IArtifactDescriptor.FORMAT_PACKED)) {
//if we have a packed artifact
IArtifactDescriptor newDescriptor = new ArtifactDescriptor(key);
Map<String, String> properties = new OrderedProperties();
- properties.putAll(srcDescriptors[j].getProperties());
+ properties.putAll(srcDescriptor.getProperties());
properties.remove(IArtifactDescriptor.FORMAT);
((ArtifactDescriptor) newDescriptor).addProperties(properties);
//create appropriate descriptor
-
try (OutputStream repositoryStream = destinationRepo.getOutputStream(newDescriptor)) {
//System.out.println("Mirroring: " + srcDescriptors[j].getArtifactKey() + " (Descriptor: " + srcDescriptors[j] + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (repositoryStream == null)
return;
// TODO Is that ok to ignore the result?
//TODO MAKE THIS WORK PROPERLY
- packedRepo.getArtifact(srcDescriptors[j], repositoryStream, new NullProgressMonitor());
- } catch (ProvisionException e) {
+ packedRepo.getArtifact(srcDescriptor, repositoryStream, new NullProgressMonitor());
+ }catch (ProvisionException e) {
fail("27.1", e);
- } catch (IOException e) {
+ }catch (IOException e) {
fail("27.2", e);
}
//corresponding key should now be in the destination
@@ -970,7 +990,6 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest {
}
if (!canonicalFound)
fail("27.3 no canonical found for " + key.toString());
-
//ensure the canonical matches that in the expected
assertEqualArtifacts("27.3", (SimpleArtifactRepository) destinationRepo, (SimpleArtifactRepository) packedRepo);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
index 861c75e7a..173bb4ca0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
@@ -144,11 +144,12 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
//initialize to the size of both QueryResults
int numKeys = repo1.length + repo2.length;
- for (int i = 0; i < repo1.length; i++) {
- for (int j = 0; j < repo2.length; j++) {
- if (isEqual(repo1[i], repo2[j]))
+ for (IInstallableUnit repos1unit : repo1) {
+ for (IInstallableUnit repo2unit : repo2) {
+ if (isEqual(repos1unit, repo2unit)) {
numKeys--;
- //identical keys has bee found, therefore the number of unique keys is one less than previously thought
+ //identical keys has bee found, therefore the number of unique keys is one less than previously thought
+ }
}
}
return numKeys;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java
index d2862c972..b7c0a361c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java
@@ -68,8 +68,8 @@ public class MetadataRepositoryPerformanceTest extends ProvisioningPerformanceTe
@Override
protected void test() {
- for (int i = 0; i < queries.length; i++) {
- repository.query(queries[i], null);
+ for (IQuery<IInstallableUnit> query : queries) {
+ repository.query(query, null);
}
}
}.run(this, "Test query local metadata repo for " + IU_COUNT + " ius", REPEATS, 10);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java
index 562e9cd13..8215c4772 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java
@@ -46,8 +46,8 @@ public class PublisherPerformanceTest extends ProvisioningPerformanceTest {
@Override
protected void test() {
- for (int i = 0; i < queries.length; i++) {
- result.query(queries[i], null);
+ for (IQuery<IInstallableUnit> query : queries) {
+ result.query(query, null);
}
}
}.run(this, "Test query PublisherResult for " + IU_COUNT + " ius", REPEATS, 10);
@@ -73,8 +73,8 @@ public class PublisherPerformanceTest extends ProvisioningPerformanceTest {
@Override
protected void test() {
- for (int i = 0; i < queries.length; i++) {
- result.query(queries[i], null);
+ for (IQuery<IInstallableUnit> query : queries) {
+ result.query(query, null);
}
}
}.run(this, "Test query PublisherResult for " + IU_COUNT + " ius", REPEATS, 10);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java
index 7d0eb3bc6..d14302449 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java
@@ -49,9 +49,10 @@ public class AbsolutePlanTest extends AbstractProvisioningTest {
Operand[] ops = ((ProvisioningPlan) plan).getOperands();
boolean found = false;
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitPropertyOperand)
+ for (Operand op : ops) {
+ if (op instanceof InstallableUnitPropertyOperand) {
found = true;
+ }
}
assertTrue(found);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbstractPlannerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbstractPlannerTest.java
index ef69bc853..4ddd49bfb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbstractPlannerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbstractPlannerTest.java
@@ -64,10 +64,11 @@ public abstract class AbstractPlannerTest extends AbstractProvisioningTest {
protected Collection<InstallableUnitOperand> compress(IProvisioningPlan plan) {
Map<String, InstallableUnitOperand> result = new HashMap<>();
Operand[] operands = ((ProvisioningPlan) plan).getOperands();
- for (int i = 0; i < operands.length; i++) {
- if (!(operands[i] instanceof InstallableUnitOperand))
+ for (Operand oper : operands) {
+ if (!(oper instanceof InstallableUnitOperand)) {
continue;
- InstallableUnitOperand operand = (InstallableUnitOperand) operands[i];
+ }
+ InstallableUnitOperand operand = (InstallableUnitOperand) oper;
String id = operand.first() == null ? operand.second().getId() : operand.first().getId();
InstallableUnitOperand existing = result.get(id);
if (existing == null) {
@@ -171,19 +172,19 @@ public abstract class AbstractPlannerTest extends AbstractProvisioningTest {
// make sure the expected plan isn't empty
assertFalse("0.9 Plan is empty.", expectedOperands.length == 0);
- for (int outer = 0; outer < expectedOperands.length; outer++) {
- if (!(expectedOperands[outer] instanceof InstallableUnitOperand))
+ for (Operand expectedOperand : expectedOperands) {
+ if (!(expectedOperand instanceof InstallableUnitOperand)) {
continue;
- IInstallableUnit first = ((InstallableUnitOperand) expectedOperands[outer]).first();
- IInstallableUnit second = ((InstallableUnitOperand) expectedOperands[outer]).second();
-
+ }
+ IInstallableUnit first = ((InstallableUnitOperand) expectedOperand).first();
+ IInstallableUnit second = ((InstallableUnitOperand) expectedOperand).second();
// see if there is an operand in the actual plan which involved this IU.
boolean found = false;
- for (int inner = 0; inner < actualOperands.length; inner++) {
- if (!(actualOperands[inner] instanceof InstallableUnitOperand))
+ for (Operand actualOperand : actualOperands) {
+ if (!(actualOperand instanceof InstallableUnitOperand)) {
continue;
- InstallableUnitOperand actual = (InstallableUnitOperand) actualOperands[inner];
-
+ }
+ InstallableUnitOperand actual = (InstallableUnitOperand) actualOperand;
// handle removals
if (second == null) {
if (actual.second() != null)
@@ -193,7 +194,6 @@ public abstract class AbstractPlannerTest extends AbstractProvisioningTest {
// we are doing a removal and we have IUs with the same id... do they have the same version too?
assertEquals("0.5", first, actual.first());
}
-
// treat additions and updates the same as long as we end up with the same IU in the end
assertNotNull("1.2 " + actual, actual.second());
if (!actual.second().getId().equals(second.getId()))
@@ -201,7 +201,6 @@ public abstract class AbstractPlannerTest extends AbstractProvisioningTest {
// we are doing an install or upgrade and we have IUs with the same id... do they have the same version too?
assertEquals("2.0", second, actual.second());
found = true;
-
}
if (!found)
fail("3.0 Plan is missing install operand for: " + second);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300572.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300572.java
index 7153bd59e..0f55b25d1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300572.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300572.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.planner;
+import java.util.Arrays;
import java.util.Iterator;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
@@ -42,7 +43,7 @@ public class Bug300572 extends AbstractProvisioningTest {
//The following repo contains the second patch to be installed
IMetadataRepository repo = repoMgr.loadRepository(getTestData("bug300572 data", "testData/bug300572/repo/").toURI(), new NullProgressMonitor());
IInstallableUnit[] ius = repo.query(QueryUtil.createIUQuery("hellopatch.feature.group"), null).toArray(IInstallableUnit.class);
- System.out.println(ius);
+ System.out.println(Arrays.toString(ius));
IPlanner planner = agent.getService(IPlanner.class);
//The profile already contains a a feature (hellofeature) and a patch for it (hellopatch).
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug301446.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug301446.java
index e7028fb73..e8ab7a2fd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug301446.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug301446.java
@@ -61,8 +61,7 @@ public class Bug301446 extends AbstractPlannerTest {
// this is the plan that we expect - highest version only
Operand[] operands = ((ProvisioningPlan) actualPlan).getOperands();
- for (int i = 0; i < operands.length; i++) {
- Operand o = operands[i];
+ for (Operand o : operands) {
if (!(o instanceof InstallableUnitOperand))
continue;
IInstallableUnit iu = ((InstallableUnitOperand) o).second();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug302580.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug302580.java
index d17b03a60..ad0507f6c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug302580.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug302580.java
@@ -46,10 +46,9 @@ public class Bug302580 extends AbstractPlannerTest {
Operand ops[] = plan.getOperands();
String message = "The plan:\n";
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuo = (InstallableUnitOperand) ops[i];
-
+ for (Operand op : ops) {
+ if (op instanceof InstallableUnitOperand) {
+ InstallableUnitOperand iuo = (InstallableUnitOperand) op;
if (iuo.first() == null) {
message += iuo.second() + " will be installed\n";
}
@@ -63,10 +62,9 @@ public class Bug302580 extends AbstractPlannerTest {
}
System.out.println(message);
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuo = (InstallableUnitOperand) ops[i];
-
+ for (Operand op : ops) {
+ if (op instanceof InstallableUnitOperand) {
+ InstallableUnitOperand iuo = (InstallableUnitOperand) op;
if (iuo.second() == null) {
String id = iuo.first().getId();
if (id.equals("toolingorg.eclipse.equinox.launcher") || id.equals("toolingorg.eclipse.equinox.p2.reconciler.dropins") || id.equals("toolingorg.eclipse.equinox.simpleconfigurator")) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug309530.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug309530.java
index 69fc19366..822d473f7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug309530.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug309530.java
@@ -76,8 +76,7 @@ public class Bug309530 extends AbstractProvisioningTest {
ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile);
String[] ids = new String[] {"hi", "b"};
- for (int i = 0; i < ids.length; i++) {
- String id = ids[i];
+ for (String id : ids) {
IInstallableUnit iu = profile.query(QueryUtil.createIUQuery(id), new NullProgressMonitor()).iterator().next();
changeRequest.remove(iu);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java
index ac3919d53..635433a54 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java
@@ -156,8 +156,9 @@ public class TestArtifactRepository implements IArtifactRepository {
@Override
public void addDescriptors(IArtifactDescriptor[] descriptors, IProgressMonitor monitor) {
- for (int i = 0; i < descriptors.length; i++)
- addDescriptor(descriptors[i]);
+ for (IArtifactDescriptor descriptor : descriptors) {
+ addDescriptor(descriptor);
+ }
}
@Override
@@ -210,8 +211,8 @@ public class TestArtifactRepository implements IArtifactRepository {
try {
//plugin ID taken from TestActivator
MultiStatus overallStatus = new MultiStatus("org.eclipse.equinox.p2.test", IStatus.OK, null, null); //$NON-NLS-1$
- for (int i = 0; i < requests.length; i++) {
- overallStatus.add(getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1)));
+ for (IArtifactRequest request : requests) {
+ overallStatus.add(getArtifact((ArtifactRequest) request, subMonitor.newChild(1)));
}
return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus);
} finally {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java
index 3834b0038..66707af19 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java
@@ -93,9 +93,10 @@ public class AccumulateConfigDataActionTest extends ActionTest {
}
private void assertContainsSymbolicName(BundleInfo[] bundles, String symbolicName) {
- for (int i = 0; i < bundles.length; i++) {
- if (bundles[i].getSymbolicName().equals(symbolicName))
+ for (BundleInfo bundle : bundles) {
+ if (bundle.getSymbolicName().equals(symbolicName)) {
return;
+ }
}
fail();
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java
index 98140d005..6ee4cf48a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java
@@ -139,22 +139,22 @@ public abstract class ActionTest extends AbstractProvisioningTest {
}
protected Map<String, Object[]> getFileMap(Map<String, Object[]> map, File[] files, Path root) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory())
- map = getFileMap(map, files[i].listFiles(), root);
- else {
- if (files[i].getPath().endsWith(JAR))
+ for (File file : files) {
+ if (file.isDirectory()) {
+ map = getFileMap(map, file.listFiles(), root);
+ } else {
+ if (file.getPath().endsWith(JAR)) {
continue;
+ }
try {
ByteArrayOutputStream content = new ByteArrayOutputStream();
- File contentBytes = files[i];
+ File contentBytes = file;
FileUtils.copyStream(new FileInputStream(contentBytes), false, content, true);
-
- IPath entryPath = new Path(files[i].getAbsolutePath());
+ IPath entryPath = new Path(file.getAbsolutePath());
entryPath = entryPath.removeFirstSegments(root.matchingFirstSegments(entryPath));
entryPath = entryPath.setDevice(null);
map.put(entryPath.toString(), new Object[] {contentBytes, content.toByteArray()});
- } catch (IOException e) {
+ }catch (IOException e) {
e.printStackTrace();
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java
index 55339d8e1..531fafeca 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java
@@ -115,9 +115,10 @@ public class CategoryPublisherTest extends AbstractProvisioningTest {
assertTrue(directory.exists());
assertTrue(directory.isDirectory());
File[] listFiles = directory.listFiles();
- for (int i = 0; i < listFiles.length; i++) {
- if (listFiles[i].getName().equals(file))
+ for (File listFile : listFiles) {
+ if (listFile.getName().equals(file)) {
return;
+ }
}
fail("Directory does not contain file: " + file);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java
index 89e05bacf..15a57843b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java
@@ -276,8 +276,9 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest {
public void add(String message, String target, File[] files) {
assertNotNull(files);
- for (int i = 0; i < files.length; i++)
- add(message, target, files[i]);
+ for (File file : files) {
+ add(message, target, file);
+ }
}
/*
@@ -298,8 +299,9 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest {
*/
public void remove(String message, String target, String[] names) {
assertNotNull(names);
- for (int i = 0; i < names.length; i++)
- remove(message, target, names[i]);
+ for (String name : names) {
+ remove(message, target, name);
+ }
}
/*
@@ -427,8 +429,7 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest {
boolean leaveDirty = Boolean.parseBoolean(TestActivator.getContext().getProperty("p2.tests.doNotClean"));
if (leaveDirty)
return;
- for (Iterator<File> iter = toRemove.iterator(); iter.hasNext();) {
- File next = iter.next();
+ for (File next : toRemove) {
delete(next);
}
output = null;
@@ -511,8 +512,9 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest {
result.setUpdateable(updateable);
result.setUrl(uri);
if (plugins != null)
- for (int i = 0; i < plugins.length; i++)
- result.addPlugin(plugins[i]);
+ for (String plugin : plugins) {
+ result.addPlugin(plugin);
+ }
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractSharedBundleProductTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractSharedBundleProductTest.java
index 914ed14e7..2a220009d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractSharedBundleProductTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractSharedBundleProductTest.java
@@ -103,8 +103,8 @@ public class AbstractSharedBundleProductTest extends AbstractReconcilerTest {
}
// just add the bootstrap bundles into the result before returning
- for (int i = 0; i < bootstrap.length; i++) {
- BundleInfo info = map.get(bootstrap[i]);
+ for (String bundle : bootstrap) {
+ BundleInfo info = map.get(bundle);
if (info != null)
result.put(info.getSymbolicName(), info);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest.java
index 43fc1ec8f..fcdbc7467 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest.java
@@ -74,10 +74,10 @@ public class ProfileSynchronizerTest extends AbstractProvisioningTest {
private void initializeReconciler() throws IllegalAccessException {
Field[] fields = org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.class.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- if (fields[i].getName().equals("bundleContext")) {
- fields[i].setAccessible(true);
- fields[i].set(org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.class, TestActivator.getContext());
+ for (Field field : fields) {
+ if (field.getName().equals("bundleContext")) {
+ field.setAccessible(true);
+ field.set(org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.class, TestActivator.getContext());
break;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest2.java
index 98c4a3875..2e87190ab 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest2.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ProfileSynchronizerTest2.java
@@ -73,10 +73,10 @@ public class ProfileSynchronizerTest2 extends AbstractProvisioningTest {
//We need to initialize the reconciler this way to bypass the automatic reconciliation that happens when the bundle is started
private void initializeReconciler() throws IllegalAccessException {
Field[] fields = org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.class.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- if (fields[i].getName().equals("bundleContext")) {
- fields[i].setAccessible(true);
- fields[i].set(org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.class, TestActivator.getContext());
+ for (Field field : fields) {
+ if (field.getName().equals("bundleContext")) {
+ field.setAccessible(true);
+ field.set(org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.class, TestActivator.getContext());
break;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
index 4debb8c51..e2450b54c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
@@ -46,11 +46,11 @@ public abstract class AbstractSimpleConfiguratorTest extends AbstractProvisionin
//Assert that all files are in the bundles
protected void assertJarsInstalled(File[] jars, Bundle[] bundles) {
- for (int i = 0; i < jars.length; i++) {
+ for (File jar : jars) {
boolean found = false;
- String jarName = getManifestEntry(jars[i], Constants.BUNDLE_SYMBOLICNAME);
- for (int j = 0; j < bundles.length; j++) {
- String bundleName = bundles[j].getSymbolicName();
+ String jarName = getManifestEntry(jar, Constants.BUNDLE_SYMBOLICNAME);
+ for (Bundle bundle : bundles) {
+ String bundleName = bundle.getSymbolicName();
if (bundleName.equalsIgnoreCase(jarName))
found = true;
}
@@ -122,8 +122,7 @@ public abstract class AbstractSimpleConfiguratorTest extends AbstractProvisionin
try (BufferedWriter bundlesTxtOut = new BufferedWriter(new FileWriter(bundlesTxt))) {
- for (int i = 0; i < jars.length; i++) {
- File bundleJar = jars[i];
+ for (File bundleJar : jars) {
bundlesTxtOut.write(getBundlesTxtEntry(bundleJar) + "\n");
}
bundlesTxtOut.write(getBundlesTxtEntry(getLocation("org.eclipse.equinox.simpleconfigurator")) + "\n");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/testserver/helper/TestServerController.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/testserver/helper/TestServerController.java
index 568c6297b..a95d85bac 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/testserver/helper/TestServerController.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/testserver/helper/TestServerController.java
@@ -44,8 +44,7 @@ public class TestServerController {
Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
if (bundles == null)
return null;
- for (int i = 0; i < bundles.length; i++) {
- Bundle bundle = bundles[i];
+ for (Bundle bundle : bundles) {
if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0)
return bundle;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java
index 547f75097..efaf5cb37 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java
@@ -89,9 +89,10 @@ public class AddSourceBundleActionTest extends AbstractProvisioningTest {
private boolean inBundles(SourceManipulator manipulator, File osgiTarget) throws IOException {
URI location = osgiTarget.toURI();
BundleInfo[] bundles = manipulator.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (location.equals(bundles[i].getLocation()))
+ for (BundleInfo bundle : bundles) {
+ if (location.equals(bundle.getLocation())) {
return true;
+ }
}
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java
index 77c01e7ef..38f720e92 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java
@@ -85,9 +85,10 @@ public class CollectActionTest extends AbstractProvisioningTest {
private boolean hasRequest(List<IArtifactRequest[]> requests, IArtifactKey key) {
for (IArtifactRequest[] request : requests) {
- for (int i = 0; i < request.length; i++) {
- if (key.equals(request[i].getArtifactKey()))
+ for (IArtifactRequest req : request) {
+ if (key.equals(req.getArtifactKey())) {
return true;
+ }
}
}
return false;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java
index 4467ebe1a..658f07cb1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java
@@ -90,9 +90,10 @@ public class InstallBundleActionTest extends AbstractProvisioningTest {
private boolean inBundles(Manipulator manipulator, File osgiTarget) {
URI location = osgiTarget.toURI();
BundleInfo[] bundles = manipulator.getConfigData().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (location.equals(bundles[i].getLocation()))
+ for (BundleInfo bundle : bundles) {
+ if (location.equals(bundle.getLocation())) {
return true;
+ }
}
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java
index 50b6ed14f..f38e68e00 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java
@@ -188,9 +188,10 @@ public class MarkStartedActionTest extends AbstractProvisioningTest {
private boolean isMarkedStarted(Manipulator manipulator, File osgiTarget, boolean started) {
URI location = osgiTarget.toURI();
BundleInfo[] bundles = manipulator.getConfigData().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (location.equals(bundles[i].getLocation()) && (started == bundles[i].isMarkedAsStarted()))
+ for (BundleInfo bundle : bundles) {
+ if (location.equals(bundle.getLocation()) && (started == bundle.isMarkedAsStarted())) {
return true;
+ }
}
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java
index c683d9fc5..116020495 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java
@@ -90,9 +90,10 @@ public class RemoveSourceBundleActionTest extends AbstractProvisioningTest {
private boolean inBundles(SourceManipulator manipulator, File osgiTarget) throws IOException {
URI location = osgiTarget.toURI();
BundleInfo[] bundles = manipulator.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (location.equals(bundles[i].getLocation()))
+ for (BundleInfo bundle : bundles) {
+ if (location.equals(bundle.getLocation())) {
return true;
+ }
}
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java
index 7a94a3e0b..e74e0a26f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java
@@ -188,9 +188,10 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest {
private boolean isStartLevel(Manipulator manipulator, File osgiTarget, int startLevel) {
URI location = osgiTarget.toURI();
BundleInfo[] bundles = manipulator.getConfigData().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (location.equals(bundles[i].getLocation()) && (startLevel == bundles[i].getStartLevel()))
+ for (BundleInfo bundle : bundles) {
+ if (location.equals(bundle.getLocation()) && (startLevel == bundle.getStartLevel())) {
return true;
+ }
}
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java
index fafe1101f..07b9cee0f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java
@@ -92,9 +92,10 @@ public class UninstallBundleActionTest extends AbstractProvisioningTest {
private boolean inBundles(Manipulator manipulator, File osgiTarget) {
URI location = osgiTarget.toURI();
BundleInfo[] bundles = manipulator.getConfigData().getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (location.equals(bundles[i].getLocation()))
+ for (BundleInfo bundle : bundles) {
+ if (location.equals(bundle.getLocation())) {
return true;
+ }
}
return false;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java
index d92727fef..9b88d9458 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/BackupStoreTest.java
@@ -85,9 +85,11 @@ public class BackupStoreTest extends AbstractProvisioningTest {
return true;
if (file.isDirectory()) {
File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++)
- if (!fullyDelete(new File(file, children[i].getName())))
+ for (File child : children) {
+ if (!fullyDelete(new File(file, child.getName()))) {
return false;
+ }
+ }
}
return file.delete();
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java
index 41b2780da..81b391781 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java
@@ -76,9 +76,10 @@ public class CollectActionTest extends AbstractProvisioningTest {
private boolean hasRequest(List<IArtifactRequest[]> requests, IArtifactKey key) {
for (IArtifactRequest[] request : requests) {
- for (int i = 0; i < request.length; i++) {
- if (key.equals(request[i].getArtifactKey()))
+ for (IArtifactRequest req : request) {
+ if (key.equals(req.getArtifactKey())) {
return true;
+ }
}
}
return false;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java
index 09a97a01a..368e46f9f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java
@@ -742,8 +742,8 @@ public class UpdateSiteTest extends AbstractProvisioningTest {
assertNotNull(metadataRepoMan);
URI[] knownRepos = metadataRepoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < knownRepos.length; i++) {
- if (siteURI.equals(knownRepos[i])) {
+ for (URI knownRepo : knownRepos) {
+ if (siteURI.equals(knownRepo)) {
metadataRepoMan.removeRepository(siteURI);
knownRepos = metadataRepoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
break;
@@ -768,8 +768,8 @@ public class UpdateSiteTest extends AbstractProvisioningTest {
assertNotNull(artifactRepoMan);
URI[] knownRepos = artifactRepoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < knownRepos.length; i++) {
- if (siteURI.equals(knownRepos[i])) {
+ for (URI knownRepo : knownRepos) {
+ if (siteURI.equals(knownRepo)) {
artifactRepoMan.removeRepository(siteURI);
knownRepos = artifactRepoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
break;

Back to the top