From a3e5e4104ff31c9f06d90bd0f6876bef305831dc Mon Sep 17 00:00:00 2001
From: Andy Clement This contains contributions from the AspectJ community of "
+ "
* output.dir=c:/latest
* "context.javaPath=c:/apps/jdk1.3.1
*
- *
+ *
* List
of String using
* comma as the delimiter and trimming whitespace from the result.
- *
+ *
* @param text
* String
to split.
* @return unmodifiable List (String) of String delimited by comma in text
*/
- public static List commaStrings(String text) {
+ public static List{moduleName}.mf.txt
is taken as the manifest of
* any .jar file produced, after filtering. day and
age";
// System.err.println("from " + source);
// System.err.println(" to " + SampleUtil.replace(source, from, to));
-//
+//
// }
/**
* Emit samples gathered from any input args.
@@ -88,7 +101,7 @@ public class SampleGatherer {
fos.close();
System.out.println("see file:///" + out);
}
-
+
/**
* Gather samples from a source file or directory
* @param source the File file or directory to start with
@@ -96,7 +109,7 @@ public class SampleGatherer {
* @return sink or a new Samples collection with any samples found
* @throws IOException if unable to read a source file
*/
- public static Samples gather(File source, Samples sink)
+ public static Samples gather(File source, Samples sink)
throws IOException {
if (null == sink) {
sink = new Samples();
@@ -122,8 +135,8 @@ public class SampleGatherer {
}
return line;
}
-
- private static void doGather(File source, Samples sink)
+
+ private static void doGather(File source, Samples sink)
throws IOException {
if (source.isFile()) {
if (isSource(source)) {
@@ -150,8 +163,8 @@ public class SampleGatherer {
}
return false;
}
-
- private static void gatherFromFile(final File source, final Samples sink)
+
+ private static void gatherFromFile(final File source, final Samples sink)
throws IOException {
Reader reader = null;
try {
@@ -185,7 +198,7 @@ public class SampleGatherer {
anchorName = anchorName.substring(0, loc);
}
continue;
- }
+ }
// found end?
loc = line.indexOf(END);
@@ -203,10 +216,10 @@ public class SampleGatherer {
endLine = lineNumber;
Sample sample = new Sample(anchorName,
anchorTitle,
- author,
- sampleCode.toString(),
- source,
- startLine,
+ author,
+ sampleCode.toString(),
+ source,
+ startLine,
endLine,
(String[]) flags.toArray(new String[flags.size()]));
sink.addSample(sample);
@@ -216,7 +229,7 @@ public class SampleGatherer {
startLine = -1;
endLine = Integer.MAX_VALUE;
continue;
- }
+ }
// found author?
loc = line.indexOf(AUTHOR);
@@ -228,7 +241,7 @@ public class SampleGatherer {
if (-1 != loc) {
flags.add(trimCommentEnd(line, loc + FLAG.length()));
}
-
+
// reading?
if ((-1 != startLine) && (-1 == endLine)) {
sampleCode.append(line);
@@ -272,21 +285,21 @@ class Sample {
public int compare(Sample left, Sample right) {
if (null == left) {
return (null == right ? 0 : -1);
- }
+ }
if (null == right) {
return 1;
- }
+ }
int result = left.anchorName.compareTo(right.anchorName);
if (0 != result) {
- return result;
+ return result;
}
result = left.sourcePath.compareTo(right.sourcePath);
if (0 != result) {
- return result;
+ return result;
}
result = right.startLine - left.startLine;
if (0 != result) {
- return result;
+ return result;
}
return right.endLine - left.endLine;
}
@@ -297,18 +310,18 @@ class Sample {
public int compare(Sample left, Sample right) {
if (null == left) {
return (null == right ? 0 : -1);
- }
+ }
if (null == right) {
return 1;
- }
+ }
int result = left.author.compareTo(right.author);
if (0 != result) {
- return result;
+ return result;
}
return NAME_SOURCE_COMPARER.compare(left,right);
}
};
-
+
final String anchorName;
final String anchorTitle;
final String author;
@@ -349,10 +362,10 @@ class Sample {
}
public static class Kind {
-
+
/** lowercase source suffixes identify files to gather samples from */
public static final String[] SOURCE_SUFFIXES = new String[]
- { ".java", ".aj", ".sh", ".ksh",
+ { ".java", ".aj", ".sh", ".ksh",
".txt", ".text", ".html", ".htm", ".xml" };
static final Kind XML = new Kind();
static final Kind HTML = new Kind();
@@ -404,7 +417,7 @@ class Samples {
List
Copyright 2003 Contributors. All Rights Reserved. " + "This sample code is made available under the Common Public " + "License version 1.0 available at " + "" @@ -448,7 +461,7 @@ class SamplesRenderer { + "the source by reference to the AspectJ project home page " + " at http://eclipse.org/aspectj.
" + EOL; - + /** template algorithm to render */ public final StringBuffer render(Samples samples, StringBuffer sink) { if (null == sink) { @@ -458,15 +471,15 @@ class SamplesRenderer { return sink; } startList(samples, sink); - List list = samples.getSortedSamples(); + List"); + sampleSection.append("
"); sampleSection.append(EOL); if (doFlags) { boolean flagHeaderDone = false; @@ -609,7 +622,7 @@ class HTMLSamplesRenderer extends SamplesRenderer { } } } - + protected void renderXML(Sample sample) { renderStandardHeader(sample); sampleSection.append("
"); @@ -756,10 +769,10 @@ class HTMLSamplesRenderer extends SamplesRenderer { tableOfContents.append(EOL); tableOfContents.append("
List
to hold events submitted. */
private static ListList
to hold events we expect. */
private static Listnote.toString()
is it wasn't found.
*
* @param note Message that should've been added using {@link #note}.
- * XXX deprecated checkEvent(String)
+ * XXX deprecated checkEvent(String)
*/
- public static void check(Object note) {
+ public static void check(String note) {
check(note, "expected note \"" + note.toString() + "\"");
}
@@ -141,7 +151,7 @@ public class Tester {
* @param message Message with which to fail if node
* wasn't added.
*/
- public static void check(Object note, String message) {
+ public static void check(String note, String message) {
check(notes.contains(note), message);
}
@@ -156,7 +166,7 @@ public class Tester {
throwable(t, null);
}
-
+
/**
* Reports that t
shouldn't have been thrown.
* using msg
as the message.
@@ -503,7 +513,7 @@ public class Tester {
*/
public static void checkEqual(long value, long expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compared value
and expectedValue
@@ -533,7 +543,7 @@ public class Tester {
*/
public static void checkEqual(double value, double expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compared value
and expectedValue
@@ -564,7 +574,7 @@ public class Tester {
*/
public static void checkEqual(short value, short expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compared value
and expectedValue
@@ -594,7 +604,7 @@ public class Tester {
*/
public static void checkEqual(byte value, byte expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compares value
and expectedValue
@@ -624,7 +634,7 @@ public class Tester {
*/
public static void checkEqual(char value, char expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compares value
and expectedValue
@@ -654,7 +664,7 @@ public class Tester {
*/
public static void checkEqual(boolean value, boolean expectedValue) {
checkEqual(value, expectedValue, "compare");
- }
+ }
/**
* Compares value
and expectedValue
@@ -679,23 +689,23 @@ public class Tester {
* @param expectedSet Expected String
of values.
* @param msg Message with which to fail.
*/
- public static void checkEqual(Collection set, String expectedSet, String msg) {
+ public static void checkEqual(Collectionset
are equal
* using equals
to the corresponding entry in
* expectedSet
and fails with message msg
,
* except that duplicate actual entries are ignored.
- * This issues fail messages for each failure; when
+ * This issues fail messages for each failure; when
* aborting on failure, only the first will be reported.
*
* @param set Unkown set of values.
* @param expectedSet Expected String
of values.
* @param msg Message with which to fail.
*/
- public static void checkEqualIgnoreDups(Collection set, String[] expected, String msg,
+ public static void checkEqualIgnoreDups(CollectionString
of values.
* @param msg Message with which to fail.
*/
- public static void checkEqual(Collection set, String[] expected, String msg) {
+ public static void checkEqual(Collectionset
are equal
@@ -790,14 +800,14 @@ public class Tester {
expectedEvents.add(s);
}
}
-
+
/** add expected events */
public static void expectEvent(Object s) {
if (null != s) {
expectEvent(s.toString());
}
}
-
+
/**
* add expected events, parse out ; from string
* Expect those messages in s
separated by
@@ -836,26 +846,26 @@ public class Tester {
if (null != events[i]) {
expectEvent(events[i].toString());
}
- }
+ }
}
}
-
+
/** check actual and expected have same members */
public static void checkAllEvents() {
- checkAndClearEvents((String[]) expectedEvents.toArray(new String[0]));
+ checkAndClearEvents(expectedEvents.toArray(new String[0]));
}
-
+
/** also ignore duplicate actual entries for expected */
public static void checkAllEventsIgnoreDups() {
final boolean ignoreDups = true;
- final String[] exp = (String[]) expectedEvents.toArray(new String[0]);
+ final String[] exp = expectedEvents.toArray(new String[0]);
checkEqualIgnoreDups(actualEvents, exp, "event", ignoreDups);
clearEvents();
}
-
+
/** Check events, file is line-delimited. If there is a non-match, signalls
- * a single error for the first event that does not match the next event in
- * the file. The equivalence is {@link #checkEqualLists}. Blank lines are
+ * a single error for the first event that does not match the next event in
+ * the file. The equivalence is {@link #checkEqualLists}. Blank lines are
* ignored. lines that start with '//' are ignored. */
public static void checkEventsFromFile(String eventsFile) {
// XXX bug reads into current expected and checks all - separate read and check
@@ -864,19 +874,20 @@ public class Tester {
BufferedReader in = new BufferedReader(new FileReader(file));
//final File parentDir = (null == file? null : file.getParentFile());
String line;
- List expEvents = new ArrayList();
+ ListThrowable
to print.
* @see #maxStackTrace
*/
- public void unexpectedExceptionFailure(Throwable thrown) {
+ public void unexpectedExceptionFailure(Throwable thrown) {
handle("unexpectedExceptionFailure", thrown, true);
}
-
+
/**
* Handle message by delegation to message handler, doing
- * IMessage.FAIL if (fail || (thrown != null) and IMessage.INFO
+ * IMessage.FAIL if (fail || (thrown != null) and IMessage.INFO
* otherwise.
*/
@@ -964,7 +975,7 @@ public class Tester {
// private static void resofhandle(String message, Throwable thrown, boolean fail) {
// /* If FAIL and the message handler returns false (normally),
// * Then this preserves "abort" semantics by throwing an
-// * abort exception.
+// * abort exception.
// */
// if (failed) {
// if (handled) {
diff --git a/testing-client/src/main/java/org/aspectj/testing/server/TestServer.java b/testing-client/src/main/java/org/aspectj/testing/server/TestServer.java
index c1f7afc52..a8b500ff0 100644
--- a/testing-client/src/main/java/org/aspectj/testing/server/TestServer.java
+++ b/testing-client/src/main/java/org/aspectj/testing/server/TestServer.java
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2006,2017 IBM Corporation and others.
- * 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
@@ -37,19 +37,19 @@ public class TestServer implements Runnable {
private String mainClass = "UnknownClass";
private String mainLoader = "UnknownLoader";
-
+
public void initialize () throws IOException {
createRootLoader();
loadConfiguration();
}
-
+
private void loadConfiguration () throws IOException {
File file = new File(workingDirectory,"server.properties");
Properties props = new Properties();
FileInputStream in = new FileInputStream(file);
props.load(in);
in.close();
-
+
Enumeration> enu = props.propertyNames();
while (enu.hasMoreElements()) {
String key = (String)enu.nextElement();
@@ -63,7 +63,7 @@ public class TestServer implements Runnable {
}
}
}
-
+
private void createLoader (String property) throws IOException {
ClassLoader parent = rootLoader;
@@ -73,10 +73,10 @@ public class TestServer implements Runnable {
if (debug) System.err.println("Creating loader "+name+" with classpath "+classpath);
if (st.hasMoreTokens()) {
String parentName = st.nextToken();
- parent = (ClassLoader)loaders.get(parentName);
+ parent = loaders.get(parentName);
if (parent == null) error("No such loader: " + parentName);
}
-
+
ListTester.event("foo"); @@ -57,10 +56,10 @@ public class TesterTest extends TestCase { public void testEventArrayPattern() { MyTestReporter reporter = new MyTestReporter(); Tester.setMessageHandler(reporter); - + //--------- positive test - got expected events reporter.clear(); - Tester.clear(); + Tester.clear(); Tester.event("one"); Tester.event("two"); Tester.checkEvents(new String[] { "one", "two"}); @@ -75,14 +74,14 @@ public class TesterTest extends TestCase { //--------- got and didn't get expected events reporter.clear(); - Tester.clear(); + Tester.clear(); Tester.event("one"); Tester.event("two"); Tester.checkEvents(new String[] { "one", "two", "three"}); reporter.assertSize(1); assertTrue(reporter.gotFail("three")); } - + /** * Test the usage pattern *Tester.event("foo"); @@ -92,10 +91,10 @@ public class TesterTest extends TestCase { public void testEventStringPattern() { MyTestReporter reporter = new MyTestReporter(); Tester.setMessageHandler(reporter); - + //--------- positive test - got expected events reporter.clear(); - Tester.clear(); + Tester.clear(); Tester.event("one"); Tester.event("two"); Tester.expectEvent("one"); @@ -113,7 +112,7 @@ public class TesterTest extends TestCase { //--------- got and didn't get expected events reporter.clear(); - Tester.clear(); + Tester.clear(); Tester.expectEvent("one"); Tester.expectEvent("two"); Tester.expectEvent("three"); @@ -123,7 +122,7 @@ public class TesterTest extends TestCase { assertTrue(reporter.gotFail("three")); reporter.assertSize(1); } - + /** * Test the usage pattern *Tester.note("foo"); @@ -132,10 +131,10 @@ public class TesterTest extends TestCase { public void testNotePattern() { MyTestReporter reporter = new MyTestReporter(); Tester.setMessageHandler(reporter); - + //--------- positive test - got expected events reporter.clear(); - Tester.clear(); + Tester.clear(); Tester.note("one"); Tester.note("two"); Tester.check("one"); @@ -152,7 +151,7 @@ public class TesterTest extends TestCase { //--------- got and didn't get expected events reporter.clear(); - Tester.clear(); + Tester.clear(); Tester.note("one"); Tester.check("one"); Tester.note("two"); @@ -161,7 +160,7 @@ public class TesterTest extends TestCase { assertTrue(reporter.gotFail("three")); reporter.assertSize(1); } - + /** * Stub to record failures emitted by Tester. * @author isberg @@ -179,15 +178,15 @@ public class TesterTest extends TestCase { assertTrue(-1 < size); assertTrue("failures: " + failures, size == failures.size()); } - + boolean gotPass(String substring) { return gotItem(passes, substring); } - + boolean gotFail(String substring) { return gotItem(failures, substring); } - + boolean gotItem(Listlist, String substring) { for (IMessage element: list) { String s = element.getMessage(); @@ -197,13 +196,13 @@ public class TesterTest extends TestCase { } return false; } - + public boolean isIgnoring(IMessage.Kind kind) { return false; } public void dontIgnore(IMessage.Kind kind) { - ; + } public void ignore(IMessage.Kind kind) { @@ -214,13 +213,13 @@ public class TesterTest extends TestCase { return true; } } -} +} // /** // * @see ReporterI#abortWithFailure(String, Throwable) // */ // public void abortWithFailure(String message, Throwable exception) { // if (null == exception) { -// check(message, true); +// check(message, true); // } else { // String s = message + Util.unqualifiedClassName(exception) // + ": " + exception.getMessage(); diff --git a/testing-drivers/pom.xml b/testing-drivers/pom.xml index 63bb5b89d..383732416 100644 --- a/testing-drivers/pom.xml +++ b/testing-drivers/pom.xml @@ -6,7 +6,7 @@ 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 @@ org.aspectj aspectj-parent -1.9.5 +1.9.6.BUILD-SNAPSHOT .. 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 org.aspectj aspectj-parent -1.9.5 +1.9.6.BUILD-SNAPSHOT .. map = new HashMap<>(); + for (Iterator