public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* RFC: JDWP filter tests
@ 2006-06-09 14:55 Kyle Galloway
  2006-06-09 15:05 ` Kyle Galloway
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Galloway @ 2006-06-09 14:55 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 580 bytes --]

Here are 5 tests for JDWP filters.

ChangeLog:

2006-06-05    Kyle Galloway <kgallowa@redhat.com>

    * 
gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java:
    New file.
    * 
gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java: 

    New file.
    * 
gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java: 

    New file.
    * gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java:
    New file.
    * 
gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java:
    New file.

[-- Attachment #2: jdwp-filter-testspatch --]
[-- Type: text/plain, Size: 19784 bytes --]

Index: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,95 @@
+/* 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.
+
+ */
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.ClassExcludeFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+public class TestOfClassExcludeFilter
+    extends TestOfClassMatchFilter
+    implements Testlet
+{
+  /**
+   * Tests the <code>ClassExcludeFilter</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" };
+
+    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 valid 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, "String: " + validStrings[i] + " threw " + ex);
+          }
+      }
+    // check to see that the invalid 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, "String: " + validStrings[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/events/filters/TestOfClassMatchFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,146 @@
+/* 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: JDK1.1
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.ClassMatchFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+/**
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+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 valid 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, "String: " + validStrings[i] + " threw " + ex);
+          }
+      }
+    // check to see that the invalid 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, "String: " + validStrings[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/events/filters/TestOfClassOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,105 @@
+/* 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: JDK1.4
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.ClassOnlyFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+
+import java.lang.ref.SoftReference;
+
+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");
+    for (int i = 0; i < 3; i++)
+      {
+        ReferenceTypeId testId = new ClassReferenceTypeId();
+        SoftReference testSR = new SoftReference(Integer.class);
+        testId.setReference(testSR);
+
+        try
+          {
+            ClassOnlyFilter testCOF = new ClassOnlyFilter(testId);
+          }
+        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");
+    ReferenceTypeId testId = new ClassReferenceTypeId();
+    SoftReference testSR = new SoftReference(Integer.class);
+    testId.setReference(testSR);
+    try
+      {
+        ClassOnlyFilter testCOF = new ClassOnlyFilter(testId);
+        ClassPrepareEvent testEvent = new ClassPrepareEvent(
+                                                            Thread.currentThread(),
+                                                            Integer.class, 0);
+
+        harness.check(testCOF.matches(testEvent), "matches method");
+      }
+    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/events/filters/TestOfCountFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,120 @@
+/*/* 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: JDK1.1
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.CountFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.exception.InvalidCountException;
+
+/**
+ * @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)
+  {
+    boolean matched = false;
+    harness.checkPoint("matches method");
+    
+    try
+    {
+      CountFilter testCF = new CountFilter(COUNT);
+      for (int i = 0; i < COUNT; i++)
+        {
+          matched = testCF.matches(new ClassPrepareEvent(Thread.currentThread(),
+                                                         Integer.class, 0));
+          if(i < COUNT-1)
+            harness.check(!matched, "Matches returns false for < count");
+          else
+            harness.check(matched, "Matches returns true after count # of"
+                          + "events");
+        }
+    }
+    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/events/filters/TestOfInstanceOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,105 @@
+/* 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: JDK 1.4
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.event.filters.InstanceOnlyFilter;
+import gnu.classpath.jdwp.event.BreakpointEvent;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+
+/**
+ * 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");
+      }
+
+  }
+
+  /**
+   * 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 Instance match");
+      }
+    catch (InvalidObjectException ex)
+      {
+        harness.check(false, "constructor failed for valid ObjectId");
+      }
+  }
+
+  public void test(TestHarness harness)
+  {
+    testConstructor(harness);
+    testMatches(harness);
+  }
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: JDWP filter tests
  2006-06-09 14:55 RFC: JDWP filter tests Kyle Galloway
@ 2006-06-09 15:05 ` Kyle Galloway
  2006-06-09 21:02   ` Keith Seitz
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Galloway @ 2006-06-09 15:05 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

Kyle Galloway wrote:
> Here are 5 tests for JDWP filters.
>
> ChangeLog:
>
> 2006-06-05    Kyle Galloway <kgallowa@redhat.com>
>
>    * 
> gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java: 
>
>    New file.
>    * 
> gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java: 
>
>    New file.
>    * 
> gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java: 
>
>    New file.
>    * 
> gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java:
>    New file.
>    * 
> gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java:
>    New file.
Reposting with Tags properly set, sorry about that...

-Kyle

[-- Attachment #2: jdwp-filter-tests.patch --]
[-- Type: text/x-patch, Size: 19804 bytes --]

Index: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,97 @@
+/* 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: JDK 1.4
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.ClassExcludeFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+public class TestOfClassExcludeFilter
+    extends TestOfClassMatchFilter
+    implements Testlet
+{
+  /**
+   * Tests the <code>ClassExcludeFilter</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" };
+
+    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 valid 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, "String: " + validStrings[i] + " threw " + ex);
+          }
+      }
+    // check to see that the invalid 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, "String: " + validStrings[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/events/filters/TestOfClassMatchFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassMatchFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,146 @@
+/* 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: JDK1.4
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.ClassMatchFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.exception.InvalidStringException;
+
+/**
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+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 valid 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, "String: " + validStrings[i] + " threw " + ex);
+          }
+      }
+    // check to see that the invalid 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, "String: " + validStrings[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/events/filters/TestOfClassOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,105 @@
+/* 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: JDK1.4
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.ClassOnlyFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
+import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+
+import java.lang.ref.SoftReference;
+
+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");
+    for (int i = 0; i < 3; i++)
+      {
+        ReferenceTypeId testId = new ClassReferenceTypeId();
+        SoftReference testSR = new SoftReference(Integer.class);
+        testId.setReference(testSR);
+
+        try
+          {
+            ClassOnlyFilter testCOF = new ClassOnlyFilter(testId);
+          }
+        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");
+    ReferenceTypeId testId = new ClassReferenceTypeId();
+    SoftReference testSR = new SoftReference(Integer.class);
+    testId.setReference(testSR);
+    try
+      {
+        ClassOnlyFilter testCOF = new ClassOnlyFilter(testId);
+        ClassPrepareEvent testEvent = new ClassPrepareEvent(
+                                                            Thread.currentThread(),
+                                                            Integer.class, 0);
+
+        harness.check(testCOF.matches(testEvent), "matches method");
+      }
+    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/events/filters/TestOfCountFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,120 @@
+/*/* 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: JDK1.4
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.event.filters.CountFilter;
+import gnu.classpath.jdwp.event.ClassPrepareEvent;
+import gnu.classpath.jdwp.exception.InvalidCountException;
+
+/**
+ * @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)
+  {
+    boolean matched = false;
+    harness.checkPoint("matches method");
+    
+    try
+    {
+      CountFilter testCF = new CountFilter(COUNT);
+      for (int i = 0; i < COUNT; i++)
+        {
+          matched = testCF.matches(new ClassPrepareEvent(Thread.currentThread(),
+                                                         Integer.class, 0));
+          if(i < COUNT-1)
+            harness.check(!matched, "Matches returns false for < count");
+          else
+            harness.check(matched, "Matches returns true after count # of"
+                          + "events");
+        }
+    }
+    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/events/filters/TestOfInstanceOnlyFilter.java
===================================================================
RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java
diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,105 @@
+/* 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: JDK 1.4
+
+
+package gnu.testlet.gnu.classpath.jdwp.events.filters;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.event.filters.InstanceOnlyFilter;
+import gnu.classpath.jdwp.event.BreakpointEvent;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+
+/**
+ * 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");
+      }
+
+  }
+
+  /**
+   * 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 Instance match");
+      }
+    catch (InvalidObjectException ex)
+      {
+        harness.check(false, "constructor failed for valid ObjectId");
+      }
+  }
+
+  public void test(TestHarness harness)
+  {
+    testConstructor(harness);
+    testMatches(harness);
+  }
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: JDWP filter tests
  2006-06-09 15:05 ` Kyle Galloway
