1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17 package org.apache.asn1.ber.digester;
18
19
20 import junit.framework.*;
21 import org.apache.asn1.ber.digester.TagNode;
22
23
24 /**
25 * Unit test for the TagNode class.
26 *
27 * @author <a href="mailto:dev@directory.apache.org">
28 * Apache Directory Project</a>
29 * @version $Rev: 157644 $
30 */
31 public class TagNodeTest extends TestCase
32 {
33 TagNode n0 = null ;
34 TagNode n1 = null ;
35 TagNode n2 = null ;
36
37
38 public void setUp() throws Exception
39 {
40 super.setUp() ;
41
42 n0 = new TagNode( new Integer( 0 ) ) ;
43 n1 = new TagNode( new Integer( 1 ) ) ;
44 n2 = new TagNode( new Integer( 2 ) ) ;
45 }
46
47 /**
48 * Tests the TagNode.getDepth() method.
49 */
50 public void testDepth()
51 {
52 assertEquals( 0, n0.getDepth() ) ;
53 n0.addNode( n1 ) ;
54 assertEquals( 0, n0.getDepth() ) ;
55 assertEquals( 1, n1.getDepth() ) ;
56 n1.addNode( n2 ) ;
57 assertEquals( 0, n0.getDepth() ) ;
58 assertEquals( 1, n1.getDepth() ) ;
59 assertEquals( 2, n2.getDepth() ) ;
60 }
61
62
63 /**
64 * Tests the TagNode.hasChildren() method.
65 */
66 public void testHasChildren()
67 {
68 assertFalse( n0.hasChild( new Integer( 1 ) ) ) ;
69 n0.addNode( n1 ) ;
70 assertTrue( n0.hasChild( new Integer( 1 ) ) ) ;
71 }
72 }