* RFA JDWP Event Filter Tests
2006-06-16 18:03 ` Michael Koch
@ 2006-06-16 18:30 ` Kyle Galloway
0 siblings, 0 replies; 9+ messages in thread
From: Kyle Galloway @ 2006-06-16 18:30 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]
Alright I have changed the tags on these tests. Same tests as before,
but all tagged as GNU-JDWP. I submitted these as one patch since the
comprise a full set of tests for the JDWP event filters. Requesting
approval and commit(I don't have access).
Thanks,
Kyle
2006-06-16 Kyle Galloway <kgallowa@redhat.com>
*
gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassMatchFilter.java:
New Test.
*
gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassExcludeFilter.java:
New Test.
*
gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassOnlyFilter.java:
New Test.
* gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfCountFilter.java:
New Test.
*
gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfExceptionOnlyFilter.java:
New Test.
*
gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfInstanceOnlyFilter.java:
New Test.
*
gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfThreadOnlyFilter.java:
New Test.
Michael Koch wrote:
> On Fri, Jun 16, 2006 at 01:57:36PM -0400, Kyle Galloway wrote:
>
>> Michael Koch wrote:
>>
>>> On Fri, Jun 16, 2006 at 11:44:04AM -0400, Kyle Galloway wrote:
>>>
>>>
>>>> Looking at the GNU-Crypto tests, I think that the JDWP test should be
>>>> tagged GNU-JDWP JDK 1.4. Any comments about this idea?
>>>>
>>>>
>>> As AFAIK a new tag begins after a whitespace this would be three tags
>>> with two of them wrong.
>>>
>>>
>> Ok, so would just GNU-JDWP be the best option, I don't know much about
>> how these tags work, but this seems like it would allow for these tests
>> to be excluded from the normal Classpath vs Sun tests while still being
>> able to call the whole set of them to test all the JDWP filters.
>>
>
> Ok.
>
>
> Michael
>
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 31376 bytes --]
Index: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassExcludeFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassExcludeFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassExcludeFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassExcludeFilter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,150 @@
+/* TestOfClassExcludeFilter.java -- test of ClassExcludeFilter
+
+ Written by Kyle Galloway (kgallowa@redhat.com)
+
+ This file is part of Mauve.
+
+ Mauve is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Mauve is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Mauve; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ */
+
+// Tags: GNU-JDWP
+
+
+package gnu.testlet.gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.event.filters.ClassExcludeFilter;
+import gnu.classpath.jdwp.event.filters.ClassMatchFilter;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * @author Kyle Galloway (kgallowa@redhat.com) This class performs a test of the
+ * <code>ClassExcludeFilter</code> from JDWP.
+ */
+public class TestOfClassExcludeFilter
+ implements Testlet
+{
+
+ /**
+ * Tests the <code>ClassMatchFilter</code> constructor
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testConstructor(TestHarness harness)
+ {
+ harness.checkPoint("Constructor");
+
+ ClassMatchFilter testCMF = null;
+
+ String[] validStrings = { "SomeString", "", "*omeString", "SomeStr*" };
+ String[] invalidStrings = { "Som*String", "SomeStri*g" };
+
+ // check to see if the valid strings don't throw exceptions
+ for (int i = 0; i < validStrings.length; i++)
+ {
+ try
+ {
+ testCMF = new ClassMatchFilter(validStrings[i]);
+ harness.check(true);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(false, "constructor threw exception for valid "
+ + "string: " + validStrings[i]);
+ }
+ }
+
+ // check that invalid strings throw exceptions
+ for (int i = 0; i < invalidStrings.length; i++)
+ {
+ try
+ {
+ testCMF = new ClassMatchFilter(invalidStrings[i]);
+ harness.check(false, "constructor didn't throw exception for "
+ + "invalid string: " + invalidStrings[i]);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(true);
+ }
+ }
+ }
+
+ /**
+ * Tests the <code>ClassExcludeFilter</code> from
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testMatches(TestHarness harness)
+ {
+ harness.checkPoint("matches method");
+ String[] validStrings = { "java.lang.Integer", "*nteger", "java.lang.*",
+ "*" };
+ String[] invalidStrings = { "Float", "Double", "AWT" };
+
+ ClassExcludeFilter testCEF = null;
+
+ // create an event to use as a test
+ ClassPrepareEvent testEvent = new ClassPrepareEvent(Thread.currentThread(),
+ Integer.class, 0);
+
+ // check to see that the matching strings match the class name
+ for (int i = 0; i < validStrings.length; i++)
+ {
+ try
+ {
+ testCEF = new ClassExcludeFilter(validStrings[i]);
+ harness.check(testCEF.matches(testEvent), false, "for string: "
+ + validStrings[i]);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(false, "valid String: " + validStrings[i] + " threw "
+ + ex);
+ }
+ }
+
+ // check to see that the nonmatching strings don't match the class name
+ for (int i = 0; i < invalidStrings.length; i++)
+ {
+ try
+ {
+ testCEF = new ClassExcludeFilter(invalidStrings[i]);
+ harness.check(testCEF.matches(testEvent), true, "for string: "
+ + invalidStrings[i]);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(false, "valid String: " + invalidStrings[i]
+ + " threw " + ex);
+ }
+ }
+ }
+
+ /**
+ * Test the <code>ClassExcludeFilter</code> class
+ *
+ * @param harness the TestHarness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testConstructor(harness);
+ testMatches(harness);
+ }
+}
Index: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassMatchFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassMatchFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassMatchFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassMatchFilter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,150 @@
+/* TestOfClassMatchFilter.java -- test of ClassMatchFilter
+
+ Written by Kyle Galloway (kgallowa@redhat.com)
+
+ This file is part of Mauve.
+
+ Mauve is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Mauve is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Mauve; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ */
+
+// Tags: GNU-JDWP
+
+
+package gnu.testlet.gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.event.filters.ClassMatchFilter;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * @author Kyle Galloway (kgallowa@redhat.com) This class performs a test of the
+ * <code>ClassMatchFilter</code> from JDWP.
+ */
+public class TestOfClassMatchFilter
+ implements Testlet
+{
+
+ /**
+ * Tests the <code>ClassMatchFilter</code> constructor
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testConstructor(TestHarness harness)
+ {
+ harness.checkPoint("Constructor");
+
+ ClassMatchFilter testCMF = null;
+
+ String[] validStrings = { "SomeString", "", "*omeString", "SomeStr*" };
+ String[] invalidStrings = { "Som*String", "SomeStri*g" };
+
+ // check to see if the valid strings don't throw exceptions
+ for (int i = 0; i < validStrings.length; i++)
+ {
+ try
+ {
+ testCMF = new ClassMatchFilter(validStrings[i]);
+ harness.check(true);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(false, "constructor threw exception for valid "
+ + "string: " + validStrings[i]);
+ }
+ }
+
+ // check that invalid strings throw exceptions
+ for (int i = 0; i < invalidStrings.length; i++)
+ {
+ try
+ {
+ testCMF = new ClassMatchFilter(invalidStrings[i]);
+ harness.check(false, "constructor didn't throw exception for "
+ + "invalid string: " + invalidStrings[i]);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(true);
+ }
+ }
+ }
+
+ /**
+ * Tests the <code>ClassMatchFilter</code> method matches
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testMatches(TestHarness harness)
+ {
+ harness.checkPoint("matches method");
+ String[] validStrings = { "java.lang.Integer", "*nteger", "java.lang.*",
+ "*" };
+ String[] invalidStrings = { "Float", "Double", "AWT" };
+
+ ClassMatchFilter testCMF = null;
+
+ // create an event to use as a test
+ ClassPrepareEvent testEvent = new ClassPrepareEvent(Thread.currentThread(),
+ Integer.class, 0);
+ // check to see that the matching strings match the class name
+ for (int i = 0; i < validStrings.length; i++)
+ {
+ try
+ {
+ testCMF = new ClassMatchFilter(validStrings[i]);
+ harness.check(testCMF.matches(testEvent), true, "for string: "
+ + validStrings[i]);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(false, "valid String: " + validStrings[i] + " threw "
+ + ex);
+ }
+ }
+
+ // check to see that the nonmatching strings don't match the class name
+ for (int i = 0; i < invalidStrings.length; i++)
+ {
+ try
+ {
+ testCMF = new ClassMatchFilter(invalidStrings[i]);
+ harness.check(testCMF.matches(testEvent), false,
+ "for string: " + invalidStrings[i]);
+ }
+ catch (InvalidStringException ex)
+ {
+ harness.check(false, "valid String: " + invalidStrings[i]
+ + " threw " + ex);
+ }
+ }
+ }
+
+ /**
+ * Test the <code>ClassMatchFilter</code> class
+ *
+ * @param harness the TestHarness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testConstructor(harness);
+ testMatches(harness);
+ }
+
+}
Index: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassOnlyFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfClassOnlyFilter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,117 @@
+/* TestOfClassOnlyFilter.java -- test of ClassOnlyFilter
+
+ Written by Kyle Galloway (kgallowa@redhat.com)
+
+ This file is part of Mauve.
+
+ Mauve is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Mauve is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Mauve; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ */
+
+// Tags: GNU-JDWP
+
+
+package gnu.testlet.gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.event.filters.ClassOnlyFilter;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class TestOfClassOnlyFilter
+ implements Testlet
+{
+ /**
+ * Tests the <code>ClassOnlyFilter</code> constructor
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testConstructor(TestHarness harness)
+ {
+ harness.checkPoint("Constructor");
+
+ VMIdManager idm = VMIdManager.getDefault();
+ ReferenceTypeId validTestId = idm.getReferenceTypeId(Integer.class);
+
+ try
+ {
+ ClassOnlyFilter testCOF = new ClassOnlyFilter(validTestId);
+ harness.check(true, "Constructor successful");
+ }
+ catch (InvalidClassException ex)
+ {
+ harness.check(false, "Constructor failed with exception" + ex);
+ }
+
+ }
+
+ /**
+ * Tests the <code>ClassOnlyFilter</code> matches method
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testMatches(TestHarness harness)
+ {
+ harness.checkPoint("matches method");
+
+ VMIdManager idm = VMIdManager.getDefault();
+ ReferenceTypeId testId = idm.getReferenceTypeId(Integer.class);
+
+ try
+ {
+ ClassOnlyFilter testCOF = new ClassOnlyFilter(testId);
+ ClassPrepareEvent testEvent = new ClassPrepareEvent(
+ Thread.currentThread(),
+ Integer.class, 0);
+
+ harness.check(testCOF.matches(testEvent), "test correct refid");
+ }
+ catch (InvalidClassException ex)
+ {
+ harness.check(false, "Constructor(in methods test) failed with"
+ + "exception" + ex);
+ }
+
+ try
+ {
+ ClassOnlyFilter testCOF = new ClassOnlyFilter(testId);
+ ClassPrepareEvent testEvent = new ClassPrepareEvent(
+ Thread.currentThread(),
+ String.class, 0);
+
+ harness.check(! testCOF.matches(testEvent), "test wrong refid");
+ }
+ catch (InvalidClassException ex)
+ {
+ harness.check(false, "Constructor(in methods test) failed with"
+ + "exception" + ex);
+ }
+ }
+
+ /**
+ * Test the <code>ClassOnlyFilter</code> class
+ *
+ * @param harness the TestHarness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testConstructor(harness);
+ testMatches(harness);
+ }
+}
Index: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfCountFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfCountFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfCountFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfCountFilter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,122 @@
+/*/* TestOfClassMatchFilter.java -- test of CountFilter
+
+ Written by Kyle Galloway (kgallowa@redhat.com)
+
+ This file is part of Mauve.
+
+ Mauve is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Mauve is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Mauve; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ */
+
+// Tags: GNU-JDWP
+
+
+package gnu.testlet.gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.event.filters.CountFilter;
+import gnu.classpath.jdwp.exception.InvalidCountException;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests the <code>CountFilter</code> from JDWP
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class TestOfCountFilter
+ implements Testlet
+{
+
+ public final int COUNT = 5;
+
+ public final int INVALID_COUNT = - 1;
+
+ /**
+ * Tests the <code>ClountFilter</code> constructor
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testConstructor(TestHarness harness)
+ {
+
+ harness.checkPoint("Constructor");
+
+ try
+ {
+ CountFilter testCF = new CountFilter(COUNT);
+ harness.check(true, "Constructor passed test");
+ }
+ catch (InvalidCountException ex)
+ {
+ harness.check(false, "Constructor failed for valid count");
+ }
+
+ try
+ {
+ CountFilter testCF = new CountFilter(INVALID_COUNT);
+ harness.check(false, "Constructor threw no exception for invalid count");
+ }
+ catch (InvalidCountException ex)
+ {
+ harness.check(true, "Constructor failed correctly for invalid count");
+ }
+ }
+
+ /**
+ * Tests the <code>CountFilter</code> method matches
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testMatches(TestHarness harness)
+ {
+ harness.checkPoint("matches method");
+
+ try
+ {
+ CountFilter testCF = new CountFilter(COUNT);
+ ClassPrepareEvent testCPE = new ClassPrepareEvent(
+ Thread.currentThread(),
+ Integer.class, 0);
+
+ for (int i = 1; i <= COUNT + 1; i++)
+ {
+ if (i != COUNT)
+ harness.check(! testCF.matches(testCPE),
+ "Matches where # != COUNT");
+ else
+ harness.check(testCF.matches(testCPE), "Matches after correct #");
+ }
+ }
+ catch (InvalidCountException ex)
+ {
+ harness.check(false, "Constructor failed for valid count");
+ }
+ }
+
+ /**
+ * Test the <code>CountFilter</code> class
+ *
+ * @param harness the TestHarness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testConstructor(harness);
+ testMatches(harness);
+ }
+
+}
Index: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfExceptionOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfExceptionOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfExceptionOnlyFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfExceptionOnlyFilter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,134 @@
+/* TestOfExceptionOnlyFilter.java -- test for Exception filter
+
+ Written by Kyle Galloway (kgallowa@redhat.com)
+
+ This file is part of Mauve.
+
+ Mauve is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Mauve is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Mauve; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ */
+
+// Tags: GNU-JDWP
+
+
+package gnu.testlet.gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.event.ExceptionEvent;
+import gnu.classpath.jdwp.event.filters.ExceptionOnlyFilter;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.io.IOException;
+
+/**
+ * Tests the ExceptionOnlyFilter class
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class TestOfExceptionOnlyFilter
+ implements Testlet
+{
+ /**
+ * Tests the constructor of the <code>ExceptionOnlyFilter</code> class
+ *
+ * @param harness the <code>TestHarness</code> to use
+ */
+ public void testConstructor(TestHarness harness)
+ {
+ harness.checkPoint("Constructor");
+
+ VMIdManager idm = VMIdManager.getDefault();
+ ReferenceTypeId validrid = idm.getReferenceTypeId(NullPointerException.class);
+
+ try
+ {
+ ExceptionOnlyFilter testEOF = new ExceptionOnlyFilter(validrid, true,
+ true);
+ harness.check(true, "Constructor successful");
+ }
+ catch (InvalidClassException ex)
+ {
+ harness.check(false, "constructor failed for valid class");
+ }
+
+ try
+ {
+ ExceptionOnlyFilter testEOF = new ExceptionOnlyFilter(null, true, true);
+ harness.check(true, "Constructor successful correctly for null");
+ }
+ catch (InvalidClassException ex)
+ {
+ harness.check(false, "constructor failed unexpectedly for null");
+ }
+
+ }
+
+ /**
+ * Tests the matches method of <code>ExceptionOnlyFilter</code>
+ *
+ * @param harness the <code>TestHarness</code> to use
+ */
+ public void testMatches(TestHarness harness)
+ {
+ harness.checkPoint("matches method");
+
+ NullPointerException testException = new NullPointerException();
+
+ VMIdManager idm = VMIdManager.getDefault();
+ ReferenceTypeId rid = idm.getReferenceTypeId(NullPointerException.class);
+
+ Integer testInt = new Integer(6);
+ try
+ {
+ ExceptionOnlyFilter testEOF = new ExceptionOnlyFilter(rid, true, true);
+ ExceptionEvent testEvent = new ExceptionEvent(testException,
+ Thread.currentThread(),
+ null, null, testInt);
+
+ harness.check(testEOF.matches(testEvent), "matching valid exception");
+
+ testEOF = new ExceptionOnlyFilter(null, true, true);
+ testEvent = new ExceptionEvent(testException, Thread.currentThread(),
+ null, null, testInt);
+
+ harness.check(testEOF.matches(testEvent), "matching any exception");
+
+ rid = idm.getReferenceTypeId(IOException.class);
+
+ testEOF = new ExceptionOnlyFilter(rid, true, true);
+ testEvent = new ExceptionEvent(testException, Thread.currentThread(),
+ null, null, testInt);
+
+ harness.check(! testEOF.matches(testEvent),
+ "not matching incorrect exception");
+ }
+ catch (InvalidClassException ex)
+ {
+ harness.check(false, "constructor failed for valid class");
+ }
+
+ }
+
+ public void test(TestHarness harness)
+ {
+ testConstructor(harness);
+ testMatches(harness);
+ }
+}
Index: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfInstanceOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfInstanceOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfInstanceOnlyFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfInstanceOnlyFilter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,122 @@
+/* TestOfInstanceOnlyFilter.java -- tests the InstanceOnly Filter
+
+ Written By Kyle Galloway (kgallowa@redhat.com)
+
+ This file is part of Mauve.
+
+ Mauve is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Mauve is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Mauve; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ */
+
+// Tags: GNU-JDWP
+
+
+package gnu.testlet.gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.event.BreakpointEvent;
+import gnu.classpath.jdwp.event.filters.InstanceOnlyFilter;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.id.ObjectId;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests the functionality of the InstanceOnlyFilter of JDWP
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class TestOfInstanceOnlyFilter
+ implements Testlet
+{
+ /**
+ * Tests the <code>InstanceOnlyFilter</code> constructor
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testConstructor(TestHarness harness)
+ {
+ harness.checkPoint("Constructor");
+ VMIdManager idm = VMIdManager.getDefault();
+
+ Integer testInt = new Integer(6);
+
+ ObjectId testOID = idm.getObjectId(testInt);
+
+ try
+ {
+ InstanceOnlyFilter testIOF = new InstanceOnlyFilter(testOID);
+ harness.check(true, "Constructor successful");
+ }
+ catch (InvalidObjectException ex)
+ {
+ harness.check(false, "constructor failed for valid ObjectId");
+ }
+
+ //test null since it is valid
+ try
+ {
+ InstanceOnlyFilter testIOF = new InstanceOnlyFilter(null);
+ harness.check(true, "Constructor successful");
+ }
+ catch (InvalidObjectException ex)
+ {
+ harness.check(false, "constructor failed incorrectly for null");
+ }
+
+ }
+
+ /**
+ * Tests the <code>InstanceOnlyFilter</code> matches method
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testMatches(TestHarness harness)
+ {
+ harness.checkPoint("matches method");
+
+ VMIdManager idm = VMIdManager.getDefault();
+
+ Integer testInt = new Integer(6);
+
+ ObjectId testOID = idm.getObjectId(testInt);
+
+ try
+ {
+ InstanceOnlyFilter testIOF = new InstanceOnlyFilter(testOID);
+ BreakpointEvent testEvent = new BreakpointEvent(Thread.currentThread(),
+ null, testInt);
+ harness.check(testIOF.matches(testEvent), "testing matching Instance "
+ + "match");
+
+ testEvent = new BreakpointEvent(Thread.currentThread(), null, null);
+
+ harness.check(! testIOF.matches(testEvent),
+ "testing non-matching Instance");
+ }
+ catch (InvalidObjectException ex)
+ {
+ harness.check(false, "constructor failed for valid ObjectId");
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ testConstructor(harness);
+ testMatches(harness);
+ }
+}
Index: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfThreadOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfThreadOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfThreadOnlyFilter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/event/filters/TestOfThreadOnlyFilter.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,118 @@
+/* TestOfThreadOnlyFilter.java -- test of the ThreadOnlyFilter
+ Copyright (C) 2006
+
+ Written by Kyle Galloway (kgallowa@redhat.com)
+
+ This file is part of Mauve.
+
+ Mauve is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Mauve is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Mauve; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ */
+
+// Tags: GNU-JDWP
+
+
+package gnu.testlet.gnu.classpath.jdwp.event.filters;
+
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.event.ThreadStartEvent;
+import gnu.classpath.jdwp.event.filters.ThreadOnlyFilter;
+import gnu.classpath.jdwp.exception.InvalidThreadException;
+import gnu.classpath.jdwp.id.ThreadId;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class TestOfThreadOnlyFilter
+ implements Testlet
+{
+ /**
+ * Tests the <code>ThreadOnlyFilter</code> constructor
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testConstructor(TestHarness harness)
+ {
+ harness.checkPoint("Constructor");
+ VMIdManager idm = VMIdManager.getDefault();
+
+ Thread thread = new Thread();
+
+ ThreadId tid = (ThreadId) idm.getObjectId(thread);
+
+ try
+ {
+ ThreadOnlyFilter testTOF = new ThreadOnlyFilter(tid);
+ harness.check(true, "Constructor successful");
+ }
+ catch (InvalidThreadException ex)
+ {
+ harness.check(false, "constructor failed for valid ObjectId");
+ }
+
+ // test null since it is invalid
+ try
+ {
+ ThreadOnlyFilter testTOF = new ThreadOnlyFilter(null);
+ harness.check(false, "Constructor successful for null");
+ }
+ catch (InvalidThreadException ex)
+ {
+ harness.check(true, "constructor failed correctly for null");
+ }
+
+ }
+
+ /**
+ * Tests the <code>InstanceOnlyFilter</code> matches method
+ *
+ * @param harness the TestHarness to use
+ */
+ public void testMatches(TestHarness harness)
+ {
+ harness.checkPoint("matches method");
+
+ VMIdManager idm = VMIdManager.getDefault();
+
+ Thread thread = new Thread();
+
+ ThreadId tid = (ThreadId) idm.getObjectId(Thread.currentThread());
+
+ ThreadStartEvent testTSE = new ThreadStartEvent(Thread.currentThread());
+
+ try
+ {
+ ThreadOnlyFilter testTOF = new ThreadOnlyFilter(tid);
+
+ harness.check(testTOF.matches(testTSE), "Matches correct thread");
+
+ testTSE = new ThreadStartEvent(thread);
+
+ harness.check(! testTOF.matches(testTSE),
+ "Doesn't match incorrect thread");
+ }
+ catch (InvalidThreadException ex)
+ {
+ harness.check(false, "constructor failed for valid ObjectId");
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ testConstructor(harness);
+ testMatches(harness);
+ }
+}
^ permalink raw reply [flat|nested] 9+ messages in thread