1 7 package org.hammurapi.inspectors.metrics.callertrace.tests; 8 9 10 import junit.framework.Test; 11 import junit.framework.TestCase; 12 import junit.framework.TestSuite; 13 14 import org.apache.log4j.Logger; 15 import org.apache.log4j.PropertyConfigurator; 16 import org.hammurapi.inspectors.metrics.callertrace.MethodWrapperDeclaration; 17 import org.hammurapi.inspectors.metrics.callertrace.Trace; 18 import org.hammurapi.inspectors.metrics.callertrace.TraceList; 19 import org.hammurapi.inspectors.metrics.callertrace.TraceTable; 20 import org.hammurapi.inspectors.metrics.callertrace.TracedMethod; 21 22 28 public class TraceCaller extends TestCase { 29 private static Logger logger = Logger.getLogger(TraceCaller.class.getName()); 30 31 32 protected void setUp() throws Exception { 33 34 super.setUp(); 35 PropertyConfigurator.configure("D:/a/Jegustator/0.7.0/src/config/TestRunLogConfig.txt"); 36 } 37 38 39 public static Test suite() { 40 return new TestSuite(TraceCaller.class); 41 } 42 43 public void testTraceCaller1() { 44 45 TracedMethod tm1 = new TracedMethod(new MethodWrapperDeclaration("executeEndPoint", "MyClass")); 46 47 48 TracedMethod tm2 = new TracedMethod(new MethodWrapperDeclaration("execute2", "MyClass")); 49 50 51 TracedMethod tm3 = new TracedMethod(new MethodWrapperDeclaration("executeStartPoint", "MyClass")); 52 53 54 Trace t = new Trace(); 55 t.add(tm1); 56 t.add(tm2); 57 t.add(tm3); 58 59 TraceList tl = new TraceList("java.lang.String>>equals(String)"); 60 tl.add(t); 61 62 TraceTable tt = new TraceTable(); 63 tt.put("java.lang.String>>equals(String)", tl); 64 65 assertTrue(tt.size() == 1); 66 TraceList tlo = tt.get("java.lang.String>>equals(String)"); 67 assertTrue(tlo.size() == 1); 68 Trace to = tlo.traceElementAt(0); 69 assertTrue(to.size() == 3); 70 71 72 logger.debug( to ); 73 TracedMethod tmo = to.traceElementAt(0); 74 logger.debug( tmo.getMethod().toString() ); 75 assertTrue("should be endpoint but is " + tmo.getMethod().toString(), tmo.getMethod().toString().equals("MyClass>>executeEndPoint")); 76 tmo = to.traceElementAt(1); 77 logger.debug( tmo.getMethod().toString() ); 78 assertTrue("should be execute2 but is " +tmo.getMethod().toString(), tmo.getMethod().toString().equals("MyClass>>execute2")); 79 tmo = to.traceElementAt(2); 80 logger.debug( tmo.getMethod().toString() ); 81 assertTrue(tmo.getMethod().toString().equals("MyClass>>executeStartPoint")); 82 assertTrue(true); 83 logger.debug( tt.toXml() ); 84 85 return; 86 } 87 88 } 89 90 | Popular Tags |