01: /*
02: * Created on Nov 4, 2003
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.hammurapi.inspectors.metrics.callertrace.tests;
08:
09: import junit.framework.Test;
10: import junit.framework.TestCase;
11: import junit.framework.TestSuite;
12:
13: import org.apache.log4j.Logger;
14: import org.apache.log4j.PropertyConfigurator;
15: import org.hammurapi.inspectors.metrics.callertrace.MethodWrapperDeclaration;
16: import org.hammurapi.inspectors.metrics.callertrace.Trace;
17: import org.hammurapi.inspectors.metrics.callertrace.TraceList;
18: import org.hammurapi.inspectors.metrics.callertrace.TraceTable;
19: import org.hammurapi.inspectors.metrics.callertrace.TracedMethod;
20:
21: /**
22: * @author mucbj0
23: *
24: * To change the template for this generated type comment go to
25: * Window>Preferences>Java>Code Generation>Code and Comments
26: */
27: public class TraceCaller extends TestCase {
28: private static Logger logger = Logger.getLogger(TraceCaller.class
29: .getName());
30:
31: protected void setUp() throws Exception {
32:
33: super .setUp();
34: PropertyConfigurator
35: .configure("D:/a/Jegustator/0.7.0/src/config/TestRunLogConfig.txt");
36: }
37:
38: public static Test suite() {
39: return new TestSuite(TraceCaller.class);
40: }
41:
42: public void testTraceCaller1() {
43:
44: TracedMethod tm1 = new TracedMethod(
45: new MethodWrapperDeclaration("executeEndPoint",
46: "MyClass"));
47:
48: TracedMethod tm2 = new TracedMethod(
49: new MethodWrapperDeclaration("execute2", "MyClass"));
50:
51: TracedMethod tm3 = new TracedMethod(
52: new MethodWrapperDeclaration("executeStartPoint",
53: "MyClass"));
54:
55: Trace t = new Trace();
56: t.add(tm1);
57: t.add(tm2);
58: t.add(tm3);
59:
60: TraceList tl = new TraceList("java.lang.String>>equals(String)");
61: tl.add(t);
62:
63: TraceTable tt = new TraceTable();
64: tt.put("java.lang.String>>equals(String)", tl);
65:
66: assertTrue(tt.size() == 1);
67: TraceList tlo = tt.get("java.lang.String>>equals(String)");
68: assertTrue(tlo.size() == 1);
69: Trace to = tlo.traceElementAt(0);
70: assertTrue(to.size() == 3);
71:
72: logger.debug(to);
73: TracedMethod tmo = to.traceElementAt(0);
74: logger.debug(tmo.getMethod().toString());
75: assertTrue("should be endpoint but is "
76: + tmo.getMethod().toString(), tmo.getMethod()
77: .toString().equals("MyClass>>executeEndPoint"));
78: tmo = to.traceElementAt(1);
79: logger.debug(tmo.getMethod().toString());
80: assertTrue("should be execute2 but is "
81: + tmo.getMethod().toString(), tmo.getMethod()
82: .toString().equals("MyClass>>execute2"));
83: tmo = to.traceElementAt(2);
84: logger.debug(tmo.getMethod().toString());
85: assertTrue(tmo.getMethod().toString().equals(
86: "MyClass>>executeStartPoint"));
87: assertTrue(true);
88: logger.debug(tt.toXml());
89:
90: return;
91: }
92:
93: }
|