aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java284
-rw-r--r--testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java43
-rw-r--r--testing/src/test/java/org/aspectj/testing/WeaveSpec.java12
-rw-r--r--testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java16
-rw-r--r--testing/src/test/java/org/aspectj/testing/ajde/CompileCommand.java4
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java3
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java32
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java3
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java171
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java144
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java34
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java59
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java10
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java18
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/Sandbox.java49
-rw-r--r--testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java24
-rw-r--r--testing/src/test/java/org/aspectj/testing/run/RunStatus.java12
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java8
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/Diffs.java11
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/FileUtil.java65
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/LangUtil.java122
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java4
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/LineReader.java26
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/LinkCheck.java28
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java27
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/SFileReader.java18
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java13
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java12
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/TestDiffs.java30
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/options/Option.java10
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/options/Options.java14
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java6
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/options/Values.java112
-rw-r--r--testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReader.java30
-rw-r--r--testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java49
-rw-r--r--testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java4
-rw-r--r--testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java14
-rw-r--r--testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java37
38 files changed, 748 insertions, 810 deletions
diff --git a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java
index 0dcc23dfd..67e73ed6c 100644
--- a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java
+++ b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java
@@ -419,27 +419,27 @@ public class Ajctest extends Task implements PropertyChangeListener {
String str = "";
if (files.size() > 0) {
str += "files:" + "\n";
- for (Iterator<File> i = files.iterator(); i.hasNext();) {
- str += "\t" + i.next() + "\n";
- }
+ for (File file : files) {
+ str += "\t" + file + "\n";
+ }
}
if (argfiles.size() > 0) {
str += "argfiles:" + "\n";
- for (Iterator<File> i = argfiles.iterator(); i.hasNext();) {
- str += "\t" + i.next() + "\n";
- }
+ for (File argfile : argfiles) {
+ str += "\t" + argfile + "\n";
+ }
}
if (args.size() > 0) {
str += "args:" + "\n";
- for (Iterator i = args.iterator(); i.hasNext();) {
- str += "\t" + i.next() + "\n";
- }
+ for (Argument arg : args) {
+ str += "\t" + arg + "\n";
+ }
}
if (testclasses.size() > 0) {
str += "classes:" + "\n";
- for (Iterator i = testclasses.iterator(); i.hasNext();) {
- str += "\t" + i.next() + "\n";
- }
+ for (Run testclass : testclasses) {
+ str += "\t" + testclass + "\n";
+ }
}
return str;
}
@@ -581,26 +581,24 @@ public class Ajctest extends Task implements PropertyChangeListener {
File src = getDir(project);
argfiles = new Vector<>();
files = new Vector<>();
- for(Iterator<Argfile> iter = argfileNames.iterator(); iter.hasNext();) {
- String name = iter.next().name;
- File argfile = new File(src, name);
- if (check(argfile, name, location)) argfiles.add(argfile);
- }
+ for (Argfile argfileName : argfileNames) {
+ String name = argfileName.name;
+ File argfile = new File(src, name);
+ if (check(argfile, name, location)) argfiles.add(argfile);
+ }
if (havecludes || argfiles.size() <= 0) {
String[] filenames =
getDirectoryScanner(project).getIncludedFiles();
- for (int j = 0; j < filenames.length; j++) {
- String name = filenames[j];
- if (name.endsWith(".java")) {
- File file = new File(src, name);
- if (check(file, name, location)) files.add(file);
- }
- }
- }
- for (Iterator i = Ajctest.this.testclasses.iterator();
- i.hasNext();) {
- this.testclasses.add((Run)i.next());
- }
+ for (String name : filenames) {
+ if (name.endsWith(".java")) {
+ File file = new File(src, name);
+ if (check(file, name, location)) files.add(file);
+ }
+ }
+ }
+ for (Run run : Ajctest.this.testclasses) {
+ this.testclasses.add(run);
+ }
if (this.classpath == null) {
setClasspath(Ajctest.this.classpath);
}
@@ -611,9 +609,9 @@ public class Ajctest extends Task implements PropertyChangeListener {
this.ajdoc = Ajctest.this.ajdoc;
}
if (this.fork) {
- for (Iterator<Run> i = this.testclasses.iterator(); i.hasNext();) {
- i.next().setFork(fork);
- }
+ for (Run testclass : this.testclasses) {
+ testclass.setFork(fork);
+ }
}
if (!this.noclean) {
this.noclean = Ajctest.this.noclean;
@@ -691,35 +689,35 @@ public class Ajctest extends Task implements PropertyChangeListener {
private void log(String space, List<?> list, String title) {
if (list == null || list.size() < 1) return;
log(space + title);
- for (Iterator<?> i = list.iterator(); i.hasNext();) {
- log(space + " " + i.next());
- }
+ for (Object o : list) {
+ log(space + " " + o);
+ }
}
private void execute(Testset testset, List<Arg> args) throws BuildException {
if (testset.files.size() > 0) {
log("\tfiles:");
- for (Iterator<File> i = testset.files.iterator(); i.hasNext();) {
- log("\t " + i.next());
- }
+ for (File file : testset.files) {
+ log("\t " + file);
+ }
}
if (testset.argfiles.size() > 0) {
log("\targfiles:");
- for (Iterator<File> i = testset.argfiles.iterator(); i.hasNext();) {
- log("\t " + i.next());
- }
+ for (File file : testset.argfiles) {
+ log("\t " + file);
+ }
}
if (args.size() > 0) {
log("\targs:");
- for (Iterator<Arg> i = args.iterator(); i.hasNext();) {
- log("\t " + i.next());
- }
+ for (Arg arg : args) {
+ log("\t " + arg);
+ }
}
if (testset.testclasses.size() > 0) {
log("\tclasses:");
- for (Iterator<Run> i = testset.testclasses.iterator(); i.hasNext();) {
- log("\t " + i.next());
- }
+ for (Run testclass : testset.testclasses) {
+ log("\t " + testclass);
+ }
}
if (!testset.noclean &&
(!isSet("noclean") && !isSet("nocompile"))) {
@@ -728,11 +726,11 @@ public class Ajctest extends Task implements PropertyChangeListener {
}
delete(workingdir);
make(workingdir);
- for (Iterator<String> i = testset.depends.iterator(); i.hasNext();) {
- String target = i.next()+"";
- // todo: capture failures here?
- project.executeTarget(target);
- }
+ for (String depend : testset.depends) {
+ String target = depend + "";
+ // todo: capture failures here?
+ project.executeTarget(target);
+ }
int exit;
if (!isSet("nodoc") && testset.ajdoc != null) {
log("\tdoc... " + testset.ajdoc);
@@ -785,19 +783,18 @@ public class Ajctest extends Task implements PropertyChangeListener {
-1, "run");
} else if (!isSet("norun")) {
- for (Iterator<Run> i = testset.testclasses.iterator(); i.hasNext();) {
- Run testclass = i.next();
- log("\ttest..." + testclass.classname());
- if (null != destdir) {
- testclass.setClassesDir(destdir.getAbsolutePath());
- }
- if ((exit = testclass.executeJava()) != 0) {
- post(testset, new Vector(), testclass.msgs, exit, "run");
- } else {
- fire("run.good");
- }
- fire("run.done");
- }
+ for (Run testclass : testset.testclasses) {
+ log("\ttest..." + testclass.classname());
+ if (null != destdir) {
+ testclass.setClassesDir(destdir.getAbsolutePath());
+ }
+ if ((exit = testclass.executeJava()) != 0) {
+ post(testset, new Vector(), testclass.msgs, exit, "run");
+ } else {
+ fire("run.good");
+ }
+ fire("run.done");
+ }
}
log("");
}
@@ -1288,23 +1285,21 @@ public class Ajctest extends Task implements PropertyChangeListener {
private List<List<Arg>> argcombo(List<Argument> arguments) {
List<Argument> combos = new Vector<>();
List<Arg> always = new Vector<>();
- for (Iterator<Argument> iter = arguments.iterator(); iter.hasNext();) {
- Argument arg = iter.next();
- if (arg.values.size() == 0) arg.values.add("");
- if (!arg.always && !arg.values.contains(null)) arg.values.add(null);
- if (arg.values.size() > 0) {
- combos.add(arg);
- } else if (arg.always) {
- always.add(new Arg(arg.name, arg.values.get(0)+"", arg.isj));
- }
- }
+ for (Argument arg : arguments) {
+ if (arg.values.size() == 0) arg.values.add("");
+ if (!arg.always && !arg.values.contains(null)) arg.values.add(null);
+ if (arg.values.size() > 0) {
+ combos.add(arg);
+ } else if (arg.always) {
+ always.add(new Arg(arg.name, arg.values.get(0) + "", arg.isj));
+ }
+ }
List<List<Arg>> argcombo = combinations(combos);
- for (Iterator<Arg> iter = always.iterator(); iter.hasNext();) {
- Arg arg = iter.next();
- for (Iterator<List<Arg>> comboiter = argcombo.iterator(); comboiter.hasNext();) {
- comboiter.next().add(arg);
- }
- }
+ for (Arg arg : always) {
+ for (List<Arg> argList : argcombo) {
+ argList.add(arg);
+ }
+ }
return argcombo;
}
@@ -1431,9 +1426,9 @@ public class Ajctest extends Task implements PropertyChangeListener {
public AjdocWrapper(Testset testset, List args) {
super(testset, ajdocArgs(args), true);
String[] cmds = testset.getAjdoc().getCommandline().getCommandline();
- for (int i = 0; i < cmds.length; i++) {
- this.args.add(cmds[i]);
- }
+ for (String cmd : cmds) {
+ this.args.add(cmd);
+ }
}
String getMainClassName() {
return "org.aspectj.tools.ajdoc.Main";
@@ -1485,34 +1480,34 @@ public class Ajctest extends Task implements PropertyChangeListener {
cp.append(Path.systemClasspath);
}
cmd.createArgument().setPath(cp);
- for (Iterator iter = args.iterator(); iter.hasNext();) {
- Arg arg = (Arg)iter.next();
- if (arg.isj) {
- cmd.createArgument().setValue(arg.name);
- if (!arg.value.equals("")) {
- cmd.createArgument().setValue(arg.value);
- }
- }
- }
+ for (Object item : args) {
+ Arg arg = (Arg) item;
+ if (arg.isj) {
+ cmd.createArgument().setValue(arg.name);
+ if (!arg.value.equals("")) {
+ cmd.createArgument().setValue(arg.value);
+ }
+ }
+ }
cmd.createArgument().setValue(getMainClassName());
boolean alreadySetDestDir = false;
boolean alreadySetClasspath = false;
- for (Iterator iter = args.iterator(); iter.hasNext();) {
- Arg arg = (Arg)iter.next();
- if (!arg.isj) {
- cmd.createArgument().setValue(arg.name);
- if (arg.name.equals("-d")) {
- setDestdir(arg.value+"");
- alreadySetDestDir = true;
- }
- if (arg.name.equals("-classpath")) {
- alreadySetClasspath = true;
- }
- if (!arg.value.equals("")) {
- cmd.createArgument().setValue(arg.value);
- }
- }
- }
+ for (Object o : args) {
+ Arg arg = (Arg) o;
+ if (!arg.isj) {
+ cmd.createArgument().setValue(arg.name);
+ if (arg.name.equals("-d")) {
+ setDestdir(arg.value + "");
+ alreadySetDestDir = true;
+ }
+ if (arg.name.equals("-classpath")) {
+ alreadySetClasspath = true;
+ }
+ if (!arg.value.equals("")) {
+ cmd.createArgument().setValue(arg.value);
+ }
+ }
+ }
if (destdir == null) {
setDestdir(".");
}
@@ -1530,13 +1525,13 @@ public class Ajctest extends Task implements PropertyChangeListener {
cmd.createArgument().setValue("-classpath");
cmd.createArgument().setPath(_cp);
}
- for (Iterator iter = testset.files.iterator(); iter.hasNext();) {
- cmd.createArgument().setFile((File)iter.next());
- }
- for (Iterator iter = testset.argfiles.iterator(); iter.hasNext();) {
- cmd.createArgument().setValue("-argfile");
- cmd.createArgument().setFile((File)iter.next());
- }
+ for (File value : testset.files) {
+ cmd.createArgument().setFile(value);
+ }
+ for (File file : testset.argfiles) {
+ cmd.createArgument().setValue("-argfile");
+ cmd.createArgument().setFile(file);
+ }
return cmd;
}
}
@@ -1622,19 +1617,18 @@ public class Ajctest extends Task implements PropertyChangeListener {
private List<List<Arg>> combinations(List<Argument> arglist) {
List<List<Arg>> result = new Vector<>();
result.add(new Vector<Arg>());
- for (Iterator<Argument> iter = arglist.iterator(); iter.hasNext();) {
- Argument arg = iter.next();
- int N = result.size();
- for (int i = 0; i < N; i++) {
- List<Arg> to = result.remove(0);
- for (Iterator<String> valiter = arg.values.iterator(); valiter.hasNext();) {
- List<Arg> newlist = new Vector<>(to);
- Object val = valiter.next();
- if (val != null) newlist.add(new Arg(arg.name, val+"", arg.isj));
- result.add(newlist);
- }
- }
- }
+ for (Argument arg : arglist) {
+ int N = result.size();
+ for (int i = 0; i < N; i++) {
+ List<Arg> to = result.remove(0);
+ for (String s : arg.values) {
+ List<Arg> newlist = new Vector<>(to);
+ Object val = s;
+ if (val != null) newlist.add(new Arg(arg.name, val + "", arg.isj));
+ result.add(newlist);
+ }
+ }
+ }
return result;
}
@@ -1764,9 +1758,9 @@ public class Ajctest extends Task implements PropertyChangeListener {
Object[] names = new String[] {
"Task", "Type", "Number", "Time"
};
- for (int i = 0; i < names.length; i++) {
- model.addColumn(names[i]);
- }
+ for (Object name : names) {
+ model.addColumn(name);
+ }
table = new TJable(model, failures);
this.add(new JScrollPane(table), BorderLayout.CENTER);
}
@@ -1841,19 +1835,19 @@ public class Ajctest extends Task implements PropertyChangeListener {
"Files",
"Classnames",
};
- for (int i = 0; i < os.length; i++) {
- String name = os[i]+"";
- JLabel label = new JLabel(name+":");
- JTextField comp = new JTextField(25);
- comp.setEditable(false);
- comp.setBackground(Color.white);
- comp.setBorder(BorderFactory.
- createBevelBorder(BevelBorder.LOWERED));
- label.setLabelFor(comp);
- fields.put(name, comp);
- add(label, gbc.forLabel());
- add(comp, gbc.forField());
- }
+ for (Object o : os) {
+ String name = o + "";
+ JLabel label = new JLabel(name + ":");
+ JTextField comp = new JTextField(25);
+ comp.setEditable(false);
+ comp.setBackground(Color.white);
+ comp.setBorder(BorderFactory.
+ createBevelBorder(BevelBorder.LOWERED));
+ label.setLabelFor(comp);
+ fields.put(name, comp);
+ add(label, gbc.forLabel());
+ add(comp, gbc.forField());
+ }
add(new JLabel(), gbc.forLastLabel());
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java
index 59974f1b1..966166c33 100644
--- a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java
+++ b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java
@@ -68,22 +68,20 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase {
Map<String,AjcTest> ajTests = wired.getSuiteTests();
- for (Iterator<Map.Entry<String,AjcTest>> iterator = ajTests.entrySet().iterator(); iterator.hasNext();) {
- final Map.Entry<String,AjcTest> entry = iterator.next();
-
- suite.addTest(
- new TestCase(entry.getKey().toString()) {
-
- protected void runTest() {
- entry.getValue().runTest(wired);
- }
-
- public String getName() {
- return entry.getKey();
- }
- }
- );
- }
+ for (final Map.Entry<String, AjcTest> entry : ajTests.entrySet()) {
+ suite.addTest(
+ new TestCase(entry.getKey().toString()) {
+
+ protected void runTest() {
+ entry.getValue().runTest(wired);
+ }
+
+ public String getName() {
+ return entry.getKey();
+ }
+ }
+ );
+ }
} catch (Throwable t) {
final String message = t.toString();
suite.addTest(
@@ -99,13 +97,12 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase {
// this simple check avoids failure when no test.. method is found.
// it could be refined to lookup in the hierarchy as well, and excluding private method as JUnit does.
Method[] testMethods = testCaseClass.getDeclaredMethods();
- for (int i = 0; i < testMethods.length; i++) {
- Method testMethod = testMethods[i];
- if (testMethod.getName().startsWith("test")) {
- suite.addTestSuite(testCaseClass);
- break;
- }
- }
+ for (Method testMethod : testMethods) {
+ if (testMethod.getName().startsWith("test")) {
+ suite.addTestSuite(testCaseClass);
+ break;
+ }
+ }
TestSetup wrapper = new TestSetup(suite) {
/* (non-Javadoc)
diff --git a/testing/src/test/java/org/aspectj/testing/WeaveSpec.java b/testing/src/test/java/org/aspectj/testing/WeaveSpec.java
index 2793b63ac..b0907a3c1 100644
--- a/testing/src/test/java/org/aspectj/testing/WeaveSpec.java
+++ b/testing/src/test/java/org/aspectj/testing/WeaveSpec.java
@@ -115,13 +115,13 @@ public class WeaveSpec extends CompileSpec {
private void collectClassFiles(File inDir, List<File> inList, List<File> toExclude) {
File[] contents = inDir.listFiles();
- for (int i = 0; i < contents.length; i++) {
- if (contents[i].getName().endsWith(".class")) {
- if (!toExclude.contains(contents[i])) {
- inList.add(contents[i]);
+ for (File content : contents) {
+ if (content.getName().endsWith(".class")) {
+ if (!toExclude.contains(content)) {
+ inList.add(content);
}
- } else if (contents[i].isDirectory()) {
- collectClassFiles(contents[i],inList, toExclude);
+ } else if (content.isDirectory()) {
+ collectClassFiles(content, inList, toExclude);
}
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java
index f8d12e80e..0c5b6ddeb 100644
--- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java
+++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java
@@ -397,12 +397,11 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
protected Method getMethodStartsWith(JavaClass jc, String prefix, int whichone) {
Method[] meths = jc.getMethods();
- for (int i = 0; i < meths.length; i++) {
- Method method = meths[i];
+ for (Method method : meths) {
System.out.println(method);
if (method.getName().startsWith(prefix)) {
whichone--;
- if (whichone==0) {
+ if (whichone == 0) {
return method;
}
}
@@ -416,8 +415,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
public List<LocalVariable> sortedLocalVariables(LocalVariableTable lvt) {
List<LocalVariable> l = new ArrayList<LocalVariable>();
LocalVariable lv[] = lvt.getLocalVariableTable();
- for (int i = 0; i < lv.length; i++) {
- LocalVariable lvEntry = lv[i];
+ for (LocalVariable lvEntry : lv) {
l.add(lvEntry);
}
Collections.sort(l, new MyComparator());
@@ -448,8 +446,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
StringBuffer sb = new StringBuffer();
sb.append("LocalVariableTable. Entries=#" + lvt.getTableLength()).append("\n");
LocalVariable lv[] = lvt.getLocalVariableTable();
- for (int i = 0; i < lv.length; i++) {
- LocalVariable lvEntry = lv[i];
+ for (LocalVariable lvEntry : lv) {
sb.append(lvEntry.getSignature()).append(" ").append(lvEntry.getName()).append("(").append(lvEntry.getIndex())
.append(") start=").append(lvEntry.getStartPC()).append(" len=").append(lvEntry.getLength()).append("\n");
}
@@ -493,10 +490,9 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
protected Method getMethodFromClass(JavaClass clazz, String methodName) {
Method[] meths = clazz.getMethods();
- for (int i = 0; i < meths.length; i++) {
- Method method = meths[i];
+ for (Method method : meths) {
if (method.getName().equals(methodName)) {
- return meths[i];
+ return method;
}
}
return null;
diff --git a/testing/src/test/java/org/aspectj/testing/ajde/CompileCommand.java b/testing/src/test/java/org/aspectj/testing/ajde/CompileCommand.java
index 86c5fbaf7..ccae0fd43 100644
--- a/testing/src/test/java/org/aspectj/testing/ajde/CompileCommand.java
+++ b/testing/src/test/java/org/aspectj/testing/ajde/CompileCommand.java
@@ -129,8 +129,8 @@ public class CompileCommand implements ICommand {
try {
out = new FileOutputStream(result);
PrintStream outs = new PrintStream(out, true);
- for (int i = 0; i < args.length; i++) {
- outs.println(args[i]);
+ for (String arg : args) {
+ outs.println(arg);
}
return result;
} catch (IOException e) {
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java
index 9e302f41f..993d4f545 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AbstractRunSpec.java
@@ -335,8 +335,7 @@ abstract public class AbstractRunSpec implements IRunSpec {
public void addMessages(List messages) {
if (null != messages) {
- for (Iterator iter = messages.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : messages) {
if (o instanceof IMessage) {
addMessage((IMessage) o);
} else {
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java
index b2060480c..6a7932703 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcMessageHandler.java
@@ -84,10 +84,8 @@ public class AjcMessageHandler extends MessageHandler {
this.ignoreWarnings = ignoreWarnings;
int fails = 0;
int errors = 0;
- for (Iterator iter = expectedMessagesAsList.iterator();
- iter.hasNext();
- ) {
- IMessage m = (IMessage) iter.next();
+ for (Object o : expectedMessagesAsList) {
+ IMessage m = (IMessage) o;
IMessage.Kind kind = m.getKind();
if (IMessage.FAIL.isSameOrLessThan(kind)) {
fails++;
@@ -250,12 +248,10 @@ public class AjcMessageHandler extends MessageHandler {
private boolean expecting(IMessage message) {
boolean match = false;
if (null != message) {
- for (Iterator iter = expectedMessagesAsList.iterator();
- iter.hasNext();
- ) {
+ for (Object o : expectedMessagesAsList) {
// amc - we have to compare against all messages to consume multiple
// text matches on same line. Return true if any matches.
- if (0 == COMP_IMessage.compare(message, iter.next())) {
+ if (0 == COMP_IMessage.compare(message, o)) {
match = true;
}
}
@@ -271,16 +267,16 @@ public class AjcMessageHandler extends MessageHandler {
// remove all expected fail+ (COSTLY)
ArrayList<IMessage> list = new ArrayList<>();
int leftToFilter = numExpectedFailed;
- for (int i = 0; i < result.length; i++) {
+ for (IMessage iMessage : result) {
if ((0 == leftToFilter)
- || !IMessage.FAIL.isSameOrLessThan(result[i].getKind())) {
- list.add(result[i]);
+ || !IMessage.FAIL.isSameOrLessThan(iMessage.getKind())) {
+ list.add(iMessage);
} else {
// see if this failure was expected
- if (expectedMessagesHasMatchFor(result[i])) {
+ if (expectedMessagesHasMatchFor(iMessage)) {
leftToFilter--; // ok, don't add
} else {
- list.add(result[i]);
+ list.add(iMessage);
}
}
}
@@ -293,10 +289,8 @@ public class AjcMessageHandler extends MessageHandler {
* @return true if actual message is matched in the expected messages
*/
private boolean expectedMessagesHasMatchFor(IMessage actual) {
- for (Iterator iter = expectedMessagesAsList.iterator();
- iter.hasNext();
- ) {
- IMessage expected = (IMessage) iter.next();
+ for (Object o : expectedMessagesAsList) {
+ IMessage expected = (IMessage) o;
if (0 == COMP_IMessage.compare(expected, actual)) {
return true;
}
@@ -316,8 +310,8 @@ public class AjcMessageHandler extends MessageHandler {
private void render(// LangUtil instead?
StringBuffer result, String prefix, String suffix, List items) {
if ((null != items)) {
- for (Iterator iter = items.iterator(); iter.hasNext();) {
- result.append(prefix + iter.next() + suffix);
+ for (Object item : items) {
+ result.append(prefix + item + suffix);
}
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java
index 4d1a47ceb..52a3e2266 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcSpecTest.java
@@ -122,8 +122,7 @@ public class AjcSpecTest extends TestCase {
StringBuffer sb = new StringBuffer();
sb.append("[");
boolean first = true;
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- Object o = iter.next();
+ for (Object o : list) {
if (!first) {
sb.append(", ");
} else {
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java
index 629b0a0a3..cd07733ea 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/AjcTest.java
@@ -375,92 +375,91 @@ public class AjcTest extends RunSpecIterator {
runtime.copy(parentRuntime);
String[] globalOptions = runtime.extractOptions(VALID_OPTIONS, true);
- for (int i = 0; i < globalOptions.length; i++) {
- String option = globalOptions[i];
- if (!option.startsWith(OPTION_PREFIX)) {
- throw new Error("only expecting " + OPTION_PREFIX + "..: " + option);
- }
- option = option.substring(OPTION_PREFIX.length());
- boolean keywordMustExist = false;
- List<String> permittedTitles = null;
- List<String> permittedTitleStrings = null;
- String havePr = null;
- if (option.startsWith(REQUIRE_KEYWORDS)) {
- option = option.substring(REQUIRE_KEYWORDS.length());
- keywordMustExist = true;
- } else if (option.startsWith(SKIP_KEYWORDS)) {
- option = option.substring(SKIP_KEYWORDS.length());
- } else if (option.startsWith(TITLE_LIST)) {
- option = option.substring(TITLE_LIST.length());
- permittedTitles = getTitles(option);
- } else if (option.startsWith(TITLE_FAIL_LIST)) {
- option = option.substring(TITLE_FAIL_LIST.length());
- permittedTitles = getTitles(option, true);
- } else if (option.startsWith(TITLE_CONTAINS)) {
- option = option.substring(TITLE_CONTAINS.length());
- permittedTitleStrings = getTitles(option);
- } else if (option.startsWith(PICK_PR)) {
- if (0 == bugId) {
- skipMessage(handler, "bugId required, but no bugId for this test");
- return false;
- } else {
- havePr = "" + bugId;
- }
- option = option.substring(PICK_PR.length());
- } else {
- throw new Error("unrecognized suffix: " + globalOptions[i]
- + " (expecting: " + OPTION_PREFIX + VALID_SUFFIXES + "...)");
- }
- if (null != permittedTitleStrings) {
- boolean gotHit = false;
- for (Iterator<String> iter = permittedTitleStrings.iterator();
- !gotHit && iter.hasNext();
- ) {
- String substring = (String) iter.next();
- if (-1 != this.description.indexOf(substring)) {
- gotHit = true;
- }
- }
- if (!gotHit) {
- String reason = "title "
- + this.description
- + " does not contain any of "
- + option;
- skipMessage(handler, reason);
- return false;
- }
- } else if (null != permittedTitles) {
- if (!permittedTitles.contains(this.description)) {
- String reason = "titlesList "
- + option
- + " did not contain "
- + this.description;
- skipMessage(handler, reason);
- return false;
- }
- } else {
- // all other options handled as comma-delimited lists
- List<String> specs = LangUtil.commaSplit(option);
- // XXX also throw Error on empty specs...
- for (Iterator<String> iter = specs.iterator(); iter.hasNext();) {
- String spec = (String) iter.next();
- if (null != havePr) {
- if (havePr.equals(spec)) { // String.equals()
- havePr = null;
- }
- } else if (keywordMustExist != keywords.contains(spec)) {
- String reason = "keyword " + spec
- + " was " + (keywordMustExist ? "not found" : "found");
- skipMessage(handler, reason);
- return false;
- }
- }
- if (null != havePr) {
- skipMessage(handler, "bugId required, but not matched for this test");
- return false;
- }
- }
- }
+ for (String globalOption : globalOptions) {
+ String option = globalOption;
+ if (!option.startsWith(OPTION_PREFIX)) {
+ throw new Error("only expecting " + OPTION_PREFIX + "..: " + option);
+ }
+ option = option.substring(OPTION_PREFIX.length());
+ boolean keywordMustExist = false;
+ List<String> permittedTitles = null;
+ List<String> permittedTitleStrings = null;
+ String havePr = null;
+ if (option.startsWith(REQUIRE_KEYWORDS)) {
+ option = option.substring(REQUIRE_KEYWORDS.length());
+ keywordMustExist = true;
+ } else if (option.startsWith(SKIP_KEYWORDS)) {
+ option = option.substring(SKIP_KEYWORDS.length());
+ } else if (option.startsWith(TITLE_LIST)) {
+ option = option.substring(TITLE_LIST.length());
+ permittedTitles = getTitles(option);
+ } else if (option.startsWith(TITLE_FAIL_LIST)) {
+ option = option.substring(TITLE_FAIL_LIST.length());
+ permittedTitles = getTitles(option, true);
+ } else if (option.startsWith(TITLE_CONTAINS)) {
+ option = option.substring(TITLE_CONTAINS.length());
+ permittedTitleStrings = getTitles(option);
+ } else if (option.startsWith(PICK_PR)) {
+ if (0 == bugId) {
+ skipMessage(handler, "bugId required, but no bugId for this test");
+ return false;
+ } else {
+ havePr = "" + bugId;
+ }
+ option = option.substring(PICK_PR.length());
+ } else {
+ throw new Error("unrecognized suffix: " + globalOption
+ + " (expecting: " + OPTION_PREFIX + VALID_SUFFIXES + "...)");
+ }
+ if (null != permittedTitleStrings) {
+ boolean gotHit = false;
+ for (Iterator<String> iter = permittedTitleStrings.iterator();
+ !gotHit && iter.hasNext();
+ ) {
+ String substring = (String) iter.next();
+ if (-1 != this.description.indexOf(substring)) {
+ gotHit = true;
+ }
+ }
+ if (!gotHit) {
+ String reason = "title "
+ + this.description
+ + " does not contain any of "
+ + option;
+ skipMessage(handler, reason);
+ return false;
+ }
+ } else if (null != permittedTitles) {
+ if (!permittedTitles.contains(this.description)) {
+ String reason = "titlesList "
+ + option
+ + " did not contain "
+ + this.description;
+ skipMessage(handler, reason);
+ return false;
+ }
+ } else {
+ // all other options handled as comma-delimited lists
+ List<String> specs = LangUtil.commaSplit(option);
+ // XXX also throw Error on empty specs...
+ for (String spec : specs) {
+ if (null != havePr) {
+ if (havePr.equals(spec)) { // String.equals()
+ havePr = null;
+ }
+ } else if (keywordMustExist != keywords.contains(spec)) {
+ String reason = "keyword " + spec
+ + " was " + (keywordMustExist ? "not found" : "found");
+ skipMessage(handler, reason);
+ return false;
+ }
+ }
+ if (null != havePr) {
+ skipMessage(handler, "bugId required, but not matched for this test");
+ return false;
+ }
+ }
+ }
return true;
}
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java
index c5d4b0b60..6c8b2ba5f 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java
@@ -134,16 +134,15 @@ public class CompilerRun implements IAjcRun {
return new String[0];
}
ArrayList result = new ArrayList();
- for (int i = 0; i < inputs.length; i++) {
- String input = inputs[i];
- if (null == input) {
- continue;
- }
- File inputFile = new File(baseDir, input);
- if (inputFile.canRead() && inputFile.isDirectory()) {
- result.add(input);
- }
- }
+ for (String input : inputs) {
+ if (null == input) {
+ continue;
+ }
+ File inputFile = new File(baseDir, input);
+ if (inputFile.canRead() && inputFile.isDirectory()) {
+ result.add(input);
+ }
+ }
return (String[]) result.toArray(new String[0]);
}
@@ -167,25 +166,24 @@ public class CompilerRun implements IAjcRun {
suffixes = temp;
}
ArrayList result = new ArrayList();
- for (int i = 0; i < inputs.length; i++) {
- String input = inputs[i];
- if (null == input) {
- continue;
- }
- if (!ignoreCase) {
- input = input.toLowerCase();
- }
- for (int j = 0; j < suffixes.length; j++) {
- String suffix = suffixes[j];
- if (null == suffix) {
- continue;
- }
- if (input.endsWith(suffix)) {
- result.add(input);
- break;
- }
- }
- }
+ for (String s : inputs) {
+ String input = s;
+ if (null == input) {
+ continue;
+ }
+ if (!ignoreCase) {
+ input = input.toLowerCase();
+ }
+ for (String suffix : suffixes) {
+ if (null == suffix) {
+ continue;
+ }
+ if (input.endsWith(suffix)) {
+ result.add(input);
+ break;
+ }
+ }
+ }
return (String[]) result.toArray(new String[0]);
}
@@ -407,12 +405,12 @@ public class CompilerRun implements IAjcRun {
return (first != last);
}
};
- for (int i = 0; i < sourcerootFiles.length; i++) {
- FileUtil.deleteContents(
- sourcerootFiles[i],
- pickIncFiles,
- false);
- }
+ for (File sourcerootFile : sourcerootFiles) {
+ FileUtil.deleteContents(
+ sourcerootFile,
+ pickIncFiles,
+ false);
+ }
if (0 < sourcerootFiles.length) {
FileUtil.sleepPastFinalModifiedTime(
sourcerootFiles);
@@ -469,9 +467,9 @@ public class CompilerRun implements IAjcRun {
}
if (!LangUtil.isEmpty(argFiles)) {
String[] ra = FileUtil.getPaths(argFiles);
- for (int j = 0; j < ra.length; j++) {
- arguments.add("@" + ra[j]);
- }
+ for (String s : ra) {
+ arguments.add("@" + s);
+ }
if (!spec.badInput && spec.isStaging) {
validator.fail(
"warning: files listed in argfiles not staged");
@@ -602,13 +600,11 @@ public class CompilerRun implements IAjcRun {
false,
slop);
if (!LangUtil.isEmpty(found)) {
- for (Iterator iter = found.iterator();
- iter.hasNext();
- ) {
- MessageUtil.info(
- status,
- Spec.SEEK_MESSAGE_PREFIX + iter.next());
- }
+ for (Object o : found) {
+ MessageUtil.info(
+ status,
+ Spec.SEEK_MESSAGE_PREFIX + o);
+ }
}
}
ICommand compiler = spec.reuseCompiler
@@ -1198,16 +1194,14 @@ public class CompilerRun implements IAjcRun {
boolean hasInvalidOptions(Values values, TestSetup result) {
// not supporting 1.0 options any more
- for (Iterator iter = CRSOPTIONS.invalidOptions.iterator();
- iter.hasNext();
- ) {
- Option option = (Option) iter.next();
- if (null != values.firstOption(option)) {
- result.failureReason =
- "invalid option in harness: " + option;
- return true;
- }
- }
+ for (Object o : CRSOPTIONS.invalidOptions) {
+ Option option = (Option) o;
+ if (null != values.firstOption(option)) {
+ result.failureReason =
+ "invalid option in harness: " + option;
+ return true;
+ }
+ }
return false;
}
@@ -1243,15 +1237,13 @@ public class CompilerRun implements IAjcRun {
return true;
}
// not supporting 1.0 options any more
- for (Iterator iter = CRSOPTIONS.ajc10Options.iterator();
- iter.hasNext();
- ) {
- Option option = (Option) iter.next();
- if (null != values.firstOption(option)) {
- result.failureReason = "old ajc 1.0 option: " + option;
- return true;
- }
- }
+ for (Object o : CRSOPTIONS.ajc10Options) {
+ Option option = (Option) o;
+ if (null != values.firstOption(option)) {
+ result.failureReason = "old ajc 1.0 option: " + option;
+ return true;
+ }
+ }
return false;
}
@@ -1771,21 +1763,17 @@ public class CompilerRun implements IAjcRun {
};
// among options not permitted: extdirs...
-
- for (int i = 0; i < options.length; i++) {
- crsOptions.addOption(options[i]);
- }
- for (Iterator iter = compilerOptions.iterator();
- iter.hasNext();
- ) {
- crsOptions.addOption((Option) iter.next());
- }
+
+ for (Option option : options) {
+ crsOptions.addOption(option);
+ }
+ for (Object compilerOption : compilerOptions) {
+ crsOptions.addOption((Option) compilerOption);
+ }
// these are recognized but records with them are skipped
- for (Iterator iter = ajc10Options.iterator();
- iter.hasNext();
- ) {
- crsOptions.addOption((Option) iter.next());
- }
+ for (Object ajc10Option : ajc10Options) {
+ crsOptions.addOption((Option) ajc10Option);
+ }
crsOptions.freeze();
}
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java
index 1a8873072..12b91679a 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRunSpecTest.java
@@ -204,17 +204,17 @@ public class CompilerRunSpecTest extends TestCase {
Set options = crsOptions.compilerOptions();
assertTrue(null != options);
StringBuffer notLoaded = new StringBuffer();
- for (Iterator iter = options.iterator(); iter.hasNext();) {
- Option compilerOption = (Option) iter.next();
- if (!(crsOptions.compilerIsLoadable(compilerOption))) {
- notLoaded.append(" " + compilerOption);
- } else {
- String className = crsOptions.compilerClassName(compilerOption);
- String argValue = compilerOption.toString(); // XXX snoop
- String arg = Option.ON.render(argValue);
- checkCompilerOption(arg, className);
- }
- }
+ for (Object option : options) {
+ Option compilerOption = (Option) option;
+ if (!(crsOptions.compilerIsLoadable(compilerOption))) {
+ notLoaded.append(" " + compilerOption);
+ } else {
+ String className = crsOptions.compilerClassName(compilerOption);
+ String argValue = compilerOption.toString(); // XXX snoop
+ String arg = Option.ON.render(argValue);
+ checkCompilerOption(arg, className);
+ }
+ }
if (0 < notLoaded.length()) {
System.err.println(
getClass().getName()
@@ -298,12 +298,12 @@ public class CompilerRunSpecTest extends TestCase {
new String[] { "-verbose", "-g:vars,source" },
};
// normal
- for (int i = 0; i < input.length; i++) {
- optionChecker.checkOptions(input[i], input[i]);
- }
- for (int i = 0; i < literalInput.length; i++) {
- optionChecker.checkOptions(literalInput[i], literalInput[i]);
- }
+ for (String[] value : input) {
+ optionChecker.checkOptions(value, value);
+ }
+ for (String[] strings : literalInput) {
+ optionChecker.checkOptions(strings, strings);
+ }
// force-on
String[][] forceInput = duplicate(input, "!");
for (int i = 0; i < input.length; i++) {
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java
index 13281607b..95977aeee 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/DirChanges.java
@@ -238,31 +238,31 @@ public class DirChanges {
// final File expDir = ((!doCompare || (null == spec.expDir))
// ? null
// : new File(baseDir, spec.expDir));
- for (Iterator iter = pathList.iterator(); iter.hasNext();) {
- final String entry = (String) iter.next() ;
- String path = entry ;
- if (null != spec.defaultSuffix) {
- if (".class".equals(spec.defaultSuffix)) {
- path = path.replace('.', '/');
- }
- path = path + spec.defaultSuffix;
- }
- File actualFile = new File(baseDir, path);
- if (exists != (actualFile.canRead() && actualFile.isFile()
- && (expectStartEarlier
- ? startTime <= actualFile.lastModified()
- : startTime > actualFile.lastModified()
- ))) {
- failMessage(handler, exists, label, path, actualFile);
- if (result) {
- result = false;
- }
- } else if (exists && doCompare && (null != fileChecker)) {
- if (!fileChecker.checkFile(handler, path, actualFile) && result) {
- result = false;
- }
- }
- }
+ for (Object o : pathList) {
+ final String entry = (String) o;
+ String path = entry;
+ if (null != spec.defaultSuffix) {
+ if (".class".equals(spec.defaultSuffix)) {
+ path = path.replace('.', '/');
+ }
+ path = path + spec.defaultSuffix;
+ }
+ File actualFile = new File(baseDir, path);
+ if (exists != (actualFile.canRead() && actualFile.isFile()
+ && (expectStartEarlier
+ ? startTime <= actualFile.lastModified()
+ : startTime > actualFile.lastModified()
+ ))) {
+ failMessage(handler, exists, label, path, actualFile);
+ if (result) {
+ result = false;
+ }
+ } else if (exists && doCompare && (null != fileChecker)) {
+ if (!fileChecker.checkFile(handler, path, actualFile) && result) {
+ result = false;
+ }
+ }
+ }
}
return result;
}
@@ -600,12 +600,11 @@ public class DirChanges {
return;
}
LangUtil.throwIaxIfNull(out, "out");
- for (Iterator<DirChanges.Spec> iter = dirChanges.iterator(); iter.hasNext();) {
- DirChanges.Spec spec = iter.next();
+ for (Spec spec : dirChanges) {
if (null == spec) {
- continue;
- }
- spec.writeXml(out);
+ continue;
+ }
+ spec.writeXml(out);
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java
index ac707a183..a0c48878e 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/IncCompilerRun.java
@@ -413,11 +413,11 @@ public class IncCompilerRun implements IAjcRun {
if (null != items) {
String[] classes = XMLWriter.unflattenList(items);
if (!LangUtil.isEmpty(classes)) {
- for (int i = 0; i < classes.length; i++) {
- if (!LangUtil.isEmpty(classes[i])) {
- list.add(classes[i]);
- }
- }
+ for (String aClass : classes) {
+ if (!LangUtil.isEmpty(aClass)) {
+ list.add(aClass);
+ }
+ }
}
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java
index c891f134c..ee07fe4f6 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java
@@ -58,17 +58,17 @@ public class ParseTestCase extends TestCase {
Sandbox sandbox = new Sandbox(new File("testdata"), validator);
IRunListener listenerNULL = null;
ISourceLocation sl = new SourceLocation(suiteFile, 0, 0,0);
- for (Iterator iter = tests.iterator(); iter.hasNext();) {
- status = new RunStatus(handler, runner);
- AjcTest.Spec test = (AjcTest.Spec) iter.next();
- test.setSourceLocation(sl);
+ for (Object o : tests) {
+ status = new RunStatus(handler, runner);
+ AjcTest.Spec test = (AjcTest.Spec) o;
+ test.setSourceLocation(sl);
IRunIterator child = test.makeRunIterator(sandbox, validator);
- //test.setup(new String[0], validator); // XXX
+ //test.setup(new String[0], validator); // XXX
//IRun child = runner.wrap(test, null);
- // huh? runIterator not generating child status?
- //RunStatus childStatus = runner.makeChildStatus();
- runner.runIterator(child, status, listenerNULL);
- MessageUtil.print(System.err, status);
+ // huh? runIterator not generating child status?
+ //RunStatus childStatus = runner.makeChildStatus();
+ runner.runIterator(child, status, listenerNULL);
+ MessageUtil.print(System.err, status);
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/Sandbox.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/Sandbox.java
index f7f4df31e..5108444e1 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/Sandbox.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/Sandbox.java
@@ -341,13 +341,12 @@ public class Sandbox {
ArrayList result = new ArrayList();
NamesFilter filter = new NamesFilter(names);
File[] bases = { testBaseDir, sandboxDir };
- for (int i = 0; i < bases.length; i++) {
- File base = bases[i];
- if ((null == base) || !base.canRead()) {
- continue;
- }
- result.addAll(Arrays.asList(FileUtil.listFiles(base, filter)));
- }
+ for (File base : bases) {
+ if ((null == base) || !base.canRead()) {
+ continue;
+ }
+ result.addAll(Arrays.asList(FileUtil.listFiles(base, filter)));
+ }
return (File[]) result.toArray(new File[0]);
}
File getTestBaseSrcDir(JavaRun caller) {
@@ -482,11 +481,10 @@ public class Sandbox {
assertState(null != compileClasspath, "classpath not set");
ArrayList result = new ArrayList();
File[] src = compileClasspath;
- for (int i = 0; i < src.length; i++) {
- File f = src[i];
- if ((null != f) && (f.isDirectory()) && (!readable || f.canRead())) {
- result.add(f);
- }
+ for (File f : src) {
+ if ((null != f) && (f.isDirectory()) && (!readable || f.canRead())) {
+ result.add(f);
+ }
}
if (includeOutput && (null != classesDir)
&& (!readable || classesDir.canRead())) {
@@ -505,16 +503,15 @@ public class Sandbox {
assertState(null != compileClasspath, "classpath not set");
ArrayList result = new ArrayList();
File[][] src = new File[][] { compileClasspath, aspectpath };
- for (int i = 0; i < src.length; i++) {
- File[] paths = src[i];
- int len = (null == paths ? 0 : paths.length);
- for (int j = 0; j < len; j++) {
- File f = paths[j];
- if (FileUtil.isZipFile(f) && (!readable || f.canRead())) {
- result.add(f);
- }
+ for (File[] paths : src) {
+ int len = (null == paths ? 0 : paths.length);
+ for (int j = 0; j < len; j++) {
+ File f = paths[j];
+ if (FileUtil.isZipFile(f) && (!readable || f.canRead())) {
+ result.add(f);
+ }
}
- }
+ }
return (File[]) result.toArray(new File[0]);
}
@@ -562,11 +559,11 @@ public class Sandbox {
if (null != file) {
String name = file.getName();
if ((null != name) && (null != names)) {
- for (int i = 0; i < names.length; i++) {
- if (name.equals(names[i])) {
- return true;
- }
- }
+ for (String s : names) {
+ if (name.equals(s)) {
+ return true;
+ }
+ }
}
}
return false;
diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java
index 5bb1a15b2..a0b4f5e96 100644
--- a/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java
+++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/Validator.java
@@ -150,8 +150,8 @@ public class Validator {
public boolean nullcheck(Collection list, String message) {
if (nullcheck((Object) list, message + " list")) {
int i = 0;
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- if (!nullcheck(iter.next(), message + "[" + i++ + "]")) {
+ for (Object o : list) {
+ if (!nullcheck(o, message + "[" + i++ + "]")) {
return false;
}
}
@@ -286,9 +286,8 @@ public class Validator {
public boolean canReadFiles(Collection dirs, String message) {
if (nullcheck((Object) dirs, message + " files")) {
int i = 0;
- for (Iterator iter = dirs.iterator(); iter.hasNext();) {
- Object o = iter.next();
- if (! (o instanceof File)) {
+ for (Object o : dirs) {
+ if (!(o instanceof File)) {
fail(i + ": not a file " + o);
}
if (!canRead((File) o, message + "[" + i++ + "]")) {
@@ -319,9 +318,8 @@ public class Validator {
public boolean canReadDirs(Collection dirs, String message) {
if (nullcheck((Object) dirs, message + " dirs")) {
int i = 0;
- for (Iterator iter = dirs.iterator(); iter.hasNext();) {
- Object o = iter.next();
- if (! (o instanceof File)) {
+ for (Object o : dirs) {
+ if (!(o instanceof File)) {
fail(i + ": not a file " + o);
}
if (!canReadDir((File) o, message + "[" + i++ + "]")) {
@@ -353,9 +351,8 @@ public class Validator {
public boolean canWriteFiles(Collection dirs, String message) {
if (nullcheck((Object) dirs, message + " files")) {
int i = 0;
- for (Iterator iter = dirs.iterator(); iter.hasNext();) {
- Object o = iter.next();
- if (! (o instanceof File)) {
+ for (Object o : dirs) {
+ if (!(o instanceof File)) {
fail(i + ": not a file " + o);
}
if (!canWrite((File) o, message + "[" + i++ + "]")) {
@@ -387,9 +384,8 @@ public class Validator {
public boolean canWriteDirs(Collection dirs, String message) {
if (nullcheck((Object) dirs, message + " dirs")) {
int i = 0;
- for (Iterator iter = dirs.iterator(); iter.hasNext();) {
- Object o = iter.next();
- if (! (o instanceof File)) {
+ for (Object o : dirs) {
+ if (!(o instanceof File)) {
fail(i + ": not a file " + o);
}
if (!canWriteDir((File) o, message + "[" + i++ + "]")) {
diff --git a/testing/src/test/java/org/aspectj/testing/run/RunStatus.java b/testing/src/test/java/org/aspectj/testing/run/RunStatus.java
index ac22280ba..272f57103 100644
--- a/testing/src/test/java/org/aspectj/testing/run/RunStatus.java
+++ b/testing/src/test/java/org/aspectj/testing/run/RunStatus.java
@@ -230,8 +230,8 @@ public class RunStatus implements IRunStatus {
}
if (includeChildren) {
IRunStatus[] kids = getChildren();
- for (int i = 0; i < kids.length; i++) {
- if (kids[i].hasAnyMessage(kind, orGreater, true)) {
+ for (IRunStatus kid : kids) {
+ if (kid.hasAnyMessage(kind, orGreater, true)) {
return true;
}
}
@@ -250,8 +250,8 @@ public class RunStatus implements IRunStatus {
}
IRunStatus[] kids = getChildren();
- for (int i = 0; i < kids.length; i++) {
- result = kids[i].getMessages(kind, orGreater, includeChildren);
+ for (IRunStatus kid : kids) {
+ result = kid.getMessages(kind, orGreater, includeChildren);
if (!LangUtil.isEmpty(result)) {
sink.addAll(Arrays.asList(result));
}
@@ -429,8 +429,8 @@ public class RunStatus implements IRunStatus {
if ((null != children) && (0 < children.size())) {
String label = "### --------- " + name;
int index = 0;
- for (Iterator iter = children.iterator(); iter.hasNext();) {
- IRunStatus childStatus = (IRunStatus) iter.next();
+ for (Object child : children) {
+ IRunStatus childStatus = (IRunStatus) child;
String childLabel = "\n" + label + " child[" + index++ + "] " + childStatus.getIdentifier();
sb.append(childLabel + " ---- start\n");
sb.append(childStatus.toString());
diff --git a/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java b/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java
index a4672b23f..a6e4c7cab 100644
--- a/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java
+++ b/testing/src/test/java/org/aspectj/testing/util/BridgeUtil.java
@@ -458,10 +458,10 @@ public class BridgeUtil {
final int numTests = numIncomplete + numChildren + numSkips;
int numFails = 0;
if (!LangUtil.isEmpty(children)) {
- for (int i = 0; i < children.length; i++) {
- if (!RunValidator.NORMAL.runPassed(children[i])) {
- numFails++;
- }
+ for (IRunStatus child : children) {
+ if (!RunValidator.NORMAL.runPassed(child)) {
+ numFails++;
+ }
}
}
final int numPass = children.length - numFails;
diff --git a/testing/src/test/java/org/aspectj/testing/util/Diffs.java b/testing/src/test/java/org/aspectj/testing/util/Diffs.java
index dd54fa4da..fee19a3e1 100644
--- a/testing/src/test/java/org/aspectj/testing/util/Diffs.java
+++ b/testing/src/test/java/org/aspectj/testing/util/Diffs.java
@@ -455,8 +455,7 @@ public class Diffs {
Collections.sort(sink, MESSAGE_LINEKIND);
return sink;
}
- for (int i = 0; i < source.length; i++) {
- IMessage message = source[i];
+ for (IMessage message : source) {
IMessage.Kind mkind = message.getKind();
boolean skipping = false;
for (int j = 0; !skipping && (j < skip.length); j++) {
@@ -521,12 +520,12 @@ public class Diffs {
LangUtil.throwIaxIfNull(handler, "handler");
LangUtil.throwIaxIfNull(kind, "kind");
if (different) {
- for (Iterator iter = missing.iterator(); iter.hasNext();) {
- String s = MessageUtil.renderMessage((IMessage) iter.next());
+ for (Object value : missing) {
+ String s = MessageUtil.renderMessage((IMessage) value);
MessageUtil.fail(handler, "missing " + label + ": " + s);
}
- for (Iterator iter = unexpected.iterator(); iter.hasNext();) {
- String s = MessageUtil.renderMessage((IMessage) iter.next());
+ for (Object o : unexpected) {
+ String s = MessageUtil.renderMessage((IMessage) o);
MessageUtil.fail(handler, "unexpected " + label + ": " + s);
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java
index 86db6baa5..a47f694e4 100644
--- a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java
+++ b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java
@@ -133,12 +133,11 @@ public class FileUtil {
// normalize sources to ignore
final ArrayList expected = (!checkExpected ? null : new ArrayList());
if (checkExpected) {
- for (int i = 0; i < expectedPaths.length; i++) {
- String srcPath = expectedPaths[i];
- if (!LangUtil.isEmpty(srcPath)) {
- expected.add(org.aspectj.util.FileUtil.weakNormalize(srcPath));
- }
- }
+ for (String srcPath : expectedPaths) {
+ if (!LangUtil.isEmpty(srcPath)) {
+ expected.add(org.aspectj.util.FileUtil.weakNormalize(srcPath));
+ }
+ }
}
// gather, normalize paths changed
@@ -166,18 +165,16 @@ public class FileUtil {
return false;
}
} else {
- for (Iterator iter = expected.iterator();
- iter.hasNext();
- ) {
- String exp = (String) iter.next();
- if (path.startsWith(exp)) {
- String suffix = path.substring(exp.length());
- if (-1 == suffix.indexOf("/")) { // normalized...
- expected.remove(path);
- // found - do not add to unexpected
- return false;
- }
- }
+ for (Object o : expected) {
+ String exp = (String) o;
+ if (path.startsWith(exp)) {
+ String suffix = path.substring(exp.length());
+ if (-1 == suffix.indexOf("/")) { // normalized...
+ expected.remove(path);
+ // found - do not add to unexpected
+ return false;
+ }
+ }
}
}
}
@@ -292,26 +289,26 @@ public class FileUtil {
// go through files first
File[] files = file.listFiles(ValidFileFilter.FILE_EXISTS);
if (null != files) {
- for (int i = 0; i < files.length; i++) {
- if (!fileFilter.accept(files[i])) {
- return false;
- }
- }
+ for (File value : files) {
+ if (!fileFilter.accept(value)) {
+ return false;
+ }
+ }
}
// now recurse to handle directories
File[] dirs = file.listFiles(ValidFileFilter.DIR_EXISTS);
if (null != dirs) {
- for (int i = 0; i < dirs.length; i++) {
- if (userRecursion) {
- if (!fileFilter.accept(dirs[i])) {
- return false;
- }
- } else {
- if (!descendFileTree(dirs[i], fileFilter,userRecursion)) {
- return false;
- }
- }
- }
+ for (File dir : dirs) {
+ if (userRecursion) {
+ if (!fileFilter.accept(dir)) {
+ return false;
+ }
+ } else {
+ if (!descendFileTree(dir, fileFilter, userRecursion)) {
+ return false;
+ }
+ }
+ }
}
} // readable directory (ignore unreadable ones)
return true;
diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java
index 2baf81c48..e78ec84c8 100644
--- a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java
+++ b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java
@@ -406,18 +406,18 @@ public class LangUtil {
twoList.addAll(org.aspectj.util.LangUtil.arrayAsList(two));
ArrayList result = new ArrayList();
if (null != one) {
- for (int i = 0; i < one.length; i++) {
- if (null != one[i]) {
- twoList.remove(one[i]);
- result.add(one[i]);
- }
- }
+ for (String s : one) {
+ if (null != s) {
+ twoList.remove(s);
+ result.add(s);
+ }
+ }
}
- for (Iterator iterator = twoList.iterator(); iterator.hasNext(); ) {
- String element = (String) iterator.next();
+ for (Object o : twoList) {
+ String element = (String) o;
if (null != element) {
- result.add(element);
- }
+ result.add(element);
+ }
}
return (String[]) result.toArray(NONE);
}
@@ -425,19 +425,19 @@ public class LangUtil {
public static Properties combine(Properties dest, Properties add, boolean respectExisting) { // XXX
if (null == add) return dest;
if (null == dest) return add;
- for (Iterator iterator = add.keySet().iterator(); iterator.hasNext(); ) {
- String key = (String) iterator.next();
- if (null == key) {
- continue;
- }
- String value = add.getProperty(key);
- if (null == value) {
- continue;
- }
- if (! respectExisting || (null == dest.getProperty(key))) {
- dest.setProperty(key, value);
- }
- }
+ for (Object o : add.keySet()) {
+ String key = (String) o;
+ if (null == key) {
+ continue;
+ }
+ String value = add.getProperty(key);
+ if (null == value) {
+ continue;
+ }
+ if (!respectExisting || (null == dest.getProperty(key))) {
+ dest.setProperty(key, value);
+ }
+ }
return dest;
}
@@ -547,22 +547,22 @@ public class LangUtil {
public static void loadClasses(String[] args, StringBuffer out,
StringBuffer err) {
if (null != args) {
- for (int i = 0; i < args.length; i++) {
- try {
- Class c = Class.forName(args[i]);
- if (null != out) {
- out.append("\n");
- out.append(args[i]);
- out.append(": ");
- out.append(c.getName());
- }
- } catch (Throwable t) {
- if (null != err) {
- err.append("\n");
- FileUtil.render(t, err);
- }
- }
- }
+ for (String arg : args) {
+ try {
+ Class c = Class.forName(arg);
+ if (null != out) {
+ out.append("\n");
+ out.append(arg);
+ out.append(": ");
+ out.append(c.getName());
+ }
+ } catch (Throwable t) {
+ if (null != err) {
+ err.append("\n");
+ FileUtil.render(t, err);
+ }
+ }
+ }
}
}
@@ -577,20 +577,20 @@ public class LangUtil {
}
int length = path.length() - ".class".length();
path = path.substring(prefix.length()+1, length);
- for (int i = 0; i < SEPS.length; i++) {
- path = path.replace(SEPS[i], '.');
- }
+ for (char sep : SEPS) {
+ path = path.replace(sep, '.');
+ }
return path;
}
public static void main (String[] args) { // todo remove as testing
StringBuffer err = new StringBuffer();
StringBuffer out = new StringBuffer();
- for (int i = 0; i < args.length; i++) {
- String[] names = classesIn(new File(args[i]));
- System.err.println(args[i] + " -> " + render(names));
- loadClasses(names, out, err);
- }
+ for (String arg : args) {
+ String[] names = classesIn(new File(arg));
+ System.err.println(arg + " -> " + render(names));
+ loadClasses(names, out, err);
+ }
if (0 < err.length()) {
System.err.println(err.toString());
}
@@ -887,8 +887,7 @@ public class LangUtil {
return;
}
BitSet actualExpected = new BitSet();
- for (int i = 0; i < expectedListIn.size(); i++) {
- Object expect = expectedListIn.get(i);
+ for (Object expect : expectedListIn) {
int loc = actualListIn.indexOf(expect);
if (-1 == loc) {
if (null != missingListOut) {
@@ -962,19 +961,18 @@ public class LangUtil {
// messages on the same line, but with different text content.
while (actualIter.hasNext()) {
act = actualIter.next();
- for (Iterator expectedIter = expected.iterator(); expectedIter.hasNext();) {
- Object exp = expectedIter.next();
- // if actual matches expected remove actual from extraListOut, and
- // remove expected from missingListOut
- int diff = comparator.compare(exp,act);
- if (diff == 0) {
- extraListOut.remove(act);
- missingListOut.remove(exp);
- } else if (diff > 0) {
- // since list is sorted, there can be no more matches...
- break;
- }
- }
+ for (Object exp : expected) {
+ // if actual matches expected remove actual from extraListOut, and
+ // remove expected from missingListOut
+ int diff = comparator.compare(exp, act);
+ if (diff == 0) {
+ extraListOut.remove(act);
+ missingListOut.remove(exp);
+ } else if (diff > 0) {
+ // since list is sorted, there can be no more matches...
+ break;
+ }
+ }
}
// while (((null != act) || actualIter.hasNext())
diff --git a/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java
index 8131fdf7e..30f2a0b06 100644
--- a/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java
+++ b/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java
@@ -89,8 +89,8 @@ public class LangUtilTest extends TestCase {
, new FTest("[1,2]", new String[] {"1,2"}, LIST)
, new FTest("[1, 2, 3]", new String[] {"1","2","3"}, LIST)
};
- for (int i = 0; i < tests.length; i++) {
- checkUnflatten(tests[i]);
+ for (FTest test : tests) {
+ checkUnflatten(test);
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/LineReader.java b/testing/src/test/java/org/aspectj/testing/util/LineReader.java
index a6af8266a..0c75aa9d1 100644
--- a/testing/src/test/java/org/aspectj/testing/util/LineReader.java
+++ b/testing/src/test/java/org/aspectj/testing/util/LineReader.java
@@ -164,21 +164,21 @@ public class LineReader extends LineNumberReader {
if (result == null)
return null;
result = result.trim();
- for (int i = 0; i < eolComments.length; i++) {
- int loc = result.indexOf(eolComments[i]);
- if (-1 != loc) {
- result = result.substring(0, loc);
- break;
- }
- }
+ for (String eolComment : eolComments) {
+ int loc = result.indexOf(eolComment);
+ if (-1 != loc) {
+ result = result.substring(0, loc);
+ break;
+ }
+ }
len = result.length();
if (0 < len) {
- for (int i = 0; i < leadComments.length; i++) {
- if (result.startsWith(leadComments[i])) {
- result = "";
- break;
- }
- }
+ for (String leadComment : leadComments) {
+ if (result.startsWith(leadComment)) {
+ result = "";
+ break;
+ }
+ }
len = result.length();
}
len = result.length();
diff --git a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java
index 3317f7746..380766a3b 100644
--- a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java
+++ b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java
@@ -226,24 +226,22 @@ public class LinkCheck {
messages.checkingLinks(linksToCheck.size());
list.clear();
list.addAll(linksToCheck);
- for (Iterator<Link> iter = list.iterator(); iter.hasNext();) {
- final Link link = iter.next();
- String urlString = link.url.toString();
- if (!checkedUrls.contains(urlString)) {
- checkedUrls.add(urlString);
- messages.checkingLink(link);
- checkLink(link);
- }
- }
+ for (final Link link : list) {
+ String urlString = link.url.toString();
+ if (!checkedUrls.contains(urlString)) {
+ checkedUrls.add(urlString);
+ messages.checkingLink(link);
+ checkLink(link);
+ }
+ }
linksToCheck.removeAll(list);
}
// now check that all named references are accounted for
- for (Iterator<String> iter = refsToCheck.iterator(); iter.hasNext();) {
- String ref = iter.next();
- if (!validRefs.contains(ref)) {
- messages.namedReferenceNotFound(ref);
- }
- }
+ for (String ref : refsToCheck) {
+ if (!validRefs.contains(ref)) {
+ messages.namedReferenceNotFound(ref);
+ }
+ }
}
/** @return null if link known or if unable to create */
diff --git a/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java
index 571633a0c..954ab38c0 100644
--- a/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java
+++ b/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java
@@ -104,25 +104,20 @@ public class MessageUtilTest extends TestCase {
MessageHandler getSampleMessages() {
MessageHandler result = new MessageHandler();
- for (Iterator kinds = IMessage.KINDS.iterator(); kinds.hasNext();) {
- IMessage.Kind kind = (IMessage.Kind) kinds.next();
- for (Iterator locs = getSampleLocations().iterator(); locs.hasNext();) {
- ISourceLocation sourceLoc = (ISourceLocation) locs.next();
- for (Iterator texts = getSampleMessageTexts().iterator();
- texts.hasNext();
- ) {
- String text = (String) texts.next();
- for (Iterator exs = getSampleExceptions().iterator();
- exs.hasNext();
- ) {
- Throwable thrown = (Throwable) exs.next();
- result.handleMessage(new Message(text, kind, thrown, sourceLoc));
+ for (IMessage.Kind kind : IMessage.KINDS) {
+ for (Object item : getSampleLocations()) {
+ ISourceLocation sourceLoc = (ISourceLocation) item;
+ for (Object value : getSampleMessageTexts()) {
+ String text = (String) value;
+ for (Object o : getSampleExceptions()) {
+ Throwable thrown = (Throwable) o;
+ result.handleMessage(new Message(text, kind, thrown, sourceLoc));
}
- result.handleMessage(new Message(text, kind, null, sourceLoc));
+ result.handleMessage(new Message(text, kind, null, sourceLoc));
}
- result.handleMessage(new Message("", kind, null, sourceLoc));
+ result.handleMessage(new Message("", kind, null, sourceLoc));
}
- result.handleMessage(new Message("", kind, null, null));
+ result.handleMessage(new Message("", kind, null, null));
}
return result;
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/SFileReader.java b/testing/src/test/java/org/aspectj/testing/util/SFileReader.java
index eecf2d304..afa66d46f 100644
--- a/testing/src/test/java/org/aspectj/testing/util/SFileReader.java
+++ b/testing/src/test/java/org/aspectj/testing/util/SFileReader.java
@@ -41,15 +41,15 @@ public class SFileReader {
ArrayList result = new ArrayList();
ObjectChecker collector = new StandardObjectChecker(String.class, result);
SFileReader me = new SFileReader(null);
- for (int i = 0; i < args.length; i++) {
- Node node = me.readNodes(new File(args[i]), null, true, System.err);
- if (!Node.visit(node, collector, null)) {
- System.err.println("halted during copy of " +args[i]);
- } else {
- String s = org.aspectj.testing.util.LangUtil.debugStr(null, "\n ", null,
- null, result.toArray(), "\n ", "");
- System.err.println(args[i] + ": " + s);
- }
+ for (String arg : args) {
+ Node node = me.readNodes(new File(arg), null, true, System.err);
+ if (!Node.visit(node, collector, null)) {
+ System.err.println("halted during copy of " + arg);
+ } else {
+ String s = org.aspectj.testing.util.LangUtil.debugStr(null, "\n ", null,
+ null, result.toArray(), "\n ", "");
+ System.err.println(arg + ": " + s);
+ }
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java
index cd3727e9b..1763e73dd 100644
--- a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java
+++ b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java
@@ -146,12 +146,11 @@ public class StructureModelUtil {
public static Set getAspectsAffectingPackage(IProgramElement packageNode) {
List<IProgramElement> files = StructureModelUtil.getFilesInPackage(packageNode);
Set aspects = new HashSet();
- for (Iterator<IProgramElement> it = files.iterator(); it.hasNext();) {
- IProgramElement fileNode = (IProgramElement) it.next();
+ for (IProgramElement fileNode : files) {
Map adviceMap = getLinesToAspectMap(fileNode.getSourceLocation().getSourceFile().getAbsolutePath());
Collection values = adviceMap.values();
- for (Iterator it2 = values.iterator(); it2.hasNext();) {
- aspects.add(it2.next());
+ for (Object value : values) {
+ aspects.add(value);
}
}
return aspects;
@@ -182,8 +181,7 @@ public class StructureModelUtil {
matches.add(o);
}
- for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
- IProgramElement nextNode = (IProgramElement) it.next();
+ for (IProgramElement nextNode : node.getChildren()) {
getPackagesHelper(nextNode, kind, prename, matches);
}
@@ -251,8 +249,7 @@ public class StructureModelUtil {
packageContents = packageNode.getChildren();
}
List<IProgramElement> files = new ArrayList<IProgramElement>();
- for (Iterator<IProgramElement> it = packageContents.iterator(); it.hasNext();) {
- IProgramElement packageItem = (IProgramElement) it.next();
+ for (IProgramElement packageItem : packageContents) {
if (packageItem.getKind() == IProgramElement.Kind.FILE_JAVA
|| packageItem.getKind() == IProgramElement.Kind.FILE_ASPECTJ) {
files.add(packageItem);
diff --git a/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java b/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java
index dd9c10c8f..8a753dfc7 100644
--- a/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java
+++ b/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java
@@ -119,12 +119,12 @@ public class TestClassLoader extends URLClassLoader {
/** @return null if class not found or byte[] of class otherwise */
private byte[] readClass(String className) throws ClassNotFoundException {
final String fileName = className.replace('.', '/')+".class";
- for (Iterator iter = dirs.iterator(); iter.hasNext();) {
- File file = new File((File) iter.next(), fileName);
- if (file.canRead()) {
- return getClassData(file);
- }
- }
+ for (Object dir : dirs) {
+ File file = new File((File) dir, fileName);
+ if (file.canRead()) {
+ return getClassData(file);
+ }
+ }
return null;
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java b/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java
index 54f72e9b9..dbb0c1bb1 100644
--- a/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java
+++ b/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java
@@ -125,8 +125,8 @@ public class TestDiffs { // XXX pretty dumb implementation
final String suffix = " " + label;
final String LABEL = list.size() + suffix;
out.println("## START " + LABEL);
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- TestResult result = (TestResult) iter.next();
+ for (Object o : list) {
+ TestResult result = (TestResult) o;
out.println(" " + result.test + " ## " + suffix);
}
out.println("## END " + LABEL);
@@ -146,14 +146,12 @@ public class TestDiffs { // XXX pretty dumb implementation
if (!LangUtil.isEmpty(input) && !LangUtil.isEmpty(trim)) {
for (ListIterator iter = result.listIterator(); iter.hasNext();) {
TestResult inputItem = (TestResult) iter.next();
- for (Iterator iterator = trim.iterator();
- iterator.hasNext();
- ) {
- TestResult trimItem = (TestResult) iterator.next();
+ for (Object o : trim) {
+ TestResult trimItem = (TestResult) o;
if (inputItem.test.equals(trimItem.test)) {
- iter.remove();
- break;
- }
+ iter.remove();
+ break;
+ }
}
}
}
@@ -163,13 +161,13 @@ public class TestDiffs { // XXX pretty dumb implementation
/** split input List by whether the TestResult element passed or failed */
private static void split(List input, ArrayList pass, ArrayList fail) {
- for (ListIterator iter = input.listIterator(); iter.hasNext();) {
- TestResult result = (TestResult) iter.next();
- if (result.pass) {
- pass.add(result);
- } else {
- fail.add(result);
- }
+ for (Object o : input) {
+ TestResult result = (TestResult) o;
+ if (result.pass) {
+ pass.add(result);
+ } else {
+ fail.add(result);
+ }
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/options/Option.java b/testing/src/test/java/org/aspectj/testing/util/options/Option.java
index f8ea3d9c4..b9c6d2cab 100644
--- a/testing/src/test/java/org/aspectj/testing/util/options/Option.java
+++ b/testing/src/test/java/org/aspectj/testing/util/options/Option.java
@@ -226,11 +226,11 @@ public class Option implements Comparable {
return "no input permitted at " + position;
}
String[] permitted = permittedArguments[position];
- for (int i = 0; i < permitted.length; i++) {
- if (input.equals(permitted[i])) {
- return null;
- }
- }
+ for (String s : permitted) {
+ if (input.equals(s)) {
+ return null;
+ }
+ }
return input + " not permitted, expecting one of "
+ Arrays.asList(permitted);
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/options/Options.java b/testing/src/test/java/org/aspectj/testing/util/options/Options.java
index f3e52767f..92e84c106 100644
--- a/testing/src/test/java/org/aspectj/testing/util/options/Options.java
+++ b/testing/src/test/java/org/aspectj/testing/util/options/Options.java
@@ -141,13 +141,13 @@ public class Options {
private Option.Value firstMatch(String value) {
LangUtil.throwIaxIfNull(value, "value");
// ArrayList list = new ArrayList();
- for (Iterator iter = options.iterator(); iter.hasNext();) {
- Option option = (Option) iter.next();
- Option.Value result = option.acceptValue(value);
- if (null != result) {
- return result;
- }
- }
+ for (Object o : options) {
+ Option option = (Option) o;
+ Option.Value result = option.acceptValue(value);
+ if (null != result) {
+ return result;
+ }
+ }
return null;
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java b/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java
index bd7d98613..5c380d739 100644
--- a/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java
+++ b/testing/src/test/java/org/aspectj/testing/util/options/OptionsTest.java
@@ -473,9 +473,9 @@ public class OptionsTest extends TestCase {
new String[] { "-g:vars,source" },
new String[] { "-verbose", "-g:vars,source" },
};
- for (int i = 0; i < input.length; i++) {
- optionChecker.checkOptions(input[i], input[i]);
- }
+ for (String[] strings : input) {
+ optionChecker.checkOptions(strings, strings);
+ }
}
private OptionChecker getOptionChecker() {
diff --git a/testing/src/test/java/org/aspectj/testing/util/options/Values.java b/testing/src/test/java/org/aspectj/testing/util/options/Values.java
index d21f03165..7a04fbed0 100644
--- a/testing/src/test/java/org/aspectj/testing/util/options/Values.java
+++ b/testing/src/test/java/org/aspectj/testing/util/options/Values.java
@@ -63,11 +63,11 @@ public class Values {
input = new Value[length];
length = 0;
Value[] temp;
- for (int i = 0; i < values.length; i++) {
- temp = values[i].asArray();
- System.arraycopy(temp, 0, input, length, temp.length);
- length += temp.length;
- }
+ for (Values value : values) {
+ temp = value.asArray();
+ System.arraycopy(temp, 0, input, length, temp.length);
+ length += temp.length;
+ }
}
return new Values(input);
}
@@ -260,19 +260,19 @@ public class Values {
throw new IllegalArgumentException(
"expecting force-off: " + value);
}
- for (int i = 0; i < matches.length; i++) {
- Option.Value match = input[matches[i]];
- if ((null != match) && value.sameValueIdentifier(match)) {
- if (match.prefix.forceOn()) {
- return "force conflict between "
- + value
- + " and "
- + match;
- } else {
- input[matches[i]] = null; // unset matches[i]?
- }
- }
- }
+ for (int j : matches) {
+ Value match = input[j];
+ if ((null != match) && value.sameValueIdentifier(match)) {
+ if (match.prefix.forceOn()) {
+ return "force conflict between "
+ + value
+ + " and "
+ + match;
+ } else {
+ input[j] = null; // unset matches[i]?
+ }
+ }
+ }
return null;
}
@@ -388,22 +388,22 @@ public class Values {
*/
private static String[] render(Value[] values) {
ArrayList list = new ArrayList();
- for (int i = 0; i < values.length; i++) {
- if (null != values[i]) {
- String[] output = values[i].unflatten();
- if (LangUtil.isEmpty(output)) {
- throw new Error("no output for " + values[i]);
- }
-
- String s = values[i].prefix.render(output[0]);
- if (null != s) { // this means the prefix is set
- list.add(s);
- for (int j = 1; j < output.length; j++) {
- list.add(output[j]);
- }
- }
- }
- }
+ for (Value value : values) {
+ if (null != value) {
+ String[] output = value.unflatten();
+ if (LangUtil.isEmpty(output)) {
+ throw new Error("no output for " + value);
+ }
+
+ String s = value.prefix.render(output[0]);
+ if (null != s) { // this means the prefix is set
+ list.add(s);
+ for (int j = 1; j < output.length; j++) {
+ list.add(output[j]);
+ }
+ }
+ }
+ }
return (String[]) list.toArray(new String[list.size()]);
}
@@ -545,34 +545,34 @@ public class Values {
protected Option.Value[] find(Selector filter, boolean findAll) {
LangUtil.throwIaxIfNull(filter, "filter");
ArrayList result = new ArrayList();
- for (int i = 0; i < values.length; i++) {
- final boolean accepted;
- try {
- accepted = filter.accept(values[i]);
- } catch (Error e) {
- if (Selector.STOP != e) {
- throw e;
- }
- break;
- }
- if (accepted) {
- result.add(values[i]);
- if (findAll != FIND_ALL) {
- break;
- }
- }
- }
+ for (Value value : values) {
+ final boolean accepted;
+ try {
+ accepted = filter.accept(value);
+ } catch (Error e) {
+ if (Selector.STOP != e) {
+ throw e;
+ }
+ break;
+ }
+ if (accepted) {
+ result.add(value);
+ if (findAll != FIND_ALL) {
+ break;
+ }
+ }
+ }
return toArray(result);
}
private Option.Value[] valuesNotNull() {
if (null == valuesNotNull) {
ArrayList list = new ArrayList();
- for (int i = 0; i < this.values.length; i++) {
- if (null != this.values[i]) {
- list.add(this.values[i]);
- }
- }
+ for (Value value : this.values) {
+ if (null != value) {
+ list.add(value);
+ }
+ }
valuesNotNull = toArray(list);
}
return valuesNotNull;
diff --git a/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReader.java b/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReader.java
index 62e3fd186..3ab25c088 100644
--- a/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReader.java
+++ b/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReader.java
@@ -462,21 +462,21 @@ public class AjcSpecXmlReader {
"../../../tests", "tests", "modules/tests"
};
File baseDir;
- for (int j = 0; j < baseDirs.length; j++) {
- baseDir = baseDirs[j];
- if (!isDir(baseDir)) {
- continue;
- }
- for (int i = 0; i < locations.length; i++) {
- File dir = new File(baseDir, locations[i]);
- if (isDir(dir)) {
- File temp = new File(dir, NAME);
- if (temp.isFile() && temp.canRead()) {
- return temp.getPath();
- }
- }
- }
- }
+ for (File file : baseDirs) {
+ baseDir = file;
+ if (!isDir(baseDir)) {
+ continue;
+ }
+ for (String location : locations) {
+ File dir = new File(baseDir, location);
+ if (isDir(dir)) {
+ File temp = new File(dir, NAME);
+ if (temp.isFile() && temp.canRead()) {
+ return temp.getPath();
+ }
+ }
+ }
+ }
return null;
}
public InputSource resolveEntity(
diff --git a/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java b/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java
index 397e8ccfa..796bf0399 100644
--- a/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java
+++ b/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java
@@ -51,8 +51,7 @@ public class AjcSpecXmlReaderTest extends TestCase {
public void tearDown() {
if (!LangUtil.isEmpty(tempFiles)) {
- for (Iterator<File> iter = tempFiles.iterator(); iter.hasNext();) {
- File file = (File) iter.next();
+ for (File file : tempFiles) {
if (file.canRead()) {
file.delete();
}
@@ -66,23 +65,23 @@ public class AjcSpecXmlReaderTest extends TestCase {
AjcSpecXmlReader.BProps[] expected
= AjcSpecXmlReader.expectedProperties();
PropertyDescriptor[] des;
- for (int i = 0; i < expected.length; i++) {
- Class<?> clazz = expected[i].cl;
- BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
- assertTrue(null != beanInfo);
- des = beanInfo.getPropertyDescriptors();
- for (int j = 0; j < expected[i].props.length; j++) {
- String name = expected[i].props[j];
- String fqn = clazz.getName() + "." + name;
- boolean gotIt = false;
- for (int k = 0; k < des.length; k++) {
- String desName = des[k].getName();
- if (name.equals(desName)) {
- assertTrue(fqn, null != des[k].getWriteMethod());
- gotIt = true;
- }
- }
- assertTrue("no such property: " + fqn, gotIt);
+ for (AjcSpecXmlReader.BProps bProps : expected) {
+ Class<?> clazz = bProps.cl;
+ BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
+ assertTrue(null != beanInfo);
+ des = beanInfo.getPropertyDescriptors();
+ for (int j = 0; j < bProps.props.length; j++) {
+ String name = bProps.props[j];
+ String fqn = clazz.getName() + "." + name;
+ boolean gotIt = false;
+ for (PropertyDescriptor de : des) {
+ String desName = de.getName();
+ if (name.equals(desName)) {
+ assertTrue(fqn, null != de.getWriteMethod());
+ gotIt = true;
+ }
+ }
+ assertTrue("no such property: " + fqn, gotIt);
}
}
@@ -140,9 +139,9 @@ public class AjcSpecXmlReaderTest extends TestCase {
assertTrue("CloneNotSupportedException: " + e.getMessage(), false);
}
- for (Iterator<File> iter = toDelete.iterator(); iter.hasNext();) {
- iter.next().delete();
- }
+ for (File file : toDelete) {
+ file.delete();
+ }
}
void checkRoundTrip(String path) throws IOException, Exception {
@@ -199,9 +198,9 @@ public class AjcSpecXmlReaderTest extends TestCase {
//System.err.println("----------------------- suite2 " + xml2Path);
AjcSpecTest.sameAjcSuiteSpec(suite1, suite2, this);
AjcSpecTest.sameAjcSuiteSpec(suite0, suite2, this);
-
- for (Iterator<File> iter = toDelete.iterator(); iter.hasNext();) {
- iter.next().delete();
+
+ for (File file : toDelete) {
+ file.delete();
}
}
}
diff --git a/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java b/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java
index 6d0eeffff..342484a76 100644
--- a/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java
+++ b/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java
@@ -38,8 +38,8 @@ public class MessageListXmlReaderTest extends TestCase {
public void tearDown() {
if (!LangUtil.isEmpty(tempFiles)) {
- for (Iterator iter = tempFiles.iterator(); iter.hasNext();) {
- File file = (File) iter.next();
+ for (Object tempFile : tempFiles) {
+ File file = (File) tempFile;
if (file.canRead()) {
file.delete();
}
diff --git a/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java b/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java
index 9a39d0cc8..2241904bd 100644
--- a/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java
+++ b/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java
@@ -64,8 +64,8 @@ public class SoftMessage implements IMessage {
return;
}
List list = messages.getUnmodifiableListView();
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- writeXml(out, (IMessage) iter.next());
+ for (Object o : list) {
+ writeXml(out, (IMessage) o);
}
}
@@ -77,8 +77,8 @@ public class SoftMessage implements IMessage {
if ((null == out) || (null == messages)) {
return;
}
- for (int i = 0; i < messages.length; i++) {
- writeXml(out, messages[i]);
+ for (IMessage iMessage : messages) {
+ writeXml(out, iMessage);
}
}
@@ -125,9 +125,9 @@ public class SoftMessage implements IMessage {
List extras = message.getExtraSourceLocations();
if (!LangUtil.isEmpty(extras)) {
out.endAttributes();
- for (Iterator iter = extras.iterator(); iter.hasNext();) {
- /*ISourceLocation element = (ISourceLocation)*/ iter.next();
- SoftSourceLocation.writeXml(out, sl);
+ for (Object extra : extras) {
+ /*ISourceLocation element = (ISourceLocation)*/
+ SoftSourceLocation.writeXml(out, sl);
}
}
out.endElement(elementName);
diff --git a/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java b/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java
index 422576c56..eaa42326e 100644
--- a/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java
+++ b/testing/src/test/java/org/aspectj/testing/xml/XMLWriter.java
@@ -89,11 +89,11 @@ public class XMLWriter {
if (null != input) {
String[] items = XMLWriter.unflattenList(input);
if (!LangUtil.isEmpty(items)) {
- for (int i = 0; i < items.length; i++) {
- if (!LangUtil.isEmpty(items[i])) {
- list.add(items[i]);
- }
- }
+ for (String item : items) {
+ if (!LangUtil.isEmpty(item)) {
+ list.add(item);
+ }
+ }
}
}
}
@@ -124,20 +124,19 @@ public class XMLWriter {
StringBuffer sb = new StringBuffer();
if (null != list) {
boolean printed = false;
- for (int i = 0; i < list.length; i++) {
- Object o = list[i];
- if (null != o) {
- if (printed) {
- sb.append(",");
- } else {
- printed = true;
- }
- String s = o.toString();
- if (-1 != s.indexOf(",")) {
- throw new IllegalArgumentException("comma in " + s);
- }
- sb.append(s);
- }
+ for (Object o : list) {
+ if (null != o) {
+ if (printed) {
+ sb.append(",");
+ } else {
+ printed = true;
+ }
+ String s = o.toString();
+ if (-1 != s.indexOf(",")) {
+ throw new IllegalArgumentException("comma in " + s);
+ }
+ sb.append(s);
+ }
}
}
return sb.toString();