1 22 package org.jboss.test.aop.invoketarget; 23 24 import org.jboss.test.aop.AOPTestWithSetup; 25 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 import junit.textui.TestRunner; 29 30 34 public class InvokeTargetTestCase extends AOPTestWithSetup 35 { 36 37 public static void main(String [] args) 38 { 39 TestRunner.run(suite()); 40 } 41 42 public static Test suite() 43 { 44 TestSuite suite = new TestSuite("ProxyTester"); 45 suite.addTestSuite(InvokeTargetTestCase.class); 46 return suite; 47 } 48 49 public InvokeTargetTestCase(String name) 50 { 51 super(name); 52 } 53 54 public void testExecution() throws Exception 55 { 56 BypassInterceptor.invocations = 0; 57 CountingInterceptor.invocations = 0; 58 POJO pojo = new POJO("Test"); 59 assertEquals("Test", pojo.plain); 61 assertEquals(2, BypassInterceptor.invocations); 63 assertEquals(2, CountingInterceptor.invocations); 64 65 BypassInterceptor.invocations = 0; 66 CountingInterceptor.invocations = 0; 67 pojo.i = 5; 68 assertEquals(1, BypassInterceptor.invocations); 69 assertEquals(1, CountingInterceptor.invocations); 70 71 BypassInterceptor.invocations = 0; 72 CountingInterceptor.invocations = 0; 73 int i = pojo.i; 74 assertEquals(5, i); 75 assertEquals(1, BypassInterceptor.invocations); 76 assertEquals(1, CountingInterceptor.invocations); 77 78 BypassInterceptor.invocations = 0; 79 CountingInterceptor.invocations = 0; 80 pojo.s = "Blah"; 81 assertEquals(1, BypassInterceptor.invocations); 82 assertEquals(1, CountingInterceptor.invocations); 83 84 BypassInterceptor.invocations = 0; 85 CountingInterceptor.invocations = 0; 86 String str = pojo.s; 87 assertEquals("Blah", str); 88 assertEquals(1, BypassInterceptor.invocations); 89 assertEquals(1, CountingInterceptor.invocations); 90 91 BypassInterceptor.invocations = 0; 92 CountingInterceptor.invocations = 0; 93 pojo.test(); 94 assertEquals(1, BypassInterceptor.invocations); 95 assertEquals(1, CountingInterceptor.invocations); 96 97 BypassInterceptor.invocations = 0; 98 CountingInterceptor.invocations = 0; 99 String s = pojo.echo("Hello"); 100 assertEquals("Hello", s); 101 assertEquals(1, BypassInterceptor.invocations); 102 assertEquals(1, CountingInterceptor.invocations); 103 104 BypassInterceptor.invocations = 0; 105 CountingInterceptor.invocations = 0; 106 i = pojo.echo(100); 107 assertEquals(100, i); 108 assertEquals(1, BypassInterceptor.invocations); 109 assertEquals(1, CountingInterceptor.invocations); 110 } 111 112 public void testConstructorCaller() 113 { 114 CallingPOJO pojo = new CallingPOJO(); 115 } 116 117 public void testStaticMethodCaller() 118 { 119 CallingPOJO.testStatic(); 120 } 121 122 public void testMethodCaller() 123 { 124 CallingPOJO pojo = new CallingPOJO(); 125 pojo.test(); 126 } 127 } 128 | Popular Tags |