1 22 package org.jboss.test.aop.callerargs; 23 24 29 public class AdvisedPOJOCaller 30 { 31 public AdvisedPOJOCaller() 32 { 33 CallerInterceptor.intercepted = false; 34 ExecutionInterceptor.intercepted = false; 35 AdvisedPOJO.voidStaticNoArgsMethod(); 36 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 37 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 38 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 39 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 40 41 CallerInterceptor.intercepted = false; 42 ExecutionInterceptor.intercepted = false; 43 int ret = AdvisedPOJO.intStaticArgsMethod(3); 44 if (ret != 6) throw new RuntimeException ("Expected 6 as return value"); 45 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 46 if (CallerInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 47 if (((Integer )CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 48 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 49 if (ExecutionInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 50 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 51 52 CallerInterceptor.intercepted = false; 53 ExecutionInterceptor.intercepted = false; 54 AdvisedPOJO pojo = new AdvisedPOJO(); 55 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 56 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 57 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 58 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 59 60 CallerInterceptor.intercepted = false; 61 ExecutionInterceptor.intercepted = false; 62 pojo.voidNoArgsMethod(); 63 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 64 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 65 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 66 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 67 68 CallerInterceptor.intercepted = false; 69 ExecutionInterceptor.intercepted = false; 70 AdvisedPOJO pojo2 = new AdvisedPOJO(10, 100); 71 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 72 if(pojo2.i != 10) throw new RuntimeException ("Expected pojo.i to be 10"); 73 if(pojo2.j != 100) throw new RuntimeException ("Expected pojo.i to be 100"); 74 if (CallerInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 75 if (((Integer )CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 76 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 77 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 78 if (ExecutionInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 79 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 80 if (((Integer )ExecutionInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 81 82 CallerInterceptor.intercepted = false; 83 ExecutionInterceptor.intercepted = false; 84 ret = pojo2.intArgsMethod(20, 100); 85 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 86 if (ret != 2000)throw new RuntimeException ("Expected 2000 as return value"); 87 if (((Integer )CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 88 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 89 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 90 if (ExecutionInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 91 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 92 if (((Integer )ExecutionInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 93 } 94 95 public void method() 96 { 97 CallerInterceptor.intercepted = false; 98 ExecutionInterceptor.intercepted = false; 99 AdvisedPOJO.voidStaticNoArgsMethod(); 100 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 101 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 102 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 103 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 104 105 CallerInterceptor.intercepted = false; 106 ExecutionInterceptor.intercepted = false; 107 int ret = AdvisedPOJO.intStaticArgsMethod(3); 108 if (ret != 6) throw new RuntimeException ("Expected 6 as return value"); 109 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 110 if (CallerInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 111 if (((Integer )CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 112 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 113 if (ExecutionInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 114 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 115 116 CallerInterceptor.intercepted = false; 117 ExecutionInterceptor.intercepted = false; 118 AdvisedPOJO pojo = new AdvisedPOJO(); 119 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 120 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 121 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 122 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 123 124 CallerInterceptor.intercepted = false; 125 ExecutionInterceptor.intercepted = false; 126 pojo.voidNoArgsMethod(); 127 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 128 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 129 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 130 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 131 132 CallerInterceptor.intercepted = false; 133 ExecutionInterceptor.intercepted = false; 134 AdvisedPOJO pojo2 = new AdvisedPOJO(10, 100); 135 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 136 if(pojo2.i != 10) throw new RuntimeException ("Expected pojo.i to be 10"); 137 if(pojo2.j != 100) throw new RuntimeException ("Expected pojo.i to be 100"); 138 if (CallerInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 139 if (((Integer )CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 140 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 141 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 142 if (ExecutionInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 143 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 144 if (((Integer )ExecutionInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 145 146 CallerInterceptor.intercepted = false; 147 ExecutionInterceptor.intercepted = false; 148 ret = pojo2.intArgsMethod(20, 100); 149 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 150 if (ret != 2000)throw new RuntimeException ("Expected 2000 as return value"); 151 if (((Integer )CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 152 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 153 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 154 if (ExecutionInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 155 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 156 if (((Integer )ExecutionInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 157 } 158 159 public static void staticMethod() 160 { 161 CallerInterceptor.intercepted = false; 162 ExecutionInterceptor.intercepted = false; 163 AdvisedPOJO.voidStaticNoArgsMethod(); 164 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 165 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 166 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 167 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 168 169 CallerInterceptor.intercepted = false; 170 ExecutionInterceptor.intercepted = false; 171 int ret = AdvisedPOJO.intStaticArgsMethod(3); 172 if (ret != 6) throw new RuntimeException ("Expected 6 as return value"); 173 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 174 if (CallerInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 175 if (((Integer )CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 176 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 177 if (ExecutionInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 178 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 179 180 CallerInterceptor.intercepted = false; 181 ExecutionInterceptor.intercepted = false; 182 AdvisedPOJO pojo = new AdvisedPOJO(); 183 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 184 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 185 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 186 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 187 188 CallerInterceptor.intercepted = false; 189 ExecutionInterceptor.intercepted = false; 190 pojo.voidNoArgsMethod(); 191 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 192 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 193 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 194 if (ExecutionInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 195 196 CallerInterceptor.intercepted = false; 197 ExecutionInterceptor.intercepted = false; 198 AdvisedPOJO pojo2 = new AdvisedPOJO(10, 100); 199 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 200 if(pojo2.i != 10) throw new RuntimeException ("Expected pojo.i to be 10"); 201 if(pojo2.j != 100) throw new RuntimeException ("Expected pojo.i to be 100"); 202 if (CallerInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 203 if (((Integer )CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 204 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 205 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 206 if (ExecutionInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 207 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 208 if (((Integer )ExecutionInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 209 210 CallerInterceptor.intercepted = false; 211 ExecutionInterceptor.intercepted = false; 212 ret = pojo2.intArgsMethod(20, 100); 213 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 214 if (ret != 2000)throw new RuntimeException ("Expected 2000 as return value"); 215 if (((Integer )CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 216 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 217 if (!ExecutionInterceptor.intercepted) throw new RuntimeException ("Did not intercept execution"); 218 if (ExecutionInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 219 if (((Integer )ExecutionInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 220 if (((Integer )ExecutionInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[0] should have been 100"); 221 } 222 } 223 | Popular Tags |