Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCarsten Hammer2019-06-14 18:01:57 +0000
committerPaul Pazderski2019-06-15 15:17:08 +0000
commit1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857 (patch)
tree7552c5a980252e5ed0a5e4c04bd4ff34d824a028 /tests
parent3a934d23cb1afac1bb9cc7302248ee2c3f126ed3 (diff)
downloadeclipse.platform.team-1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857.tar.gz
eclipse.platform.team-1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857.tar.xz
eclipse.platform.team-1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857.zip
Use jdk 5 for-each loopI20190616-1800I20190615-1800
Replace simple uses of Iterator with a corresponding for-each loop. Also add missing braces on loops as necessary. Change-Id: I8cee98245fb49892d80949d1dcda89c9bf72f3e4 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java11
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchLinesTest.java6
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java13
-rw-r--r--tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/WorkspaceTest.java7
-rw-r--r--tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java12
-rw-r--r--tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java17
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeBuildingTests.java3
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java3
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java12
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java3
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java84
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java6
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java8
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java18
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java3
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java30
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java10
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java46
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java19
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CompareEditorTests.java4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java3
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSProjectSetImportTest.java17
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java4
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java3
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PatchTreeTest.java9
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java29
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkUtils.java24
28 files changed, 183 insertions, 225 deletions
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
index 8afde80d0..50123fb89 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
@@ -261,13 +261,12 @@ public class DocLineComparatorTest extends TestCase {
IRangeComparator l, r;
for (int i=0;i<docs.length;i++)
for (int j=i+1;j<docs.length;j++)
- for (int k=0;k<filters.length;k++) {
- l = new DocLineComparator(docs[i], null, false, filters[k], 'L');
- r = new DocLineComparator(docs[j], null, false, filters[k], 'R');
+ for (ICompareFilter[] filter : filters) {
+ l = new DocLineComparator(docs[i], null, false, filter, 'L');
+ r = new DocLineComparator(docs[j], null, false, filter, 'R');
Assert.assertFalse(l.rangesEqual(0, r, 0));
-
- l = new DocLineComparator(docs[i], null, true, filters[k], 'L');
- r = new DocLineComparator(docs[j], null, true, filters[k], 'R');
+ l = new DocLineComparator(docs[i], null, true, filter, 'L');
+ r = new DocLineComparator(docs[j], null, true, filter, 'R');
Assert.assertTrue(l.rangesEqual(0, r, 0));
}
}
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchLinesTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchLinesTest.java
index 3dea82a77..2f08d7731 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchLinesTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchLinesTest.java
@@ -113,11 +113,9 @@ public class PatchLinesTest extends TestCase {
int fileDiffSum = 0;
FilePatch2[] diffs = patcher.getDiffs();
- for (int i = 0; i < diffs.length; i++) {
- FilePatch2 fileDiff = diffs[i];
+ for (FilePatch2 fileDiff : diffs) {
IHunk[] hunks = fileDiff.getHunks();
- for (int j = 0; j < hunks.length; j++) {
- IHunk hunk = hunks[j];
+ for (IHunk hunk : hunks) {
hunksLengthSum += getNewLength(hunk);
hunksLengthSum -= getOldLength(hunk);
}
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java
index 3f0a4de80..09b049059 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java
@@ -168,17 +168,14 @@ public class StructureCreatorTest extends TestCase {
DocumentRangeNode l, r;
for (int i = 0; i < docs.length; i++)
for (int j = i + 1; j < docs.length; j++)
- for (int k = 0; k < filters.length; k++) {
-
+ for (ICompareFilter[] filter : filters) {
l = new DocumentRangeNode(1, "ID", docs[i], 0,
docs[i].getLength());
r = new DocumentRangeNode(1, "ID", docs[j], 0,
docs[j].getLength());
- creator.contentsEquals(l, 'L', r, 'R', true, filters[k]);
- Assert.assertFalse(creator.contentsEquals(l, 'L', r, 'R',
- false, filters[k]));
- Assert.assertTrue(creator.contentsEquals(l, 'L', r, 'R',
- true, filters[k]));
- }
+ creator.contentsEquals(l, 'L', r, 'R', true, filter);
+ Assert.assertFalse(creator.contentsEquals(l, 'L', r, 'R', false, filter));
+ Assert.assertTrue(creator.contentsEquals(l, 'L', r, 'R', true, filter));
+ }
}
} \ No newline at end of file
diff --git a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/WorkspaceTest.java b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/WorkspaceTest.java
index 0452e6085..8b5f16e11 100644
--- a/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/WorkspaceTest.java
+++ b/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/WorkspaceTest.java
@@ -99,9 +99,10 @@ public class WorkspaceTest extends ResourceTest {
resources.addAll(Arrays.asList(buildResources(container, hierarchy)));
IResource[] result = resources.toArray(new IResource[resources.size()]);
ensureExistsInWorkspace(result, true);
- for (int i = 0; i < result.length; i++) {
- if (result[i].getType() == IResource.FILE) // 3786 bytes is the average size of Eclipse Java files!
- ((IFile) result[i]).setContents(getRandomContents(100), true, false, null);
+ for (IResource r : result) {
+ if (r.getType() == IResource.FILE) {
+ ((IFile) r).setContents(getRandomContents(100), true, false, null);
+ }
}
return result;
}
diff --git a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
index 54d39cc7c..734b4ab4c 100644
--- a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
+++ b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java
@@ -54,8 +54,7 @@ public class NetTest {
setProxiesEnabled(isProxiesDefault);
setSystemProxiesEnabled(isSystemProxiesDefault);
IProxyData[] data = getProxyManager().getProxyData();
- for (int i = 0; i < data.length; i++) {
- IProxyData proxyData = data[i];
+ for (IProxyData proxyData : data) {
proxyData.disable();
}
getProxyManager().setProxyData(data);
@@ -227,8 +226,7 @@ public class NetTest {
private void performSettingData() throws CoreException {
IProxyData[] data = (IProxyData[]) dataCache.values().toArray(new IProxyData[dataCache.size()]);
this.getProxyManager().setProxyData(data);
- for (int i = 0; i < data.length; i++) {
- IProxyData proxyData = data[i];
+ for (IProxyData proxyData : data) {
assertProxyDataEqual(proxyData);
}
isSetEnabled = true;
@@ -241,8 +239,7 @@ public class NetTest {
setDataTest(IProxyData.HTTPS_PROXY_TYPE);
setDataTest(IProxyData.SOCKS_PROXY_TYPE);
IProxyData[] data = this.getProxyManager().getProxyData();
- for (int i = 0; i < data.length; i++) {
- IProxyData proxyData = data[i];
+ for (IProxyData proxyData : data) {
disableProxy(proxyData);
}
}
@@ -257,8 +254,7 @@ public class NetTest {
delaySettingData();
IProxyData[] data = this.getProxyManager().getProxyData();
- for (int i = 0; i < data.length; i++) {
- IProxyData proxyData = data[i];
+ for (IProxyData proxyData : data) {
disableProxy(proxyData);
}
performSettingData();
diff --git a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java
index fdf46745f..918fee7b0 100644
--- a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java
+++ b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java
@@ -59,8 +59,7 @@ public class SystemProxyTest extends TestCase {
setProxiesEnabled(isProxiesDefault);
setSystemProxiesEnabled(isSystemProxiesDefault);
IProxyData[] data = getProxyManager().getProxyData();
- for (int i = 0; i < data.length; i++) {
- IProxyData proxyData = data[i];
+ for (IProxyData proxyData : data) {
proxyData.disable();
}
getProxyManager().setProxyData(data);
@@ -118,10 +117,9 @@ public class SystemProxyTest extends TestCase {
assertNotNull(proxiesData);
Map<String, String> typeMap = new HashMap<>();
- for (int i = 0; i < proxiesData.length; i++) {
- assertProxyDataEqual(proxiesData[i], (IProxyData) proxyDataMap
- .get(proxiesData[i].getType()));
- typeMap.put(proxiesData[i].getType(), proxiesData[i].getType());
+ for (IProxyData p : proxiesData) {
+ assertProxyDataEqual(p, (IProxyData) proxyDataMap.get(p.getType()));
+ typeMap.put(p.getType(), p.getType());
}
assertEquals(3, typeMap.size());
@@ -132,10 +130,9 @@ public class SystemProxyTest extends TestCase {
assertNotNull(proxiesData);
Map<String, String> typeMap = new HashMap<>();
- for (int i = 0; i < proxiesData.length; i++) {
- assertProxyDataEqual(proxiesData[i], (IProxyData) proxyDataMap
- .get(proxiesData[i].getType()));
- typeMap.put(proxiesData[i].getType(), proxiesData[i].getType());
+ for (IProxyData p : proxiesData) {
+ assertProxyDataEqual(p, (IProxyData) proxyDataMap.get(p.getType()));
+ typeMap.put(p.getType(), p.getType());
}
assertEquals(3, typeMap.size());
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeBuildingTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeBuildingTests.java
index 3791b47dc..6f4b6fd6e 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeBuildingTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeBuildingTests.java
@@ -40,8 +40,7 @@ public class ScopeBuildingTests extends TeamTest {
IProgressMonitor monitor) throws CoreException {
super.initialize(monitor);
// Add the additional test mappings to the scope
- for (int i = 0; i < additionalMappings.length; i++) {
- ResourceMapping mapping = additionalMappings[i];
+ for (ResourceMapping mapping : additionalMappings) {
ResourceTraversal[] traversals = mapping.getTraversals(getContext(), monitor);
((ResourceMappingScope)getScope()).addMapping(mapping, traversals);
// TODO: The additional mappings and additional resources boolean will not be set
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java
index c5ec12e43..7db0fd74a 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java
@@ -85,8 +85,7 @@ public class ScopeTests extends TeamTest {
private boolean isInWorkingSet(IProject project) {
IAdaptable[] elements = workingSet.getElements();
- for (int i = 0; i < elements.length; i++) {
- IAdaptable adaptable = elements[i];
+ for (IAdaptable adaptable : elements) {
if (adaptable.equals(project))
return true;
}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java
index 743c95943..f4d01f0b6 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java
@@ -101,8 +101,7 @@ public class ResourceContentTests extends TeamTest {
private void assertContentsMatch(IResource[] resources) {
Set paths = getPaths(ResourcesPlugin.getWorkspace().getRoot());
Set<Object> resourceSet = new HashSet<>();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
resourceSet.add(resource);
}
for (Iterator iterator = paths.iterator(); iterator.hasNext();) {
@@ -124,8 +123,7 @@ public class ResourceContentTests extends TeamTest {
private Set getPaths(Object root) {
Set<Object> result = new HashSet<>();
Object[] elements = provider.getElements(root);
- for (int i = 0; i < elements.length; i++) {
- Object object = elements[i];
+ for (Object object : elements) {
TreePath path = new TreePath(new Object[] { object });
Set childPaths = getPaths(provider, path);
result.addAll(childPaths);
@@ -138,8 +136,7 @@ public class ResourceContentTests extends TeamTest {
Set<TreePath> result = new HashSet<>();
if (children.length == 0)
result.add(path);
- for (int i = 0; i < children.length; i++) {
- Object object = children[i];
+ for (Object object : children) {
TreePath childPath = path.createChildPath(object);
Set childPaths = getPaths(provider, childPath);
result.addAll(childPaths);
@@ -172,8 +169,7 @@ public class ResourceContentTests extends TeamTest {
private IResource[] asResources(IProject project, String[] resourcePaths) {
List<IResource> resources = new ArrayList<>();
- for (int i = 0; i < resourcePaths.length; i++) {
- String path = resourcePaths[i];
+ for (String path : resourcePaths) {
if (path.endsWith("/")) {
resources.add(project.getFolder(path));
} else {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
index 89eddde14..3de1dac8b 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CommandLineCVSClient.java
@@ -73,8 +73,7 @@ public class CommandLineCVSClient implements ICVSClient {
}
private static void appendStrings(StringBuffer commandLine, String[] strings) {
- for (int i = 0; i < strings.length; i++) {
- String string = strings[i];
+ for (String string : strings) {
if (string != null && string.length() != 0) {
commandLine.append(" \"");
commandLine.append(string);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
index 60bd15983..576be08e4 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseCVSClient.java
@@ -76,8 +76,8 @@ public class EclipseCVSClient implements ICVSClient {
// get global options
List<CustomGlobalOption> globals = new ArrayList<>();
- for (int i = 0; i < globalOptions.length; i++) {
- globals.add(new CustomGlobalOption(globalOptions[i]));
+ for (String globalOption : globalOptions) {
+ globals.add(new CustomGlobalOption(globalOption));
}
GlobalOption[] cvsGlobalOptions = globals.toArray(new GlobalOption[globals.size()]);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
index 4e9ecdb6d..a6cdf88e1 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
@@ -286,8 +286,8 @@ public class EclipseTest extends ResourceTest {
*/
public IResource[] changeResources(IContainer container, String[] hierarchy, boolean checkin) throws CoreException, TeamException {
List<IResource> changedResources = new ArrayList<>(hierarchy.length);
- for (int i=0;i<hierarchy.length;i++) {
- IResource resource = container.findMember(hierarchy[i]);
+ for (String h : hierarchy) {
+ IResource resource = container.findMember(h);
if (resource.getType() == IResource.FILE) {
changedResources.add(resource);
setContentsAndEnsureModified((IFile)resource);
@@ -316,8 +316,7 @@ public class EclipseTest extends ResourceTest {
*/
protected void deleteResources(IResource[] resources) throws TeamException, CoreException {
if (resources.length == 0) return;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
delete(resource, IResource.NONE, DEFAULT_MONITOR);
}
}
@@ -330,8 +329,8 @@ public class EclipseTest extends ResourceTest {
}
protected void unmanageResources(IResource[] resources) throws TeamException, CoreException {
- for (int i=0;i<resources.length;i++) {
- CVSWorkspaceRoot.getCVSResourceFor(resources[i]).unmanage(null);
+ for (IResource resource : resources) {
+ CVSWorkspaceRoot.getCVSResourceFor(resource).unmanage(null);
}
}
@@ -552,10 +551,11 @@ public class EclipseTest extends ResourceTest {
resources.add(container);
IResource[] result = resources.toArray(new IResource[resources.size()]);
ensureExistsInWorkspace(result, true);
- for (int i = 0; i < result.length; i++) {
- if (result[i].getType() == IResource.FILE)
+ for (IResource r : result) {
+ if (r.getType() == IResource.FILE) {
// 3786 bytes is the average size of Eclipse Java files!
- ((IFile) result[i]).setContents(getRandomContents(RANDOM_CONTENT_SIZE), true, false, null);
+ ((IFile) r).setContents(getRandomContents(RANDOM_CONTENT_SIZE), true, false, null);
+ }
}
return result;
}
@@ -645,8 +645,8 @@ public class EclipseTest extends ResourceTest {
assertTrue("The number of resource in " + c1.getProjectRelativePath().toString() + " differs",
c1.members().length == c2.members().length);
IResource[] resources = c1.members();
- for (int i= 0;i <resources.length;i++) {
- assertContentsEqual(resources[i], c2.findMember(resources[i].getName()));
+ for (IResource resource : resources) {
+ assertContentsEqual(resource, c2.findMember(resource.getName()));
}
}
@@ -699,8 +699,8 @@ public class EclipseTest extends ResourceTest {
container1.members(ICVSFolder.ALL_EXISTING_MEMBERS).length
== container2.members(ICVSFolder.ALL_EXISTING_MEMBERS).length);
ICVSResource[] resources = container1.members(ICVSFolder.ALL_EXISTING_MEMBERS);
- for (int i= 0;i <resources.length;i++) {
- assertEquals(path, resources[i], container2.getChild(resources[i].getName()), includeTimestamps, includeTags);
+ for (ICVSResource resource : resources) {
+ assertEquals(path, resource, container2.getChild(resource.getName()), includeTimestamps, includeTags);
}
}
@@ -787,13 +787,13 @@ public class EclipseTest extends ResourceTest {
ICVSRemoteResource[] members2 = container2.getMembers(DEFAULT_MONITOR);
assertTrue("Number of members differ for " + path, members1.length == members2.length);
Map<String, ICVSRemoteResource> memberMap2 = new HashMap<>();
- for (int i= 0; i < members2.length; i++) {
- memberMap2.put(members2[i].getName(), members2[i]);
+ for (ICVSRemoteResource m : members2) {
+ memberMap2.put(m.getName(), m);
}
- for (int i= 0; i < members1.length; i++) {
- ICVSRemoteResource member2 = memberMap2.get(members1[i].getName());
- assertNotNull("Resource does not exist: " + path.append(members1[i].getName()) + member2);
- assertEquals(path, members1[i], member2, includeTags);
+ for (ICVSRemoteResource m : members1) {
+ ICVSRemoteResource member2 = memberMap2.get(m.getName());
+ assertNotNull("Resource does not exist: " + path.append(m.getName()) + member2);
+ assertEquals(path, m, member2, includeTags);
}
}
protected void assertEquals(IPath parent, ICVSRemoteResource resource1, ICVSRemoteResource resource2, boolean includeTags) throws CoreException, TeamException, IOException {
@@ -820,8 +820,9 @@ public class EclipseTest extends ResourceTest {
}
protected void assertHasNoRemote(String prefix, IResource[] resources) {
- for (int i=0;i<resources.length;i++)
- assertHasNoRemote(prefix, resources[i]);
+ for (IResource resource : resources) {
+ assertHasNoRemote(prefix, resource);
+ }
}
protected void assertHasNoRemote(String prefix, IResource resource) {
@@ -829,8 +830,9 @@ public class EclipseTest extends ResourceTest {
}
protected void assertHasRemote(String prefix, IResource[] resources) {
- for (int i=0;i<resources.length;i++)
- assertHasRemote(prefix, resources[i]);
+ for (IResource resource : resources) {
+ assertHasRemote(prefix, resource);
+ }
}
protected void assertHasRemote(String prefix, IResource resource) {
@@ -838,8 +840,9 @@ public class EclipseTest extends ResourceTest {
}
protected void assertIsModified(String prefix, IResource[] resources) throws TeamException {
- for (int i=0;i<resources.length;i++)
- assertIsModified(prefix, resources[i]);
+ for (IResource resource : resources) {
+ assertIsModified(prefix, resource);
+ }
}
protected void assertIsModified(String prefix, IResource resource) throws TeamException {
@@ -849,8 +852,9 @@ public class EclipseTest extends ResourceTest {
}
protected void assertNotModified(String prefix, IResource[] resources) throws TeamException {
- for (int i=0;i<resources.length;i++)
- assertNotModified(prefix, resources[i]);
+ for (IResource resource : resources) {
+ assertNotModified(prefix, resource);
+ }
}
protected void assertNotModified(String prefix, IResource resource) throws TeamException {
@@ -869,8 +873,7 @@ public class EclipseTest extends ResourceTest {
}
protected void assertReadOnly(IResource[] resources, final boolean isReadOnly, final boolean recurse) throws CoreException {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
resource.accept(resource1 -> {
if (resource1.getType() == IResource.FILE) {
assertEquals(isReadOnly, resource1.getResourceAttributes().isReadOnly());
@@ -1001,9 +1004,9 @@ public class EclipseTest extends ResourceTest {
protected void commitNewProject(IProject project) throws CoreException, CVSException, TeamException {
List<IResource> resourcesToAdd = new ArrayList<IResource>();
IResource[] members = project.members();
- for (int i = 0; i < members.length; i++) {
- if ( ! CVSWorkspaceRoot.getCVSResourceFor(members[i]).isIgnored()) {
- resourcesToAdd.add(members[i]);
+ for (IResource member : members) {
+ if (!CVSWorkspaceRoot.getCVSResourceFor(member).isIgnored()) {
+ resourcesToAdd.add(member);
}
}
addResources(resourcesToAdd.toArray(new IResource[resourcesToAdd.size()]));
@@ -1082,8 +1085,7 @@ public class EclipseTest extends ResourceTest {
protected static void waitForDecorator() {
// Wait for the decorator job
Job[] decorators = Job.getJobManager().find(DecoratorManager.FAMILY_DECORATE);
- for (int i = 0; i < decorators.length; i++) {
- Job job = decorators[i];
+ for (Job job : decorators) {
waitForJobCompletion(job);
}
}
@@ -1335,8 +1337,9 @@ public class EclipseTest extends ResourceTest {
if (status.isMultiStatus()) {
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++)
- write(children[i], indent + 1);
+ for (IStatus child : children) {
+ write(child, indent + 1);
+ }
}
}
@@ -1371,8 +1374,7 @@ public class EclipseTest extends ResourceTest {
if (status.getException() instanceof CVSCommunicationException) return true;
if (status.isMultiStatus()) {
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus child = children[i];
+ for (IStatus child : children) {
if (child.getException() instanceof CVSCommunicationException) return true;
}
}
@@ -1395,8 +1397,7 @@ public class EclipseTest extends ResourceTest {
if (allJobs.length == 0) {
System.out.println("None"); //$NON-NLS-1$
}
- for (int i = 0; i < allJobs.length; i++) {
- Job job = allJobs[i];
+ for (Job job : allJobs) {
System.out.println(job.getName() + ": " + job.getState());
}
if (CVSTestSetup.FAIL_IF_EXCEPTION_LOGGED) {
@@ -1474,8 +1475,7 @@ public class EclipseTest extends ResourceTest {
protected void assertStatusContainsCode(IStatus status, int code) {
if (status.isMultiStatus()) {
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus child = children[i];
+ for (IStatus child : children) {
if (child.getCode() == code)
return;
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java
index 29a91a420..c55af8dde 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/FindCommittersTest.java
@@ -63,11 +63,9 @@ public class FindCommittersTest extends EclipseTest {
private Set<String> getAuthors(RemoteLogOperation.LogEntryCache logEntryCache) {
String[] paths = logEntryCache.getCachedFilePaths();
Set<String> authors = new HashSet<>();
- for (int i = 0; i < paths.length; i++) {
- String path = paths[i];
+ for (String path : paths) {
ILogEntry[] entries = logEntryCache.getLogEntries(path);
- for (int j = 0; j < entries.length; j++) {
- ILogEntry entry = entries[j];
+ for (ILogEntry entry : entries) {
authors.add(entry.getAuthor());
}
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
index 75af792ff..5e018d788 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/JUnitTestCase.java
@@ -146,8 +146,8 @@ public abstract class JUnitTestCase extends TestCase {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream os = new PrintStream(bos);
try {
- for (int i = 0; i < contents.length; i++) {
- os.println(contents[i]);
+ for (String content : contents) {
+ os.println(content);
}
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
if (file.exists()) {
@@ -299,8 +299,8 @@ public abstract class JUnitTestCase extends TestCase {
*/
protected static void createRandomFile(IContainer parent, String[] fileNameArray)
throws IOException, CoreException {
- for (int i = 0; i < fileNameArray.length; i++) {
- IFile file = parent.getFile(new Path(fileNameArray[i]));
+ for (String fileName : fileNameArray) {
+ IFile file = parent.getFile(new Path(fileName));
createRandomFile(file);
}
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
index 974a020fe..1d72833ac 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
@@ -67,6 +67,7 @@ public final class SameResultEnv extends JUnitTestCase {
* Always to be called in the setUp of the testCase that wants to
* use the same-result environment.
*/
+ @Override
public void setUp() throws Exception {
super.setUp();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -91,6 +92,7 @@ public final class SameResultEnv extends JUnitTestCase {
* Always to be called in the tearDown of the testCase that wants to
* use the same-result environment.
*/
+ @Override
public void tearDown() throws Exception {
// we deliberately don't clean up test projects to simplify debugging
super.tearDown();
@@ -158,6 +160,7 @@ public final class SameResultEnv extends JUnitTestCase {
/**
* Deletes files on the both of the cvs-servers.
*/
+ @Override
public void magicDeleteRemote(String remoteName) throws CVSException {
super.magicDeleteRemote(CompatibleTestSetup.referenceClientRepository, remoteName);
super.magicDeleteRemote(CompatibleTestSetup.eclipseClientRepository, remoteName);
@@ -181,6 +184,7 @@ public final class SameResultEnv extends JUnitTestCase {
* Set up both of the repos on the cvs-server(s) with a file structure
* resulting for your input in the parameter createResources.
*/
+ @Override
public void magicSetUpRepo(String projectName, String[] createResources)
throws IOException, CoreException, CVSException {
magicDeleteRemote(projectName);
@@ -228,8 +232,8 @@ public final class SameResultEnv extends JUnitTestCase {
} else if (! pathRelativeToRoot.endsWith("/")) {
pathRelativeToRoot += "/";
}
- for (int i = 0; i < relativeFileNames.length; i++) {
- createRandomFile(pathRelativeToRoot + relativeFileNames[i]);
+ for (String relativeFileName : relativeFileNames) {
+ createRandomFile(pathRelativeToRoot + relativeFileName);
}
}
@@ -438,16 +442,16 @@ public final class SameResultEnv extends JUnitTestCase {
ICVSResource[] resourceList1 = mFolder1.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.FOLDER_MEMBERS);
ICVSResource[] resourceList2 = mFolder2.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.FOLDER_MEMBERS);
assertEquals(resourceList1.length, resourceList2.length);
- for (int i=0; i<resourceList1.length; i++) {
+ for (ICVSResource r : resourceList1) {
boolean resourceFound = false;
- for (int j=0; j<resourceList2.length; j++) {
- if (resourceList1[i].getName().equals(resourceList2[j].getName())) {
- assertEquals(resourceList1[i], resourceList2[j]);
+ for (ICVSResource _r : resourceList2) {
+ if (r.getName().equals(_r.getName())) {
+ assertEquals(r, _r);
resourceFound = true;
break;
}
}
- assertTrue("Resource " + resourceList1[i].getName() + " not found in the list",resourceFound);
+ assertTrue("Resource " + r.getName() + " not found in the list", resourceFound);
}
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
index 4f9eec2f7..9527a9532 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ModuleTest.java
@@ -270,8 +270,7 @@ public class ModuleTest extends EclipseTest {
}
public RemoteModule getRemoteModule(String moduleName) {
- for (int i = 0; i < remoteModules.length; i++) {
- RemoteModule module = remoteModules[i];
+ for (RemoteModule module : remoteModules) {
// XXX shouldn't be getName
if (module.getName().equals(moduleName))
return module;
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
index 5e0f9dc21..3b2ba5ee3 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java
@@ -71,9 +71,10 @@ public class RemoteResourceTest extends EclipseTest {
protected void getMembers(ICVSRemoteFolder folder, boolean deep) throws TeamException {
ICVSRemoteResource[] children = folder.members(DEFAULT_MONITOR);
if (deep) {
- for (int i=0;i<children.length;i++) {
- if (children[i].isContainer())
- getMembers((ICVSRemoteFolder)children[i], deep);
+ for (ICVSRemoteResource c : children) {
+ if (c.isContainer()) {
+ getMembers((ICVSRemoteFolder) c, deep);
+ }
}
}
}
@@ -243,10 +244,9 @@ public class RemoteResourceTest extends EclipseTest {
ICVSRemoteFile remote = (ICVSRemoteFile)CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("file.txt"));
ILogEntry[] entries = remote.getLogEntries(DEFAULT_MONITOR);
- for (int i=0;i<entries.length;i++) {
- InputStream in = entries[i].getRemoteFile().getContents(DEFAULT_MONITOR);
-
- if (entries[i].getRevision().equals("1.2")) {
+ for (ILogEntry entry : entries) {
+ InputStream in = entry.getRemoteFile().getContents(DEFAULT_MONITOR);
+ if (entry.getRevision().equals("1.2")) {
int count = 0;
byte[] buffer = new byte[1024];
int c;
@@ -256,7 +256,7 @@ public class RemoteResourceTest extends EclipseTest {
}
String contents = new String(buffer, 0, count);
assertEquals("the contents of revision 1.2 are not equal", contents, "hi there");
- } else if (entries[i].getRevision().equals("1.3")) {
+ } else if (entry.getRevision().equals("1.3")) {
int count = 0;
byte[] buffer = new byte[1024];
int c;
@@ -378,18 +378,20 @@ public class RemoteResourceTest extends EclipseTest {
}
private LogEntry getLogEntryByRevision(ILogEntry[] entries, String revision) {
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getRevision().equals(revision) && entries[i] instanceof LogEntry) {
- return (LogEntry) entries[i];
+ for (ILogEntry entry : entries) {
+ if (entry.getRevision().equals(revision) && entry instanceof LogEntry) {
+ return (LogEntry) entry;
}
}
return null;
}
private CVSTag getTagByName(CVSTag[] tags, String name) {
- for (int i = 0; i < tags.length; i++)
- if (tags[i].getName().equals(name))
- return tags[i];
+ for (CVSTag tag : tags) {
+ if (tag.getName().equals(name)) {
+ return tag;
+ }
+ }
return null;
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java
index 30453f9fd..9af4d0526 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ResourceDeltaTest.java
@@ -194,8 +194,7 @@ public class ResourceDeltaTest extends EclipseTest {
return true;
if (status.isMultiStatus()) {
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus child = children[i];
+ for (IStatus child : children) {
if (containsCode(child,code))
return true;
}
@@ -233,8 +232,7 @@ public class ResourceDeltaTest extends EclipseTest {
public void deleteIOFiles(IProject project, String[] cvsFolders)
throws CoreException {
IPath rootPath = project.getLocation();
- for (int i = 0; i < cvsFolders.length; i++) {
- String childPath = cvsFolders[i];
+ for (String childPath : cvsFolders) {
IPath fullPath = rootPath.append(childPath);
deepDelete(fullPath.toFile());
}
@@ -244,8 +242,8 @@ public class ResourceDeltaTest extends EclipseTest {
private static void deepDelete(File resource) {
if (resource.isDirectory()) {
File[] fileList = resource.listFiles();
- for (int i = 0; i < fileList.length; i++) {
- deepDelete(fileList[i]);
+ for (File f : fileList) {
+ deepDelete(f);
}
}
resource.delete();
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java
index a682ec377..7d1c58382 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java
@@ -68,8 +68,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
List<IResource> filesInSet = new ArrayList<>();
getFileChildren(node, filesInSet);
assertTrue("The number of files in the set do not match the expected number", files[i].length == filesInSet.size());
- for (int j = 0; j < files[i].length; j++) {
- IFile file = files[i][j];
+ for (IFile file : files[i]) {
assertTrue("File " + file.getFullPath() + " is not in the set", filesInSet.contains(file));
}
}
@@ -88,8 +87,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
}
private void removeTreeItemsFromList(List<?> nodeList, TreeItem[] items) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
+ for (TreeItem item : items) {
nodeList.remove(item.getData());
TreeItem[] children = item.getItems();
removeTreeItemsFromList(nodeList, children);
@@ -99,8 +97,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
private ChangeSetDiffNode[] getCheckedInChangeSetNodes(ISynchronizeModelElement root) {
List<ChangeSetDiffNode> result = new ArrayList<>();
IDiffElement[] children = root.getChildren();
- for (int i = 0; i < children.length; i++) {
- IDiffElement element = children[i];
+ for (IDiffElement element : children) {
if (element instanceof ChangeSetDiffNode) {
ChangeSetDiffNode node = (ChangeSetDiffNode)element;
if (node.getSet() instanceof CheckedInChangeSet) {
@@ -114,8 +111,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
private ChangeSetDiffNode[] getActiveChangeSetNodes(ISynchronizeModelElement root) {
List<ChangeSetDiffNode> result = new ArrayList<>();
IDiffElement[] children = root.getChildren();
- for (int i = 0; i < children.length; i++) {
- IDiffElement element = children[i];
+ for (IDiffElement element : children) {
if (element instanceof ChangeSetDiffNode) {
ChangeSetDiffNode node = (ChangeSetDiffNode)element;
if (node.getSet() instanceof ActiveChangeSet) {
@@ -135,8 +131,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
list.add(resource);
}
IDiffElement[] children = node.getChildren();
- for (int i = 0; i < children.length; i++) {
- IDiffElement child = children[i];
+ for (IDiffElement child : children) {
getFileChildren((ISynchronizeModelElement)child, list);
}
return;
@@ -144,8 +139,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
private ChangeSetDiffNode getCommitSetFor(ISynchronizeModelElement root, String message) {
IDiffElement[] children = root.getChildren();
- for (int i = 0; i < children.length; i++) {
- IDiffElement element = children[i];
+ for (IDiffElement element : children) {
if (element instanceof ChangeSetDiffNode) {
ChangeSetDiffNode node = (ChangeSetDiffNode)element;
if (node.getSet().getComment().equals(message)) {
@@ -235,11 +229,9 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
assertResourcesAreTheSame(resources, outOfSync, true);
// Assert that all active sets are visible in the view
ChangeSet[] sets = getActiveChangeSetManager().getSets();
- for (int i = 0; i < sets.length; i++) {
- ChangeSet changeSet = sets[i];
+ for (ChangeSet changeSet : sets) {
node = getChangeSetNodeFor(root, changeSet);
assertNotNull("The node for set " + set.getName() + " is not in the view", node);
-
}
ChangeSetDiffNode[] nodes = getActiveChangeSetNodes(root);
assertNodesInViewer(getWorkspaceSubscriber(), nodes);
@@ -247,8 +239,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
private ChangeSetDiffNode getChangeSetNodeFor(ISynchronizeModelElement root, ChangeSet set) {
IDiffElement[] children = root.getChildren();
- for (int i = 0; i < children.length; i++) {
- IDiffElement element = children[i];
+ for (IDiffElement element : children) {
if (element instanceof ChangeSetDiffNode) {
ChangeSetDiffNode node = (ChangeSetDiffNode)element;
if (node.getSet() == set) {
@@ -281,8 +272,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
list.add(info);
}
IDiffElement[] children = node.getChildren();
- for (int i = 0; i < children.length; i++) {
- IDiffElement child = children[i];
+ for (IDiffElement child : children) {
getOutOfSync((ISynchronizeModelElement)child, list);
}
return;
@@ -299,23 +289,19 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
if (doNotAllowExtra) {
if (resources1.length != resources2.length) {
System.out.println("Expected");
- for (int i = 0; i < resources1.length; i++) {
- IResource resource = resources1[i];
+ for (IResource resource : resources1) {
System.out.println(resource.getFullPath().toString());
}
System.out.println("Actual");
- for (int i = 0; i < resources2.length; i++) {
- IResource resource = resources2[i];
+ for (IResource resource : resources2) {
System.out.println(resource.getFullPath().toString());
}
}
assertEquals("The number of resources do not match the expected number", resources1.length, resources2.length);
}
- for (int i = 0; i < resources1.length; i++) {
- IResource resource = resources1[i];
+ for (IResource resource : resources1) {
boolean found = false;
- for (int j = 0; j < resources2.length; j++) {
- IResource resource2 = resources2[j];
+ for (IResource resource2 : resources2) {
if (resource2.equals(resource)) {
found = true;
break;
@@ -333,8 +319,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
private void assertInRootSet(IResource[] resources) throws CoreException {
ISynchronizeModelElement[] nodes = getNonChangeSetRoots(getModelRoot(((SubscriberChangeSetManager)getActiveChangeSetManager()).getSubscriber()));
List<SyncInfo> list = new ArrayList<>();
- for (int i = 0; i < nodes.length; i++) {
- ISynchronizeModelElement element = nodes[i];
+ for (ISynchronizeModelElement element : nodes) {
getOutOfSync(element, list);
}
IResource[] outOfSync = getResources(list.toArray(new SyncInfo[list.size()]));
@@ -348,8 +333,7 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest {
private ISynchronizeModelElement[] getNonChangeSetRoots(ISynchronizeModelElement modelRoot) {
List<ISynchronizeModelElement> result = new ArrayList<>();
IDiffElement[] children = modelRoot.getChildren();
- for (int i = 0; i < children.length; i++) {
- IDiffElement element = children[i];
+ for (IDiffElement element : children) {
if (!(element instanceof ChangeSetDiffNode)) {
result.add((ISynchronizeModelElement) element);
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
index 23ae57dbc..0facedf0b 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
@@ -91,11 +91,9 @@ public abstract class CVSSyncSubscriberTest extends EclipseTest {
protected void assertSyncChangesMatch(ISubscriberChangeEvent[] changes, IResource[] resources) {
// First, ensure that all the resources appear in the delta
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
boolean found = false;
- for (int j = 0; j < changes.length; j++) {
- ISubscriberChangeEvent delta = changes[j];
+ for (ISubscriberChangeEvent delta : changes) {
if (delta.getResource().equals(resource)) {
found = true;
break;
@@ -119,14 +117,15 @@ public abstract class CVSSyncSubscriberTest extends EclipseTest {
*/
protected void assertDeleted(String message, IContainer root, String[] resourcePaths) {
IResource[] resources = getResources(root, resourcePaths);
- for (int i=0;i<resources.length;i++) {
+ for (IResource resource : resources) {
try {
- if (! resources[i].exists())
+ if (!resource.exists()) {
break;
+ }
} catch (AssertionFailedError e) {
break;
}
- assertTrue(message + ": resource " + resources[i] + " still exists in some form", false);
+ assertTrue(message + ": resource " + resource + " still exists in some form", false);
}
}
@@ -139,8 +138,7 @@ public abstract class CVSSyncSubscriberTest extends EclipseTest {
protected IResource[] collect(IResource[] resources, final ResourceCondition condition, int depth) throws CoreException, TeamException {
final Set<IResource> affected = new HashSet<>();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
if (resource.exists() || resource.isPhantom()) {
resource.accept(new IResourceVisitor() {
public boolean visit(IResource r) throws CoreException {
@@ -165,8 +163,7 @@ public abstract class CVSSyncSubscriberTest extends EclipseTest {
protected IResource[] collectAncestors(IResource[] resources, ResourceCondition condition) throws CoreException, TeamException {
Set<IResource> affected = new HashSet<>();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
while (resource.getType() != IResource.ROOT) {
if (condition.matches(resource)) {
affected.add(resource);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CompareEditorTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CompareEditorTests.java
index 608bc2506..c6acde392 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CompareEditorTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CompareEditorTests.java
@@ -124,8 +124,8 @@ public class CompareEditorTests extends CVSSyncSubscriberTest {
private IEditorPart findOpenEditor(IEditorInput input) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorRefs = page.getEditorReferences();
- for (int i = 0; i < editorRefs.length; i++) {
- final IEditorPart part = editorRefs[i].getEditor(false /* don't restore editor */);
+ for (IEditorReference editorRef : editorRefs) {
+ final IEditorPart part = editorRef.getEditor(false /* don't restore editor */);
if(part != null) {
IEditorInput testInput = part.getEditorInput();
if (testInput == input)
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java
index e91264443..d3685b4fd 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java
@@ -110,8 +110,7 @@ public class SyncInfoSource {
protected void assertProjectRemoved(Subscriber subscriber, IProject project) {
IResource[] roots = subscriber.roots();
- for (int i = 0; i < roots.length; i++) {
- IResource resource = roots[i];
+ for (IResource resource : roots) {
if (resource.equals(project)) {
throw new AssertionFailedError();
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSProjectSetImportTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSProjectSetImportTest.java
index cd4702192..7b881e10c 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSProjectSetImportTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CVSProjectSetImportTest.java
@@ -58,8 +58,8 @@ public class CVSProjectSetImportTest extends TestCase {
knownRepositories = KnownRepositories.getInstance();
savedRepositories = knownRepositories.getRepositories();
// dispose all known repositories
- for (int i = 0; i < savedRepositories.length; i++) {
- knownRepositories.disposeRepository(savedRepositories[i]);
+ for (ICVSRepositoryLocation savedRepository : savedRepositories) {
+ knownRepositories.disposeRepository(savedRepository);
}
}
@@ -289,9 +289,8 @@ public class CVSProjectSetImportTest extends TestCase {
*/
private void _testPrepareSuggestedRepositoryLocations(String[] knownLocations,
String[] referenceStrings, String[][] expectedSuggestions) throws Exception {
- for (int i = 0; i < knownLocations.length; i++) {
- knownRepositories.addRepository(CVSRepositoryLocation
- .fromString(knownLocations[i]), false);
+ for (String knownLocation : knownLocations) {
+ knownRepositories.addRepository(CVSRepositoryLocation.fromString(knownLocation), false);
}
Map infoMap = new HashMap(referenceStrings.length);
@@ -369,9 +368,8 @@ public class CVSProjectSetImportTest extends TestCase {
String[] referenceStrings, String[] expectedSelections)
throws Exception {
// set up values to test
- for (int i = 0; i < knownLocations.length; i++) {
- knownRepositories.addRepository(CVSRepositoryLocation
- .fromString(knownLocations[i]), false);
+ for (String knownLocation : knownLocations) {
+ knownRepositories.addRepository(CVSRepositoryLocation.fromString(knownLocation), false);
}
Map infoMap = new HashMap(referenceStrings.length);
@@ -421,8 +419,7 @@ public class CVSProjectSetImportTest extends TestCase {
ICVSRepositoryLocation[] repositories = knownRepositories
.getRepositories();
boolean matchFound = false;
- for (int j = 0; j < repositories.length; j++) {
- ICVSRepositoryLocation rl = repositories[j];
+ for (ICVSRepositoryLocation rl : repositories) {
if (CVSRepositoryLocationMatcher.isMatching(referenceLocation, rl)) {
assertFalse("There should be only one perfect match.",
matchFound);
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java
index c9350fec3..7b0a768f3 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java
@@ -343,8 +343,8 @@ public class CreatePatchTest extends EclipseTest {
children.length > 0);
boolean errorLineOccurred = false;
- for (int i = 0; i < children.length; i++) {
- if (children[i].getCode() == CVSStatus.ERROR_LINE) {
+ for (IStatus child : children) {
+ if (child.getCode() == CVSStatus.ERROR_LINE) {
errorLineOccurred = true;
break;
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java
index 76818f070..eedf96fbc 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java
@@ -58,9 +58,8 @@ public class ParticipantSyncInfoSource extends SyncInfoSource {
public void tearDown() {
ISynchronizeParticipantReference[] participants = TeamUI.getSynchronizeManager().getSynchronizeParticipants();
- for (int i = 0; i < participants.length; i++) {
+ for (ISynchronizeParticipantReference ref : participants) {
try {
- ISynchronizeParticipantReference ref = participants[i];
if(ref.getParticipant().getId().equals(CVSMergeSubscriber.ID)) {
TeamUI.getSynchronizeManager().removeSynchronizeParticipants(new ISynchronizeParticipant[] {ref.getParticipant()});
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PatchTreeTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PatchTreeTest.java
index 9c6ffba85..fba91fe14 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PatchTreeTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PatchTreeTest.java
@@ -98,16 +98,17 @@ public class PatchTreeTest extends EclipseTest {
Object[] expected = { nodeC, nodeB, element, nodeA, nodeD };
assertEquals(expected.length, treeChildren.length);
- for (int i = 0; i < treeChildren.length; i++) {
- assertEquals(1, countByData(treeChildren, treeChildren[i]));
+ for (Item treeChild : treeChildren) {
+ assertEquals(1, countByData(treeChildren, treeChild));
}
}
private int countByData(final Item[] a, Item o) {
int c = 0;
- for (int i = 0; i < a.length; i++) {
- if (a[i].getData() == o.getData())
+ for (Item a1 : a) {
+ if (a1.getData() == o.getData()) {
c++;
+ }
}
return c;
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
index 3ebc90b65..54fe24b16 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
@@ -44,9 +44,8 @@ public class RepositoriesViewTests extends EclipseTest {
// clear repository root cache
RepositoryRoot repositoryRoot = getRepositoryRoot();
String remotePaths[] = repositoryRoot.getKnownRemotePaths();
- for (int i = 0; i < remotePaths.length; i++) {
- repositoryRoot.removeTags(remotePaths[i],
- repositoryRoot.getAllKnownTags(remotePaths[i]));
+ for (String remotePath : remotePaths) {
+ repositoryRoot.removeTags(remotePath, repositoryRoot.getAllKnownTags(remotePath));
}
}
@@ -54,8 +53,8 @@ public class RepositoriesViewTests extends EclipseTest {
RemoteContentProvider rcp = new RemoteContentProvider();
AllRootsElement are = new AllRootsElement();
Object[] repositoryRoots = rcp.getElements(are);
- for (int i = 0; i < repositoryRoots.length; i++) {
- RepositoryRoot repositoryRoot = (RepositoryRoot) repositoryRoots[i];
+ for (Object root : repositoryRoots) {
+ RepositoryRoot repositoryRoot = (RepositoryRoot) root;
if (getRepository().equals(repositoryRoot.getRoot())) {
return repositoryRoot;
}
@@ -150,11 +149,9 @@ public class RepositoriesViewTests extends EclipseTest {
// check if version exists for module
assertTrue(categories[2] instanceof VersionCategory);
Object[] modules = rcp.getChildren(categories[2]);
- for (int i = 0; i < modules.length; i++) {
- if (modules[i] instanceof RemoteModule
- && ((RemoteModule) (modules[i])).getCVSResource().getName()
- .equals(moduleName)) {
- Object folders[] = rcp.getChildren(modules[i]);
+ for (Object module : modules) {
+ if (module instanceof RemoteModule && ((RemoteModule) (module)).getCVSResource().getName().equals(moduleName)) {
+ Object[] folders = rcp.getChildren(module);
assertEquals(1, folders.length);
assertEquals(versionName, ((RemoteFolder) folders[0]).getTag()
.getName());
@@ -228,17 +225,15 @@ public class RepositoriesViewTests extends EclipseTest {
// [Branch_1]/Module_1/Project_1
// [Branch_1]/Module_1/Module_2
assertEquals(2, modules.length);
- for (int i = 0; i < modules.length; i++) {
- if (((RemoteResource) (modules[i])).getName().equals(
- project1.getName())) {
+ for (Object module : modules) {
+ if (((RemoteResource) (module)).getName().equals(project1.getName())) {
// Project_1 should have contents retrieved from CVS
- assertTrue(rcp.hasChildren(modules[i]));
- } else if (((RemoteResource) (modules[i])).getName().equals(
- secondModule)) {
+ assertTrue(rcp.hasChildren(module));
+ } else if (((RemoteResource) (module)).getName().equals(secondModule)) {
// should be only [Branch_1]/Module_1/Module_2/Project_2.
// [Branch_1]/Module_1/Module_2/Project_3 should NOT be on the
// list, it is not branched with Branch_1
- Object[] module2Children = rcp.getChildren(modules[i]);
+ Object[] module2Children = rcp.getChildren(module);
assertEquals(1, module2Children.length);
assertEquals(project2.getName(),
((RemoteResource) module2Children[0]).getName());
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkUtils.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkUtils.java
index 98f5a47f2..e86cb12a6 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkUtils.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkUtils.java
@@ -124,8 +124,8 @@ public class BenchmarkUtils {
public static IStatus findStatusByCode(IStatus status, int code) {
if (status.getCode() == code) return status;
IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus found = findStatusByCode(children[i], code);
+ for (IStatus child : children) {
+ IStatus found = findStatusByCode(child, code);
if (found != null) return found;
}
return null;
@@ -485,8 +485,8 @@ public class BenchmarkUtils {
*/
public static boolean isFolderEmpty(IFolder folder) throws CoreException {
IResource[] members = folder.members();
- for (int i = 0; i < members.length; ++i) {
- if (isValidFile(members[i]) || isValidFolder(members[i])) return false;
+ for (IResource member : members) {
+ if (isValidFile(member) || isValidFolder(member)) return false;
}
return true;
}
@@ -536,8 +536,8 @@ public class BenchmarkUtils {
*/
public static IResource[] filterResources(IResource[] resources) {
List<IResource> list = new ArrayList<>(resources.length);
- for (int i = 0; i < resources.length; ++i) {
- if (isValidResource(resources[i])) list.add(resources[i]);
+ for (IResource resource : resources) {
+ if (isValidResource(resource)) list.add(resource);
}
if (list.size() != resources.length) {
resources = list.toArray(new IResource[list.size()]);
@@ -552,8 +552,10 @@ public class BenchmarkUtils {
if (node == null) return true;
if (node.getKind() != 0) return false;
IDiffElement[] children = node.getChildren();
- for (int i = 0; i < children.length; i++) {
- if (!isEmpty(children[i])) return false;
+ for (IDiffElement child : children) {
+ if (!isEmpty(child)) {
+ return false;
+ }
}
return true;
}
@@ -562,8 +564,10 @@ public class BenchmarkUtils {
if (element.getKind() != 0) return false;
if (element instanceof IDiffContainer) {
IDiffElement[] children = ((DiffNode)element).getChildren();
- for (int i = 0; i < children.length; i++) {
- if (!isEmpty(children[i])) return false;
+ for (IDiffElement child : children) {
+ if (!isEmpty(child)) {
+ return false;
+ }
}
}
return true;

Back to the top