aboutsummaryrefslogtreecommitdiffstats
path: root/testing-util
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-11-28 15:56:46 -0800
committerAndy Clement <aclement@pivotal.io>2019-11-28 15:56:46 -0800
commita3e5e4104ff31c9f06d90bd0f6876bef305831dc (patch)
tree06bcdf079072d3edb510107d51cfbb690aacf543 /testing-util
parent355b79ad65fc6af650b1d5d6253401b8edbff395 (diff)
downloadaspectj-a3e5e4104ff31c9f06d90bd0f6876bef305831dc.tar.gz
aspectj-a3e5e4104ff31c9f06d90bd0f6876bef305831dc.zip
Move to 1.9.6.BUILD-SNAPSHOT version
Diffstat (limited to 'testing-util')
-rw-r--r--testing-util/pom.xml2
-rw-r--r--testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java72
-rw-r--r--testing-util/src/test/java/org/aspectj/testingutil/TestCompareClassFile.java57
3 files changed, 64 insertions, 67 deletions
diff --git a/testing-util/pom.xml b/testing-util/pom.xml
index 7cf0efe74..c1da23789 100644
--- a/testing-util/pom.xml
+++ b/testing-util/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.aspectj</groupId>
<artifactId>aspectj-parent</artifactId>
- <version>1.9.5</version>
+ <version>1.9.6.BUILD-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
index 654efd8c4..ef6109e37 100644
--- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
+++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
@@ -1,13 +1,13 @@
/* *******************************************************************
* 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:
- * 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;
@@ -41,6 +41,12 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.MessageUtil;
+import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
+import org.aspectj.util.Reflection;
+
import jdiff.text.FileLine;
import jdiff.util.Diff;
import jdiff.util.DiffNormalOutput;
@@ -52,12 +58,6 @@ import junit.framework.TestResult;
import junit.framework.TestSuite;
import junit.runner.TestCaseClassLoader;
-import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.MessageUtil;
-import org.aspectj.util.FileUtil;
-import org.aspectj.util.LangUtil;
-import org.aspectj.util.Reflection;
-
/**
* Things that junit should perhaps have, but doesn't. Note the file-comparison methods require JDiff to run, but JDiff types are
* not required to resolve this class. Also, the bytecode weaver is required to compare class files, but not to compare other files.
@@ -125,8 +125,8 @@ public final class TestUtil {
LIB_RPATHS.setProperty(TESTING_CLIENT_KEY, "tests/testing-client.jar");
// TODO support others loaded dynamically
- Map map = new HashMap();
- for (Iterator iter = LIB_RPATHS.keySet().iterator(); iter.hasNext();) {
+ Map<String,Object> map = new HashMap<>();
+ for (Iterator<Object> iter = LIB_RPATHS.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
String path = LIB_RPATHS.getProperty(key);
File file = null;
@@ -196,7 +196,7 @@ public final class TestUtil {
/**
* This relies on these being File (where toString() == getPath()) or URL (where toString() == toExternalForm()).
- *
+ *
* @param entries the Object[] of File or URL elements
* @return the String with entries dlimited by the File.pathSeparator
*/
@@ -220,9 +220,9 @@ public final class TestUtil {
}
public static String aspectjrtClasspath() {
- return TestUtil.aspectjrtPath().getPath();
+ return TestUtil.aspectjrtPath().getPath();
}
-
+
/**
* @param input the String to parse for [on|off|true|false]
* @throws IllegalArgumentException if input is bad
@@ -286,7 +286,7 @@ public final class TestUtil {
}
/**
- *
+ *
* @param rpath the String relative path from the library directory to a resource that must exist (may be a directory), using
* forward slashes as a file separator
* @return the File path
@@ -306,7 +306,7 @@ public final class TestUtil {
/**
* Like libPath, only it returns a URL.
- *
+ *
* @return URL or null if it does not exist
* @throws IllegalArgumentException if no such directory or file
*/
@@ -327,7 +327,7 @@ public final class TestUtil {
// ---- unordered
- public static void assertSetEquals(Collection expected, Collection found) {
+ public static void assertSetEquals(Collection<?> expected, Collection<?> found) {
assertSetEquals(null, expected, found);
}
@@ -335,13 +335,13 @@ public final class TestUtil {
assertSetEquals(msg, Arrays.asList(expected), Arrays.asList(found));
}
- public static void assertSetEquals(String msg, Collection expected, Collection found) {
+ public static void assertSetEquals(String msg, Collection<?> expected, Collection<?> found) {
msg = (msg == null) ? "" : msg + ": ";
- Set results1 = new HashSet(found);
+ Set<Object> results1 = new HashSet<>(found);
results1.removeAll(expected);
- Set results2 = new HashSet(expected);
+ Set<Object> results2 = new HashSet<>(expected);
results2.removeAll(found);
if (results1.isEmpty()) {
@@ -403,7 +403,7 @@ public final class TestUtil {
BufferedReader r1 = new BufferedReader(new StringReader(s1));
BufferedReader r2 = new BufferedReader(new StringReader(s2));
- List lines = new ArrayList();
+ List<String> lines = new ArrayList<>();
String l1, l2;
int index = 1;
@@ -456,7 +456,7 @@ public final class TestUtil {
/**
* If there is an expected dir, expect each file in its subtree to match a corresponding actual file in the base directory. This
* does NOT check that all actual files have corresponding expected files. This ignores directory paths containing "CVS".
- *
+ *
* @param handler the IMessageHandler sink for error messages
* @param expectedBaseDir the File path to the directory containing expected files, all of which are compared with any
* corresponding actual files
@@ -494,7 +494,7 @@ public final class TestUtil {
/**
* Test interface to compare two files, line by line, and report differences as one FAIL message if a handler is supplied. This
* preprocesses .class files by disassembling.
- *
+ *
* @param handler the IMessageHandler for any FAIL messages (null to ignore)
* @param expectedFile the File path to the canonical file
* @param actualFile the File path to the actual file, if any
@@ -508,7 +508,7 @@ public final class TestUtil {
* Test interface to compare two files, line by line, and report differences as one FAIL message if a handler is supplied. This
* preprocesses .class files by disassembling. This method assumes that the files are at the same offset from two respective
* base directories.
- *
+ *
* @param handler the IMessageHandler for any FAIL messages (null to ignore)
* @param expectedBaseDir the File path to the canonical file base directory
* @param actualBaseDir the File path to the actual file base directory
@@ -766,7 +766,7 @@ public final class TestUtil {
/**
* Reduce file to CanonicalLine[].
- *
+ *
* @param handler the IMessageHandler for errors (may be null)
* @param file the File to render
* @param basedir the File for the base directory (may be null)
@@ -798,7 +798,7 @@ public final class TestUtil {
private abstract static class Lineator implements ILineator {
/**
* Reduce file to CanonicalLine[].
- *
+ *
* @param handler the IMessageHandler for errors (may be null)
* @param file the File to render
* @param basedir the File for the base directory (may be null)
@@ -916,7 +916,7 @@ public final class TestUtil {
}
}
}
-
+
public static File createEmptySandbox() {
File sandbox;
@@ -973,11 +973,11 @@ public final class TestUtil {
ByteArrayOutputStream missed;
- ArrayList sink;
+ ArrayList<String> sink;
public LineStream() {
super(new ByteArrayOutputStream());
- this.sink = new ArrayList();
+ this.sink = new ArrayList<>();
missed = (ByteArrayOutputStream) out;
}
@@ -993,11 +993,11 @@ public final class TestUtil {
/**
* Get String[] of lines printed, delimited by println(..) calls.
- *
+ *
* @return lines printed, exclusive of any not yet terminated by newline
*/
public String[] getLines() {
- return (String[]) sink.toArray(new String[0]);
+ return sink.toArray(new String[0]);
}
// ---------- PrintStream overrides
diff --git a/testing-util/src/test/java/org/aspectj/testingutil/TestCompareClassFile.java b/testing-util/src/test/java/org/aspectj/testingutil/TestCompareClassFile.java
index e24ca7be8..fb3e4dbe0 100644
--- a/testing-util/src/test/java/org/aspectj/testingutil/TestCompareClassFile.java
+++ b/testing-util/src/test/java/org/aspectj/testingutil/TestCompareClassFile.java
@@ -1,28 +1,23 @@
/* *******************************************************************
- * 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.testingutil;
-import org.aspectj.util.LangUtil;
-
import java.lang.reflect.Array;
-import java.util.ArrayList;
import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
import java.util.StringTokenizer;
-import java.util.TreeSet;
+
+import org.aspectj.util.LangUtil;
/**
* This is source for a sample .class file.
@@ -45,10 +40,10 @@ public class TestCompareClassFile implements Runnable {
}
protected static void protectedRunStatic() {
}
-
+
private long privateLong;
private final Object privateFinalObject;
-
+
private TestCompareClassFile() {
super();
privateLong = System.currentTimeMillis();
@@ -65,11 +60,12 @@ public class TestCompareClassFile implements Runnable {
}
protected void protectedRun() {
}
-
+
// ------- misc stolen utility code
// Collections Util
- public static List getListInMap(Map map, Object key) {
- List list = (List)map.get(key);
+ /*
+ public static List getListInMap(Map<Object,List> map, Object key) {
+ List list = map.get(key);
if (list == null) {
list = new ArrayList();
map.put(key, list);
@@ -77,15 +73,16 @@ public class TestCompareClassFile implements Runnable {
return list;
}
- public static SortedSet getSortedSetInMap(Map map, Object key) {
- SortedSet list = (SortedSet)map.get(key);
+ public static SortedSet getSortedSetInMap(Map<Object,SortedSet> map, Object key) {
+ SortedSet list = map.get(key);
if (list == null) {
list = new TreeSet();
map.put(key, list);
}
return list;
}
-
+ */
+
// LangUtil
/**
* Make a copy of the array.
@@ -116,10 +113,10 @@ public class TestCompareClassFile implements Runnable {
lines.add(st.nextToken());
}
st = null;
-
+
String line;
int elided = 0;
- while (!lines.isEmpty()) {
+ while (!lines.isEmpty()) {
line = (String) lines.getLast();
if (null == line) {
break;
@@ -128,10 +125,10 @@ public class TestCompareClassFile implements Runnable {
lines.removeLast();
}
}
- if ((elided > 0) || (maxLines < 1)) {
- final int EOL_LEN = LangUtil.EOL.length();
+ if ((elided > 0) || (maxLines < 1)) {
+ final int EOL_LEN = LangUtil.EOL.length();
int totalLength = 0;
- while (!lines.isEmpty()) {
+ while (!lines.isEmpty()) {
totalLength += EOL_LEN + ((String) lines.getFirst()).length();
lines.removeFirst();
}
@@ -143,5 +140,5 @@ public class TestCompareClassFile implements Runnable {
}
}
}
-
+
}