From d3ce9b0f5cf1465d87b946e4025b39997a00b442 Mon Sep 17 00:00:00 2001 From: wisberg Date: Fri, 9 Jan 2004 07:24:24 +0000 Subject: [PATCH] harness tests upgraded for support for message details, extra source locations --- .../harness/bridge/AbstractRunSpecTest.java | 2 +- .../testing/harness/bridge/AjcSpecTest.java | 29 +++++++++++++++---- .../testing/xml/MessageListXmlReaderTest.java | 8 +++-- .../aspectj/testing/xml/TestingXmlTests.java | 2 ++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/testing/testsrc/org/aspectj/testing/harness/bridge/AbstractRunSpecTest.java b/testing/testsrc/org/aspectj/testing/harness/bridge/AbstractRunSpecTest.java index 0ed0010c2..f7871872d 100644 --- a/testing/testsrc/org/aspectj/testing/harness/bridge/AbstractRunSpecTest.java +++ b/testing/testsrc/org/aspectj/testing/harness/bridge/AbstractRunSpecTest.java @@ -30,7 +30,7 @@ public class AbstractRunSpecTest extends TestCase { super(name); } - public void skiptestXmlWrite() { + public void testXmlWrite() { AbstractRunSpec spec = new TestSpec(); spec.setOptions("-option1,-option2"); spec.setKeywords("keyword1, keyword2"); diff --git a/testing/testsrc/org/aspectj/testing/harness/bridge/AjcSpecTest.java b/testing/testsrc/org/aspectj/testing/harness/bridge/AjcSpecTest.java index f6009fc30..eaca921ed 100644 --- a/testing/testsrc/org/aspectj/testing/harness/bridge/AjcSpecTest.java +++ b/testing/testsrc/org/aspectj/testing/harness/bridge/AjcSpecTest.java @@ -136,7 +136,7 @@ public class AjcSpecTest extends TestCase { } /** @return true if both are empty (null or no entries) or if all match after trimming */ - public static void sameListSize(List lhs, List rhs, Assert a) { + public static void sameListSize(List lhs, List rhs) { if (null == lhs) { assertTrue((null == rhs) || (0 == rhs.size())); } else if (null == rhs) { @@ -148,7 +148,7 @@ public class AjcSpecTest extends TestCase { /** @return true if both are empty (null or no entries) or if all match after trimming */ public static void sameList(List lhs, List rhs, Assert a) { - sameListSize(lhs, rhs, a); + sameListSize(lhs, rhs); String l = normal(lhs); String r = normal(rhs); String label = l + NOTSAME + r; @@ -257,7 +257,7 @@ public class AjcSpecTest extends TestCase { } assertTrue(rhs != null); assertTrue(lhs != null); - sameListSize(lhs, rhs, a); + sameListSize(lhs, rhs); Iterator lhsIter = lhs.iterator(); Iterator rhsIter = rhs.iterator(); while (lhsIter.hasNext() && rhsIter.hasNext()) { @@ -302,11 +302,30 @@ public class AjcSpecTest extends TestCase { assertTrue(rhs != null); assertTrue(lhs.getKind() == rhs.getKind()); same(lhs.getMessage(), rhs.getMessage(), a); + same(lhs.getDetails(), rhs.getDetails(), a); assertEquals(lhs.getThrown(), rhs.getThrown()); - sameSourceLocation(lhs.getSourceLocation(), rhs.getSourceLocation(), a); + sameSourceLocation(lhs.getSourceLocation(), rhs.getSourceLocation()); + sameSourceLocations(lhs.getExtraSourceLocations(), rhs.getExtraSourceLocations()); } + public static void sameSourceLocations(List lhs, List rhs) { + sameListSize(lhs, rhs); + if ((null == lhs) || (0 == lhs.size())) { + return; + } + // ok, do order-dependent check.. + ListIterator iterLeft = lhs.listIterator(); + ListIterator iterRight = rhs.listIterator(); + while (iterLeft.hasNext() && iterRight.hasNext()) { + ISourceLocation left = (ISourceLocation) iterLeft.next(); + ISourceLocation right = (ISourceLocation) iterRight.next(); + sameSourceLocation(left, right); + } + assertTrue(!iterLeft.hasNext()); + assertTrue(!iterRight.hasNext()); + + } - public static void sameSourceLocation(ISourceLocation lhs, ISourceLocation rhs, Assert a) { + public static void sameSourceLocation(ISourceLocation lhs, ISourceLocation rhs) { if ((null == lhs) && (null == rhs)) { return; } diff --git a/testing/testsrc/org/aspectj/testing/xml/MessageListXmlReaderTest.java b/testing/testsrc/org/aspectj/testing/xml/MessageListXmlReaderTest.java index 95563633f..2d24914bf 100644 --- a/testing/testsrc/org/aspectj/testing/xml/MessageListXmlReaderTest.java +++ b/testing/testsrc/org/aspectj/testing/xml/MessageListXmlReaderTest.java @@ -46,9 +46,11 @@ public class MessageListXmlReaderTest extends TestCase { } } } - /** XXX not in suite until this is fixed */ - public void testMessageReading() throws Exception { - assertTrue("XXX need better XML wrapping - has < character", false); + public void testNothingOthersSkipped() {} + + public void skiptestMessageReading() throws Exception { + + //assertTrue("XXX need better XML wrapping - has < character", false); //checkXmlRoundTrip("testdata/dirChangesTestDir/diff/expectedMessages"); //checkXmlRoundTrip("testdata/dirChangesTestDir/same/expectedMessages"); } diff --git a/testing/testsrc/org/aspectj/testing/xml/TestingXmlTests.java b/testing/testsrc/org/aspectj/testing/xml/TestingXmlTests.java index 0ea576af4..0925f2d55 100644 --- a/testing/testsrc/org/aspectj/testing/xml/TestingXmlTests.java +++ b/testing/testsrc/org/aspectj/testing/xml/TestingXmlTests.java @@ -24,6 +24,8 @@ public class TestingXmlTests extends TestCase { TestSuite suite = new TestSuite(TestingXmlTests.class.getName()); //$JUnit-BEGIN$ suite.addTestSuite(AjcSpecXmlReaderTest.class); + suite.addTestSuite(MessageListXmlReaderTest.class); + suite.addTestSuite(XMLWriterTest.class); //$JUnit-END$ return suite; } -- 2.39.5