Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-09-25 16:03:53 -0400
committerAlexander Kurtakov2019-10-16 01:16:52 -0400
commitd312e0b88e54d9277d335ba1d8fe9f54cfd9721e (patch)
tree64d3903d7f4af98837241cc4d120ec978a271e5b
parent79098619b63c156419bfc0adfb62c728e446f1c5 (diff)
downloadrt.equinox.p2-d312e0b88e54d9277d335ba1d8fe9f54cfd9721e.tar.gz
rt.equinox.p2-d312e0b88e54d9277d335ba1d8fe9f54cfd9721e.tar.xz
rt.equinox.p2-d312e0b88e54d9277d335ba1d8fe9f54cfd9721e.zip
Use jdk 5 for-each loopI20191016-1800
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: Ic763650ff6fc45428428785905afbf3ebab7dc3d Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java22
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java35
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java30
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java4
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java7
-rw-r--r--bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java6
6 files changed, 57 insertions, 47 deletions
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java
index c0bdec0d2..fc71707bf 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/AbstractFwkAdminTest.java
@@ -16,6 +16,7 @@ package org.eclipse.equinox.frameworkadmin.tests;
import java.io.*;
import java.net.URI;
import java.net.URL;
+import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import junit.framework.TestCase;
@@ -69,8 +70,9 @@ public abstract class AbstractFwkAdminTest extends TestCase {
return true;
if (file.isDirectory()) {
File[] children = file.listFiles();
- for (int i = 0; i < children.length; i++)
- delete(children[i]);
+ for (File child : children) {
+ delete(child);
+ }
}
return file.delete();
}
@@ -238,7 +240,7 @@ public abstract class AbstractFwkAdminTest extends TestCase {
if (array1 == null || array2 == null) {
if (array1 == array2)
return;
- fail(array1 + " not equal to " + array2);
+ fail(Arrays.toString(array1) + " not equal to " + Arrays.toString(array2));
}
assertEquals(array1.length, array2.length);
for (int i = 0; i < array1.length; i++) {
@@ -313,8 +315,9 @@ public abstract class AbstractFwkAdminTest extends TestCase {
if (!target.exists())
target.mkdirs();
File[] children = source.listFiles();
- 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));
@@ -368,8 +371,8 @@ public abstract class AbstractFwkAdminTest extends TestCase {
location.getParentFile().mkdirs();
try (BufferedWriter bw = new BufferedWriter(new FileWriter(location))){
- for (int j = 0; j < lines.length; j++) {
- bw.write(lines[j]);
+ for (String line : lines) {
+ bw.write(line);
bw.newLine();
}
bw.flush();
@@ -400,9 +403,10 @@ public abstract class AbstractFwkAdminTest extends TestCase {
}
public void assertContains(String message, BundleInfo[] bundles, URI location) {
- for (int i = 0; i < bundles.length; i++) {
- if (bundles[i].getLocation().equals(location))
+ for (BundleInfo bundle : bundles) {
+ if (bundle.getLocation().equals(location)) {
return;
+ }
}
fail(message + " Can't find the bundle info " + location);
}
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java
index 568553abb..878c6310b 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/CleanupTest.java
@@ -37,9 +37,10 @@ public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest {
public void testSimpleConfiguratorRemoval() {
BundleInfo[] bis = m.getConfigData().getBundles();
- for (int i = 0; i < bis.length; i++) {
- if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator"))
- m.getConfigData().removeBundle(bis[i]);
+ for (BundleInfo bi : bis) {
+ if (bi.getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) {
+ m.getConfigData().removeBundle(bi);
+ }
}
try {
m.save(false);
@@ -51,9 +52,10 @@ public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest {
//Now remove osgi
bis = m.getConfigData().getBundles();
- for (int i = 0; i < bis.length; i++) {
- if (bis[i].getSymbolicName().equals("org.eclipse.osgi"))
- m.getConfigData().removeBundle(bis[i]);
+ for (BundleInfo bi : bis) {
+ if (bi.getSymbolicName().equals("org.eclipse.osgi")) {
+ m.getConfigData().removeBundle(bi);
+ }
}
try {
m.save(false);
@@ -66,9 +68,10 @@ public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest {
public void testOSGiRemoval() {
BundleInfo[] bis = m.getConfigData().getBundles();
- for (int i = 0; i < bis.length; i++) {
- if (bis[i].getSymbolicName().equals("org.eclipse.osgi"))
- m.getConfigData().removeBundle(bis[i]);
+ for (BundleInfo bi : bis) {
+ if (bi.getSymbolicName().equals("org.eclipse.osgi")) {
+ m.getConfigData().removeBundle(bi);
+ }
}
try {
m.save(false);
@@ -80,9 +83,10 @@ public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest {
assertNotContent(new File(getConfigurationFolder(), "org.eclipse.equinox.simpleconfigurator/bundles.info"), "org.eclipse.osgi");
bis = m.getConfigData().getBundles();
- for (int i = 0; i < bis.length; i++) {
- if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator"))
- m.getConfigData().removeBundle(bis[i]);
+ for (BundleInfo bi : bis) {
+ if (bi.getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) {
+ m.getConfigData().removeBundle(bi);
+ }
}
try {
m.save(false);
@@ -99,9 +103,10 @@ public class CleanupTest extends FwkAdminAndSimpleConfiguratorTest {
m.save(false);
BundleInfo[] bis = m.getConfigData().getBundles();
- for (int i = 0; i < bis.length; i++) {
- if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator"))
- m.getConfigData().removeBundle(bis[i]);
+ for (BundleInfo bi1 : bis) {
+ if (bi1.getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) {
+ m.getConfigData().removeBundle(bi1);
+ }
}
m.save(false);
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java
index 1812d4f3a..ea24a2f6d 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/OSGiVersionChange.java
@@ -39,9 +39,9 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
public void testRemovalUsingSameManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException {
BundleInfo[] infos = defaultManipulator.getConfigData().getBundles();
BundleInfo osgi = null;
- for (int i = 0; i < infos.length; i++) {
- if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) {
- osgi = infos[i];
+ for (BundleInfo info : infos) {
+ if ("org.eclipse.osgi".equals(info.getSymbolicName())) {
+ osgi = info;
break;
}
}
@@ -55,9 +55,9 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
Manipulator newManipulator = getNewManipulator(workArea);
BundleInfo[] infos = newManipulator.getConfigData().getBundles();
BundleInfo osgi = null;
- for (int i = 0; i < infos.length; i++) {
- if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) {
- osgi = infos[i];
+ for (BundleInfo info : infos) {
+ if ("org.eclipse.osgi".equals(info.getSymbolicName())) {
+ osgi = info;
break;
}
}
@@ -70,9 +70,9 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
public void testAdditionUsingOtherManipulator() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, BundleException {
BundleInfo[] infos = defaultManipulator.getConfigData().getBundles();
BundleInfo osgi = null;
- for (int i = 0; i < infos.length; i++) {
- if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) {
- osgi = infos[i];
+ for (BundleInfo info : infos) {
+ if ("org.eclipse.osgi".equals(info.getSymbolicName())) {
+ osgi = info;
break;
}
}
@@ -90,9 +90,9 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
public void testChangeVersion() throws IllegalStateException, FrameworkAdminRuntimeException, IOException, URISyntaxException {
BundleInfo[] infos = defaultManipulator.getConfigData().getBundles();
BundleInfo osgi = null;
- for (int i = 0; i < infos.length; i++) {
- if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) {
- osgi = infos[i];
+ for (BundleInfo info : infos) {
+ if ("org.eclipse.osgi".equals(info.getSymbolicName())) {
+ osgi = info;
break;
}
}
@@ -113,9 +113,9 @@ public class OSGiVersionChange extends FwkAdminAndSimpleConfiguratorTest {
//First Create a configuration that does not contain OSGi
BundleInfo[] infos = defaultManipulator.getConfigData().getBundles();
BundleInfo osgi = null;
- for (int i = 0; i < infos.length; i++) {
- if ("org.eclipse.osgi".equals(infos[i].getSymbolicName())) {
- osgi = infos[i];
+ for (BundleInfo info : infos) {
+ if ("org.eclipse.osgi".equals(info.getSymbolicName())) {
+ osgi = info;
break;
}
}
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java
index 24e9318e1..2d933b977 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/RemovingAllBundles.java
@@ -70,8 +70,8 @@ public class RemovingAllBundles extends AbstractFwkAdminTest {
}
BundleInfo[] infos = m2.getConfigData().getBundles();
- for (int i = 0; i < infos.length; i++) {
- m2.getConfigData().removeBundle(infos[i]);
+ for (BundleInfo info : infos) {
+ m2.getConfigData().removeBundle(info);
}
m2.save(false);
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java
index d29b5996e..0b39fe925 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SimpleConfiguratorComingAndGoing.java
@@ -41,9 +41,10 @@ public class SimpleConfiguratorComingAndGoing extends FwkAdminAndSimpleConfigura
m.save(false);
BundleInfo[] bis = m.getConfigData().getBundles();
- for (int i = 0; i < bis.length; i++) {
- if (bis[i].getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator"))
- m.getConfigData().removeBundle(bis[i]);
+ for (BundleInfo bi1 : bis) {
+ if (bi1.getSymbolicName().equals("org.eclipse.equinox.simpleconfigurator")) {
+ m.getConfigData().removeBundle(bi1);
+ }
}
m.save(false);
diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java
index fdaa37232..c1cb1f42b 100644
--- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java
+++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/TestRunningInstance.java
@@ -36,13 +36,13 @@ public class TestRunningInstance extends AbstractFwkAdminTest {
Bundle[] bundles = Activator.getContext().getBundles();
assertEquals(bundles.length, infos.length);
- for (int i = 0; i < bundles.length; i++) {
+ for (Bundle bundle : bundles) {
boolean found = false;
for (int j = 0; j < infos.length && found == false; j++) {
- found = same(infos[j], bundles[i]);
+ found = same(infos[j], bundle);
}
if (found == false) {
- fail("Can't find: " + bundles[i]);
+ fail("Can't find: " + bundle);
}
}
}

Back to the top