directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9863 - in incubator/directory/snickers/trunk/ber/src: java/org/apache/snickers/ber java/org/apache/snickers/ber/digester test/org/apache/snickers/ber test/org/apache/snickers/ber/digester
Date Sun, 04 Apr 2004 18:14:08 GMT
Author: akarasulu
Date: Sun Apr  4 11:14:06 2004
New Revision: 9863

Added:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/IntStack.java
      - copied unchanged from rev 9848, incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/IntStack.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/AbstractRuleTest.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/BERDigesterTest.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/IntStackTest.java
      - copied unchanged from rev 9848, incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/IntStackTest.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/RulesBaseTest.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagNodeTest.java
Removed:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/IntStack.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/IntStackTest.java
Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/AbstractRule.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rule.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rules.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/RulesBase.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagTreeTest.java
Log:
o moved IntStack and test into their respective Digester directories
o added a bunch of unit tests
o general cleanup in process


Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/AbstractRule.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/AbstractRule.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/AbstractRule.java
Sun Apr  4 11:14:06 2004
@@ -35,7 +35,7 @@
 
     
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rule#getDecoder()
+     * @see org.apache.snickers.ber.rulesBase.Rule#getDecoder()
      */
     public BERDigester getDecoder()
     {
@@ -44,8 +44,8 @@
     
     
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rule#setDigester(
-     * org.apache.snickers.ber.digester.BERDigester)
+     * @see org.apache.snickers.ber.rulesBase.Rule#setDigester(
+     * org.apache.snickers.ber.rulesBase.BERDigester)
      */
     public void setDigester( BERDigester digester )
     {

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/BERDigester.java
Sun Apr  4 11:14:06 2004
@@ -36,8 +36,8 @@
 
 
 /**
- * A special BER TLV event digester.  This class was inspired by the XML 
- * digester in Jakarta Commons.
+ * A special BER TLV event rulesBase.  This class was inspired by the XML
+ * rulesBase in Jakarta Commons.
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">
  * Apache Directory Project</a>
@@ -45,13 +45,13 @@
  */
 public class BERDigester implements BERDecoderCallback
 {
-    /** the underlying decoder used by this digester */
+    /** the underlying decoder used by this rulesBase */
     private BERDecoder decoder ;
     /** the object stack where rules push and pop ASN.1 POJO stubs */
     private ArrayStack objectStack ;
     /** the tag stack used to store the nesting pattern */
     private IntStack tagStack ;
-    /** the rules base used by this digester */
+    /** the rules base used by this rulesBase */
     private Rules rules ;
     /** the currently matched rules */
     private List matched ;
@@ -75,11 +75,13 @@
     
 
     /**
-     * Creates a BER TLV event digester.
+     * Creates a BER TLV event rulesBase.
      */
     public BERDigester()
     {
         this.rules = new RulesBase() ;
+        this.rules.setDigester( this ) ;
+        this.tagStack = new IntStack() ;
         this.objectStack = new ArrayStack() ;
         this.decoder = new BERDecoder() ;
         this.decoder.setCallback( this ) ;
@@ -267,7 +269,7 @@
      * created after decoding.
      * 
      * @return the root object that has been created after decoding or null if 
-     * the digester has not decoded any PDUs yet.
+     * the rulesBase has not decoded any PDUs yet.
      */
     public Object getRoot()
     {
@@ -279,7 +281,7 @@
      * Set the Rules implementation object containing our rules collection 
      * and associated matching policy.
      * 
-     * @param rules the rules to add to this digester
+     * @param rules the rules to add to this rulesBase
      */
     public void setRules( Rules rules )
     {
@@ -370,7 +372,7 @@
 
 
     /*
-     Methods of interest from the original digester class:     
+     Methods of interest from the original rulesBase class:
 
  java.lang.String getMatch() 
           Return the current rule match path 
@@ -524,7 +526,7 @@
 
         if ( tagStack.empty() )
         {
-            // Fire "finish" events for all defined rules
+            // Fire "finish" events for all defined rules minues those seen
             Iterator rules = getRules().rules().iterator() ;
         
             while ( rules.hasNext() ) 

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rule.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rule.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rule.java
Sun Apr  4 11:14:06 2004
@@ -35,7 +35,7 @@
      * Get the <code>BERDigester</code> with which this <code>Rule</code>
has
      * been associated.
      * 
-     * @return the associated digester
+     * @return the associated rulesBase
      */
     BERDigester getDecoder() ;
     
@@ -43,7 +43,7 @@
      * Set the <code>BERDigester</code> with which this <code>Rule</code>
will
      * be associated.
      * 
-     * @param digester the digester to associate this rule with
+     * @param digester the rulesBase to associate this rule with
      */
     void setDigester( BERDigester digester ) ;
     

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rules.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rules.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/Rules.java
Sun Apr  4 11:14:06 2004
@@ -27,7 +27,7 @@
  * Public interface defining a collection of Rule instances (and corresponding
  * matching patterns) plus an implementation of a matching policy that selects
  * the rules that match a particular pattern of nested elements discovered
- * during parsing.  The interface has been inspired by the digester equivalent.
+ * during parsing.  The interface has been inspired by the rulesBase equivalent.
  * 
  * @author <a href="mailto:directory-dev@incubator.apache.org">
  * Apache Directory Project</a>

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/RulesBase.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/RulesBase.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/RulesBase.java
Sun Apr  4 11:14:06 2004
@@ -49,8 +49,8 @@
     
     
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rules#setDigester(
-     * org.apache.snickers.ber.digester.BERDigester)
+     * @see org.apache.snickers.ber.rulesBase.Rules#setDigester(
+     * org.apache.snickers.ber.rulesBase.BERDigester)
      */
     public void setDigester( BERDigester digester )
     {
@@ -59,7 +59,7 @@
     
     
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rules#getDigester()
+     * @see org.apache.snickers.ber.rulesBase.Rules#getDigester()
      */
     public BERDigester getDigester()
     {
@@ -68,8 +68,8 @@
     
     
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rules#add(int[], 
-     * org.apache.snickers.ber.digester.Rule)
+     * @see org.apache.snickers.ber.rulesBase.Rules#add(int[],
+     * org.apache.snickers.ber.rulesBase.Rule)
      */
     public void add( int[] pattern, Rule rule )
     {
@@ -79,7 +79,7 @@
 
     
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rules#clear()
+     * @see org.apache.snickers.ber.rulesBase.Rules#clear()
      */
     public void clear()
     {
@@ -89,7 +89,7 @@
     
 
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rules#match(int[])
+     * @see org.apache.snickers.ber.rulesBase.Rules#match(int[])
      */
     public List match( int[] pattern )
     {
@@ -98,7 +98,7 @@
     
 
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rules#match(int[])
+     * @see org.apache.snickers.ber.rulesBase.Rules#match(int[])
      */
     public List match( IntStack pattern )
     {
@@ -107,7 +107,7 @@
     
 
     /* (non-Javadoc)
-     * @see org.apache.snickers.ber.digester.Rules#rules()
+     * @see org.apache.snickers.ber.rulesBase.Rules#rules()
      */
     public List rules()
     {

Added: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/AbstractRuleTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/AbstractRuleTest.java
Sun Apr  4 11:14:06 2004
@@ -0,0 +1,43 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber.digester;
+
+import junit.framework.*;
+import org.apache.snickers.ber.TypeClass;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * Tests the AbstractRule which does not have much but is
+ * really used to shut clover up.
+ */
+public class AbstractRuleTest extends TestCase
+{
+    public void testAll()
+    {
+        AbstractRule rule = new MockRule() ;
+        rule.getDecoder() ;
+        rule.setDigester( null ) ;
+        rule.tag( 0, true, TypeClass.APPLICATION ) ;
+        rule.length( 3 ) ;
+        rule.value( ByteBuffer.allocate( 3 ) ) ;
+        rule.finish() ;
+    }
+
+    class MockRule extends AbstractRule {}
+}
\ No newline at end of file

Added: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/BERDigesterTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/BERDigesterTest.java
Sun Apr  4 11:14:06 2004
@@ -0,0 +1,65 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber.digester ;
+
+
+import junit.framework.* ;
+
+
+/**
+ * A test case for the BERDigester.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BERDigesterTest extends TestCase
+{
+    BERDigester digester ;
+
+
+    /**
+     * Sets up the decoder rulesBase system.
+     *
+     * @throws Exception
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp();
+
+        digester = new BERDigester() ;
+    }
+
+
+    /**
+     * Clears and nulls out the rulesBase.
+     *
+     * @throws Exception
+     */
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+
+        digester.clear() ;
+        digester = null ;
+    }
+
+
+    public void testTagStack()
+    {
+        
+    }
+}
\ No newline at end of file

Added: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/RulesBaseTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/RulesBaseTest.java
Sun Apr  4 11:14:06 2004
@@ -0,0 +1,175 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber.digester ;
+
+
+import junit.framework.* ;
+
+import java.util.List;
+
+import org.apache.snickers.ber.IntStack;
+
+
+/**
+ * A test case for the RulesBase.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class RulesBaseTest extends TestCase
+{
+    int[] p0 = { 1, 2, 3 } ;
+    IntStack s0 = new IntStack( p0 ) ;
+    int[] p1 = { 1, 6, 7, 8 } ;
+    IntStack s1 = new IntStack( p1 ) ;
+    int[] p2 = { 4, 5, 6 } ;
+    IntStack s2 = new IntStack( p2 ) ;
+    MockRule r0 = new MockRule() ;
+    MockRule r1 = new MockRule() ;
+    MockRule r2 = new MockRule() ;
+    RulesBase rulesBase ;
+
+
+    /**
+     * Sets up the decoder rulesBase system.
+     *
+     * @throws Exception
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp() ;
+
+        rulesBase = new RulesBase() ;
+    }
+
+
+    /**
+     * Clears and nulls out the rulesBase.
+     *
+     * @throws Exception
+     */
+    public void tearDown() throws Exception
+    {
+        super.tearDown() ;
+
+        rulesBase.clear() ;
+        rulesBase = null ;
+    }
+
+
+    /**
+     * Tests the RulesBase.add(int[],Rule) method.
+     */
+    public void testAdd()
+    {
+
+        assertTrue( "Should be empty on creation", rulesBase.rules().isEmpty() ) ;
+
+        rulesBase.add( p0, r0 ) ;
+        assertFalse( rulesBase.rules().isEmpty() ) ;
+        assertEquals( "Should have 1 rule  after 1st add", 1, rulesBase.rules().size() )
;
+        assertSame( "1st rule should be r0", rulesBase.rules().get( 0 ), r0 ) ;
+
+        rulesBase.add( p1, r1 ) ;
+        assertFalse( rulesBase.rules().isEmpty() ) ;
+        assertEquals( "Should have 2 rules after 2nd add", 2, rulesBase.rules().size() )
;
+        assertSame( "2nd rule should be r1", rulesBase.rules().get( 1 ), r1 ) ;
+
+        rulesBase.add( p2, r2 ) ;
+        assertFalse( rulesBase.rules().isEmpty() ) ;
+        assertEquals( "Should have 3 rules after 3rd add", 3, rulesBase.rules().size() )
;
+        assertSame( "3rd rule should be r2", rulesBase.rules().get( 2 ), r2 ) ;
+    }
+
+
+    /**
+     * Tests the RulesBase.match(int[]) method.
+     */
+    public void testMatchint()
+    {
+        List matched = null ;
+
+        matched = rulesBase.match( p0 ) ;
+        assertTrue( "match on p0 should not return any rules", matched.isEmpty() ) ;
+        rulesBase.add( p0, r0 ) ;
+        matched = rulesBase.match( p0 ) ;
+        assertSame( "match on p0 should return r0 only", matched.get( 0 ), r0 ) ;
+        assertEquals( "match on p0 should only match for one rule", 1, matched.size() ) ;
+
+        matched = rulesBase.match( p1 ) ;
+        assertTrue( "match on p1 should not return any rules", matched.isEmpty() ) ;
+        rulesBase.add( p1, r1 ) ;
+        matched = rulesBase.match( p1 ) ;
+        assertSame( "match on p1 should return r1 only", matched.get( 0 ), r1 ) ;
+        assertEquals( "match on p1 should only match for one rule", 1, matched.size() ) ;
+
+        matched = rulesBase.match( p2 ) ;
+        assertTrue( "match on p2 should not return any rules", matched.isEmpty() ) ;
+        rulesBase.add( p2, r2 ) ;
+        matched = rulesBase.match( p2 ) ;
+        assertSame( "match on p2 should return r2 only", matched.get( 0 ), r2 ) ;
+        assertEquals( "match on p2 should only match for one rule", 1, matched.size() ) ;
+    }
+
+
+    /**
+     * Tests the RulesBase.match(int[]) method.
+     */
+    public void testMatchIntStack()
+    {
+        List matched = null ;
+
+        matched = rulesBase.match( s0 ) ;
+        assertTrue( "match on s0 should not return any rules", matched.isEmpty() ) ;
+        rulesBase.add( p0, r0 ) ;
+        matched = rulesBase.match( s0 ) ;
+        assertSame( "match on s0 should return r0 only", matched.get( 0 ), r0 ) ;
+        assertEquals( "match on s0 should only match for one rule", 1, matched.size() ) ;
+
+        matched = rulesBase.match( s1 ) ;
+        assertTrue( "match on s1 should not return any rules", matched.isEmpty() ) ;
+        rulesBase.add( p1, r1 ) ;
+        matched = rulesBase.match( s1 ) ;
+        assertSame( "match on s1 should return r1 only", matched.get( 0 ), r1 ) ;
+        assertEquals( "match on s1 should only match for one rule", 1, matched.size() ) ;
+
+        matched = rulesBase.match( s2 ) ;
+        assertTrue( "match on s2 should not return any rules", matched.isEmpty() ) ;
+        rulesBase.add( p2, r2 ) ;
+        matched = rulesBase.match( s2 ) ;
+        assertSame( "match on s2 should return r2 only", matched.get( 0 ), r2 ) ;
+        assertEquals( "match on s2 should only match for one rule", 1, matched.size() ) ;
+    }
+
+
+    public void testGetDigester()
+    {
+        assertNull( rulesBase.getDigester() ) ;
+    }
+
+
+    public void testSetDigester()
+    {
+        assertNull( rulesBase.getDigester() ) ;
+        BERDigester digester = new BERDigester() ;
+        rulesBase.setDigester( digester ) ;
+        assertSame( digester, rulesBase.getDigester() ) ;
+    }
+
+
+    class MockRule extends AbstractRule {}
+}
\ No newline at end of file

Added: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagNodeTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagNodeTest.java
Sun Apr  4 11:14:06 2004
@@ -0,0 +1,71 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ber.digester;
+
+
+import junit.framework.*;
+
+
+/**
+ * Unit test for the TagNode class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TagNodeTest extends TestCase
+{
+    TagNode n0 = null ;
+    TagNode n1 = null ;
+    TagNode n2 = null ;
+
+
+    public void setUp() throws Exception
+    {
+        super.setUp() ;
+
+        n0 = new TagNode( new Integer( 0 ) ) ;
+        n1 = new TagNode( new Integer( 1 ) ) ;
+        n2 = new TagNode( new Integer( 2 ) ) ;
+    }
+
+    /**
+     * Tests the TagNode.getDepth() method.
+     */
+    public void testDepth()
+    {
+        assertEquals( 0, n0.getDepth() ) ;
+        n0.addNode( n1 ) ;
+        assertEquals( 0, n0.getDepth() ) ;
+        assertEquals( 1, n1.getDepth() ) ;
+        n1.addNode( n2 ) ;
+        assertEquals( 0, n0.getDepth() ) ;
+        assertEquals( 1, n1.getDepth() ) ;
+        assertEquals( 2, n2.getDepth() ) ;
+    }
+
+
+    /**
+     * Tests the TagNode.hasChildren() method.
+     */
+    public void testHasChildren()
+    {
+        assertFalse( n0.hasChild( new Integer( 1 ) ) ) ;
+        n0.addNode( n1 ) ;
+        assertTrue( n0.hasChild( new Integer( 1 ) ) ) ;
+    }
+}
\ No newline at end of file

Modified: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagTreeTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagTreeTest.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagTreeTest.java
Sun Apr  4 11:14:06 2004
@@ -62,9 +62,15 @@
         assertNotNull( node ) ;
         node = node.getChild( new Integer(4) ) ;
         assertNull( node ) ;
+
+        int[] pat1 = {1,2,3} ;
+        tree.addRule( pattern, new MockRule() ) ;
     }
 
-    
+
+    /**
+     * Tests the TagTree.match(int[]) method.
+     */
     public void testMatchintArray()
     {
         TagTree tree = new TagTree() ;
@@ -84,9 +90,15 @@
         assertNotSame( rule0, ( (List) tree.match( pattern1 ) ).get(0) ) ;
         assertNotSame( rule1, ( (List) tree.match( pattern2 ) ).get(0) ) ;
         assertNotSame( rule2, ( (List) tree.match( pattern0 ) ).get(0) ) ;
+
+        int[] pattern3 = { 12 } ;
+        tree.match( pattern3 ) ;
     }
 
 
+    /**
+     * Tests the TagTree.match(IntStack) method.
+     */
     public void testMatchIntStack()
     {
         TagTree tree = new TagTree() ;
@@ -112,6 +124,27 @@
                 .get(0) ) ;
         assertNotSame( rule2, ( (List) tree.match( new IntStack( pattern0 ) ) )
                 .get(0) ) ;
+    }
+
+
+    /**
+     * Tests the TagTree.getNode(int[]) method.
+     */
+    public void testGetNodeintArray()
+    {
+        TagTree tree = new TagTree() ;
+        int[] pattern0 = {1,2,3} ;
+        int[] pattern1 = {4,2,7} ;
+        int[] pattern2 = {1,5,3} ;
+        Rule rule0 = new MockRule() ;
+        Rule rule1 = new MockRule() ;
+        Rule rule2 = new MockRule() ;
+        tree.addRule( pattern0, rule0 ) ;
+        tree.addRule( pattern1, rule1 ) ;
+        tree.addRule( pattern2, rule2 ) ;
+
+        int[] pattern3 = { 1, 23 } ;
+        assertNull( tree.getNode( pattern3 ) ) ;
     }
 
 

Mime
View raw message