1 22 package org.jboss.test.aop.bean; 23 24 import org.jboss.aop.Advised; 25 26 31 public class CallingPOJO 32 { 33 POJO pojo; 34 NonadvisedPOJO nonpojo; 35 36 public CallingPOJO() 37 { 38 CallerInterceptor.called = false; 39 pojo = new POJO(); 40 if (!CallerInterceptor.called) 41 { 42 throw new RuntimeException ("constructor caller interceptor didn't work from within constructor"); 43 } 44 CallerInterceptor.called = false; 45 pojo.someMethod(); 46 if (!CallerInterceptor.called) 47 { 48 throw new RuntimeException ("caller interceptor didn't work"); 49 } 50 CallerInterceptor.called = false; 51 nonpojo = new NonadvisedPOJO("helloworld"); 52 if (!CallerInterceptor.called) 53 { 54 throw new RuntimeException ("constructor caller interceptor didn't work"); 55 } 56 CallerInterceptor.called = false; 57 nonpojo.remoteTest(); 58 if (!CallerInterceptor.called) 59 { 60 throw new RuntimeException ("caller interceptor didn't work"); 61 } 62 if (nonpojo instanceof Advised) 63 { 64 throw new RuntimeException ("nonpojo is Advised when it shouldn't be"); 65 } 66 } 67 68 71 public void callSomeMethod() 72 { 73 CallerInterceptor.called = false; 74 pojo = new POJO(); 75 if (!CallerInterceptor.called) 76 { 77 throw new RuntimeException ("constructor caller interceptor didn't work within method"); 78 } 79 CallerInterceptor.called = false; 80 pojo.someMethod(); 81 if (!CallerInterceptor.called) 82 { 83 throw new RuntimeException ("caller interceptor didn't work"); 84 } 85 } 86 87 90 public void nocallSomeMethod() 91 { 92 CallerInterceptor.called = false; 93 pojo = new POJO(); 94 if (CallerInterceptor.called) 95 { 96 throw new RuntimeException ("constructor caller interceptor didn't work, interceptor was invoked when it shouldn't have been"); 97 } 98 pojo.someMethod(); 99 if (CallerInterceptor.called) 100 { 101 throw new RuntimeException ("caller interceptor didn't work, caller interceptor was invoked when it shouldn't have been"); 102 } 103 } 104 105 public void callUnadvised() 106 { 107 CallerInterceptor.called = false; 108 nonpojo = new NonadvisedPOJO("helloworld"); 109 if (!CallerInterceptor.called) 110 { 111 throw new RuntimeException ("consturctor caller interceptor didn't work"); 112 } 113 CallerInterceptor.called = false; 114 nonpojo.remoteTest(); 115 if (!CallerInterceptor.called) 116 { 117 throw new RuntimeException ("caller interceptor didn't work"); 118 } 119 if (nonpojo instanceof Advised) 120 { 121 throw new RuntimeException ("nonpojo is Advised when it shouldn't be"); 122 } 123 } 124 125 } 126 127 | Popular Tags |