Index: gnu/classpath/jdwp/event/filters/TestOfCountFilter.java =================================================================== RCS file: gnu/classpath/jdwp/event/filters/TestOfCountFilter.java diff -N gnu/classpath/jdwp/event/filters/TestOfCountFilter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ 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: JDK1.4 + + +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 CountFilter 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 ClountFilter 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 CountFilter 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 CountFilter class + * + * @param harness the TestHarness to use + */ + public void test(TestHarness harness) + { + testConstructor(harness); + testMatches(harness); + } + +}