@ 2006-06-09 21:02   ` Keith Seitz
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2006-06-09 21:02 UTC (permalink / raw)
  To: Kyle Galloway; +Cc: mauve-patches

Kyle Galloway wrote:

> Index: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
> ===================================================================
> RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
> diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassExcludeFilter.java	1 Jan 1970 00:00:00 -0000
> @@ -0,0 +1,97 @@

I only have one comment on this (and it applies to the others, too, 
probably): Are there any inputs to ClassMatchFilter which are simply 
illegal?

For example, the spec describes the pattern as "Disallowed class 
pattern. Matches are limited to exact matches of the given class pattern 
and matches of patterns that begin or end with '*'; for example, "*.Foo" 
or "java.*"." One of the errors that is listed at the end of the 
description of Event.Set is "INVALID_STRING".

Perhaps that is bit overboard, though. I don't really know.

You can't really do much with this for many filters, e.g., 
ClassOnlyFilter, because of they require valid IDs and the like, and 
they are checked by PacketProcessor and *CommandSet before creating the 
filter.

Of course, this begs the question: Should this check be done by the 
filter or the command set processor that is creating the filter? Alas, 
that's a different conversation for a different list. [The most prudent 
answer to this is that we should always test for invalid input. If that 
check is done in the code in the filter, then it should be tested in the 
filter. If the check is done somewhere else, it should be tested there, 
too. But regardless of where the check and test are located, they should 
both be done.]

> Index: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java
> ===================================================================
> RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java
> diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfClassOnlyFilter.java	1 Jan 1970 00:00:00 -0000
> @@ -0,0 +1,105 @@
[snip]
> +  public void testConstructor(TestHarness harness)
> +  {
> +    harness.checkPoint("Constructor");
> +    for (int i = 0; i < 3; i++)
> +      {
> +        ReferenceTypeId testId = new ClassReferenceTypeId();
> +        SoftReference testSR = new SoftReference(Integer.class);
> +        testId.setReference(testSR);
> +
> +        try
> +          {
> +            ClassOnlyFilter testCOF = new ClassOnlyFilter(testId);
> +          }
> +        catch (InvalidClassException ex)
> +          {
> +            harness.check(false, "Constructor failed with exception" + ex);
> +          }
> +      }
> +  }

I think I mentioned this before, but you could simply use VMIdManager to 
get Object and ReferenceType IDs. No big deal, though, if you would 
rather avoid that.

What about testing the case where the constructor *should* fail, i.e., 
don't set the reference for the ID. [aside from the whole "should it be 
checked here somewhere else" thing again]

> Index: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java
> ===================================================================
> RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java
> diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfCountFilter.java	1 Jan 1970 00:00:00 -0000
[snip]
> +    try
> +    {
> +      CountFilter testCF = new CountFilter(COUNT);
> +      for (int i = 0; i < COUNT; i++)
> +        {
> +          matched = testCF.matches(new ClassPrepareEvent(Thread.currentThread(),
> +                                                         Integer.class, 0));
> +          if(i < COUNT-1)
> +            harness.check(!matched, "Matches returns false for < count");
> +          else
> +            harness.check(matched, "Matches returns true after count # of"
> +                          + "events");
> +        }
> +    }
> +    catch(InvalidCountException ex)
> +    {
> +      harness.check(false, "Constructor failed for valid count");
> +    }
> +  }

I suggest looping over something like "COUNT + 1" to check what happens 
when the count has been exceeded. It should *only* match once. [Missing 
a space in the string "Matches returns true after count # ofevents".]

You could recycle the event instead of creating a new one every time. 
Probably doesn't matter, but it would be trivial enough in this case to 
keep that overhead out of the testsuite.

> Index: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java
> ===================================================================
> RCS file: gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java
> diff -N gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ gnu/testlet/gnu/classpath/jdwp/events/filters/TestOfInstanceOnlyFilter.java	1 Jan 1970 00:00:00 -0000
[snip]
> +    try
> +      {
> +        InstanceOnlyFilter testIOF = new InstanceOnlyFilter(testOID);
> +        harness.check(true, "Constructor successful");
> +      }
> +    catch (InvalidObjectException ex)
> +      {
> +        harness.check(false, "constructor failed for valid ObjectId");
> +      }
> +
> +  }

Another good place to try passing something invalid to the constructor 
and test whether it fails. Also, for this one, "null" should be tested 
as a constructor argument, since it is valid.

> +    try
> +      {
> +        InstanceOnlyFilter testIOF = new InstanceOnlyFilter(testOID);
> +        BreakpointEvent testEvent = new BreakpointEvent(Thread.currentThread(),
> +                                                        null, testInt);
> +        harness.check(testIOF.matches(testEvent), "testing Instance match");
> +      }
> +    catch (InvalidObjectException ex)
> +      {
> +        harness.check(false, "constructor failed for valid ObjectId");
> +      }
> +  }

Missing a test where this should fail.

Hmm. What about things to test object equality? Maybe add a test that 
checks against a clone of the object? I think for InstanceOnly, we need 
obj1 == obj2, not obj1.equals(obj2).

Keith

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-09 21:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-09 14:55 RFC: JDWP filter tests Kyle Galloway
2006-06-09 15:05 ` Kyle Galloway
2006-06-09 21:02   ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).