@@ -231,7 +231,7 @@ public class AjcTestCase extends TestCase { | |||
} | |||
} | |||
if (seeAlsos != null) { | |||
List extraLocations = message.getExtraSourceLocations(); | |||
List<ISourceLocation> extraLocations = message.getExtraSourceLocations(); | |||
if (extraLocations.size() != seeAlsos.length) { | |||
return false; | |||
} | |||
@@ -244,9 +244,8 @@ public class AjcTestCase extends TestCase { | |||
return true; | |||
} | |||
private boolean hasAMatch(List srcLocations, ISourceLocation sLoc) { | |||
for (Iterator iter = srcLocations.iterator(); iter.hasNext();) { | |||
ISourceLocation thisLoc = (ISourceLocation) iter.next(); | |||
private boolean hasAMatch(List<ISourceLocation> srcLocations, ISourceLocation sLoc) { | |||
for (ISourceLocation thisLoc: srcLocations) { | |||
if (thisLoc.getLine() == sLoc.getLine()) { | |||
if (thisLoc.getSourceFile().getPath().equals(sLoc.getSourceFile().getPath())) { | |||
return true; |
@@ -36,7 +36,7 @@ import org.aspectj.tools.ajc.Ajc; | |||
*/ | |||
public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase { | |||
private Map testMap = new HashMap(); | |||
private Map<String,AjcTest> testMap = new HashMap<String,AjcTest>(); | |||
public void addTest(AjcTest test) { | |||
testMap.put(test.getTitle(), test); | |||
@@ -45,11 +45,11 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase { | |||
/* | |||
* Return a map from (String) test title -> AjcTest | |||
*/ | |||
protected Map getSuiteTests() { | |||
protected Map<String,AjcTest> getSuiteTests() { | |||
return testMap; | |||
} | |||
public static Test loadSuite(Class testCaseClass) { | |||
public static Test loadSuite(Class<?> testCaseClass) { | |||
TestSuite suite = new TestSuite(testCaseClass.getName()); | |||
//suite.addTestSuite(testCaseClass); | |||
@@ -66,20 +66,20 @@ public abstract class AutowiredXMLBasedAjcTestCase extends XMLBasedAjcTestCase { | |||
} | |||
wired.ajc = new Ajc(); | |||
Map ajTests = wired.getSuiteTests(); | |||
Map<String,AjcTest> ajTests = wired.getSuiteTests(); | |||
for (Iterator iterator = ajTests.entrySet().iterator(); iterator.hasNext();) { | |||
final Map.Entry entry = (Map.Entry) iterator.next(); | |||
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() { | |||
((AjcTest) entry.getValue()).runTest(wired); | |||
entry.getValue().runTest(wired); | |||
} | |||
public String getName() { | |||
return (String) entry.getKey(); | |||
return entry.getKey(); | |||
} | |||
} | |||
); |
@@ -1,5 +1,5 @@ | |||
/* ******************************************************************* | |||
* Copyright (c) 2004 IBM Corporation | |||
* Copyright (c) 2004,2016 IBM Corporation | |||
* All rights reserved. | |||
* This program and the accompanying materials are made available | |||
* under the terms of the Eclipse Public License v1.0 | |||
@@ -13,7 +13,6 @@ package org.aspectj.testing; | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.StringTokenizer; | |||
@@ -21,14 +20,12 @@ import org.aspectj.tools.ajc.AjcTestCase; | |||
import org.aspectj.tools.ajc.CompilationResult; | |||
/** | |||
* @author colyer | |||
* | |||
* TODO To change the template for this generated type comment go to | |||
* Window - Preferences - Java - Code Style - Code Templates | |||
* @author Adrian Colyer | |||
* @author Andy Clement | |||
*/ | |||
public class CompileSpec implements ITestStep { | |||
private List expected = new ArrayList(); | |||
private List<ExpectedMessageSpec> expected = new ArrayList<ExpectedMessageSpec>(); | |||
private String files; | |||
private boolean includeClassesDir; | |||
@@ -254,8 +251,8 @@ public class CompileSpec implements ITestStep { | |||
args.append(getExtdirs()); | |||
args.append(" "); | |||
} | |||
List fileList = new ArrayList(); | |||
List jarList = new ArrayList(); | |||
List<String> fileList = new ArrayList<String>(); | |||
List<String> jarList = new ArrayList<String>(); | |||
// convention that any jar on file list should be added to inpath | |||
String files = getFiles(); | |||
if (files == null) files = ""; | |||
@@ -271,15 +268,13 @@ public class CompileSpec implements ITestStep { | |||
if ((getInpath() != null) || !jarList.isEmpty()) { | |||
args.append("-inpath "); | |||
if (getInpath() != null) args.append(getInpath()); | |||
for (Iterator iter = jarList.iterator(); iter.hasNext();) { | |||
String jar = (String) iter.next(); | |||
for (String jar: jarList) { | |||
args.append(File.pathSeparator); | |||
args.append(jar); | |||
} | |||
args.append(" "); | |||
} | |||
for (Iterator iter = fileList.iterator(); iter.hasNext();) { | |||
String file = (String) iter.next(); | |||
for (String file: fileList) { | |||
args.append(file); | |||
args.append(" "); | |||
} | |||
@@ -298,8 +293,7 @@ public class CompileSpec implements ITestStep { | |||
List<AjcTestCase.Message> errors = new ArrayList<AjcTestCase.Message>(); | |||
List<AjcTestCase.Message> fails = new ArrayList<AjcTestCase.Message>(); | |||
List<AjcTestCase.Message> weaveInfos = new ArrayList<AjcTestCase.Message>(); | |||
for (Iterator iter = expected.iterator(); iter.hasNext();) { | |||
ExpectedMessageSpec exMsg = (ExpectedMessageSpec) iter.next(); | |||
for (ExpectedMessageSpec exMsg: expected) { | |||
String kind = exMsg.getKind(); | |||
if (kind.equals("info")) { | |||
if (infos == null) infos = new ArrayList<AjcTestCase.Message>(); |
@@ -1,8 +1,6 @@ | |||
/* | |||
* Created on 02-Aug-2004 | |||
* | |||
* TODO To change the template for this generated file go to | |||
* Window - Preferences - Java - Code Style - Code Templates | |||
*/ | |||
package org.aspectj.testing; | |||
@@ -12,7 +10,6 @@ import java.io.InputStreamReader; | |||
import java.io.PrintStream; | |||
import java.text.NumberFormat; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import org.apache.commons.digester.Digester; | |||
@@ -63,7 +60,7 @@ public class MakeTestClass { | |||
private static final String FOOTER = | |||
"}\n"; | |||
private List tests = new ArrayList(); | |||
private List<AjcTest> tests = new ArrayList<AjcTest>(); | |||
private String className; | |||
private String suiteFile; | |||
@@ -97,8 +94,7 @@ public class MakeTestClass { | |||
int testNo = 1; | |||
NumberFormat nf = NumberFormat.getInstance(); | |||
nf.setMinimumIntegerDigits(3); | |||
for (Iterator iter = tests.iterator(); iter.hasNext();) { | |||
AjcTest test = (AjcTest) iter.next(); | |||
for (AjcTest test: tests) { | |||
out.println(); | |||
out.print(" public void test"); | |||
out.print(nf.format(testNo++)); |
@@ -19,7 +19,7 @@ import org.aspectj.tools.ajc.AjcTestCase; | |||
public class OutputSpec { | |||
private List expectedOutputLines = new ArrayList(); | |||
private List<String> expectedOutputLines = new ArrayList<String>(); | |||
public void addLine(OutputLine line) { | |||
expectedOutputLines.add(line.getText()); | |||
@@ -39,8 +39,7 @@ public class OutputSpec { | |||
StringTokenizer strTok = new StringTokenizer(output,"\n"); | |||
if (strTok.countTokens() == expectedOutputLines.size()) { | |||
matches = true; | |||
for (Iterator iter = expectedOutputLines.iterator(); iter.hasNext();) { | |||
String line = (String) iter.next(); | |||
for (String line: expectedOutputLines) { | |||
lineNo++; | |||
String outputLine = strTok.nextToken().trim(); | |||
/* Avoid trying to match on ajSandbox source names that appear in messages */ | |||
@@ -56,18 +55,18 @@ public class OutputSpec { | |||
} | |||
public void unorderedMatchAgainst(String output) { | |||
List outputFound = getOutputFound(output); | |||
List<String> outputFound = getOutputFound(output); | |||
if(outputFound.size() != expectedOutputLines.size()) { | |||
createFailureMessage(output, -1, outputFound.size()); | |||
return; | |||
} | |||
List expected = new ArrayList(); | |||
List<String> expected = new ArrayList<String>(); | |||
expected.addAll(expectedOutputLines); | |||
List found = new ArrayList(); | |||
List<String> found = new ArrayList<String>(); | |||
found.addAll(outputFound); | |||
for (Iterator iterator = outputFound.iterator(); iterator.hasNext();) { | |||
for (Iterator<String> iterator = outputFound.iterator(); iterator.hasNext();) { | |||
String lineFound = (String) iterator.next(); | |||
for (Iterator iterator2 = expectedOutputLines.iterator(); iterator2.hasNext();) { | |||
for (Iterator<String> iterator2 = expectedOutputLines.iterator(); iterator2.hasNext();) { | |||
String lineExpected = (String) iterator2.next(); | |||
if (lineFound.indexOf(lineExpected)!= -1) { | |||
found.remove(lineFound); | |||
@@ -84,9 +83,7 @@ public class OutputSpec { | |||
private void createFailureMessage(String output, int lineNo, int sizeFound) { | |||
StringBuffer failMessage = new StringBuffer(); | |||
failMessage.append("\n expecting output:\n"); | |||
int l = 0; | |||
for (Iterator iter = expectedOutputLines.iterator(); iter.hasNext();) { | |||
String line = (String) iter.next(); | |||
for (String line: expectedOutputLines) { | |||
failMessage.append(line); | |||
failMessage.append("\n"); | |||
} | |||
@@ -102,8 +99,8 @@ public class OutputSpec { | |||
AjcTestCase.fail(failMessage.toString()); | |||
} | |||
private List getOutputFound(String output) { | |||
List found = new ArrayList(); | |||
private List<String> getOutputFound(String output) { | |||
List<String> found = new ArrayList<String>(); | |||
StringTokenizer strTok = new StringTokenizer(output,"\n"); | |||
while(strTok.hasMoreTokens()) { | |||
String outputLine = strTok.nextToken().trim(); |
@@ -41,6 +41,9 @@ public class RunSpec implements ITestStep { | |||
private String vmargs; | |||
private String usefullltw; | |||
public String toString() { | |||
return "RunSpec: Running '"+classToRun+"' in directory '"+baseDir+"'. Classpath of '"+cpath+"'"; | |||
} | |||
public RunSpec() { | |||
} | |||
@@ -18,7 +18,6 @@ import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import java.util.StringTokenizer; | |||
import java.util.jar.JarEntry; | |||
@@ -37,7 +36,7 @@ public class WeaveSpec extends CompileSpec { | |||
private String classesFiles; | |||
private String aspectsFiles; | |||
private List classFilesFromClasses; | |||
private List<File> classFilesFromClasses; | |||
/* (non-Javadoc) | |||
* @see org.aspectj.testing.ITestStep#execute(org.aspectj.tools.ajc.AjcTestCase) | |||
@@ -46,7 +45,7 @@ public class WeaveSpec extends CompileSpec { | |||
String failMessage = "test \"" + getTest().getTitle() + "\" failed"; | |||
try { | |||
File base = new File(getBaseDir()); | |||
classFilesFromClasses = new ArrayList(); | |||
classFilesFromClasses = new ArrayList<File>(); | |||
setFiles(classesFiles); | |||
String[] args = buildArgs(); | |||
CompilationResult result = inTestCase.ajc(base,args); | |||
@@ -95,13 +94,12 @@ public class WeaveSpec extends CompileSpec { | |||
File outJar = new File(inDir,name); | |||
FileOutputStream fos = new FileOutputStream(outJar); | |||
JarOutputStream jarOut = new JarOutputStream(fos); | |||
List classFiles = new ArrayList(); | |||
List toExclude = isClasses ? Collections.EMPTY_LIST : classFilesFromClasses; | |||
List<File> classFiles = new ArrayList<File>(); | |||
List<File> toExclude = isClasses ? Collections.<File>emptyList() : classFilesFromClasses; | |||
collectClassFiles(inDir,classFiles,toExclude); | |||
if (isClasses) classFilesFromClasses = classFiles; | |||
String prefix = inDir.getPath() + File.separator; | |||
for (Iterator iter = classFiles.iterator(); iter.hasNext();) { | |||
File f = (File) iter.next(); | |||
for (File f: classFiles) { | |||
String thisPath = f.getPath(); | |||
if (thisPath.startsWith(prefix)) { | |||
thisPath = thisPath.substring(prefix.length()); | |||
@@ -115,7 +113,7 @@ public class WeaveSpec extends CompileSpec { | |||
jarOut.close(); | |||
} | |||
private void collectClassFiles(File inDir, List inList, List toExclude) { | |||
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")) { | |||
@@ -135,6 +133,7 @@ public class WeaveSpec extends CompileSpec { | |||
while((read = fis.read(buf)) != -1) { | |||
dest.write(buf,0,read); | |||
} | |||
fis.close(); | |||
} | |||
private String[] buildWeaveArgs() { |
@@ -50,10 +50,10 @@ import org.aspectj.util.FileUtil; | |||
*/ | |||
public abstract class XMLBasedAjcTestCase extends AjcTestCase { | |||
private static Map testMap = new HashMap(); | |||
private static Map<String,AjcTest> testMap = new HashMap<String,AjcTest>(); | |||
private static boolean suiteLoaded = false; | |||
private AjcTest currentTest = null; | |||
private Stack clearTestAfterRun = new Stack(); | |||
private Stack<Boolean> clearTestAfterRun = new Stack<Boolean>(); | |||
public XMLBasedAjcTestCase() { | |||
} | |||
@@ -71,7 +71,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { | |||
* @param testCaseClass | |||
* @return | |||
*/ | |||
public static Test loadSuite(Class testCaseClass) { | |||
public static Test loadSuite(Class<?> testCaseClass) { | |||
TestSuite suite = new TestSuite(testCaseClass.getName()); | |||
suite.addTestSuite(testCaseClass); | |||
TestSetup wrapper = new TestSetup(suite) { | |||
@@ -106,7 +106,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { | |||
/* | |||
* Return a map from (String) test title -> AjcTest | |||
*/ | |||
protected Map getSuiteTests() { | |||
protected Map<String,AjcTest> getSuiteTests() { | |||
return testMap; | |||
} | |||
@@ -174,7 +174,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { | |||
if (clearTestAfterRun.isEmpty()) { | |||
return false; | |||
} | |||
boolean result = ((Boolean) clearTestAfterRun.peek()).booleanValue(); | |||
boolean result = clearTestAfterRun.peek().booleanValue(); | |||
if (pop) { | |||
clearTestAfterRun.pop(); | |||
} | |||
@@ -241,7 +241,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { | |||
protected void setUp() throws Exception { | |||
super.setUp(); | |||
if (!suiteLoaded) { | |||
testMap = new HashMap(); | |||
testMap = new HashMap<String,AjcTest>(); | |||
System.out.println("LOADING SUITE: " + getSpecFile().getPath()); | |||
Digester d = getDigester(); | |||
try { |