1 8 package test; 9 10 import junit.framework.TestCase; 11 12 18 public class CFlowTest extends TestCase implements Loggable { 19 private String m_logString = ""; 20 21 public CFlowTest(String name) { 22 super(name); 23 } 24 25 public void testCallWithinCFlow() { 26 m_logString = ""; 27 step1(); assertEquals("step1 advice-before step2 advice-after ", m_logString); 29 } 30 31 public void testCallWithinCFlowAnonymous() { 32 m_logString = ""; 33 step1Anonymous(); assertEquals( 35 "step1Anonymous advice-beforeAnonymous step2Anonymous advice-afterAnonymous ", 36 m_logString 37 ); 38 } 39 40 public void testCallWithinCFlowWithinCflow() { 41 m_logString = ""; 42 step1_A(); assertEquals("step1_A step1_B advice-before2 step2_B advice-after2 ", m_logString); 44 } 45 46 public void testCallOutsideCFlow() { 47 m_logString = ""; 48 step2(); 49 assertEquals("step2 ", m_logString); 50 } 51 52 public void testCallWithinCFlow_B() { 53 m_logString = ""; 54 step1_B(); assertEquals("step1_B step2_B ", m_logString); 56 } 57 58 public void testCallOutsideCFlowAnonymous() { 59 m_logString = ""; 60 step2Anonymous(); 61 assertEquals("step2Anonymous ", m_logString); 62 } 63 64 public void testCflowOnMySelfForPrecedence() { 65 m_logString = ""; 66 cflowOnMyself(); 67 assertEquals("cflowOnMyself advice-cflowOnMyself ", m_logString); 68 } 69 70 80 public static void main(String [] args) { 81 junit.textui.TestRunner.run(suite()); 82 } 83 84 public static junit.framework.Test suite() { 85 return new junit.framework.TestSuite(CFlowTest.class); 86 } 87 88 public void log(final String wasHere) { 90 m_logString += wasHere; 91 } 92 93 public void step1() { 94 log("step1 "); 95 step2(); 96 } 97 98 public void step1Anonymous() { 99 log("step1Anonymous "); 100 step2Anonymous(); 101 } 102 103 public void step1_B() { 104 log("step1_B "); 105 step2_B(); 106 } 107 108 public void step1_A() { 109 log("step1_A "); 110 step1_B(); 111 } 112 113 public void step2() { 114 log("step2 "); 115 } 116 117 public void step2Anonymous() { 118 log("step2Anonymous "); 119 } 120 121 public void step2_B() { 122 log("step2_B "); 123 } 124 125 public void step1_C() { 126 log("step1_C "); 127 step2_C(); 128 } 129 130 public void step2_C() { 131 log("step2_C "); 132 } 133 134 public void cflowOnMyself() { 135 log("cflowOnMyself "); 136 } 137 } | Popular Tags |