directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9822 - incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester
Date Tue, 30 Mar 2004 07:40:07 GMT
Author: akarasulu
Date: Mon Mar 29 23:40:06 2004
New Revision: 9822

Added:
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagTreeTest.java
Log:
oops forgot the test cases

Added: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagTreeTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/digester/TagTreeTest.java
Mon Mar 29 23:40:06 2004
@@ -0,0 +1,89 @@
+/*
+ *   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 java.util.List;
+
+import junit.framework.TestCase ;
+
+
+/**
+ * Tests the TagTree class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class TagTreeTest extends TestCase
+{
+    /**
+     * Constructor for TagTreeTest.
+     * @param name the name of the test case
+     */
+    public TagTreeTest( String name )
+    {
+        super( name ) ;
+    }
+
+    
+    /**
+     * Tests the addRule method of the tree.
+     */
+    public void testAddRule()
+    {
+        TagTree tree = new TagTree() ;
+        int[] pattern = {1,2,3} ;
+        tree.addRule( pattern, new MockRule() ) ;
+        
+        assertNull( tree.getNode(4) ) ;
+        
+        TagNode node = tree.getNode( 1 ) ;
+        assertNotNull( node ) ;
+        node = node.getChild( new Integer(2) ) ;
+        assertNotNull( node ) ;
+        node = node.getChild( new Integer(3) ) ;
+        assertNotNull( node ) ;
+        node = node.getChild( new Integer(4) ) ;
+        assertNull( node ) ;
+    }
+
+    
+    public void testMatch()
+    {
+        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 ) ;
+        assertEquals( rule0, ( (List) tree.match( pattern0 ) ).get(0) ) ;
+        assertEquals( rule1, ( (List) tree.match( pattern1 ) ).get(0) ) ;
+        assertEquals( rule2, ( (List) tree.match( pattern2 ) ).get(0) ) ;
+
+        assertNotSame( rule0, ( (List) tree.match( pattern1 ) ).get(0) ) ;
+        assertNotSame( rule1, ( (List) tree.match( pattern2 ) ).get(0) ) ;
+        assertNotSame( rule2, ( (List) tree.match( pattern0 ) ).get(0) ) ;
+    }
+
+
+    class MockRule extends AbstractRule { }
+}

Mime
View raw message