diff options
Diffstat (limited to 'testing')
38 files changed, 94 insertions, 143 deletions
diff --git a/testing/pom.xml b/testing/pom.xml index d7e167d8b..d0c20be24 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -134,7 +134,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> + <version>4.13</version> </dependency> <dependency> <groupId>commons</groupId> 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 546eadba3..98878dcbc 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 @@ -36,13 +36,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.text.DateFormat; //import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; +import java.util.*; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -1426,9 +1420,7 @@ 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 (String cmd : cmds) { - this.args.add(cmd); - } + Collections.addAll(this.args, cmds); } String getMainClassName() { return "org.aspectj.tools.ajdoc.Main"; diff --git a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java index 2b7e4942f..ca9a7f431 100644 --- a/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/AutowiredXMLBasedAjcTestCase.java @@ -13,7 +13,6 @@ package org.aspectj.testing; import java.io.InputStreamReader; import java.lang.reflect.Method; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.apache.commons.digester.Digester; @@ -48,7 +47,7 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase { return testMap; } - public static Test loadSuite(Class<?> testCaseClass) { + public static Test loadSuite(Class<? extends TestCase> testCaseClass) { TestSuite suite = new TestSuite(testCaseClass.getName()); //suite.addTestSuite(testCaseClass); diff --git a/testing/src/test/java/org/aspectj/testing/OutputSpec.java b/testing/src/test/java/org/aspectj/testing/OutputSpec.java index ca7d0f232..8e1fd2612 100644 --- a/testing/src/test/java/org/aspectj/testing/OutputSpec.java +++ b/testing/src/test/java/org/aspectj/testing/OutputSpec.java @@ -87,10 +87,8 @@ public class OutputSpec { createFailureMessage(output, -1, outputFound.size()); return; } - List<String> expected = new ArrayList<>(); - expected.addAll(expectedOutputLines); - List<String> found = new ArrayList<>(); - found.addAll(outputFound); + List<String> expected = new ArrayList<>(expectedOutputLines); + List<String> found = new ArrayList<>(outputFound); for (String lineFound : outputFound) { for (String lineExpected : expectedOutputLines) { if (lineFound.contains(lineExpected)) { diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java index e5e2fcdb9..68e14ec2e 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Stack; +import junit.framework.TestCase; import org.apache.commons.digester.Digester; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.JavaClass; @@ -81,7 +82,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { * @param testCaseClass * @return */ - public static Test loadSuite(Class<?> testCaseClass) { + public static Test loadSuite(Class<? extends TestCase> testCaseClass) { TestSuite suite = new TestSuite(testCaseClass.getName()); suite.addTestSuite(testCaseClass); TestSetup wrapper = new TestSetup(suite) { @@ -415,10 +416,8 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { public List<LocalVariable> sortedLocalVariables(LocalVariableTable lvt) { List<LocalVariable> l = new ArrayList<>(); LocalVariable lv[] = lvt.getLocalVariableTable(); - for (LocalVariable lvEntry : lv) { - l.add(lvEntry); - } - Collections.sort(l, new MyComparator()); + Collections.addAll(l, lv); + l.sort(new MyComparator()); return l; } 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 cf615f6d1..ed4f560c0 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 @@ -83,7 +83,7 @@ abstract public class AbstractRunSpec implements IRunSpec { private boolean skipAll; protected String xmlElementName; // nonfinal only for clone() - protected final ArrayList<String> keywords; + protected final List<String> keywords; protected final IMessageHolder /* IMessage */messages; protected final ArrayList<String> options; protected final ArrayList<String> paths; @@ -197,7 +197,7 @@ abstract public class AbstractRunSpec implements IRunSpec { } } - public ArrayList<String> getKeywordsList() { + public List<String> getKeywordsList() { return makeList(keywords); } @@ -257,7 +257,7 @@ abstract public class AbstractRunSpec implements IRunSpec { // --------------- (String) paths /** @return ArrayList of String paths */ - public ArrayList<String> getPathsList() { + public List<String> getPathsList() { return makeList(paths); } 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 6a7932703..da265e7f9 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 @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; 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 52a3e2266..2ff173362 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 @@ -250,7 +250,7 @@ public class AjcSpecTest extends TestCase { sameDirChangesList(lhs.dirChanges, rhs.dirChanges, a); } - public static void sameDirChangesList(ArrayList<DirChanges.Spec> lhs, ArrayList<DirChanges.Spec> rhs, Assert a) { + public static void sameDirChangesList(List<DirChanges.Spec> lhs, List<DirChanges.Spec> rhs, Assert a) { if ((null == lhs) && (null == rhs)) { return; } 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 7bbc50adf..5ca41509f 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 @@ -161,7 +161,7 @@ public class AjcTest extends RunSpecIterator { * @return the unmodifiable List of titles (maybe empty, never null) */ private static List<String> parseTitlesList(String titlesList) { - ArrayList<String> result = new ArrayList<>(); + List<String> result = new ArrayList<>(); String last = null; StringTokenizer st = new StringTokenizer(titlesList, ","); while (st.hasMoreTokens()) { @@ -206,7 +206,7 @@ public class AjcTest extends RunSpecIterator { * @return the unmodifiable List of titles (maybe empty, never null) */ private static List<String> readTitlesFile(File titlesFile, boolean fail) { - ArrayList<String> result = new ArrayList<>(); + List<String> result = new ArrayList<>(); Reader reader = null; try { reader = new FileReader(titlesFile); 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 7a5bff3df..d85384a8a 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 @@ -22,7 +22,6 @@ import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -729,7 +728,7 @@ public class CompilerRun implements IAjcRun { private static String updateBootclasspathForSourceVersion( String sourceVersion, String compilerName, - ArrayList toAdd) { + List toAdd) { if (null == sourceVersion) { return null; } @@ -1497,7 +1496,7 @@ public class CompilerRun implements IAjcRun { String seek; /** if setup completed, this has the combined global/local options */ - ArrayList commandOptions; + List commandOptions; public Object clone() { TestSetup testSetup = new TestSetup(); 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 abac95dfe..7e73a9233 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 @@ -15,7 +15,6 @@ package org.aspectj.testing.harness.bridge; import java.util.Arrays; -import java.util.Iterator; import java.util.Set; import org.aspectj.bridge.MessageHandler; 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 e3e60e028..5a3ad13ab 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 @@ -15,7 +15,6 @@ package org.aspectj.testing.harness.bridge; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessageHandler; @@ -469,19 +468,19 @@ public class DirChanges { boolean fastFail; /** relative paths (String) of expected files added */ - final ArrayList<String> added; + final List<String> added; /** relative paths (String) of expected files removed/deleted */ - final ArrayList<String> removed; + final List<String> removed; /** relative paths (String) of expected files updated/changed */ - final ArrayList<String> updated; + final List<String> updated; /** relative paths (String) of expected files NOT * added, removed, or changed * XXX unchanged unimplemented */ - final ArrayList<String> unchanged; + final List<String> unchanged; public Spec() { added = new ArrayList<>(); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java index 28db821cb..696d491a5 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java @@ -150,7 +150,7 @@ public class FlatSuiteReader implements SFileReader.Maker { throw new AbortException("expected sources at " + reader); } - ArrayList<Message> exp = new ArrayList<>(); + List<Message> exp = new ArrayList<>(); // !compile || noerrors || className {runOption..} String first = words[0]; if ("!compile".equals(first)) { @@ -290,7 +290,7 @@ public class FlatSuiteReader implements SFileReader.Maker { result.description = input; ArrayList<String> newOptions = new ArrayList<>(); - ArrayList<String> optionsCopy = result.getOptionsList(); + Iterable<String> optionsCopy = result.getOptionsList(); for (String option: optionsCopy) { if (option.startsWith("-")) { newOptions.add("!" + option.substring(1)); @@ -325,7 +325,7 @@ public class FlatSuiteReader implements SFileReader.Maker { */ private List<Message> makeMessages(// XXX weak - also support expected exceptions, etc. Kind kind, String[] words, int start, File lastFile) { - ArrayList<Message> result = new ArrayList<>(); + List<Message> result = new ArrayList<>(); for (int i = start; i < words.length; i++) { ISourceLocation sl = BridgeUtil.makeSourceLocation(words[i], lastFile); diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java index ad62c9735..22e52ec61 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/Globals.java @@ -71,7 +71,7 @@ public class Globals { && FileUtil.canReadFile(F_aspectjrt_jar) && FileUtil.canReadFile(J2SE13_RTJAR) && FileUtil.canReadFile(J2SE14_RTJAR)); - HashMap map = new HashMap(); + Map map = new HashMap(); map.put("1.2", "java.lang.ref.Reference"); map.put("1.3", "java.lang.reflect.Proxy"); map.put("1.4", "java.nio.Buffer"); 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 a0c48878e..e3bbb9209 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 @@ -409,7 +409,7 @@ public class IncCompilerRun implements IAjcRun { addItems(classesRemoved, items); } - private void addItems(ArrayList list, String items) { + private void addItems(List list, String items) { if (null != items) { String[] classes = XMLWriter.unflattenList(items); if (!LangUtil.isEmpty(classes)) { diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java index ea88c49f1..acc3245ca 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/JavaRun.java @@ -167,8 +167,7 @@ public class JavaRun implements IAjcRun { File[] files = sandbox.findFiles(spec.aspectpath); aspectURLs = FileUtil.getFileURLs(files); } - ArrayList classpath = new ArrayList(); - classpath.addAll(Arrays.asList(aspectURLs)); + ArrayList classpath = new ArrayList(Arrays.asList(aspectURLs)); final URL[] classURLs; { classpath.addAll(Arrays.asList(clAndLibs)); 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 7aaa1767c..b557da6a6 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 @@ -15,7 +15,6 @@ package org.aspectj.testing.harness.bridge; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.xml.parsers.DocumentBuilder; 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 a0b4f5e96..1bda6adda 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 @@ -13,12 +13,7 @@ package org.aspectj.testing.harness.bridge; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.ListIterator; -import java.util.Stack; +import java.util.*; import org.aspectj.bridge.AbortException; import org.aspectj.bridge.IMessage; @@ -51,10 +46,10 @@ public class Validator { private final Stack<IMessageHandler> handlers; /** list of File registered for deletion on demand */ - private final ArrayList<File> tempFiles; // deleteTempFiles requires ListIterator.remove() + private final List<File> tempFiles; // deleteTempFiles requires ListIterator.remove() /** list of Sandboxes registered for cleanup on demand */ - private final ArrayList<Sandbox> sandboxes; + private final List<Sandbox> sandboxes; /** if true, throw AbortException on failure */ boolean abortOnFailure; diff --git a/testing/src/test/java/org/aspectj/testing/run/RunListeners.java b/testing/src/test/java/org/aspectj/testing/run/RunListeners.java index 4eb8e7a74..ebdc227d0 100644 --- a/testing/src/test/java/org/aspectj/testing/run/RunListeners.java +++ b/testing/src/test/java/org/aspectj/testing/run/RunListeners.java @@ -16,6 +16,7 @@ package org.aspectj.testing.run; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; /** * Aggregate listeners into one and run synchronously in order added. @@ -23,7 +24,7 @@ import java.util.Iterator; */ public class RunListeners extends RunListener implements IRunListener { - ArrayList listeners; + List listeners; public RunListeners() { listeners = new ArrayList(); } 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 272f57103..c82a61ed1 100644 --- a/testing/src/test/java/org/aspectj/testing/run/RunStatus.java +++ b/testing/src/test/java/org/aspectj/testing/run/RunStatus.java @@ -15,7 +15,6 @@ package org.aspectj.testing.run; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; diff --git a/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java b/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java index 3871ee74b..b20a5650a 100644 --- a/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java +++ b/testing/src/test/java/org/aspectj/testing/taskdefs/AjcTaskCompileCommandTest.java @@ -14,6 +14,7 @@ package org.aspectj.testing.taskdefs; import java.io.File; import java.util.ArrayList; +import java.util.List; import org.aspectj.bridge.IMessageHolder; import org.aspectj.bridge.MessageHandler; @@ -33,7 +34,7 @@ import junit.framework.TestCase; public class AjcTaskCompileCommandTest extends TestCase { static boolean loggedWarning = false; static boolean runAllTests = true; - static ArrayList<File> tempFiles = new ArrayList<>(); + static List<File> tempFiles = new ArrayList<>(); private static File getClassesDir() { File tempDir = FileUtil.getTempDir("AjcTaskCompileCommandTest-classes"); @@ -41,7 +42,7 @@ public class AjcTaskCompileCommandTest extends TestCase { return tempDir; } - private static void addCommonArgs(ArrayList<String> list) { + private static void addCommonArgs(List<String> list) { list.add("-d"); list.add(getClassesDir().getAbsolutePath()); list.add("-classpath"); 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 c9a58e99f..43739b752 100644 --- a/testing/src/test/java/org/aspectj/testing/util/Diffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/Diffs.java @@ -148,8 +148,8 @@ public class Diffs { IMessage[] actual, IMessage.Kind[] ignoreExpectedKinds, IMessage.Kind[] ignoreActualKinds) { - ArrayList exp = getExcept(expected, ignoreExpectedKinds); - ArrayList act = getExcept(actual, ignoreActualKinds); + List exp = getExcept(expected, ignoreExpectedKinds); + List act = getExcept(actual, ignoreActualKinds); ArrayList missing = new ArrayList(); List unexpected = new ArrayList(); @@ -161,8 +161,8 @@ public class Diffs { } else { ListIterator expectedIterator = exp.listIterator(); int lastLine = Integer.MIN_VALUE + 1; - ArrayList expectedFound = new ArrayList(); - ArrayList expectedForLine = new ArrayList(); + List expectedFound = new ArrayList(); + List expectedForLine = new ArrayList(); for (ListIterator iter = act.listIterator(); iter.hasNext();) { IMessage actualMessage = (IMessage) iter.next(); int actualLine = getLine(actualMessage); @@ -452,7 +452,7 @@ public class Diffs { if (LangUtil.isEmpty(skip)) { sink.addAll(Arrays.asList(source)); - Collections.sort(sink, MESSAGE_LINEKIND); + sink.sort(MESSAGE_LINEKIND); return sink; } for (IMessage message : source) { @@ -467,7 +467,7 @@ public class Diffs { sink.add(message); } } - Collections.sort(sink, MESSAGE_LINEKIND); + sink.sort(MESSAGE_LINEKIND); return sink; } 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 ab780cd29..4f9f56424 100644 --- a/testing/src/test/java/org/aspectj/testing/util/FileUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/FileUtil.java @@ -25,12 +25,7 @@ import java.io.StringBufferInputStream; import java.io.StringWriter; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.Vector; +import java.util.*; import java.util.jar.Attributes; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; @@ -131,7 +126,7 @@ public class FileUtil { final boolean checkExpected = !LangUtil.isEmpty(expectedPaths); // normalize sources to ignore - final ArrayList expected = (!checkExpected ? null : new ArrayList()); + final List expected = (!checkExpected ? null : new ArrayList()); if (checkExpected) { for (String srcPath : expectedPaths) { if (!LangUtil.isEmpty(srcPath)) { @@ -185,9 +180,8 @@ public class FileUtil { // skip if not file or not right time return false; } - }; - ArrayList unexp = new ArrayList(); - unexp.addAll(Arrays.asList(dir.listFiles(touchedCollector))); + }; + List unexp = new ArrayList(Arrays.asList(dir.listFiles(touchedCollector))); // report any unexpected changes return Diffs.makeDiffs(label, expected, unexp, String.CASE_INSENSITIVE_ORDER); 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 ddf3a832a..b4acc5ce3 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtil.java @@ -402,8 +402,7 @@ public class LangUtil { * @see Util#combine(Object[], Object[]) */ public static String[] combine(String[] one, String[] two) { - ArrayList twoList = new ArrayList(); - twoList.addAll(org.aspectj.util.LangUtil.arrayAsList(two)); + List twoList = new ArrayList(org.aspectj.util.LangUtil.arrayAsList(two)); ArrayList result = new ArrayList(); if (null != one) { for (String s : one) { @@ -938,14 +937,12 @@ public class LangUtil { if ((0 == actualListIn.size()) && (0 == expectedListIn.size()) ) { return; } - - ArrayList expected = new ArrayList(); - expected.addAll(expectedListIn); - Collections.sort(expected, comparator); - - ArrayList actual = new ArrayList(); - actual.addAll(actualListIn); - Collections.sort(actual, comparator); + + List expected = new ArrayList(expectedListIn); + expected.sort(comparator); + + List actual = new ArrayList(actualListIn); + actual.sort(comparator); Iterator actualIter = actual.iterator(); Object act = null; 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 30f2a0b06..853e51f50 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/LangUtilTest.java @@ -67,7 +67,7 @@ public class LangUtilTest extends TestCase { void checkUnflatten(FTest test) { String[] exp = test.unflattened; - ArrayList result = LangUtil.unflatten(test.toUnflatten, test.spec); + List result = LangUtil.unflatten(test.toUnflatten, test.spec); String label = test + " -> " + result; assertNotNull(label, result); @@ -96,7 +96,7 @@ public class LangUtilTest extends TestCase { public void testArrayList() { - ArrayList l = new ArrayList(); + List l = new ArrayList(); l.add(null); l.add(null); assertTrue(null == l.get(0)); @@ -269,16 +269,15 @@ public class LangUtilTest extends TestCase { if (unmodifiable) { return Collections.unmodifiableList(Arrays.asList(ra)); } else { - ArrayList list = new ArrayList(); - list.addAll(Arrays.asList(ra)); + List list = new ArrayList(Arrays.asList(ra)); return list; } } /** check both hard and soft - assuming list contain String */ void checkDiff(List expected, List actual, List missing, List extra) { - ArrayList extraOut = new ArrayList(); - ArrayList missingOut = new ArrayList(); + List extraOut = new ArrayList(); + List missingOut = new ArrayList(); LangUtil.makeDiffs(expected, actual, missingOut, extraOut); checkSame(missing, missingOut); checkSame(extra, extraOut); @@ -302,8 +301,8 @@ public class LangUtilTest extends TestCase { /** check only soft - assuming list contain String */ void checkDiffSoft(List expected, List actual, List missing, List extra) { - ArrayList extraOut = new ArrayList(); - ArrayList missingOut = new ArrayList(); + List extraOut = new ArrayList(); + List missingOut = new ArrayList(); LangUtil.makeSoftDiffs(expected, actual, missingOut, extraOut, String.CASE_INSENSITIVE_ORDER); checkSameSoft(missing, missingOut); @@ -317,9 +316,8 @@ public class LangUtilTest extends TestCase { String label = one + "?=" + two; assertTrue(label, (null == one) == (null == two)); if (null != one) { - ArrayList aone = new ArrayList(); - aone.addAll(one); - ArrayList atwo = new ArrayList(); + List aone = new ArrayList(one); + List atwo = new ArrayList(); aone.addAll(two); Collections.sort(aone); Collections.sort(atwo); 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 a576c4ae4..973f57b97 100644 --- a/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java +++ b/testing/src/test/java/org/aspectj/testing/util/LinkCheck.java @@ -24,7 +24,6 @@ import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import javax.swing.text.MutableAttributeSet; @@ -171,10 +170,10 @@ public class LinkCheck { private final Messages messages; private final HTMLEditorKit.Parser parser; // XXX untested - stateful - private final ArrayList<Link> linksToCheck; - private final ArrayList<String> checkedUrls; // String (URL.toString) - private final ArrayList<String> validRefs; // String (URL.toString) - private final ArrayList<String> refsToCheck; // String (URL.toString) + private final List<Link> linksToCheck; + private final List<String> checkedUrls; // String (URL.toString) + private final List<String> validRefs; // String (URL.toString) + private final List<String> refsToCheck; // String (URL.toString) private final Link.Check checkExists; private final Link.Check checkContents; @@ -221,7 +220,7 @@ public class LinkCheck { } public synchronized void run() { - ArrayList<Link> list = new ArrayList<>(); + List<Link> list = new ArrayList<>(); while (0 < linksToCheck.size()) { messages.checkingLinks(linksToCheck.size()); list.clear(); 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 954ab38c0..178cb88bb 100644 --- a/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/MessageUtilTest.java @@ -19,7 +19,6 @@ import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; @@ -71,9 +70,8 @@ public class MessageUtilTest extends TestCase { List getSampleMessageTexts() { if (null == messageTexts) { - ArrayList result = new ArrayList(); - result.addAll(Arrays.asList(new String[] - { "one", "two", "now is the time for all good men..." })); + List result = new ArrayList(Arrays.asList(new String[] + {"one", "two", "now is the time for all good men..."})); messageTexts = result; } return messageTexts; @@ -81,7 +79,7 @@ public class MessageUtilTest extends TestCase { List getSampleExceptions() { if (null == exceptions) { - ArrayList result = new ArrayList(); + List result = new ArrayList(); int i = 1; result.add(new Error("Error " + i++)); result.add(new RuntimeException("RuntimeException " + i++)); @@ -93,7 +91,7 @@ public class MessageUtilTest extends TestCase { List getSampleLocations() { if (null == locations) { - ArrayList result = new ArrayList(); + List result = new ArrayList(); File file = new File("testsrc/org/aspectj/testing/util/MessageUtilTest.java"); result.add(new SourceLocation(file, 1, 2, 1)); result.add(new SourceLocation(file, 100, 100, 0)); 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 f49ba3b87..8bde398ed 100644 --- a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java +++ b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtil.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; diff --git a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java index 11b9ea2b4..0b9d7ef41 100644 --- a/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/StructureModelUtilTest.java @@ -34,10 +34,6 @@ public class StructureModelUtilTest extends AjdeCoreTestCase { "figures" + File.separator + "primitives" + File.separator + "planar" + File.separator + "Point.java", "figures" + File.separator + "primitives" + File.separator + "solid" + File.separator + "SolidPoint.java" }; - public static void main(String[] args) { - junit.swingui.TestRunner.run(StructureModelUtilTest.class); - } - public static TestSuite suite() { TestSuite result = new TestSuite(); result.addTestSuite(StructureModelUtilTest.class); 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 8a753dfc7..cac9816cd 100644 --- a/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java +++ b/testing/src/test/java/org/aspectj/testing/util/TestClassLoader.java @@ -23,7 +23,6 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; /** @@ -41,7 +40,7 @@ public class TestClassLoader extends URLClassLoader { super(urls); this.urlsForDebugString = urls; LangUtil.throwIaxIfComponentsBad(dirs, "dirs", null); - ArrayList dcopy = new ArrayList(); + List dcopy = new ArrayList(); if (!LangUtil.isEmpty(dirs)) { dcopy.addAll(Arrays.asList(dirs)); 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 dbb0c1bb1..ca1aa72ed 100644 --- a/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java +++ b/testing/src/test/java/org/aspectj/testing/util/TestDiffs.java @@ -21,7 +21,6 @@ import java.io.PrintStream; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -83,8 +82,8 @@ public class TestDiffs { // XXX pretty dumb implementation Diffs tests = Diffs.makeDiffs("tests", exp, act, TestResult.BY_NAME); // remove missing/unexpected (removed, added) tests from results // otherwise, unexpected-[pass|fail] look like [fixes|broken] - ArrayList expResults = trimByName(exp, tests.missing); - ArrayList actResults = trimByName(act, tests.unexpected); + List expResults = trimByName(exp, tests.missing); + List actResults = trimByName(act, tests.unexpected); Diffs results = Diffs.makeDiffs("results", expResults, actResults, TestResult.BY_PASSNAME); @@ -141,8 +140,7 @@ public class TestDiffs { // XXX pretty dumb implementation * @return ArrayList with all input except those in trim (by name) */ private static ArrayList trimByName(List input, List trim) { - ArrayList result = new ArrayList(); - result.addAll(input); + ArrayList result = new ArrayList(input); if (!LangUtil.isEmpty(input) && !LangUtil.isEmpty(trim)) { for (ListIterator iter = result.listIterator(); iter.hasNext();) { TestResult inputItem = (TestResult) iter.next(); @@ -160,7 +158,7 @@ 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) { + private static void split(List input, List pass, List fail) { for (Object o : input) { TestResult result = (TestResult) o; if (result.pass) { @@ -281,8 +279,7 @@ public class TestDiffs { // XXX pretty dumb implementation actualFailed = safeList(failed); // stillPassing: expected.passed w/o broken, missingPasses - passed = new ArrayList(); - passed.addAll(expectedPassed); + passed = new ArrayList(expectedPassed); passed = trimByName(passed, this.broken); ArrayList missingPasses = new ArrayList(); ArrayList missingFails = new ArrayList(); @@ -291,8 +288,7 @@ public class TestDiffs { // XXX pretty dumb implementation stillPassing = safeList(passed); // stillFailing: expected.failed w/o fixed, missingFails - failed = new ArrayList(); - failed.addAll(expectedFailed); + failed = new ArrayList(expectedFailed); failed = trimByName(failed, this.fixed); failed = trimByName(failed, missingFails); stillFailing = safeList(failed); diff --git a/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java b/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java index 17fa8234d..a0c5e115f 100644 --- a/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java +++ b/testing/src/test/java/org/aspectj/testing/util/TestDiffsTest.java @@ -18,6 +18,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.List; import java.util.ListIterator; import org.aspectj.util.FileUtil; @@ -67,7 +68,7 @@ public class TestDiffsTest extends TestCase { } } - ArrayList tempFiles; + List tempFiles; /** * Constructor for FileUtilTest. * @param arg0 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 b9c6d2cab..5d3ec4ba6 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 @@ -365,7 +365,7 @@ public class Option implements Comparable { private final Map familyNameToFamily = new TreeMap(); /** enforce uniqueness of options */ - private final ArrayList names = new ArrayList(); + private final List names = new ArrayList(); public Factory(String factoryName) { this.factoryName = factoryName; 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 92e84c106..03b3a6d51 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 @@ -14,6 +14,7 @@ package org.aspectj.testing.util.options; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.aspectj.util.LangUtil; @@ -59,7 +60,7 @@ public class Options { return sb.toString(); } - private final ArrayList options = new ArrayList(); + private final List options = new ArrayList(); private final boolean stopAtFirstMatch; private boolean frozen = !FROZEN; 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 7a04fbed0..de35c8c67 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 @@ -398,13 +398,11 @@ public class Values { 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]); - } + list.addAll(Arrays.asList(output).subList(1, output.length)); } } } - return (String[]) list.toArray(new String[list.size()]); + return (String[]) list.toArray(new String[0]); } private final Option.Value[] values; @@ -700,9 +698,7 @@ public class Values { private void add(int i) { if (insert >= input.length) { int[] temp = new int[insert + 256]; - for (int j = 0; j < input.length; j++) { - temp[j] = input[j]; - } + System.arraycopy(input, 0, temp, 0, input.length); input = temp; } input[insert++] = i; @@ -710,9 +706,7 @@ public class Values { private int[] getList() { int[] result = new int[insert]; - for (int i = 0; i < result.length; i++) { - result[i] = input[i]; - } + if (result.length >= 0) System.arraycopy(input, 0, result, 0, result.length); return result; } } 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 d6ebc774e..b60e56470 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java +++ b/testing/src/test/java/org/aspectj/testing/xml/AjcSpecXmlReaderTest.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.aspectj.testing.harness.bridge.AjcSpecTest; import org.aspectj.testing.harness.bridge.AjcTest; @@ -35,7 +36,7 @@ import junit.framework.TestCase; */ public class AjcSpecXmlReaderTest extends TestCase { - ArrayList<File> tempFiles = new ArrayList<>(); + List<File> tempFiles = new ArrayList<>(); /** * Constructor for AjcSpecXmlReaderTest. * @param name @@ -111,7 +112,7 @@ public class AjcSpecXmlReaderTest extends TestCase { String xml2Path = path + ".tmp.xml"; final File file1 = new File(xmlPath); - final ArrayList<File> toDelete = new ArrayList<>(); + final List<File> toDelete = new ArrayList<>(); final AjcSpecXmlReader writer = AjcSpecXmlReader.getReader(); assertTrue("" + file1, file1.canRead()); @@ -154,7 +155,7 @@ public class AjcSpecXmlReaderTest extends TestCase { AjcSpecXmlReader writer = AjcSpecXmlReader.getReader(); File file0 = new File(txtPath); File file1 = new File(xmlPath); - ArrayList<File> toDelete = new ArrayList<>(); + List<File> toDelete = new ArrayList<>(); AjcTest.Suite.Spec suite0 = null; if (file0.canRead()) { System.out.println("reading " + file0); 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 342484a76..3201d4288 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java +++ b/testing/src/test/java/org/aspectj/testing/xml/MessageListXmlReaderTest.java @@ -16,6 +16,7 @@ package org.aspectj.testing.xml; import java.io.File; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.aspectj.bridge.IMessage; import org.aspectj.util.LangUtil; @@ -27,7 +28,7 @@ import junit.framework.TestCase; */ public class MessageListXmlReaderTest extends TestCase { - ArrayList tempFiles = new ArrayList(); + List tempFiles = new ArrayList(); public MessageListXmlReaderTest(String name) { super(name); } 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 969c8ecd8..970a1c457 100644 --- a/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java +++ b/testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java @@ -16,7 +16,6 @@ package org.aspectj.testing.xml; import java.io.File; import java.util.ArrayList; //import java.util.Collections; -import java.util.Iterator; import java.util.List; import org.aspectj.bridge.IMessage; @@ -41,7 +40,7 @@ public class SoftMessage implements IMessage { private String details; private int id; private int sourceStart,sourceEnd; - private final ArrayList extraSourceLocations = new ArrayList(); + private final List extraSourceLocations = new ArrayList(); //private ISourceLocation pseudoSourceLocation; // set directly // collapse enclosed source location for shorter, property-based xml |