* ******************************************************************/
-// default package
-
-import org.aspectj.asm.NameConvertorTest;
-
-import junit.framework.*;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
public class AsmModuleTests extends TestCase {
*******************************************************************/
package org.aspectj.asm;
-import junit.framework.TestCase;
-
import org.aspectj.asm.internal.CharOperation;
import org.aspectj.asm.internal.NameConvertor;
+import junit.framework.TestCase;
+
public class NameConvertorTest extends TestCase {
public void testBoolean() {
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.StringTokenizer;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Constant;
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.ClassParser;
import org.aspectj.apache.bcel.classfile.JavaClass;
-import org.aspectj.apache.bcel.util.ClassLoaderRepository.SoftHashMap.SpecialValue;
/**
* The repository maintains information about which classes have been loaded.
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/*******************************************************************************
* Copyright (c) 2008 Contributors
- * All rights reserved. This program and the accompanying materials
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Andy Clement
*******************************************************************************/
package org.aspectj.matcher.tools;
-import junit.framework.TestCase;
-
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.tools.StandardPointcutExpression;
import org.aspectj.weaver.tools.StandardPointcutParser;
+import junit.framework.TestCase;
+
/**
* Test the use of the pointcut parser and matching infrastructure. The org.aspectj.matcher.tools infrastructure used should not be
* aware of what kind of World it is working with and only operate in terms of the type abstraction expressed in the
* org.aspectj.matcher project (so Members, etc). These tests only use base java types, there is no other testdata.
- *
+ *
* This is based on the Reflection oriented PointcutExpressionTest in the weaver project.
- *
+ *
* @author Andy Clement
*/
public abstract class CommonPointcutExpressionTests extends TestCase {
private ResolvedMember getMethod(ResolvedType type, String methodName, String methodSignature) {
ResolvedMember[] methods = type.getDeclaredMethods();
for (ResolvedMember method : methods) {
- System.out.println(method.getName() + method.getSignature());
if (method.getName().equals(methodName)
&& (methodSignature == null || methodSignature.equals(method.getSignature()))) {
return method;
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing.harness.bridge;
import org.aspectj.testing.run.WrappedRunIterator;
import org.aspectj.testing.util.StructureModelUtil;
import org.aspectj.testing.util.StructureModelUtil.ModelIncorrectException;
+import org.aspectj.testing.xml.AjcSpecXmlReader;
+import org.aspectj.testing.xml.IXmlWritable;
import org.aspectj.testing.xml.SoftMessage;
import org.aspectj.testing.xml.XMLWriter;
import org.aspectj.util.FileUtil;
* The staging directory is updated by prefix/suffix rules applied
* to files found below Sandbox.testBaseSrcDir.
* Files with suffix .{tag}.java are owned by this run
- * and are copied to the staging directory
+ * and are copied to the staging directory
* unless they are prefixed "delete.", in which case the
* corresponding file is deleted. Any "owned" file is passed to
* the compiler as the list of changed files.
- * The files entry contains the expected files recompiled. XXX underinclusive
+ * The files entry contains the expected files recompiled. XXX underinclusive
* XXX prefer messages for expected files?
* XXX later: also support specified paths, etc.
*/
final Spec spec; // nonfinal later to make re-runnable
Sandbox sandbox;
-
+
/**
* @param handler must not be null, but may be reused in the same thread
*/
this.spec = spec;
}
- /**
+ /**
* Initialize this from the sandbox, using compiler and changedFiles.
* @param sandbox the Sandbox setup for this test, including copying
* any changed files, etc.
this.sandbox = sandbox;
return doStaging(validator);
}
-
- /**
+
+ /**
* Handle copying and deleting of files per tag.
- * This returns false unless
+ * This returns false unless
* (1) tag is "same", or
* (2) some file was copied or deleted successfully
* and there were no failures copying or deleting files.
- * @return true if staging completed successfully
+ * @return true if staging completed successfully
*/
boolean doStaging(final Validator validator) {
if ("same".equals(spec.tag)) {
// deleting any with ChangedFilesCollector.DELETE_SUFFIX
// sigh - delay until after last last-mod-time
intHolder holder = new intHolder();
- List copied = new ArrayList();
+ List<File> copied = new ArrayList<>();
doStaging(validator,".java",holder,copied);
doStaging(validator,".jar",holder,copied);
doStaging(validator,".class",holder,copied);
result = (0 == holder.numFails);
}
if (0 < copied.size()) {
- File[] files = (File[]) copied.toArray(new File[0]);
+ File[] files = copied.toArray(new File[0]);
FileUtil.sleepPastFinalModifiedTime(files);
}
} catch (NullPointerException npe) {
return result;
}
-
- private void doStaging(final Validator validator, final String toSuffix,
+
+ private void doStaging(final Validator validator, final String toSuffix,
final intHolder holder,final List copied)
throws IOException
{
File destDir = sandbox.stagingDir;
FileUtil.copyDir(srcDir, destDir, fromSuffix, toSuffix, deleteOrCount);
}
-
+
private static class intHolder {
int numCopies;
int numDeletes;
if (null == compiler) {
MessageUtil.abort(status, "null compiler");
}
-
+
// // This is a list of expected classes (in File-normal form
// // relative to base class/src dir, without .class suffix
// // -- like "org/aspectj/tools/ajc/Main")
// }
//
// // now add any (additional) expected-class entries listed in the spec
-// // normalize to a similar file path (and do info messages for redundancies).
+// // normalize to a similar file path (and do info messages for redundancies).
//
// List alsoChanged = spec.getPathsAsFile(sandbox.stagingDir);
// for (Iterator iter = alsoChanged.iterator(); iter.hasNext();) {
// File f = (File) iter.next();
-//
+//
// if (expectedClasses.contains(f)) {
// // XXX remove old comment changed.contains() works b/c getPathsAsFile producing both File
// // normalizes the paths, and File.equals(..) compares these lexically
// MessageUtil.info(status, s + f);
// } else {
// expectedClasses.add(f);
-// }
+// }
// }
-//
+//
// // now can create handler, use it for reporting
// List errors = spec.getMessages(IMessage.ERROR);
// List warnings = spec.getMessages(IMessage.WARNING);
// AjcMessageHandler handler = new AjcMessageHandler(errors, warnings, expectedClasses);
-
- // same DirChanges handling for JavaRun, CompilerRun, IncCompilerRun
+
+ // same DirChanges handling for JavaRun, CompilerRun, IncCompilerRun
// XXX around advice or template method/class
DirChanges dirChanges = null;
if (!LangUtil.isEmpty(spec.dirChanges)) {
LangUtil.throwIaxIfFalse(1 == spec.dirChanges.size(), "expecting only 1 dirChanges");
- dirChanges = new DirChanges((DirChanges.Spec) spec.dirChanges.get(0));
+ dirChanges = new DirChanges(spec.dirChanges.get(0));
if (!dirChanges.start(status, sandbox.classesDir)) {
return false; // setup failed
}
} else {
result = (commandResult == handler.expectingCommandTrue());
if (! result) {
- String m = commandResult
+ String m = commandResult
? "incremental compile command did not return false as expected"
- : "incremental compile command returned false unexpectedly";
+ : "incremental compile command returned false unexpectedly";
MessageUtil.fail(status, m);
} else if (null != dirChanges) {
result = dirChanges.end(status, sandbox.testBaseDir);
}
// XXX weak - actual messages not reported in real-time, no fast-fail
if (report) {
- handler.report(status);
+ handler.report(status);
}
- }
+ }
return result;
}
public String toString() {
- return "" + spec;
+ return "" + spec;
// return "IncCompilerRun(" + spec + ")"; // XXX
}
- /**
+ /**
* initializer/factory for IncCompilerRun.
*/
public static class Spec extends AbstractRunSpec {
public static final String XMLNAME = "inc-compile";
protected boolean fresh;
- protected ArrayList classesAdded;
- protected ArrayList classesRemoved;
- protected ArrayList classesUpdated;
-
+ protected ArrayList<String> classesAdded;
+ protected ArrayList<String> classesRemoved;
+ protected ArrayList<String> classesUpdated;
+
protected String checkModel;
/**
- * skip description, skip sourceLocation,
+ * skip description, skip sourceLocation,
* do keywords, skip options, do paths as classes, do comment,
* skip staging (always true), skip badInput (irrelevant)
- * do dirChanges, do messages but skip children.
+ * do dirChanges, do messages but skip children.
*/
// private static final XMLNames NAMES = new XMLNames(XMLNames.DEFAULT,
// "", "", null, "", "classes", null, "", "", false, false, true);
-//
+//
/** identifies files this run owns, so {name}.{tag}.java maps to {name}.java */
String tag;
public Spec() {
super(XMLNAME);
setStaging(true);
- classesAdded = new ArrayList();
- classesRemoved = new ArrayList();
- classesUpdated = new ArrayList();
+ classesAdded = new ArrayList<>();
+ classesRemoved = new ArrayList<>();
+ classesUpdated = new ArrayList<>();
checkModel="";
}
-
- protected void initClone(Spec spec)
+
+ protected void initClone(Spec spec)
throws CloneNotSupportedException {
super.initClone(spec);
spec.fresh = fresh;
spec.classesUpdated.clear();
spec.classesUpdated.addAll(classesUpdated);
}
-
+
public Object clone() throws CloneNotSupportedException {
Spec result = new Spec();
initClone(result);
- return result;
+ return result;
}
public void setFresh(boolean fresh) {
this.fresh = fresh;
}
-
+
public void setTag(String input) {
tag = input;
}
-
+
public void setCheckModel(String thingsToCheck) {
this.checkModel=thingsToCheck;
}
-
+
public String toString() {
return "IncCompile.Spec(" + tag + ", " + super.toString() + ",["+checkModel+"])";
}
-
+
/** override to set dirToken to Sandbox.CLASSES and default suffix to ".class" */
public void addDirChanges(DirChanges.Spec spec) { // XXX copy/paste of CompilerRun.Spec...
if (null == spec) {
spec.setDefaultSuffix(".class");
super.addDirChanges(spec);
}
-
+
/** @return a IncCompilerRun with this as spec if setup completes successfully. */
public IRunIterator makeRunIterator(Sandbox sandbox, Validator validator) {
IncCompilerRun run = new IncCompilerRun(this);
}
return null;
}
-
- /**
+
+ /**
* Write this out as a compile element as defined in
* AjcSpecXmlReader.DOCTYPE.
- * @see AjcSpecXmlReader#DOCTYPE
- * @see IXmlWritable#writeXml(XMLWriter)
+ * @see AjcSpecXmlReader#DOCTYPE
+ * @see IXmlWritable#writeXml(XMLWriter)
*/
public void writeXml(XMLWriter out) {
String attr = XMLWriter.makeAttribute("tag", tag);
SoftMessage.writeXml(out, getMessages());
out.endElement(xmlElementName);
}
-
+
public void setClassesAdded(String items) {
addItems(classesAdded, items);
}
-
+
public void setClassesUpdated(String items) {
addItems(classesUpdated, items);
}
-
+
public void setClassesRemoved(String items) {
addItems(classesRemoved, items);
}
-
- private void addItems(List list, String items) {
+
+ private void addItems(List<String> list, String items) {
if (null != items) {
String[] classes = XMLWriter.unflattenList(items);
if (!LangUtil.isEmpty(classes)) {
}
}
}
- }
+ }
}
} // class IncCompilerRun.Spec
}
// // XXX replaced with method-local class - revisit if useful
-//
-// /**
+//
+// /**
// * This class collects the list of all changed files and
// * deletes the corresponding file for those prefixed "delete."
// */
// final Validator validator;
// /** need this to generate paths by clipping */
// final File destDir;
-//
+//
// /** @param changed the sink for all files changed (full paths) */
// public ChangedFilesCollector(ArrayList changed, File destDir, Validator validator) {
// LangUtil.throwIaxIfNull(validator, "ChangedFilesCollector - handler");
// }
//
// /**
-// * This converts the input File to normal String path form
+// * This converts the input File to normal String path form
// * (without any source suffix) and adds it to the list changed.
// * If the name of the file is suffixed ".delete..", then
-// * delete the corresponding file, and return false (no copy).
-// * Return true otherwise (copy file).
+// * delete the corresponding file, and return false (no copy).
+// * Return true otherwise (copy file).
// * @see java.io.FileFilter#accept(File)
// */
// public boolean accept(File file) {
// } else {
// int loc = name.lastIndexOf(path);
// if (-1 == loc) { // sigh
-//
+//
// } else {
-//
+//
// }
// }
// }
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing.util;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.MessageUtil;
+import org.aspectj.testing.util.TestDiffs.TestResult;
import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
-/**
- * Result struct for expected/actual diffs for Collection
+/**
+ * Result struct for expected/actual diffs for Collection
*/
public class Diffs {
* @throws NullPointerException if anything is null
*/
public int compare(IMessage lhs, IMessage rhs) {
- IMessage lm = (IMessage) lhs;
- IMessage rm = (IMessage) rhs;
+ IMessage lm = lhs;
+ IMessage rm = rhs;
ISourceLocation ls = (lm == null ? null : lm.getSourceLocation());
ISourceLocation rs = (rm == null ? null : rm.getSourceLocation());
int left = (ls == null ? -1 : ls.getLine());
return true;
}
};
- // // XXX List -> Collection b/c comparator orders
- // public static final Diffs NONE
+ // // XXX List -> Collection b/c comparator orders
+ // public static final Diffs NONE
// = new Diffs("NONE", Collections.EMPTY_LIST, Collections.EMPTY_LIST);
public static Diffs makeDiffs(
IMessage[] actual) {
return makeDiffs(label, expected, actual, null, null);
}
-
+
private static int getLine(ISourceLocation loc) {
int result = -1;
if (null != loc) {
IMessage[] actual,
IMessage.Kind[] ignoreExpectedKinds,
IMessage.Kind[] ignoreActualKinds) {
- List exp = getExcept(expected, ignoreExpectedKinds);
- List act = getExcept(actual, ignoreActualKinds);
+ List<IMessage> exp = getExcept(expected, ignoreExpectedKinds);
+ List<IMessage> act = getExcept(actual, ignoreActualKinds);
- ArrayList missing = new ArrayList();
- List unexpected = new ArrayList();
+ List<IMessage> missing = new ArrayList<>();
+ List<IMessage> unexpected = new ArrayList<>();
if (LangUtil.isEmpty(expected)) {
unexpected.addAll(act);
unexpected.add(actualMessage);
}
}
- // missing: all expected results not found
+ // missing: all expected results not found
exp.removeAll(expectedFound);
missing.addAll(exp);
}
// if (LangUtil.isEmpty(kinds)) {
// return sink.length;
// } else if (LangUtil.isEmpty(sink)) {
- // return 0;
+ // return 0;
// }
// int from = -1;
// int to = -1;
* extraSourceLocation[]
* if any are defined in expected, then there
* must be exactly the actual elements as are
- * defined in expected (so it is an error to
+ * defined in expected (so it is an error to
* not define all if you define any)
* <pre>
* @param expected
return false;
}
ISourceLocation[] esl =
- (ISourceLocation[]) expected.getExtraSourceLocations().toArray(
- new ISourceLocation[0]);
+ expected.getExtraSourceLocations().toArray(
+ new ISourceLocation[0]);
ISourceLocation[] asl =
- (ISourceLocation[]) actual.getExtraSourceLocations().toArray(
- new ISourceLocation[0]);
+ actual.getExtraSourceLocations().toArray(
+ new ISourceLocation[0]);
Arrays.sort(esl, SORT_SOURCELOC);
Arrays.sort(asl, SORT_SOURCELOC);
* (i.e., it ignored any extra source locations if no expectations stated).
* XXX need const like NO_FILE.
* @param expected the sorted ISourceLocation[] expected
- * @param expected the actual sorted ISourceLocation[]
+ * @param expected the actual sorted ISourceLocation[]
* @return true if any expected element is expected by the corresponding actual element.
*/
static boolean expectingSourceLocations(
}
}
- private static ArrayList getExcept(
+ private static List<IMessage> getExcept(
IMessage[] source,
IMessage.Kind[] skip) {
- ArrayList<IMessage> sink = new ArrayList<>();
+ List<IMessage> sink = new ArrayList<>();
if (LangUtil.isEmpty(source)) {
return sink;
}
public final String label;
/** immutable List */
- public final List missing;
+ public final List<TestResult> missing;
/** immutable List */
- public final List unexpected;
+ public final List<TestResult> unexpected;
/** true if there are any missing or unexpected */
public final boolean different;
((0 != this.missing.size()) || (0 != this.unexpected.size()));
}
- /**
+ /**
* Report missing and extra items to handler.
- * For each item in missing or unexpected, this creates a {kind} IMessage with
+ * For each item in missing or unexpected, this creates a {kind} IMessage with
* the text "{missing|unexpected} {label}: {message}"
- * where {message} is the result of
+ * where {message} is the result of
* <code>MessageUtil.renderMessage(IMessage)</code>.
* @param handler where the messages go - not null
* @param kind the kind of message to construct - not null
+ missing.size()
+ ")";
}
- public static interface Filter {
+ public interface Filter {
/** @return true to keep input in list of messages */
boolean accept(Object input);
}
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing.util;
import org.aspectj.util.LangUtil;
/**
- * Calculated differences between two test runs
+ * Calculated differences between two test runs
* based on their output files
* assuming that tests are logged with prefix [PASS|FAIL]
* (as they are when using <tt>-traceTestsMin</tt> with the Harness).
print(System.out, result.missing, "missing");
print(System.out, result.fixed, "fixed");
print(System.out, result.broken, "broken");
-
+
System.out.println("## Summary");
System.out.println(" # expected " + result.expected.size() + " tests: " + args[0] );
System.out.println(" # actual " + result.actual.size() + " tests: " + args[1]);
append(sb, result.stillFailing, " still failing");
System.out.println(" # diffs: " + sb);
}
-
+
/**
* @param expected the expected/old File results with Harness -traceTestsMin lines
* @param actual the actual/new File results with Harness -traceTestsMin lines
* @return TestDiffs null if error, valid otherwise
*/
public static TestDiffs compareResults(File expected, File actual) {
- ArrayList exp = null;
- ArrayList act = null;
+ List<TestResult> exp = null;
+ List<TestResult> act = null;
File reading = expected;
try {
exp = TestDiffs.readTestResults(expected, expected.getPath());
reading = actual;
act = TestDiffs.readTestResults(actual, actual.getPath());
-
+
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]
- List expResults = trimByName(exp, tests.missing);
- List actResults = trimByName(act, tests.unexpected);
-
+ List<TestResult> expResults = trimByName(exp, tests.missing);
+ List<TestResult> actResults = trimByName(act, tests.unexpected);
+
Diffs results = Diffs.makeDiffs("results", expResults, actResults, TestResult.BY_PASSNAME);
// broken tests show up in results as unexpected-fail or missing-pass
// fixed tests show up in results as unexpected-pass or missing-fail
- ArrayList broken = new ArrayList();
- ArrayList fixed = new ArrayList();
+ ArrayList<TestResult> broken = new ArrayList<TestResult>();
+ ArrayList<TestResult> fixed = new ArrayList<TestResult>();
split(results.unexpected, fixed, broken);
return new TestDiffs(
exp,
act,
- tests.missing,
- tests.unexpected,
- broken,
- fixed);
+ tests.missing,
+ tests.unexpected,
+ broken,
+ fixed);
} catch (IOException e) {
System.err.println("error reading " + reading);
e.printStackTrace(System.err); // XXX
}
}
- private static void append(StringBuffer sb, List list, String label) {
+ private static void append(StringBuffer sb, List<TestResult> list, String label) {
if (!LangUtil.isEmpty(list)) {
if (0 < sb.length()) {
sb.append(" ");
sb.append(list.size() + label);
}
}
-
- private static void print(PrintStream out, List list, String label) {
+
+ private static void print(PrintStream out, List<TestResult> list, String label) {
if ((null == out) || LangUtil.isEmpty(list)) {
return;
}
}
out.println("## END " + LABEL);
}
-
+
/**
- * Create ArrayList with input TestResult list
+ * Create ArrayList with input TestResult list
* but without elements in trim list,
* comparing based on test name only.
* @param input
* @param trim
* @return ArrayList with all input except those in trim (by name)
*/
- private static ArrayList trimByName(List input, List trim) {
- ArrayList result = new ArrayList(input);
+ private static List<TestResult> trimByName(List<TestResult> input, List<TestResult> trim) {
+ List<TestResult> result = new ArrayList<TestResult>(input);
if (!LangUtil.isEmpty(input) && !LangUtil.isEmpty(trim)) {
- for (ListIterator iter = result.listIterator(); iter.hasNext();) {
- TestResult inputItem = (TestResult) iter.next();
+ for (ListIterator<TestResult> iter = result.listIterator(); iter.hasNext();) {
+ TestResult inputItem = iter.next();
for (Object o : trim) {
TestResult trimItem = (TestResult) o;
if (inputItem.test.equals(trimItem.test)) {
return result;
}
-
+
/** split input List by whether the TestResult element passed or failed */
- private static void split(List input, List pass, List fail) {
+ private static void split(List<TestResult> input, List<TestResult> pass, List<TestResult> fail) {
for (Object o : input) {
TestResult result = (TestResult) o;
if (result.pass) {
}
}
- /**
+ /**
* Read a file of test results,
* defined as lines starting with [PASS|FAIL]
* (produced by Harness option <tt>-traceTestsmin</tt>).
- * @return ArrayList of TestResult, one for every -traceTestsMin line in File
+ * @return ArrayList of TestResult, one for every -traceTestsMin line in File
*/
- private static ArrayList readTestResults(File file, String config) throws IOException {
+ private static ArrayList<TestResult> readTestResults(File file, String config) throws IOException {
LangUtil.throwIaxIfNull(file, "file");
if (null == config) {
config = file.getPath();
}
- ArrayList result = new ArrayList();
+ ArrayList<TestResult> result = new ArrayList<TestResult>();
FileReader in = null;
try {
in = new FileReader(file);
}
return result;
}
-
- private static List safeList(List list) {
+
+ private static List<TestResult> safeList(List<TestResult> list) {
return (null == list
? Collections.EMPTY_LIST
: Collections.unmodifiableList(list));
}
-
+
/** List of TestResult results from expected run. */
- public final List expected;
+ public final List<TestResult> expected;
/** List of TestResult results from actual run. */
- public final List actual;
-
+ public final List<TestResult> actual;
+
/** List of TestResult tests disappeared from test suite between expected and actual runs. */
- public final List missing;
-
+ public final List<TestResult> missing;
+
/** List of TestResult tests added to test suite between expected and actual runs. */
- public final List added;
-
+ public final List<TestResult> added;
+
/** List of TestResult tests in both runs, expected to pass but actually failed */
- public final List broken;
-
+ public final List<TestResult> broken;
+
/** List of TestResult tests in both runs, expected to fail but actually passed */
- public final List fixed;
-
+ public final List<TestResult> fixed;
+
/** List of TestResult passed tests in expected run */
- public final List expectedPassed;
+ public final List<TestResult> expectedPassed;
/** List of TestResult failed tests in expected run */
- public final List expectedFailed;
+ public final List<TestResult> expectedFailed;
/** List of TestResult passed tests in actual run */
- public final List actualPassed;
+ public final List<TestResult> actualPassed;
/** List of TestResult tests failed in actual run */
- public final List actualFailed;
+ public final List<TestResult> actualFailed;
/** List of TestResult tests passed in both expected and actual run */
- public final List stillPassing;
+ public final List<TestResult> stillPassing;
/** List of TestResult tests failed in both expected and actual run */
- public final List stillFailing;
-
+ public final List<TestResult> stillFailing;
+
private TestDiffs(
- List expected,
- List actual,
- List missing,
- List added,
- List broken,
- List fixed) {
+ List<TestResult> expected,
+ List<TestResult> actual,
+ List<TestResult> missing,
+ List<TestResult> added,
+ List<TestResult> broken,
+ List<TestResult> fixed) {
this.expected = safeList(expected);
this.actual = safeList(actual);
this.missing = safeList(missing);
this.broken = safeList(broken);
this.fixed = safeList(fixed);
// expected[Passed|Failed]
- ArrayList passed = new ArrayList();
- ArrayList failed = new ArrayList();
+ List<TestResult> passed = new ArrayList<TestResult>();
+ List<TestResult> failed = new ArrayList<TestResult>();
split(this.expected, passed, failed);
expectedPassed = safeList(passed);
expectedFailed = safeList(failed);
// actual[Passed|Failed]
- passed = new ArrayList();
- failed = new ArrayList();
+ passed = new ArrayList<TestResult>();
+ failed = new ArrayList<TestResult>();
split(this.actual, passed, failed);
actualPassed = safeList(passed);
actualFailed = safeList(failed);
// stillPassing: expected.passed w/o broken, missingPasses
- passed = new ArrayList(expectedPassed);
+ passed = new ArrayList<TestResult>(expectedPassed);
passed = trimByName(passed, this.broken);
- ArrayList missingPasses = new ArrayList();
- ArrayList missingFails = new ArrayList();
+ ArrayList<TestResult> missingPasses = new ArrayList<TestResult>();
+ ArrayList<TestResult> missingFails = new ArrayList<TestResult>();
split(this.missing, missingPasses, missingFails);
- passed = trimByName(passed, missingPasses);
+ passed = trimByName(passed, missingPasses);
stillPassing = safeList(passed);
// stillFailing: expected.failed w/o fixed, missingFails
- failed = new ArrayList(expectedFailed);
+ failed = new ArrayList<TestResult>(expectedFailed);
failed = trimByName(failed, this.fixed);
- failed = trimByName(failed, missingFails);
+ failed = trimByName(failed, missingFails);
stillFailing = safeList(failed);
}
-
+
/** results of a test */
public static class TestResult {
public static final Comparator BY_PASSNAME = new Comparator() {
}
TestResult lhs = (TestResult) o1;
TestResult rhs = (TestResult) o2;
- return (lhs.pass == rhs.pass
+ return (lhs.pass == rhs.pass
? lhs.test.compareTo(rhs.test)
: (lhs.pass ? 1 : -1 ));
}
-
+
public boolean equals(Object lhs, Object rhs) {
return (0 == compare(lhs, rhs));
}
};
-
+
public static final Comparator BY_NAME = new Comparator() {
public int compare(Object o1, Object o2) {
if (o1 == o2) {
TestResult rhs = (TestResult) o2;
return lhs.test.compareTo(rhs.test);
}
-
+
public boolean equals(Object lhs, Object rhs) {
return (0 == compare(lhs, rhs));
}
};
-
+
//private static final ArrayList TESTS = new ArrayList();
public static final String FIELDSEP = "\t";
-
+
public final String test;
public final String config;
public final boolean pass;
private final String toString;
-
+
public TestResult(String test, String config, boolean pass) {
LangUtil.throwIaxIfNull(test, "test");
LangUtil.throwIaxIfNull(test, "config");
toString = (pass ? "PASS" : "FAIL") + FIELDSEP + test + FIELDSEP + config;
}
-
+
/** @return [PASS|FAIL]{FIELDSEP}test{FIELDSEP}config */
public String toString() {
return toString;
/* *******************************************************************
* Copyright (c) 2005 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors:
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
* Adrian Colyer Initial implementation
* ******************************************************************/
package org.aspectj.weaver;
// test cases for Adrian's additions to ReferenceType
// XXX - couldn't find any unit test cases for the rest of the ReferenceType class
+@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class ReferenceTypeTestCase extends TestCase {
public void testIsRawTrue() {
assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfInteger));
// void around(): execution(* C.m1(..)) && args(ArrayList<? extends Number>){}// Should runtime check (it does!)
- arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfInteger;
+ arrayListOfSomethingNumberish = listOfInteger;
assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfInteger));
assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfInteger));
assertTrue(ajList.isAssignableFrom(ajListOfInteger));
// void around(): execution(* C.m1(..)) && args(ArrayList){}//: Should runtime check (it does not match!)
- arraylist = (ArrayList) listOfInteger;
+ arraylist = listOfInteger;
assertFalse(ajArrayList.isAssignableFrom(ajListOfInteger));
assertTrue(ajArrayList.isCoerceableFrom(ajListOfInteger));
assertTrue(ajListOfSomething.isAssignableFrom(ajListOfInteger));
// void around(): execution(* C.m1(..)) && args(ArrayList<?>){}// Should runtime check (it does not match!)
- arrayListOfSomething = (ArrayList<?>) listOfInteger;
+ arrayListOfSomething = listOfInteger;
assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfInteger));
assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfInteger));
assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish));
// void around(): execution(* C.m2(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
- arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfSomethingNumberish;
+ arrayListOfSomethingNumberish = listOfSomethingNumberish;
assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish));
assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomethingNumberish));
assertTrue(ajList.isAssignableFrom(ajListOfSomethingNumberish));
// void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
- arraylist = (ArrayList) listOfSomethingNumberish;
+ arraylist = listOfSomethingNumberish;
assertFalse(ajArrayList.isAssignableFrom(ajListOfSomethingNumberish));
assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomethingNumberish));
assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomethingNumberish));
// void around(): execution(* C.m2(..)) && args(ArrayList<?>){}//: Should runtime check (it does!)
- arrayListOfSomething = (ArrayList) listOfSomethingNumberish;
+ arrayListOfSomething = listOfSomethingNumberish;
assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomethingNumberish));
assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomethingNumberish));
assertTrue(ajListOfNumber.isAssignableFrom(ajListOfNumber));
// void around(): execution(* C.m3(..)) && args(ArrayList<Number>){}//: Should runtime match (it does)
- arrayListOfNumber = (ArrayList<Number>) listOfNumber;
+ arrayListOfNumber = listOfNumber;
assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfNumber));
assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfNumber));
assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfNumber));
// void around(): execution(* C.m3(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
- arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfNumber;
+ arrayListOfSomethingNumberish = listOfNumber;
assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfNumber));
assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfNumber));
assertTrue(ajList.isAssignableFrom(ajListOfNumber));
// void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
- arrayList = (ArrayList) listOfNumber;
+ arrayList = listOfNumber;
assertFalse(ajArrayList.isAssignableFrom(ajListOfNumber));
assertTrue(ajArrayList.isCoerceableFrom(ajListOfNumber));
assertTrue(ajListOfSomething.isAssignableFrom(ajListOfNumber));
// void around(): execution(* C.m3(..)) && args(ArrayList<?>){}//: Should runtime check (it does!)
- arrayListOfSomething = (ArrayList<?>) listOfNumber;
+ arrayListOfSomething = listOfNumber;
assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfNumber));
assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfNumber));
static class ClassA<T> {
}
- static interface IMarker<H> {
+ interface IMarker<H> {
}
static class ClassB<T> implements IMarker<ClassA<T>> {
assertTrue(ajList.isAssignableFrom(ajListOfSomething));
// void around(): execution(* C.m4(..)) && args(ArrayList){} // Should runtime check
- arraylist = (ArrayList) listOfSomething;
+ arraylist = listOfSomething;
assertFalse(ajArrayList.isAssignableFrom(ajListOfSomething));
assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomething));
assertTrue(ajList.isAssignableFrom(ajListOfSomething));
// void around(): execution(* C.m4(..)) && args(ArrayList<?>){} // Should runtime check
- arrayListOfSomething = (ArrayList<?>) listOfSomething;
+ arrayListOfSomething = listOfSomething;
assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomething));
assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomething));
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver.bcel;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.aspectj.weaver.AdviceKind;
}
public void weaveTest(String name, String outName, ShadowMunger planner) throws IOException {
- List l = new ArrayList(1);
- l.add(planner);
+ List<ShadowMunger> l = Collections.singletonList(planner);
weaveTest(name, outName, l);
}
/* *******************************************************************
* Copyright (c) 2004 IBM Corporation.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
* ******************************************************************/
package org.aspectj.weaver.tools;
return;
}
- Set pcKinds = PointcutParser.getAllSupportedPointcutPrimitives();
+ Set<PointcutPrimitive> pcKinds = PointcutParser.getAllSupportedPointcutPrimitives();
pcKinds.remove(PointcutPrimitive.REFERENCE);
PointcutParser p = PointcutParser.getPointcutParserSupportingSpecifiedPrimitivesAndUsingSpecifiedClassLoaderForResolution(
pcKinds, this.getClass().getClassLoader());