1 22 package org.jboss.test.aop.callerargs; 23 24 29 public class NotAdvisedPOJOCaller 30 { 31 public NotAdvisedPOJOCaller() 32 { 33 CallerInterceptor.intercepted = false; 34 NotAdvisedPOJO.voidStaticNoArgsMethod(); 35 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 36 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 37 38 CallerInterceptor.intercepted = false; 39 int ret = NotAdvisedPOJO.intStaticArgsMethod(3); 40 if (ret != 6) throw new RuntimeException ("Expected 6 as return value"); 41 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 42 if (CallerInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 43 if (((Integer )CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 44 45 CallerInterceptor.intercepted = false; 46 NotAdvisedPOJO pojo = new NotAdvisedPOJO(); 47 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 48 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 49 50 CallerInterceptor.intercepted = false; 51 pojo.voidNoArgsMethod(); 52 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 53 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 54 55 CallerInterceptor.intercepted = false; 56 NotAdvisedPOJO pojo2 = new NotAdvisedPOJO(10, 100); 57 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 58 if(pojo2.i != 10) throw new RuntimeException ("Expected pojo.i to be 10"); 59 if(pojo2.j != 100) throw new RuntimeException ("Expected pojo.i to be 100"); 60 if (CallerInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 61 if (((Integer )CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 62 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[1] should have been 100"); 63 64 CallerInterceptor.intercepted = false; 65 ret = pojo2.intArgsMethod(20, 100); 66 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 67 if (ret != 2000)throw new RuntimeException ("Expected 2000 as return value"); 68 if (((Integer )CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 69 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[1] should have been 100"); 70 } 71 72 public void method() 73 { 74 CallerInterceptor.intercepted = false; 75 NotAdvisedPOJO.voidStaticNoArgsMethod(); 76 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 77 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 78 79 CallerInterceptor.intercepted = false; 80 int ret = NotAdvisedPOJO.intStaticArgsMethod(3); 81 if (ret != 6) throw new RuntimeException ("Expected 6 as return value"); 82 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 83 if (CallerInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 84 if (((Integer )CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 85 86 CallerInterceptor.intercepted = false; 87 NotAdvisedPOJO pojo = new NotAdvisedPOJO(); 88 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 89 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 90 91 CallerInterceptor.intercepted = false; 92 pojo.voidNoArgsMethod(); 93 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 94 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 95 96 CallerInterceptor.intercepted = false; 97 NotAdvisedPOJO pojo2 = new NotAdvisedPOJO(10, 100); 98 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 99 if(pojo2.i != 10) throw new RuntimeException ("Expected pojo.i to be 10"); 100 if(pojo2.j != 100) throw new RuntimeException ("Expected pojo.i to be 100"); 101 if (CallerInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 102 if (((Integer )CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 103 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[1] should have been 100"); 104 105 CallerInterceptor.intercepted = false; 106 ret = pojo2.intArgsMethod(20, 100); 107 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 108 if (ret != 2000)throw new RuntimeException ("Expected 2000 as return value"); 109 if (((Integer )CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 110 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[1] should have been 100"); 111 } 112 113 public static void staticMethod() 114 { 115 CallerInterceptor.intercepted = false; 116 NotAdvisedPOJO.voidStaticNoArgsMethod(); 117 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 118 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 119 120 CallerInterceptor.intercepted = false; 121 int ret = NotAdvisedPOJO.intStaticArgsMethod(3); 122 if (ret != 6) throw new RuntimeException ("Expected 6 as return value"); 123 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 124 if (CallerInterceptor.argsLength != 1) throw new RuntimeException ("Args length should have been 1"); 125 if (((Integer )CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException ("Args[0] should have been 3"); 126 127 CallerInterceptor.intercepted = false; 128 NotAdvisedPOJO pojo = new NotAdvisedPOJO(); 129 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 130 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 131 132 CallerInterceptor.intercepted = false; 133 pojo.voidNoArgsMethod(); 134 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 135 if (CallerInterceptor.argsLength != 0) throw new RuntimeException ("Args length should have been 0"); 136 137 CallerInterceptor.intercepted = false; 138 NotAdvisedPOJO pojo2 = new NotAdvisedPOJO(10, 100); 139 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 140 if(pojo2.i != 10) throw new RuntimeException ("Expected pojo.i to be 10"); 141 if(pojo2.j != 100) throw new RuntimeException ("Expected pojo.i to be 100"); 142 if (CallerInterceptor.argsLength != 2) throw new RuntimeException ("Args length should have been 2"); 143 if (((Integer )CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException ("Args[0] should have been 10"); 144 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[1] should have been 100"); 145 146 CallerInterceptor.intercepted = false; 147 ret = pojo2.intArgsMethod(20, 100); 148 if (!CallerInterceptor.intercepted) throw new RuntimeException ("Did not intercept"); 149 if (ret != 2000)throw new RuntimeException ("Expected 2000 as return value"); 150 if (((Integer )CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException ("Args[0] should have been 20"); 151 if (((Integer )CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException ("Args[1] should have been 100"); 152 } 153 } 154 | Popular Tags |