diff options
author | Carsten Hammer | 2019-06-17 20:44:58 +0000 |
---|---|---|
committer | Thomas Watson | 2019-07-15 13:10:24 +0000 |
commit | 20f0afb5895ee5019e3c9a1b5107456c5485694e (patch) | |
tree | 77e9c5476ae7cac3c9dc90197485f9fbabb833c2 /bundles/org.eclipse.osgi.tests/src/org/eclipse | |
parent | 5595b19ec459226e5fe38f8d39c71e1f72efab75 (diff) | |
download | rt.equinox.framework-20f0afb5895ee5019e3c9a1b5107456c5485694e.tar.gz rt.equinox.framework-20f0afb5895ee5019e3c9a1b5107456c5485694e.tar.xz rt.equinox.framework-20f0afb5895ee5019e3c9a1b5107456c5485694e.zip |
Use jdk 5 for-each loopY20190722-0900Y20190718-0905Y20190718-0450Y20190715-2335I20190722-1800I20190721-1800I20190720-1800I20190719-1800I20190718-1800I20190717-1800I20190716-1800I20190715-1800
Replace simple uses of Iterator with a corresponding for-loop. Also add
missing braces on loops as necessary.
Change-Id: I97b9a58053098327f05ac48338486ed40144b987
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/src/org/eclipse')
51 files changed, 569 insertions, 530 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java index 00420aac7..3fc7203bc 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/appadmin/ApplicationAdminTest.java @@ -44,8 +44,9 @@ public class ApplicationAdminTest extends OSGiTest { ConfigurationSessionTestSuite appAdminSessionTest = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, ApplicationAdminTest.class.getName()); String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) - appAdminSessionTest.addBundle(ids[i]); + for (String id : ids) { + appAdminSessionTest.addBundle(id); + } appAdminSessionTest.addBundle(PI_OSGI_UTIL); appAdminSessionTest.addBundle(PI_OSGI_SERVICES); appAdminSessionTest.addBundle(PI_OSGI_TESTS); @@ -56,8 +57,9 @@ public class ApplicationAdminTest extends OSGiTest { throw new RuntimeException(e); } // we add tests the hard way so we can control the order of the tests. - for (int i = 0; i < tests.length; i++) - appAdminSessionTest.addTest(new ApplicationAdminTest(tests[i])); + for (String test : tests) { + appAdminSessionTest.addTest(new ApplicationAdminTest(test)); + } suite.addTest(appAdminSessionTest); return suite; } @@ -1164,8 +1166,9 @@ public class ApplicationAdminTest extends OSGiTest { if (foundEvents.length > 0) { StringBuilder eventsBuffer = new StringBuilder(); eventsBuffer.append("\nFound the following events: \n"); //$NON-NLS-1$ - for (int i = 0; i < foundEvents.length; i++) - eventsBuffer.append(" handle event: ").append(foundEvents[i][0]).append(" ").append(foundEvents[i][1]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + for (Object[] foundEvent : foundEvents) { + eventsBuffer.append(" handle event: ").append(foundEvent[0]).append(" ").append(foundEvent[1]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } foundEventsMsg = eventsBuffer.toString(); } else { foundEventsMsg = "\nNo events recorded"; //$NON-NLS-1$ @@ -1243,8 +1246,9 @@ public class ApplicationAdminTest extends OSGiTest { if (foundEvents.length > 0) { StringBuilder eventsBuffer = new StringBuilder(); eventsBuffer.append("\nFound the following events: \n"); //$NON-NLS-1$ - for (int i = 0; i < foundEvents.length; i++) - eventsBuffer.append(" descriptor event: ").append(foundEvents[i][0]).append(" ").append(foundEvents[i][1]).append(" ").append(foundEvents[i][2]).append(" ").append(foundEvents[i][3]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + for (Object[] foundEvent : foundEvents) { + eventsBuffer.append(" descriptor event: ").append(foundEvent[0]).append(" ").append(foundEvent[1]).append(" ").append(foundEvent[2]).append(" ").append(foundEvent[3]).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + } foundEventsMsg = eventsBuffer.toString(); } else { foundEventsMsg = "\nNo events recorded"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java index 586237f20..1b28ff4fd 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java @@ -1028,44 +1028,44 @@ public class ClassLoadingBundleTests extends AbstractBundleTests { urls[1] = test.getEntry("a/b/c/d"); //$NON-NLS-1$ assertNotNull("resource", urls[0]); //$NON-NLS-1$ assertNotNull("entry", urls[1]); //$NON-NLS-1$ - for (int i = 0; i < urls.length; i++) { - URL testURL = new URL(urls[i], "g"); //$NON-NLS-1$ + for (URL url : urls) { + URL testURL = new URL(url, "g"); //$NON-NLS-1$ assertEquals("g", "/a/b/c/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "./g"); //$NON-NLS-1$ + testURL = new URL(url, "./g"); //$NON-NLS-1$ assertEquals("./g", "/a/b/c/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "g/"); //$NON-NLS-1$ + testURL = new URL(url, "g/"); //$NON-NLS-1$ assertEquals("g/", "/a/b/c/g/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "/g"); //$NON-NLS-1$ + testURL = new URL(url, "/g"); //$NON-NLS-1$ assertEquals("/g", "/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "?y"); //$NON-NLS-1$ + testURL = new URL(url, "?y"); //$NON-NLS-1$ assertEquals("?y", "/a/b/c/?y", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "g?y"); //$NON-NLS-1$ + testURL = new URL(url, "g?y"); //$NON-NLS-1$ assertEquals("g?y", "/a/b/c/g?y", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "g#s"); //$NON-NLS-1$ + testURL = new URL(url, "g#s"); //$NON-NLS-1$ assertEquals("g#s", "/a/b/c/g#s", testURL.getPath() + "#s"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - testURL = new URL(urls[i], "g?y#s"); //$NON-NLS-1$ + testURL = new URL(url, "g?y#s"); //$NON-NLS-1$ assertEquals("g?y#s", "/a/b/c/g?y#s", testURL.getPath() + "#s"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - testURL = new URL(urls[i], ";x"); //$NON-NLS-1$ + testURL = new URL(url, ";x"); //$NON-NLS-1$ assertEquals(";x", "/a/b/c/;x", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "g;x"); //$NON-NLS-1$ + testURL = new URL(url, "g;x"); //$NON-NLS-1$ assertEquals("g;x", "/a/b/c/g;x", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "g;x?y#s"); //$NON-NLS-1$ + testURL = new URL(url, "g;x?y#s"); //$NON-NLS-1$ assertEquals("g;x?y#s", "/a/b/c/g;x?y#s", testURL.getPath() + "#s"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - testURL = new URL(urls[i], "."); //$NON-NLS-1$ + testURL = new URL(url, "."); //$NON-NLS-1$ assertEquals(".", "/a/b/c/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "./"); //$NON-NLS-1$ + testURL = new URL(url, "./"); //$NON-NLS-1$ assertEquals("./", "/a/b/c/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], ".."); //$NON-NLS-1$ + testURL = new URL(url, ".."); //$NON-NLS-1$ assertEquals("..", "/a/b/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "../"); //$NON-NLS-1$ + testURL = new URL(url, "../"); //$NON-NLS-1$ assertEquals("../", "/a/b/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "../g"); //$NON-NLS-1$ + testURL = new URL(url, "../g"); //$NON-NLS-1$ assertEquals("../g", "/a/b/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "../.."); //$NON-NLS-1$ + testURL = new URL(url, "../.."); //$NON-NLS-1$ assertEquals("../..", "/a/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "../../"); //$NON-NLS-1$ + testURL = new URL(url, "../../"); //$NON-NLS-1$ assertEquals("../../", "/a/", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ - testURL = new URL(urls[i], "../../g"); //$NON-NLS-1$ + testURL = new URL(url, "../../g"); //$NON-NLS-1$ assertEquals("../../g", "/a/g", testURL.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java index 556c7e235..c0e582016 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java @@ -319,8 +319,9 @@ public class PackageAdminBundleTests extends AbstractBundleTests { private String getMessage(Throwable[] results) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); - for (int i = 0; i < results.length; i++) - results[i].printStackTrace(pw); + for (Throwable result : results) { + result.printStackTrace(pw); + } return sw.toString(); } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java index 8d56e7d6b..54796c412 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SubstituteExportsBundleTests.java @@ -309,11 +309,11 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests { } String[] unexpectedClasseNames = new String[] {"substitutes.x.Jx", "substitutes.x.Lx", "substitutes.x.Nx", "substitutes.y.Jy", "substitutes.y.Ly", "substitutes.y.Ny"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - for (int i = 0; i < unexpectedClasseNames.length; i++) { - for (int j = 0; j < allBundles.length; j++) { + for (String unexpectedClasseName : unexpectedClasseNames) { + for (Bundle bundle : allBundles) { try { - Class found = allBundles[j].loadClass(unexpectedClasseNames[i]); - fail("Found class " + found + " in bundle " + allBundles[j]); //$NON-NLS-1$//$NON-NLS-2$ + Class found = bundle.loadClass(unexpectedClasseName); + fail("Found class " + found + " in bundle " + bundle); //$NON-NLS-1$//$NON-NLS-2$ } catch (ClassNotFoundException cnfe) { // expected } @@ -402,11 +402,11 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests { } String[] unexpectedClasseNames = new String[] {"substitutes.x.Ix", "substitutes.x.Kx", "substitutes.x.Mx", "substitutes.y.Iy", "substitutes.y.Ky", "substitutes.y.My"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - for (int i = 0; i < unexpectedClasseNames.length; i++) { - for (int j = 0; j < allBundles.length; j++) { + for (String unexpectedClasseName : unexpectedClasseNames) { + for (Bundle bundle : allBundles) { try { - Class found = allBundles[j].loadClass(unexpectedClasseNames[i]); - fail("Found class " + found + " in bundle " + allBundles[j]); //$NON-NLS-1$//$NON-NLS-2$ + Class found = bundle.loadClass(unexpectedClasseName); + fail("Found class " + found + " in bundle " + bundle); //$NON-NLS-1$//$NON-NLS-2$ } catch (ClassNotFoundException cnfe) { // expected } @@ -472,12 +472,14 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests { private void doRefreshTest(Bundle[] allBundles, Bundle toRefresh) { installer.resolveBundles(allBundles); Bundle[] refreshed = installer.refreshPackages(new Bundle[] {toRefresh}); - for (int i = 0; i < allBundles.length; i++) { + for (Bundle allBundle : allBundles) { boolean found = false; - for (int j = 0; j < refreshed.length && !found; j++) - found = allBundles[i] == refreshed[j]; - if (!found) - fail("bundle did not get refreshed: " + allBundles[i]); //$NON-NLS-1$ + for (int j = 0; j < refreshed.length && !found; j++) { + found = allBundle == refreshed[j]; + } + if (!found) { + fail("bundle did not get refreshed: " + allBundle); //$NON-NLS-1$ + } } assertEquals("Wrong number of bundles refreshed", allBundles.length, refreshed.length); //$NON-NLS-1$ } @@ -509,9 +511,9 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests { assertEquals("Wrong number of yImporters", 3, yImporters.length); //$NON-NLS-1$ Bundle[] expectedImporters = new Bundle[] {b, c, d}; - for (int i = 0; i < expectedImporters.length; i++) { - contains("xPackages importers does not contain", xImporters, expectedImporters[i]); //$NON-NLS-1$ - contains("yPackages importers does not contain", yImporters, expectedImporters[i]); //$NON-NLS-1$ + for (Bundle expectedImporter : expectedImporters) { + contains("xPackages importers does not contain", xImporters, expectedImporter); //$NON-NLS-1$ + contains("yPackages importers does not contain", yImporters, expectedImporter); //$NON-NLS-1$ } } @@ -538,27 +540,28 @@ public class SubstituteExportsBundleTests extends AbstractBundleTests { assertEquals("yPackages wrong number", 3, yPackages.length); //$NON-NLS-1$ Bundle[] expectedExporters = new Bundle[] {iBundle, kBundle, mBundle}; - for (int i = 0; i < expectedExporters.length; i++) { + for (Bundle expectedExporter : expectedExporters) { boolean found = false; for (int j = 0; j < xPackages.length && !found; j++) { - found = expectedExporters[i] == xPackages[j].getExportingBundle(); + found = expectedExporter == xPackages[j].getExportingBundle(); if (found) { Bundle[] importingBundles = xPackages[j].getImportingBundles(); Bundle[] expectedImporters = null; String message = null; - if (expectedExporters[i] == iBundle) { + if (expectedExporter == iBundle) { expectedImporters = new Bundle[] {jBundle, mBundle, nBundle, pBundle, qBundle}; message = "iBundle "; //$NON-NLS-1$ - } else if (expectedExporters[i] == kBundle) { + } else if (expectedExporter == kBundle) { expectedImporters = new Bundle[] {lBundle, mBundle, nBundle, pBundle, qBundle}; message = "kBundle "; //$NON-NLS-1$ - } else if (expectedExporters[i] == mBundle) { + } else if (expectedExporter == mBundle) { expectedImporters = new Bundle[] {nBundle, pBundle, qBundle}; message = "mBundle "; //$NON-NLS-1$ } assertEquals(message, expectedImporters.length, importingBundles.length); - for (int k = 0; k < expectedImporters.length; k++) - contains(message, importingBundles, expectedImporters[k]); + for (Bundle expectedImporter : expectedImporters) { + contains(message, importingBundles, expectedImporter); + } } } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java index b159cddff..ceb80c2fe 100755 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java @@ -1133,10 +1133,10 @@ public class SystemBundleTests extends AbstractBundleTests { } catch (IOException e) { fail("Unexpected error creating budnles", e); //$NON-NLS-1$ } - for (int i = 0; i < testBundles.length; i++) { + for (File testBundle : testBundles) { try { - systemContext.installBundle("reference:file:///" + testBundles[i].getAbsolutePath()); //$NON-NLS-1$ - } catch (BundleException e) { + systemContext.installBundle("reference:file:///" + testBundle.getAbsolutePath()); //$NON-NLS-1$ + }catch (BundleException e) { fail("Unexpected install error", e); //$NON-NLS-1$ } } @@ -1219,8 +1219,8 @@ public class SystemBundleTests extends AbstractBundleTests { Bundle[] bundles = context.getBundles(); // get an entry from each bundle to ensure each one gets opened. try { - for (int i = 0; i < bundles.length; i++) { - assertNotNull("No manifest for: " + bundles[i], bundles[i].getEntry("/META-INF/MANIFEST.MF")); + for (Bundle bundle : bundles) { + assertNotNull("No manifest for: " + bundle, bundle.getEntry("/META-INF/MANIFEST.MF")); } } catch (Throwable t) { // An exception used to get thrown here when we tried to close @@ -1587,8 +1587,8 @@ public class SystemBundleTests extends AbstractBundleTests { Bundle[] bundles = systemContext.getBundles(); // get the headers from each bundle try { - for (int i = 0; i < bundles.length; i++) { - bundles[i].getHeaders(); //$NON-NLS-1$ + for (Bundle bundle : bundles) { + bundle.getHeaders(); //$NON-NLS-1$ } } catch (Throwable t) { // An exception used to get thrown here when we tried to close @@ -3798,8 +3798,7 @@ public class SystemBundleTests extends AbstractBundleTests { ExecutorService executor = Executors.newFixedThreadPool(50); final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>(); try { - for (int i = 0; i < testBundles.length; i++) { - final File testBundleFile = testBundles[i]; + for (final File testBundleFile : testBundles) { executor.execute(new Runnable() { @Override @@ -3812,7 +3811,6 @@ public class SystemBundleTests extends AbstractBundleTests { } } }); - } } finally { executor.shutdown(); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java index 806143866..eff971fd9 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigIniTest.java @@ -32,16 +32,18 @@ public class EclipseStarterConfigIniTest extends OSGiTest { ConfigurationSessionTestSuite falseCompatBootDelegation = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigIniTest.class.getName()); String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) - falseCompatBootDelegation.addBundle(ids[i]); + for (String id : ids) { + falseCompatBootDelegation.addBundle(id); + } falseCompatBootDelegation.addBundle(PI_OSGI_TESTS); falseCompatBootDelegation.addTest(new EclipseStarterConfigIniTest("testFalseCompatBootDelegation")); falseCompatBootDelegation.setConfigIniValue("osgi.compatibility.bootdelegation", "false"); suite.addTest(falseCompatBootDelegation); ConfigurationSessionTestSuite defaultCompatBootDelegation = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigIniTest.class.getName()); - for (int i = 0; i < ids.length; i++) - defaultCompatBootDelegation.addBundle(ids[i]); + for (String id : ids) { + defaultCompatBootDelegation.addBundle(id); + } defaultCompatBootDelegation.addBundle(PI_OSGI_TESTS); defaultCompatBootDelegation.addTest(new EclipseStarterConfigIniTest("testDefaultCompatBootDelegation")); suite.addTest(defaultCompatBootDelegation); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java index 6792fa2a1..ededca5ab 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/EclipseStarterConfigurationAreaTest.java @@ -32,8 +32,9 @@ public class EclipseStarterConfigurationAreaTest extends OSGiTest { ConfigurationSessionTestSuite initialization = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigurationAreaTest.class.getName()); String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; initialization.addBundle("org.eclipse.osgi.compatibility.state"); - for (int i = 0; i < ids.length; i++) - initialization.addBundle(ids[i]); + for (String id : ids) { + initialization.addBundle(id); + } initialization.addBundle(PI_OSGI_TESTS); // disable clean-up, we want to reuse the configuration initialization.setCleanup(false); @@ -45,8 +46,9 @@ public class EclipseStarterConfigurationAreaTest extends OSGiTest { ConfigurationSessionTestSuite removeExtension = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, EclipseStarterConfigurationAreaTest.class.getName()); removeExtension.setConfigurationPath(configPath); - for (int i = 0; i < ids.length; i++) - removeExtension.addBundle(ids[i]); + for (String id : ids) { + removeExtension.addBundle(id); + } removeExtension.addBundle(PI_OSGI_TESTS); removeExtension.addTest(new EclipseStarterConfigurationAreaTest("testRemoveExtension")); suite.addTest(removeExtension); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java index 27857fc39..0e8eb97fa 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/MovableConfigurationAreaTest.java @@ -48,8 +48,9 @@ public class MovableConfigurationAreaTest extends OSGiTest { ConfigurationSessionTestSuite initialization = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, MovableConfigurationAreaTest.class.getName()); String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) - initialization.addBundle(ids[i]); + for (String id : ids) { + initialization.addBundle(id); + } initialization.addBundle(PI_OSGI_TESTS); initialization.setReadOnly(true); // disable clean-up, we want to reuse the configuration @@ -73,8 +74,9 @@ public class MovableConfigurationAreaTest extends OSGiTest { ConfigurationSessionTestSuite afterMoving = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, MovableConfigurationAreaTest.class.getName()); afterMoving.setConfigurationPath(destinationPath); - for (int i = 0; i < ids.length; i++) - afterMoving.addBundle(ids[i]); + for (String id : ids) { + afterMoving.addBundle(id); + } afterMoving.setReadOnly(true); // make sure we don't allow priming for the first run afterMoving.setPrime(false); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java index 44fdd6a5e..778b956f2 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/configuration/ReadOnlyConfigurationAreaTest.java @@ -31,8 +31,9 @@ public class ReadOnlyConfigurationAreaTest extends OSGiTest { ConfigurationSessionTestSuite suite = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, ReadOnlyConfigurationAreaTest.class); suite.setReadOnly(true); String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) - suite.addBundle(ids[i]); + for (String id : ids) { + suite.addBundle(id); + } suite.addBundle(PI_OSGI_TESTS); return suite; } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java index ef8e43097..64059a48c 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestAttributes_001.java @@ -60,8 +60,7 @@ public class TestAttributes_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("foo")) { @@ -75,8 +74,7 @@ public class TestAttributes_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("foo")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java index 9ba9b825a..4057e05b2 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestBSN_001.java @@ -53,8 +53,7 @@ public class TestBSN_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("foo")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java index 9b0bd7537..b65a5fdd9 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_001.java @@ -51,12 +51,12 @@ public class TestCycle_001 extends AbstractStateTest { BundleDescription[] requires = bundle_2.getResolvedRequires(); assertNotNull("requires array is unexpectedly null", requires); assertTrue("requires array is unexpectedly empty", requires.length > 0); - for (int i = 0; i < requires.length; i++) { - String requiresName = requires[i].getName(); + for (BundleDescription require : requires) { + String requiresName = require.getName(); assertNotNull("package name is null", requiresName); if (requiresName.equals("B")) { - assertNotNull("Require [B] is not wired when it should be ", requires[i]); - assertEquals("Require [B] is wired incorrectly ", requires[i], bundle_2); + assertNotNull("Require [B] is not wired when it should be ", require); + assertEquals("Require [B] is wired incorrectly ", require, bundle_2); } } // end for } // end method @@ -65,12 +65,12 @@ public class TestCycle_001 extends AbstractStateTest { BundleDescription[] requires = bundle_2.getResolvedRequires(); assertNotNull("requires array is unexpectedly null", requires); assertTrue("requires array is unexpectedly empty", requires.length > 0); - for (int i = 0; i < requires.length; i++) { - String requiresName = requires[i].getName(); + for (BundleDescription require : requires) { + String requiresName = require.getName(); assertNotNull("package name is null", requiresName); if (requiresName.equals("A")) { - assertNotNull("Require [A] is not wired when it should be ", requires[i]); - assertEquals("Require [A] is wired incorrectly ", requires[i], bundle_1); + assertNotNull("Require [A] is not wired when it should be ", require); + assertEquals("Require [A] is wired incorrectly ", require, bundle_1); } } // end for } // end method diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java index 7b58fe6bc..1426390e4 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_002.java @@ -53,15 +53,15 @@ public class TestCycle_002 extends AbstractStateTest { BundleDescription[] requires = bundle_1.getResolvedRequires(); assertNotNull("requires array is unexpectedly null", requires); assertTrue("requires array is unexpectedly empty", requires.length > 0); - for (int i = 0; i < requires.length; i++) { - String requiresName = requires[i].getName(); + for (BundleDescription require : requires) { + String requiresName = require.getName(); assertNotNull("package name is null", requiresName); if (requiresName.equals("B")) { - assertNotNull("Require [B] is not wired when it should be ", requires[i]); - assertEquals("Require [B] is wired incorrectly ", requires[i], bundle_2); + assertNotNull("Require [B] is not wired when it should be ", require); + assertEquals("Require [B] is wired incorrectly ", require, bundle_2); } else if (requiresName.equals("C")) { - assertNotNull("Require [C] is not wired when it should be ", requires[i]); - assertEquals("Require [C] is wired incorrectly ", requires[i], bundle_3); + assertNotNull("Require [C] is not wired when it should be ", require); + assertEquals("Require [C] is wired incorrectly ", require, bundle_3); } } // end for } // end method @@ -70,15 +70,15 @@ public class TestCycle_002 extends AbstractStateTest { BundleDescription[] requires = bundle_2.getResolvedRequires(); assertNotNull("requires array is unexpectedly null", requires); assertTrue("requires array is unexpectedly empty", requires.length > 0); - for (int i = 0; i < requires.length; i++) { - String requiresName = requires[i].getName(); + for (BundleDescription require : requires) { + String requiresName = require.getName(); assertNotNull("package name is null", requiresName); if (requiresName.equals("A")) { - assertNotNull("Require [A] is not wired when it should be ", requires[i]); - assertEquals("Require [A] is wired incorrectly ", requires[i], bundle_1); + assertNotNull("Require [A] is not wired when it should be ", require); + assertEquals("Require [A] is wired incorrectly ", require, bundle_1); } else if (requiresName.equals("C")) { - assertNotNull("Require [C] is not wired when it should be ", requires[i]); - assertEquals("Require [C] is wired incorrectly ", requires[i], bundle_3); + assertNotNull("Require [C] is not wired when it should be ", require); + assertEquals("Require [C] is wired incorrectly ", require, bundle_3); } } // end for } // end method @@ -87,15 +87,15 @@ public class TestCycle_002 extends AbstractStateTest { BundleDescription[] requires = bundle_3.getResolvedRequires(); assertNotNull("requires array is unexpectedly null", requires); assertTrue("requires array is unexpectedly empty", requires.length > 0); - for (int i = 0; i < requires.length; i++) { - String requiresName = requires[i].getName(); + for (BundleDescription require : requires) { + String requiresName = require.getName(); assertNotNull("package name is null", requiresName); if (requiresName.equals("A")) { - assertNotNull("Require [A] is not wired when it should be ", requires[i]); - assertEquals("Require [A] is wired incorrectly ", requires[i], bundle_1); + assertNotNull("Require [A] is not wired when it should be ", require); + assertEquals("Require [A] is wired incorrectly ", require, bundle_1); } else if (requiresName.equals("B")) { - assertNotNull("Require [B] is not wired when it should be ", requires[i]); - assertEquals("Require [B] is wired incorrectly ", requires[i], bundle_2); + assertNotNull("Require [B] is not wired when it should be ", require); + assertEquals("Require [B] is wired incorrectly ", require, bundle_2); } } // end for } // end method diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java index 47ff2cbd4..ebdb45b59 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_004.java @@ -51,8 +51,7 @@ public class TestCycle_004 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { @@ -66,8 +65,7 @@ public class TestCycle_004 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("q")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java index 5b3956177..3d5e1f8b7 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestCycle_005.java @@ -56,8 +56,7 @@ public class TestCycle_005 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("q")) { @@ -71,8 +70,7 @@ public class TestCycle_005 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("r")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java index bb04e25bf..842593b84 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_002.java @@ -65,8 +65,7 @@ public class TestDynamic_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java index eef665c25..2accc37f6 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_003.java @@ -66,8 +66,7 @@ public class TestDynamic_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java index aa0f65afd..a6ebf7147 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestDynamic_004.java @@ -68,8 +68,7 @@ public class TestDynamic_004 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { @@ -83,8 +82,7 @@ public class TestDynamic_004 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("q")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java index 270ca93e6..9b90fb7d5 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGenerated_001.java @@ -81,8 +81,7 @@ public class TestGenerated_001 extends AbstractStateTest { exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("a2")) { @@ -110,8 +109,7 @@ public class TestGenerated_001 extends AbstractStateTest { exports = bundle_6.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("a2")) { @@ -133,8 +131,7 @@ public class TestGenerated_001 extends AbstractStateTest { exports = bundle_7.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("a2")) { @@ -156,8 +153,7 @@ public class TestGenerated_001 extends AbstractStateTest { exports = bundle_8.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("a2")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java index 8bd65a395..51a804a7d 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_001.java @@ -60,8 +60,7 @@ public class TestGrouping_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java index 6eeb93800..053ff320b 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_003.java @@ -64,8 +64,7 @@ public class TestGrouping_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("r")) { @@ -85,8 +84,7 @@ public class TestGrouping_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java index 3f8f74f0f..26cf3494b 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestGrouping_008.java @@ -60,8 +60,7 @@ public class TestGrouping_008 extends AbstractStateTest { BundleDescription[] requires = bundle_1.getResolvedRequires(); assertNotNull("requires array is unexpectedly null", requires); assertTrue("requires array is unexpectedly empty", requires.length > 0); - for (int i = 0; i < requires.length; i++) { - BundleDescription bd = requires[i]; + for (BundleDescription bd : requires) { String requiresName = bd.getName(); assertNotNull("bundle name is null", requiresName); if (requiresName.equals("B")) { @@ -72,8 +71,7 @@ public class TestGrouping_008 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java index 27aa5e361..68c1d853a 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_001.java @@ -60,8 +60,7 @@ public class TestOptional_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("q")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java index 8e8454891..536ced13c 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestOptional_002.java @@ -60,8 +60,7 @@ public class TestOptional_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("q")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java index c50983bce..10b24a77f 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_001.java @@ -62,8 +62,7 @@ public class TestPropagation_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("x")) { @@ -80,8 +79,7 @@ public class TestPropagation_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("x")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java index 2cfb05a24..2c184e876 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestPropagation_003.java @@ -65,8 +65,7 @@ public class TestPropagation_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java index e424729b5..86d5dd125 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_001.java @@ -60,12 +60,12 @@ public class TestRFC79_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -74,12 +74,12 @@ public class TestRFC79_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -88,12 +88,12 @@ public class TestRFC79_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java index c0809d3dd..9922c9f5a 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_002.java @@ -64,12 +64,12 @@ public class TestRFC79_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -78,12 +78,12 @@ public class TestRFC79_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -92,15 +92,15 @@ public class TestRFC79_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.foo.impl")) { - assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_2); } else if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -109,15 +109,15 @@ public class TestRFC79_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_4.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.foo.impl")) { - assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_1); + assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_1); } else if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -126,12 +126,12 @@ public class TestRFC79_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_5.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.foo.impl")) { - assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java index 2b30381eb..bc7f55415 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_003.java @@ -62,12 +62,12 @@ public class TestRFC79_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -76,12 +76,12 @@ public class TestRFC79_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -90,15 +90,15 @@ public class TestRFC79_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.foo.impl")) { - assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_1); + assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_1); } else if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -107,15 +107,15 @@ public class TestRFC79_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_4.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.foo.impl")) { - assertNotNull("Package [org.foo.impl] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.foo.impl] is wired incorrectly ", exports[i].getExporter(), bundle_1); + assertNotNull("Package [org.foo.impl] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.foo.impl] is wired incorrectly ", export.getExporter(), bundle_1); } else if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java index 786bd5197..e53a8e6a4 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_004.java @@ -62,15 +62,15 @@ public class TestRFC79_004 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.apache.commons.logging")) { - assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", exports[i].getExporter(), bundle_4); + assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", export.getExporter(), bundle_4); } else if (exportPackageName.equals("org.apache.commons.io")) { - assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.apache.commons.io] is wired incorrectly ", exports[i].getExporter(), bundle_4); + assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.apache.commons.io] is wired incorrectly ", export.getExporter(), bundle_4); } } // end for } // end method @@ -79,15 +79,15 @@ public class TestRFC79_004 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.apache.commons.logging")) { - assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", exports[i].getExporter(), bundle_3); + assertNotNull("Package [org.apache.commons.logging] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.apache.commons.logging] is wired incorrectly ", export.getExporter(), bundle_3); } else if (exportPackageName.equals("org.apache.commons.io")) { - assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [org.apache.commons.io] is wired incorrectly ", exports[i].getExporter(), bundle_3); + assertNotNull("Package [org.apache.commons.io] is not wired when it should be ", export.getExporter()); + assertEquals("Package [org.apache.commons.io] is wired incorrectly ", export.getExporter(), bundle_3); } } // end for } // end method diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java index c219acda9..e8bd44a6e 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_005.java @@ -60,12 +60,12 @@ public class TestRFC79_005 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method @@ -74,12 +74,12 @@ public class TestRFC79_005 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - String exportPackageName = exports[i].getName(); + for (ExportPackageDescription export : exports) { + String exportPackageName = export.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("javax.servlet")) { - assertNotNull("Package [javax.servlet] is not wired when it should be ", exports[i].getExporter()); - assertEquals("Package [javax.servlet] is wired incorrectly ", exports[i].getExporter(), bundle_2); + assertNotNull("Package [javax.servlet] is not wired when it should be ", export.getExporter()); + assertEquals("Package [javax.servlet] is wired incorrectly ", export.getExporter(), bundle_2); } } // end for } // end method diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java index e659cf355..db803468e 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_006.java @@ -66,8 +66,7 @@ public class TestRFC79_006 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.xml.sax")) { @@ -99,8 +98,7 @@ public class TestRFC79_006 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_6.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.w3c.dom")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java index eb46d41ca..ee34e7d41 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestRFC79_007.java @@ -64,8 +64,7 @@ public class TestRFC79_007 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("Q")) { @@ -85,8 +84,7 @@ public class TestRFC79_007 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_4.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("R")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java index 2f06153d8..bf8ca3f88 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_001.java @@ -60,8 +60,7 @@ public class TestVersion_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { @@ -75,8 +74,7 @@ public class TestVersion_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { @@ -90,8 +88,7 @@ public class TestVersion_001 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_3.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java index c92c84463..11f3dce8d 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_002.java @@ -60,8 +60,7 @@ public class TestVersion_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { @@ -75,8 +74,7 @@ public class TestVersion_002 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_2.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("r")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java index b6ac4497b..4640d7a0e 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/resolver/TestVersion_003.java @@ -60,8 +60,7 @@ public class TestVersion_003 extends AbstractStateTest { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); - for (int i = 0; i < exports.length; i++) { - ExportPackageDescription exp = exports[i]; + for (ExportPackageDescription exp : exports) { String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java index 789c86290..a3d356d17 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/BaseSecurityTest.java @@ -60,8 +60,8 @@ public class BaseSecurityTest extends CoreTest { protected static void addDefaultSecurityBundles(ConfigurationSessionTestSuite suite) { String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) { - suite.addBundle(ids[i]); + for (String id : ids) { + suite.addBundle(id); } suite.addBundle(BUNDLE_SECURITY_TESTS); } @@ -72,8 +72,8 @@ public class BaseSecurityTest extends CoreTest { protected static Certificate[] getTestCertificateChain(String[] aliases) throws KeyStoreException { ArrayList certs = new ArrayList(aliases.length); - for (int i = 0; i < aliases.length; i++) { - certs.add(getTestCertificate(aliases[i])); + for (String alias : aliases) { + certs.add(getTestCertificate(alias)); } return (Certificate[]) certs.toArray(new Certificate[] {}); } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java index 35828dbdd..1f3e55f34 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/KeyStoreTrustEngineTest.java @@ -13,14 +13,19 @@ *******************************************************************************/ package org.eclipse.osgi.tests.security; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.net.URL; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.util.ArrayList; -import junit.framework.*; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; import org.eclipse.osgi.internal.service.security.KeyStoreTrustEngine; import org.eclipse.osgi.service.security.TrustEngine; import org.eclipse.osgi.tests.OSGiTestsActivator; @@ -31,8 +36,8 @@ public class KeyStoreTrustEngineTest extends TestCase { private static String TYPE_DEFAULT = "JKS"; //$NON-NLS-1$ private static TestCase[] s_tests = { - /* findTrustAnchor tests */ - new KeyStoreTrustEngineTest("findTrustAnchor positive test: self signed trusted", new String[] {"ca1_root"}) { //$NON-NLS-1$ //$NON-NLS-2$ + /* findTrustAnchor tests */ + new KeyStoreTrustEngineTest("findTrustAnchor positive test: self signed trusted", new String[] {"ca1_root"}) { //$NON-NLS-1$ //$NON-NLS-2$ public void runTest() { testFindTrustAnchor0(); } @@ -74,7 +79,7 @@ public class KeyStoreTrustEngineTest extends TestCase { public void runTest() { testAddTrustAnchor0(); } - },/*, new KeyStoreTrustEngineTest("addTrustAnchor positive test: add with autogenerated alias", null) { + }, /*, new KeyStoreTrustEngineTest("addTrustAnchor positive test: add with autogenerated alias", null) { public void runTest() { testAddTrustAnchor1(); } @@ -141,8 +146,8 @@ public class KeyStoreTrustEngineTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite("Unit tests for TrustEngine"); //$NON-NLS-1$ - for (int i = 0; i < s_tests.length; i++) { - suite.addTest(s_tests[i]); + for (TestCase s_test : s_tests) { + suite.addTest(s_test); } return suite; } @@ -180,8 +185,8 @@ public class KeyStoreTrustEngineTest extends TestCase { testStore = KeyStore.getInstance(TYPE_DEFAULT); testStore.load(null, PASSWORD_DEFAULT); if (aliases != null) { - for (int i = 0; i < aliases.length; i++) { - testStore.setCertificateEntry(aliases[i], getTestCertificate(aliases[i])); + for (String alias : aliases) { + testStore.setCertificateEntry(alias, getTestCertificate(alias)); } } testStoreFile = File.createTempFile("teststore", "jks"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -220,8 +225,8 @@ public class KeyStoreTrustEngineTest extends TestCase { private static Certificate[] getTestCertificateChain(String[] aliases) throws KeyStoreException { ArrayList certs = new ArrayList(aliases.length); - for (int i = 0; i < aliases.length; i++) { - certs.add(getTestCertificate(aliases[i])); + for (String alias : aliases) { + certs.add(getTestCertificate(alias)); } return (Certificate[]) certs.toArray(new Certificate[] {}); } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java index 629d4b54f..fbce8b108 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/security/SignedBundleTest.java @@ -20,7 +20,10 @@ import java.security.cert.X509Certificate; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.tests.session.ConfigurationSessionTestSuite; -import org.eclipse.osgi.signedcontent.*; +import org.eclipse.osgi.signedcontent.InvalidContentException; +import org.eclipse.osgi.signedcontent.SignedContent; +import org.eclipse.osgi.signedcontent.SignedContentEntry; +import org.eclipse.osgi.signedcontent.SignerInfo; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; @@ -162,9 +165,9 @@ public class SignedBundleTest extends BaseSecurityTest { // verify and validate the entries SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -200,20 +203,20 @@ public class SignedBundleTest extends BaseSecurityTest { assertNotNull("SignerInfo is null", infos); assertEquals("wrong number of signers", 2, infos.length); // check the signer validity - for (int i = 0; i < infos.length; i++) { - signedContent.checkValidity(infos[i]); - signedContent.checkValidity(infos[i]); + for (SignerInfo info : infos) { + signedContent.checkValidity(info); + signedContent.checkValidity(info); // check the signer trust - assertTrue("Signer is not trusted: " + infos[i].getCertificateChain()[0], infos[i].isTrusted()); + assertTrue("Signer is not trusted: " + info.getCertificateChain()[0], info.isTrusted()); // check the trust anchor - assertNotNull("Trust anchor is null", infos[i].getTrustAnchor()); + assertNotNull("Trust anchor is null", info.getTrustAnchor()); } // verify and validate the entries SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 2, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -247,9 +250,9 @@ public class SignedBundleTest extends BaseSecurityTest { assertNotNull("SignerInfo is null", infos); assertEquals("wrong number of signers", 1, infos.length); // check the signer validity - for (int i = 0; i < infos.length; i++) { + for (SignerInfo info : infos) { // check the signer trust - assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted())); + assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted())); } } catch (Exception e) { fail("Unexpected exception", e); @@ -278,9 +281,9 @@ public class SignedBundleTest extends BaseSecurityTest { assertNotNull("SignerInfo is null", infos); assertEquals("wrong number of signers", 2, infos.length); // check the signer validity - for (int i = 0; i < infos.length; i++) { + for (SignerInfo info : infos) { // check the signer trust - assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted())); + assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted())); } } catch (Exception e) { fail("Unexpected exception", e); @@ -311,12 +314,10 @@ public class SignedBundleTest extends BaseSecurityTest { assertEquals("wrong number of signers", 2, infos.length); // make sure ca1 signer is trusted - // check the signer validity - for (int i = 0; i < infos.length; i++) { - Certificate certs[] = infos[i].getCertificateChain(); - - if (infos[i].isTrusted()) { + for (SignerInfo info : infos) { + Certificate[] certs = info.getCertificateChain(); + if (info.isTrusted()) { X509Certificate x509Cert = (X509Certificate) certs[0]; assertTrue("CA1 LeafA signer is not trusted", x509Cert.getSubjectDN().getName().indexOf("CA1 LeafA") >= 0); } @@ -352,16 +353,18 @@ public class SignedBundleTest extends BaseSecurityTest { SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { + for (SignedContentEntry entry : entries) { try { - entries[i].verify(); - if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName())) - fail("Expected a corruption for: " + entries[i].getName()); + entry.verify(); + if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) { + fail("Expected a corruption for: " + entry.getName()); + } } catch (InvalidContentException e) { - if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName())) - fail("Unexpected corruption in: " + entries[i].getName(), e); + if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) { + fail("Unexpected corruption in: " + entry.getName(), e); + } } - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -478,9 +481,9 @@ public class SignedBundleTest extends BaseSecurityTest { // verify and validate the entries SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -507,20 +510,20 @@ public class SignedBundleTest extends BaseSecurityTest { assertNotNull("SignerInfo is null", infos); assertEquals("wrong number of signers", 2, infos.length); // check the signer validity - for (int i = 0; i < infos.length; i++) { - signedContent.checkValidity(infos[i]); - signedContent.checkValidity(infos[i]); + for (SignerInfo info : infos) { + signedContent.checkValidity(info); + signedContent.checkValidity(info); // check the signer trust - assertTrue("Signer is not trusted: " + infos[i].getCertificateChain()[0], infos[i].isTrusted()); + assertTrue("Signer is not trusted: " + info.getCertificateChain()[0], info.isTrusted()); // check the trust anchor - assertNotNull("Trust anchor is null", infos[i].getTrustAnchor()); + assertNotNull("Trust anchor is null", info.getTrustAnchor()); } // verify and validate the entries SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 2, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -544,9 +547,9 @@ public class SignedBundleTest extends BaseSecurityTest { assertNotNull("SignerInfo is null", infos); assertEquals("wrong number of signers", 1, infos.length); // check the signer validity - for (int i = 0; i < infos.length; i++) { + for (SignerInfo info : infos) { // check the signer trust - assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted())); + assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted())); } } catch (Exception e) { fail("Unexpected exception", e); @@ -568,9 +571,9 @@ public class SignedBundleTest extends BaseSecurityTest { assertNotNull("SignerInfo is null", infos); assertEquals("wrong number of signers", 2, infos.length); // check the signer validity - for (int i = 0; i < infos.length; i++) { + for (SignerInfo info : infos) { // check the signer trust - assertTrue("Signer is trusted: " + infos[i].getCertificateChain()[0], !(infos[i].isTrusted())); + assertTrue("Signer is trusted: " + info.getCertificateChain()[0], !(info.isTrusted())); } } catch (Exception e) { fail("Unexpected exception", e); @@ -594,12 +597,10 @@ public class SignedBundleTest extends BaseSecurityTest { assertEquals("wrong number of signers", 2, infos.length); // make sure ca1 signer is trusted - // check the signer validity - for (int i = 0; i < infos.length; i++) { - Certificate certs[] = infos[i].getCertificateChain(); - - if (infos[i].isTrusted()) { + for (SignerInfo info : infos) { + Certificate[] certs = info.getCertificateChain(); + if (info.isTrusted()) { X509Certificate x509Cert = (X509Certificate) certs[0]; assertTrue("CA1 LeafA signer is not trusted", x509Cert.getSubjectDN().getName().indexOf("CA1 LeafA") >= 0); } @@ -627,16 +628,18 @@ public class SignedBundleTest extends BaseSecurityTest { SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { + for (SignedContentEntry entry : entries) { try { - entries[i].verify(); - if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName())) - fail("Expected a corruption for: " + entries[i].getName()); + entry.verify(); + if ("org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) { + fail("Expected a corruption for: " + entry.getName()); + } } catch (InvalidContentException e) { - if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entries[i].getName())) - fail("Unexpected corruption in: " + entries[i].getName(), e); + if (!"org/eclipse/equinox/security/junit/CorruptClass.class".equals(entry.getName())) { + fail("Unexpected corruption in: " + entry.getName(), e); + } } - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -693,9 +696,9 @@ public class SignedBundleTest extends BaseSecurityTest { // verify and validate the entries SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -717,9 +720,9 @@ public class SignedBundleTest extends BaseSecurityTest { assertFalse("Content is signed!!", signedContent.isSigned()); SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 0, entryInfos.length); } @@ -740,9 +743,9 @@ public class SignedBundleTest extends BaseSecurityTest { SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); assertEquals("Incorrect number of signed entries", 4, entries.length); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); } @@ -763,9 +766,9 @@ public class SignedBundleTest extends BaseSecurityTest { SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); assertEquals("Incorrect number of signed entries", 4, entries.length); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); } @@ -786,14 +789,14 @@ public class SignedBundleTest extends BaseSecurityTest { SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); assertEquals("Incorrect number of signed entries", 4, entries.length); - for (int i = 0; i < entries.length; i++) { + for (SignedContentEntry entry : entries) { try { - entries[i].verify(); - assertFalse("Wrong entry is validated: " + entries[i].getName(), "META-INF/test/test1.file".equals(entries[i].getName())); + entry.verify(); + assertFalse("Wrong entry is validated: " + entry.getName(), "META-INF/test/test1.file".equals(entry.getName())); } catch (InvalidContentException e) { - assertEquals("Wrong entry is corrupted", "META-INF/test/test1.file", entries[i].getName()); + assertEquals("Wrong entry is corrupted", "META-INF/test/test1.file", entry.getName()); } - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); } @@ -814,14 +817,14 @@ public class SignedBundleTest extends BaseSecurityTest { SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); assertEquals("Incorrect number of signed entries", 4, entries.length); - for (int i = 0; i < entries.length; i++) { + for (SignedContentEntry entry : entries) { try { - entries[i].verify(); - assertFalse("Wrong entry is validated: " + entries[i].getName(), "META-INF/test.file".equals(entries[i].getName())); + entry.verify(); + assertFalse("Wrong entry is validated: " + entry.getName(), "META-INF/test.file".equals(entry.getName())); } catch (InvalidContentException e) { - assertEquals("Wrong entry is corrupted", "META-INF/test.file", entries[i].getName()); + assertEquals("Wrong entry is corrupted", "META-INF/test.file", entry.getName()); } - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); } @@ -895,9 +898,9 @@ public class SignedBundleTest extends BaseSecurityTest { // verify and validate the entries SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { - entries[i].verify(); - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + for (SignedContentEntry entry : entries) { + entry.verify(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); @@ -947,14 +950,14 @@ public class SignedBundleTest extends BaseSecurityTest { SignedContentEntry[] entries = signedContent.getSignedEntries(); assertNotNull("Entries is null", entries); - for (int i = 0; i < entries.length; i++) { + for (SignedContentEntry entry : entries) { try { - entries[i].verify(); - fail("Expected a corruption for: " + entries[i].getName()); + entry.verify(); + fail("Expected a corruption for: " + entry.getName()); } catch (InvalidContentException e) { // expected } - SignerInfo[] entryInfos = entries[i].getSignerInfos(); + SignerInfo[] entryInfos = entry.getSignerInfos(); assertNotNull("SignerInfo is null", entryInfos); assertEquals("wrong number of entry signers", 1, entryInfos.length); assertEquals("Entry signer does not equal content signer", infos[0], entryInfos[0]); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java index f8e3d818c..9e114a7fb 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/serviceregistry/ServiceHookTests.java @@ -13,12 +13,28 @@ *******************************************************************************/ package org.eclipse.osgi.tests.serviceregistry; -import java.util.*; -import junit.framework.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestSuite; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.eclipse.osgi.tests.bundles.AbstractBundleTests; -import org.osgi.framework.*; -import org.osgi.framework.hooks.service.*; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.osgi.framework.hooks.service.EventHook; +import org.osgi.framework.hooks.service.FindHook; +import org.osgi.framework.hooks.service.ListenerHook; public class ServiceHookTests extends AbstractBundleTests { public static Test suite() { @@ -49,7 +65,7 @@ public class ServiceHookTests extends AbstractBundleTests { final int[] hookCalled = new int[] {0, 0, 0, 0, 0}; final boolean[] startTest = new boolean[] {false}; - final AssertionFailedError[] hookError = new AssertionFailedError[] {null, null, null, null}; + final AssertionFailedError[] hookErrors = new AssertionFailedError[] {null, null, null, null}; // register find hook 1 props.put(Constants.SERVICE_DESCRIPTION, "find hook 1"); //$NON-NLS-1$ @@ -96,7 +112,7 @@ public class ServiceHookTests extends AbstractBundleTests { fail("incorrect exception", e); //$NON-NLS-1$ } } catch (AssertionFailedError a) { - hookError[0] = a; + hookErrors[0] = a; return; } } @@ -144,7 +160,7 @@ public class ServiceHookTests extends AbstractBundleTests { fail("incorrect exception", e); //$NON-NLS-1$ } } catch (AssertionFailedError a) { - hookError[1] = a; + hookErrors[1] = a; return; } } @@ -192,7 +208,7 @@ public class ServiceHookTests extends AbstractBundleTests { fail("incorrect exception", e); //$NON-NLS-1$ } } catch (AssertionFailedError a) { - hookError[2] = a; + hookErrors[2] = a; return; } // throw an exception from the hook to test that the next hooks are called. @@ -245,7 +261,7 @@ public class ServiceHookTests extends AbstractBundleTests { fail("incorrect exception", e); //$NON-NLS-1$ } } catch (AssertionFailedError a) { - hookError[3] = a; + hookErrors[3] = a; return; } } @@ -265,9 +281,9 @@ public class ServiceHookTests extends AbstractBundleTests { assertEquals("hook 3 not called second", 3, hookCalled[2]); //$NON-NLS-1$ assertEquals("hook 4 not called third", 4, hookCalled[3]); //$NON-NLS-1$ assertEquals("hook 1 not called fourth ", 1, hookCalled[4]); //$NON-NLS-1$ - for (int i = 0; i < hookError.length; i++) { - if (hookError[i] != null) { - throw hookError[i]; + for (AssertionFailedError hookError : hookErrors) { + if (hookError != null) { + throw hookError; } } assertNotNull("service refs is null", refs); //$NON-NLS-1$ @@ -340,7 +356,7 @@ public class ServiceHookTests extends AbstractBundleTests { final BundleContext testContext = OSGiTestsActivator.getContext(); final int[] hookCalled = new int[] {0, 0}; - final AssertionFailedError[] hookError = new AssertionFailedError[] {null}; + final AssertionFailedError[] hookErrors = new AssertionFailedError[] {null}; final List events = new ArrayList(); final ServiceListener sl = new ServiceListener() { @@ -389,7 +405,7 @@ public class ServiceHookTests extends AbstractBundleTests { fail("incorrect exception", e); //$NON-NLS-1$ } } catch (AssertionFailedError a) { - hookError[0] = a; + hookErrors[0] = a; return; } } @@ -422,7 +438,7 @@ public class ServiceHookTests extends AbstractBundleTests { fail("incorrect exception", e); //$NON-NLS-1$ } } catch (AssertionFailedError a) { - hookError[0] = a; + hookErrors[0] = a; return; } } @@ -443,9 +459,9 @@ public class ServiceHookTests extends AbstractBundleTests { reg1 = testContext.registerService(Runnable.class.getName(), runIt, props); assertEquals("all hooks not called", 1, hookCalled[0]); //$NON-NLS-1$ assertEquals("hook 1 not called first", 1, hookCalled[1]); //$NON-NLS-1$ - for (int i = 0; i < hookError.length; i++) { - if (hookError[i] != null) { - throw hookError[i]; + for (AssertionFailedError hookError : hookErrors) { + if (hookError != null) { + throw hookError; } } synchronized (events) { @@ -492,9 +508,9 @@ public class ServiceHookTests extends AbstractBundleTests { } assertEquals("all hooks not called", 1, hookCalled[0]); //$NON-NLS-1$ assertEquals("hook 1 not called first", 1, hookCalled[1]); //$NON-NLS-1$ - for (int i = 0; i < hookError.length; i++) { - if (hookError[i] != null) { - throw hookError[i]; + for (AssertionFailedError hookError : hookErrors) { + if (hookError != null) { + throw hookError; } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java index d6e67430d..729f1b127 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/FileManagerTests.java @@ -13,7 +13,11 @@ *******************************************************************************/ package org.eclipse.osgi.tests.services.datalocation; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.Platform; @@ -53,16 +57,16 @@ public class FileManagerTests extends OSGiTest { rm(base); } - private void rm(File file) { - if (file.isDirectory()) { - File[] list = file.listFiles(); - if (list != null) { - for (int idx = 0; idx < list.length; idx++) { - rm(list[idx]); + private void rm(File folder) { + if (folder.isDirectory()) { + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + rm(file); } } } - file.delete(); + folder.delete(); } /** diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java index b69453ba9..7112de0f4 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/LocationAreaSessionTest.java @@ -48,8 +48,9 @@ public class LocationAreaSessionTest extends OSGiTest { // attempt to lock same location with a session ConfigurationSessionTestSuite sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName()); String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) - sessionLock.addBundle(ids[i]); + for (String id : ids) { + sessionLock.addBundle(id); + } sessionLock.addBundle(PI_OSGI_TESTS); try { sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir); @@ -69,8 +70,9 @@ public class LocationAreaSessionTest extends OSGiTest { // attempt to lock the location with a session sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName()); - for (int i = 0; i < ids.length; i++) - sessionLock.addBundle(ids[i]); + for (String id : ids) { + sessionLock.addBundle(id); + } sessionLock.addBundle(PI_OSGI_TESTS); try { sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir); @@ -94,8 +96,9 @@ public class LocationAreaSessionTest extends OSGiTest { // attempt to lock same location with a session sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName()); ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) - sessionLock.addBundle(ids[i]); + for (String id : ids) { + sessionLock.addBundle(id); + } sessionLock.addBundle(PI_OSGI_TESTS); try { sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir); @@ -117,8 +120,9 @@ public class LocationAreaSessionTest extends OSGiTest { // attempt to lock the location with a session sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName()); - for (int i = 0; i < ids.length; i++) - sessionLock.addBundle(ids[i]); + for (String id : ids) { + sessionLock.addBundle(id); + } sessionLock.addBundle(PI_OSGI_TESTS); try { sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir); diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java index 615b79ff8..3e2d017de 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/datalocation/StreamManagerTests.java @@ -13,7 +13,15 @@ *******************************************************************************/ package org.eclipse.osgi.tests.services.datalocation; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.Platform; @@ -59,16 +67,16 @@ public class StreamManagerTests extends OSGiTest { System.setProperty("osgi.useReliableFiles", reliableFile); } - private void rm(File file) { - if (file.isDirectory()) { - File[] list = file.listFiles(); - if (list != null) { - for (int idx = 0; idx < list.length; idx++) { - rm(list[idx]); + private void rm(File folder) { + if (folder.isDirectory()) { + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + rm(file); } } } - file.delete(); + folder.delete(); } private String getInputStreamContents(InputStream is) throws IOException { @@ -161,9 +169,10 @@ public class StreamManagerTests extends OSGiTest { //now request only the primary file try { InputStream[] isSet = manager1.getInputStreamSet(new String[] {fileName}); - for (int i = 0; i < isSet.length; i++) { - if (isSet[i] != null) - isSet[i].close(); + for (InputStream set : isSet) { + if (set != null) { + set.close(); + } } fail("getInputStreamSet was successful"); } catch (IOException e) { diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java index 9534b6f2c..b3686144f 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/AbstractStateTest.java @@ -13,8 +13,18 @@ *******************************************************************************/ package org.eclipse.osgi.tests.services.resolver; -import java.util.*; -import org.eclipse.osgi.service.resolver.*; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.StringTokenizer; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.BundleSpecification; +import org.eclipse.osgi.service.resolver.ExportPackageDescription; +import org.eclipse.osgi.service.resolver.HostSpecification; +import org.eclipse.osgi.service.resolver.ImportPackageSpecification; +import org.eclipse.osgi.service.resolver.PlatformAdmin; +import org.eclipse.osgi.service.resolver.State; +import org.eclipse.osgi.service.resolver.StateObjectFactory; +import org.eclipse.osgi.service.resolver.VersionConstraint; import org.eclipse.osgi.tests.OSGiTest; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.osgi.framework.BundleException; @@ -38,9 +48,11 @@ public abstract class AbstractStateTest extends OSGiTest { } public void assertContains(String tag, Object[] array, Object element) { - for (int i = 0; i < array.length; i++) - if (array[i] == element) + for (Object o : array) { + if (o == element) { return; + } + } fail(tag); } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java index 3fdaaa75c..1f553df18 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/OSGiCapabilityTest.java @@ -16,11 +16,20 @@ package org.eclipse.osgi.tests.services.resolver; import java.io.File; import java.io.IOException; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap; -import org.eclipse.osgi.service.resolver.*; +import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.ExportPackageDescription; +import org.eclipse.osgi.service.resolver.GenericDescription; +import org.eclipse.osgi.service.resolver.State; import org.eclipse.osgi.util.ManifestElement; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; @@ -194,11 +203,12 @@ public class OSGiCapabilityTest extends AbstractStateTest { assertEquals("Expected number of capabilities do not match", expectedCnt, genRequired.length); assertEquals("Specs do not match Descs", genRequired.length, genProvided.length + (fragIdentity == null ? 0 : 1)); Collection providedCollection = new ArrayList(Arrays.asList(genProvided)); - for (int i = 0; i < genRequired.length; i++) { - if (IdentityNamespace.IDENTITY_NAMESPACE.equals(genRequired[i].getType()) && genRequired[i].getSupplier().getHost() != null) - assertEquals("Wrong fragment provider: " + genRequired[i], fragIdentity, genRequired[i]); - else - assertTrue("Wrong provider for requirement: " + genRequired[i], providedCollection.remove(genRequired[i])); + for (GenericDescription requiredDescription : genRequired) { + if (IdentityNamespace.IDENTITY_NAMESPACE.equals(requiredDescription.getType()) && requiredDescription.getSupplier().getHost() != null) { + assertEquals("Wrong fragment provider: " + requiredDescription, fragIdentity, requiredDescription); + } else { + assertTrue("Wrong provider for requirement: " + requiredDescription, providedCollection.remove(requiredDescription)); + } } } @@ -613,8 +623,8 @@ public class OSGiCapabilityTest extends AbstractStateTest { GenericDescription[] required = requirer.getResolvedGenericRequires(); assertEquals("Wrong number of capabilities for bundle: " + requirer, expectedCapabilities.length, required.length); Collection providedCollection = new ArrayList(Arrays.asList(expectedCapabilities)); - for (int i = 0; i < required.length; i++) { - assertTrue("Wrong provider for requirement: " + required[i], providedCollection.remove(required[i])); + for (GenericDescription requiredDescription : required) { + assertTrue("Wrong provider for requirement: " + requiredDescription, providedCollection.remove(requiredDescription)); } } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java index 531ffd05a..5b6c147ec 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/StateResolverTest.java @@ -118,8 +118,9 @@ public class StateResolverTest extends AbstractStateTest { deltas = delta.getChanges(); assertEquals("1.0", 3, deltas.length); //$NON-NLS-1$ Map deltasMap = new HashMap(); - for (int i = 0; i < deltas.length; i++) - deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]); + for (BundleDelta bundleDelta : deltas) { + deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta); + } assertNotNull("1.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$ assertNotNull("1.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$ assertNotNull("1.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$ @@ -144,8 +145,9 @@ public class StateResolverTest extends AbstractStateTest { BundleDelta[] resolutions = delta.getChanges(BundleDelta.RESOLVED, false); assertEquals("3.0", 2, resolutions.length); //$NON-NLS-1$ Map deltasMap = new HashMap(); - for (int i = 0; i < resolutions.length; i++) - deltasMap.put(resolutions[i].getBundle().getSymbolicName(), resolutions[i]); + for (BundleDelta resolution : resolutions) { + deltasMap.put(resolution.getBundle().getSymbolicName(), resolution); + } assertNotNull("3.1", deltasMap.get(b1.getSymbolicName())); //$NON-NLS-1$ assertNotNull("3.2", deltasMap.get(b2.getSymbolicName())); //$NON-NLS-1$ // TODO why do we expect unresolved deltas here when the bundle was not resolved in the first place? @@ -179,8 +181,9 @@ public class StateResolverTest extends AbstractStateTest { BundleDelta[] resolutions = delta.getChanges(BundleDelta.RESOLVED, false); assertEquals("3.0", 6, resolutions.length); //$NON-NLS-1$ Map deltasMap = new HashMap(); - for (int i = 0; i < resolutions.length; i++) - deltasMap.put(resolutions[i].getBundle().getSymbolicName(), resolutions[i]); + for (BundleDelta resolution : resolutions) { + deltasMap.put(resolution.getBundle().getSymbolicName(), resolution); + } assertNotNull("3.1", deltasMap.get(b1.getSymbolicName())); //$NON-NLS-1$ assertNotNull("3.2", deltasMap.get(b2.getSymbolicName())); //$NON-NLS-1$ assertNotNull("3.3", deltasMap.get(b3.getSymbolicName())); //$NON-NLS-1$ @@ -429,8 +432,9 @@ public class StateResolverTest extends AbstractStateTest { deltas = delta.getChanges(); assertEquals("1.0", 4, deltas.length); //$NON-NLS-1$ Map deltasMap = new HashMap(); - for (int i = 0; i < deltas.length; i++) - deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]); + for (BundleDelta bundleDelta : deltas) { + deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta); + } assertNotNull("1.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$ assertNotNull("1.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$ assertNotNull("1.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$ @@ -503,8 +507,9 @@ public class StateResolverTest extends AbstractStateTest { deltas = delta.getChanges(); assertEquals("1.0", 3, deltas.length); //$NON-NLS-1$ Map deltasMap = new HashMap(); - for (int i = 0; i < deltas.length; i++) - deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]); + for (BundleDelta bundleDelta : deltas) { + deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta); + } assertNotNull("1.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$ assertNotNull("1.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$ assertNotNull("1.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$ @@ -515,8 +520,9 @@ public class StateResolverTest extends AbstractStateTest { deltas = delta.getChanges(); assertEquals("3.0", 3, deltas.length); //$NON-NLS-1$ deltasMap = new HashMap(); - for (int i = 0; i < deltas.length; i++) - deltasMap.put(Long.valueOf(deltas[i].getBundle().getBundleId()), deltas[i]); + for (BundleDelta bundleDelta : deltas) { + deltasMap.put(Long.valueOf(bundleDelta.getBundle().getBundleId()), bundleDelta); + } assertNotNull("3.1", deltasMap.get(Long.valueOf(1))); //$NON-NLS-1$ assertNotNull("3.2", deltasMap.get(Long.valueOf(2))); //$NON-NLS-1$ assertNotNull("3.3", deltasMap.get(Long.valueOf(3))); //$NON-NLS-1$ @@ -549,8 +555,9 @@ public class StateResolverTest extends AbstractStateTest { changes = delta.getChanges(); assertEquals("2.0", 2, changes.length); //$NON-NLS-1$ HashMap deltasMap = new HashMap(); - for (int i = 0; i < changes.length; i++) - deltasMap.put(changes[i].getBundle(), changes[i]); + for (BundleDelta change : changes) { + deltasMap.put(change.getBundle(), change); + } assertNotNull("2.1", deltasMap.get(b1)); //$NON-NLS-1$ assertNotNull("2.2", deltasMap.get(b11)); //$NON-NLS-1$ assertEquals("2.3", BundleDelta.UNRESOLVED, ((BundleDelta) deltasMap.get(b1)).getType()); //$NON-NLS-1$ @@ -3775,17 +3782,22 @@ public class StateResolverTest extends AbstractStateTest { } private ExportPackageDescription[] isConsistent(ExportPackageDescription[] pkgs1, ExportPackageDescription[] pkgs2) { - for (int i = 0; i < pkgs1.length; i++) - for (int j = 0; j < pkgs2.length; j++) - if (pkgs1[i].getName().equals(pkgs2[j].getName()) && pkgs1[i] != pkgs2[j]) - return new ExportPackageDescription[] {pkgs1[i], pkgs2[j]}; + for (ExportPackageDescription pkg1 : pkgs1) { + for (ExportPackageDescription pkg2 : pkgs2) { + if (pkg1.getName().equals(pkg2.getName()) && pkg1 != pkg2) { + return new ExportPackageDescription[]{pkg1, pkg2}; + } + } + } return null; } private boolean contains(Object[] array, Object element) { - for (int i = 0; i < array.length; i++) - if (array[i].equals(element)) + for (Object o : array) { + if (o.equals(element)) { return true; + } + } return false; } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java index 2d8988ee2..f9a7c014c 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/SubstitutableExportsTest.java @@ -1911,15 +1911,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", 6, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < allBundles.length; i++) { + for (BundleDescription description : allBundles) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == allBundles[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allBundles[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {f}); @@ -1944,15 +1943,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", 6, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < allRefreshBundles.length; i++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == allRefreshBundles[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {f}); @@ -1983,15 +1981,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", 8, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < allRefreshBundles.length; i++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == allRefreshBundles[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {f}); @@ -2003,15 +2000,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", 8, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < allRefreshBundles.length; i++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == allRefreshBundles[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } } @@ -2035,15 +2031,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", 9, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < allBundles.length; i++) { + for (BundleDescription description : allBundles) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == allBundles[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allBundles[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {f}); @@ -2056,15 +2051,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDescription[] expectedRefresh = new BundleDescription[] {c, cFrag, f}; assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", 3, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < expectedRefresh.length; i++) { + for (BundleDescription description : expectedRefresh) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == expectedRefresh[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } } @@ -2090,15 +2084,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < allRefreshBundles.length; i++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == allRefreshBundles[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {f}); @@ -2116,15 +2109,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDescription[] expectedRefresh = new BundleDescription[] {c, cFrag, f}; assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", 3, bundleDeltas.length); //$NON-NLS-1$ - - for (int i = 0; i < expectedRefresh.length; i++) { + for (BundleDescription description : expectedRefresh) { boolean found = false; for (int j = 0; j < bundleDeltas.length && !found; j++) { assertEquals("unexpected delta type " + bundleDeltas[j], BundleDelta.RESOLVED, bundleDeltas[j].getType()); //$NON-NLS-1$ - found = bundleDeltas[j].getBundle() == expectedRefresh[i]; + found = bundleDeltas[j].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[i]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } } @@ -2151,15 +2143,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int j = 0; j < allRefreshBundles.length; j++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int k = 0; k < bundleDeltas.length && !found; k++) { assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$ - found = bundleDeltas[k].getBundle() == allRefreshBundles[j]; + found = bundleDeltas[k].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[j]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {f}); @@ -2171,15 +2162,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int j = 0; j < allRefreshBundles.length; j++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int k = 0; k < bundleDeltas.length && !found; k++) { assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$ - found = bundleDeltas[k].getBundle() == allRefreshBundles[j]; + found = bundleDeltas[k].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[j]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } } @@ -2202,15 +2192,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", allBundles.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int j = 0; j < allBundles.length; j++) { + for (BundleDescription description : allBundles) { boolean found = false; for (int k = 0; k < bundleDeltas.length && !found; k++) { assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$ - found = bundleDeltas[k].getBundle() == allBundles[j]; + found = bundleDeltas[k].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allBundles[j]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } @@ -2219,15 +2208,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDescription[] expectedRefresh = new BundleDescription[] {f, i}; assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", expectedRefresh.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int j = 0; j < expectedRefresh.length; j++) { + for (BundleDescription description : expectedRefresh) { boolean found = false; for (int k = 0; k < bundleDeltas.length && !found; k++) { assertEquals("unexpected delta type " + bundleDeltas[k], BundleDelta.RESOLVED, bundleDeltas[k].getType()); //$NON-NLS-1$ - found = bundleDeltas[k].getBundle() == expectedRefresh[j]; + found = bundleDeltas[k].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[j]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {i}); @@ -2256,15 +2244,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int l = 0; l < allRefreshBundles.length; l++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int m = 0; m < bundleDeltas.length && !found; m++) { assertEquals("unexpected delta type " + bundleDeltas[m], BundleDelta.RESOLVED, bundleDeltas[m].getType()); //$NON-NLS-1$ - found = bundleDeltas[m].getBundle() == allRefreshBundles[l]; + found = bundleDeltas[m].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[l]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } @@ -2273,15 +2260,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDescription[] expectedRefresh = new BundleDescription[] {f, i}; assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", expectedRefresh.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int l = 0; l < expectedRefresh.length; l++) { + for (BundleDescription description : expectedRefresh) { boolean found = false; for (int m = 0; m < bundleDeltas.length && !found; m++) { assertEquals("unexpected delta type " + bundleDeltas[m], BundleDelta.RESOLVED, bundleDeltas[m].getType()); //$NON-NLS-1$ - found = bundleDeltas[m].getBundle() == expectedRefresh[l]; + found = bundleDeltas[m].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + expectedRefresh[l]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {i}); @@ -2314,15 +2300,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { BundleDelta[] bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int k = 0; k < allRefreshBundles.length; k++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int l = 0; l < bundleDeltas.length && !found; l++) { assertEquals("unexpected delta type " + bundleDeltas[l], BundleDelta.RESOLVED, bundleDeltas[l].getType()); //$NON-NLS-1$ - found = bundleDeltas[l].getBundle() == allRefreshBundles[k]; + found = bundleDeltas[l].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[k]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } stateDelta = state.resolve(new BundleDescription[] {i}); @@ -2334,15 +2319,14 @@ public class SubstitutableExportsTest extends AbstractStateTest { bundleDeltas = stateDelta.getChanges(); assertNotNull("bundleDeltas is null", bundleDeltas); //$NON-NLS-1$ assertEquals("bunldeDeltas wrong number", allRefreshBundles.length, bundleDeltas.length); //$NON-NLS-1$ - - for (int k = 0; k < allRefreshBundles.length; k++) { + for (BundleDescription description : allRefreshBundles) { boolean found = false; for (int l = 0; l < bundleDeltas.length && !found; l++) { assertEquals("unexpected delta type " + bundleDeltas[l], BundleDelta.RESOLVED, bundleDeltas[l].getType()); //$NON-NLS-1$ - found = bundleDeltas[l].getBundle() == allRefreshBundles[k]; + found = bundleDeltas[l].getBundle() == description; } if (!found) { - fail("Did not find RESOLVED BundleDelta for " + allRefreshBundles[k]); //$NON-NLS-1$ + fail("Did not find RESOLVED BundleDelta for " + description); //$NON-NLS-1$ } } } @@ -2604,13 +2588,13 @@ public class SubstitutableExportsTest extends AbstractStateTest { ExportPackageDescription[] expected = new ExportPackageDescription[aExported.length + dExported.length]; System.arraycopy(aExported, 0, expected, 0, aExported.length); System.arraycopy(dExported, 0, expected, aExported.length, dExported.length); - for (int index = 0; index < expected.length; index++) { - assertContains("eVisible not correct", eVisible, expected[index]); //$NON-NLS-1$ - assertContains("fVisible not correct", fVisible, expected[index]); //$NON-NLS-1$ - assertContains("gVisible not correct", gVisible, expected[index]); //$NON-NLS-1$ - assertContains("hVisible not correct", hVisible, expected[index]); //$NON-NLS-1$ - assertContains("iVisible not correct", iVisible, expected[index]); //$NON-NLS-1$ - assertContains("jVisible not correct", jVisible, expected[index]); //$NON-NLS-1$ + for (ExportPackageDescription exportDescription : expected) { + assertContains("eVisible not correct", eVisible, exportDescription); //$NON-NLS-1$ + assertContains("fVisible not correct", fVisible, exportDescription); //$NON-NLS-1$ + assertContains("gVisible not correct", gVisible, exportDescription); //$NON-NLS-1$ + assertContains("hVisible not correct", hVisible, exportDescription); //$NON-NLS-1$ + assertContains("iVisible not correct", iVisible, exportDescription); //$NON-NLS-1$ + assertContains("jVisible not correct", jVisible, exportDescription); //$NON-NLS-1$ } } @@ -2709,19 +2693,19 @@ public class SubstitutableExportsTest extends AbstractStateTest { System.arraycopy(aExported, 0, efExpected, 0, aExported.length); System.arraycopy(dExported, 0, efExpected, aExported.length, dExported.length); efExpected[aExported.length + dExported.length] = l.getSelectedExports()[1]; - for (int index = 0; index < efExpected.length; index++) { - assertContains("eVisible not correct", eVisible, efExpected[index]); //$NON-NLS-1$ - assertContains("fVisible not correct", fVisible, efExpected[index]); //$NON-NLS-1$ + for (ExportPackageDescription efExport : efExpected) { + assertContains("eVisible not correct", eVisible, efExport); //$NON-NLS-1$ + assertContains("fVisible not correct", fVisible, efExport); //$NON-NLS-1$ } ExportPackageDescription[] ghijExpected = new ExportPackageDescription[aExported.length + dExported.length]; System.arraycopy(aExported, 0, ghijExpected, 0, aExported.length); System.arraycopy(dExported, 0, ghijExpected, aExported.length, dExported.length); - for (int index = 0; index < ghijExpected.length; index++) { - assertContains("gVisible not correct", gVisible, ghijExpected[index]); //$NON-NLS-1$ - assertContains("hVisible not correct", hVisible, ghijExpected[index]); //$NON-NLS-1$ - assertContains("iVisible not correct", iVisible, ghijExpected[index]); //$NON-NLS-1$ - assertContains("jVisible not correct", jVisible, ghijExpected[index]); //$NON-NLS-1$ + for (ExportPackageDescription ghijExport : ghijExpected) { + assertContains("gVisible not correct", gVisible, ghijExport); //$NON-NLS-1$ + assertContains("hVisible not correct", hVisible, ghijExport); //$NON-NLS-1$ + assertContains("iVisible not correct", iVisible, ghijExport); //$NON-NLS-1$ + assertContains("jVisible not correct", jVisible, ghijExport); //$NON-NLS-1$ } ExportPackageDescription[] lExported = l.getSelectedExports(); @@ -2729,9 +2713,9 @@ public class SubstitutableExportsTest extends AbstractStateTest { System.arraycopy(aExported, 0, mnExpected, 0, aExported.length); System.arraycopy(dExported, 0, mnExpected, aExported.length, dExported.length); System.arraycopy(lExported, 0, mnExpected, aExported.length + dExported.length, lExported.length); - for (int index = 0; index < mnExpected.length; index++) { - assertContains("mVisible not correct", mVisible, mnExpected[index]); //$NON-NLS-1$ - assertContains("nVisible not correct", nVisible, mnExpected[index]); //$NON-NLS-1$ + for (ExportPackageDescription mnExport : mnExpected) { + assertContains("mVisible not correct", mVisible, mnExport); //$NON-NLS-1$ + assertContains("nVisible not correct", nVisible, mnExport); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java index 045f01e9d..6fcc03acd 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/services/resolver/XFriendsInternalResolverTest.java @@ -370,9 +370,11 @@ public class XFriendsInternalResolverTest extends AbstractStateTest { } private boolean contains(Object[] array, Object element) { - for (int i = 0; i < array.length; i++) - if (array[i].equals(element)) + for (Object o : array) { + if (o.equals(element)) { return true; + } + } return false; } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java index 97fb2f4ea..07dfac7fd 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/BidiTextProcessorTestCase.java @@ -174,17 +174,16 @@ public class BidiTextProcessorTestCase extends TextProcessorTestCase { public void testOtherStringsDeprocess() { int testNum = 1; - for (int i = 0; i < TEST_STAR_PATHS.length; i++) { - String result = TextProcessor.process(TEST_STAR_PATHS[i], "*."); + for (String testStarPath : TEST_STAR_PATHS) { + String result = TextProcessor.process(testStarPath, "*."); String resultDP = TextProcessor.deprocess(result); - verifyBidiResult("Deprocess other (star) string" + testNum, resultDP, TEST_STAR_PATHS[i]); + verifyBidiResult("Deprocess other (star) string" + testNum, resultDP, testStarPath); testNum++; } - - for (int i = 0; i < TEST_EQUALS_PATHS.length; i++) { - String result = TextProcessor.process(TEST_EQUALS_PATHS[i], "="); + for (String testEqualsPath : TEST_EQUALS_PATHS) { + String result = TextProcessor.process(testEqualsPath, "="); String resultDP = TextProcessor.deprocess(result); - verifyBidiResult("Deprocess other (equals) string" + testNum, resultDP, TEST_EQUALS_PATHS[i]); + verifyBidiResult("Deprocess other (equals) string" + testNum, resultDP, testEqualsPath); testNum++; } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java index e3df4a885..2e9caca5c 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/LatinTextProcessorTestCase.java @@ -27,20 +27,20 @@ public class LatinTextProcessorTestCase extends TextProcessorTestCase { int size = TEST_DEFAULT_PATHS.length + TEST_STAR_PATHS.length + TEST_EQUALS_PATHS.length + TEST_ADDITIONAL_STRINGS.length; ALL_PATHS = new String[size]; int idx = 0; - for (int i = 0; i < TEST_DEFAULT_PATHS.length; i++) { - ALL_PATHS[idx] = TEST_DEFAULT_PATHS[i]; + for (String testDefaultPath : TEST_DEFAULT_PATHS) { + ALL_PATHS[idx] = testDefaultPath; idx++; } - for (int i = 0; i < TEST_STAR_PATHS.length; i++) { - ALL_PATHS[idx] = TEST_STAR_PATHS[i]; + for (String testStartPath : TEST_STAR_PATHS) { + ALL_PATHS[idx] = testStartPath; idx++; } - for (int i = 0; i < TEST_EQUALS_PATHS.length; i++) { - ALL_PATHS[idx] = TEST_EQUALS_PATHS[i]; + for (String testEqualsPath : TEST_EQUALS_PATHS) { + ALL_PATHS[idx] = testEqualsPath; idx++; } - for (int i = 0; i < TEST_ADDITIONAL_STRINGS.length; i++) { - ALL_PATHS[idx] = TEST_ADDITIONAL_STRINGS[i]; + for (String testAdditionalString : TEST_ADDITIONAL_STRINGS) { + ALL_PATHS[idx] = testAdditionalString; idx++; } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java index bb07b9a71..93fc182f3 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/util/TextProcessorSessionTest.java @@ -30,8 +30,9 @@ public class TextProcessorSessionTest extends ConfigurationSessionTestSuite { super(pluginId, clazz); lang = language; String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET; - for (int i = 0; i < ids.length; i++) - addBundle(ids[i]); + for (String id : ids) { + addBundle(id); + } addBundle(OSGiTest.PI_OSGI_TESTS); } |