KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > inspectors > metrics > callertrace > tests > TracedMethodLocComparatorTest


1 /*
2  * Created on Nov 28, 2003
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package org.hammurapi.inspectors.metrics.callertrace.tests;
8
9
10
11 import java.util.SortedMap JavaDoc;
12 import java.util.TreeMap JavaDoc;
13
14 import junit.framework.Test;
15 import junit.framework.TestCase;
16 import junit.framework.TestSuite;
17
18 import org.hammurapi.inspectors.metrics.callertrace.MethodWrapper;
19 import org.hammurapi.inspectors.metrics.callertrace.MethodWrapperDeclaration;
20 import org.hammurapi.inspectors.metrics.callertrace.TracedMethodLocComparator;
21
22 /**
23  * @author mucbj0
24  *
25  * To change the template for this generated type comment go to
26  * Window>Preferences>Java>Code Generation>Code and Comments
27  */

28 public class TracedMethodLocComparatorTest extends TestCase {
29
30
31     public static Test suite() {
32         return new TestSuite(TracedMethodLocComparatorTest.class);
33     }
34
35
36     public void testSorted1(){
37
38         SortedMap JavaDoc keyMethodList = new TreeMap JavaDoc(new TracedMethodLocComparator());
39         MethodWrapper m = new MethodWrapperDeclaration("", "MyClass");
40         m.setLine(1);
41         keyMethodList.put(m,m);
42         m = new MethodWrapperDeclaration("", "MyClass");
43                 m.setLine(20);
44                 keyMethodList.put(m,m);
45         m = new MethodWrapperDeclaration("", "MyClass");
46                 m.setLine(30);
47                 keyMethodList.put(m,m);
48         m = (MethodWrapperDeclaration)keyMethodList.firstKey();
49
50         assertTrue("keyMethodList.size() should be 3 but is " + keyMethodList.size(), keyMethodList.size() == 3);
51
52         m = (MethodWrapperDeclaration)keyMethodList.lastKey();
53         assertTrue("m.getLine() should be 30 but is " + m.getLine(), m.getLine() == 30);
54
55     }
56 }
57
58
Popular Tags