| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
package org.apache.commons.beanutils; |
| 19 |
|
|
| 20 |
|
import java.util.*; |
| 21 |
|
|
| 22 |
|
import java.lang.ref.WeakReference; |
| 23 |
|
import java.lang.ref.ReferenceQueue; |
| 24 |
|
|
| 25 |
|
import junit.framework.TestCase; |
| 26 |
|
import junit.framework.Test; |
| 27 |
|
import junit.framework.TestSuite; |
| 28 |
|
|
| 29 |
|
import org.apache.commons.logging.LogFactory; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@author |
| 37 |
|
@author |
| 38 |
|
@version |
| 39 |
|
|
| 40 |
|
|
|
|
|
| 87.2% |
Uncovered Elements: 24 (187) |
Complexity: 31 |
Complexity Density: 0.21 |
|
| 41 |
|
public class BeanificationTestCase extends TestCase { |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
public static final int MAX_GC_ITERATIONS = 50; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
@param |
| 58 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 59 |
8
|
public BeanificationTestCase(String name) {... |
| 60 |
8
|
super(name); |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
8
|
public void setUp() {... |
| 71 |
|
|
| 72 |
8
|
ConvertUtils.deregister(); |
| 73 |
|
|
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 80 |
1
|
public static Test suite() {... |
| 81 |
1
|
return (new TestSuite(BeanificationTestCase.class)); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 88 |
8
|
public void tearDown() {... |
| 89 |
|
|
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
|
|
|
| 75% |
Uncovered Elements: 5 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
1
PASS
|
|
| 96 |
1
|
public void testMemoryTestMethodology() throws Exception {... |
| 97 |
|
|
| 98 |
|
|
| 99 |
1
|
ClassLoader loader = new ClassLoader(this.getClass().getClassLoader()) {}; |
| 100 |
1
|
WeakReference reference = new WeakReference(loader); |
| 101 |
1
|
Class myClass = loader.loadClass("org.apache.commons.beanutils.BetaBean"); |
| 102 |
|
|
| 103 |
1
|
assertNotNull("Weak reference released early", reference.get()); |
| 104 |
|
|
| 105 |
|
|
| 106 |
1
|
loader = null; |
| 107 |
1
|
myClass = null; |
| 108 |
|
|
| 109 |
1
|
int iterations = 0; |
| 110 |
1
|
int bytz = 2; |
| 111 |
1
|
while(true) { |
| 112 |
1
|
System.gc(); |
| 113 |
1
|
if(iterations++ > MAX_GC_ITERATIONS){ |
| 114 |
0
|
fail("Max iterations reached before resource released."); |
| 115 |
|
} |
| 116 |
1
|
if( reference.get() == null ) { |
| 117 |
1
|
break; |
| 118 |
|
|
| 119 |
|
} else { |
| 120 |
|
|
| 121 |
0
|
byte[] b = new byte[bytz]; |
| 122 |
0
|
bytz = bytz * 2; |
| 123 |
|
} |
| 124 |
|
} |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
|
|
|
|
| 84.4% |
Uncovered Elements: 5 (32) |
Complexity: 5 |
Complexity Density: 0.19 |
1
PASS
|
|
| 128 |
1
|
public void testMemoryLeak2() throws Exception {... |
| 129 |
|
|
| 130 |
|
|
| 131 |
1
|
if (isPre14JVM()) { |
| 132 |
0
|
System.out.println("WARNING: CANNOT TEST MEMORY LEAK ON PRE1.4 JVM"); |
| 133 |
0
|
return; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
|
| 137 |
1
|
TestClassLoader loader = new TestClassLoader(); |
| 138 |
1
|
ReferenceQueue queue = new ReferenceQueue(); |
| 139 |
1
|
WeakReference loaderReference = new WeakReference(loader, queue); |
| 140 |
1
|
Integer test = new Integer(1); |
| 141 |
|
|
| 142 |
1
|
WeakReference testReference = new WeakReference(test, queue); |
| 143 |
|
|
| 144 |
1
|
Map map = new WeakHashMap(); |
| 145 |
1
|
map.put(loader, test); |
| 146 |
|
|
| 147 |
1
|
assertEquals("In map", test, map.get(loader)); |
| 148 |
1
|
assertNotNull("Weak reference released early (1)", loaderReference.get()); |
| 149 |
1
|
assertNotNull("Weak reference released early (2)", testReference.get()); |
| 150 |
|
|
| 151 |
|
|
| 152 |
1
|
loader = null; |
| 153 |
1
|
test = null; |
| 154 |
|
|
| 155 |
1
|
int iterations = 0; |
| 156 |
1
|
int bytz = 2; |
| 157 |
1
|
while(true) { |
| 158 |
3
|
System.gc(); |
| 159 |
3
|
if(iterations++ > MAX_GC_ITERATIONS){ |
| 160 |
0
|
fail("Max iterations reached before resource released."); |
| 161 |
|
} |
| 162 |
3
|
map.isEmpty(); |
| 163 |
|
|
| 164 |
3
|
if( |
| 165 |
3
|
loaderReference.get() == null && |
| 166 |
|
testReference.get() == null) { |
| 167 |
1
|
break; |
| 168 |
|
|
| 169 |
|
} else { |
| 170 |
|
|
| 171 |
2
|
byte[] b = new byte[bytz]; |
| 172 |
2
|
bytz = bytz * 2; |
| 173 |
|
} |
| 174 |
|
} |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
|
|
|
|
| 86.8% |
Uncovered Elements: 5 (38) |
Complexity: 7 |
Complexity Density: 0.22 |
1
PASS
|
|
| 178 |
1
|
public void testMemoryLeak() throws Exception {... |
| 179 |
1
|
if (isPre14JVM()) { |
| 180 |
0
|
System.out.println("WARNING: CANNOT TEST MEMORY LEAK ON PRE1.4 JVM"); |
| 181 |
0
|
return; |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
|
| 185 |
1
|
TestClassLoader loader = new TestClassLoader(); |
| 186 |
1
|
WeakReference loaderReference = new WeakReference(loader); |
| 187 |
1
|
BeanUtilsBean.getInstance(); |
| 188 |
|
|
| 189 |
|
class GetBeanUtilsBeanThread extends Thread { |
| 190 |
|
|
| 191 |
|
BeanUtilsBean beanUtils; |
| 192 |
|
ConvertUtilsBean convertUtils; |
| 193 |
|
PropertyUtilsBean propertyUtils; |
| 194 |
|
|
| 195 |
|
GetBeanUtilsBeanThread() {} |
| 196 |
|
|
| 197 |
|
public void run() { |
| 198 |
|
beanUtils = BeanUtilsBean.getInstance(); |
| 199 |
|
convertUtils = ConvertUtilsBean.getInstance(); |
| 200 |
|
propertyUtils = PropertyUtilsBean.getInstance(); |
| 201 |
|
|
| 202 |
|
LogFactory.releaseAll(); |
| 203 |
|
} |
| 204 |
|
|
| 205 |
|
public String toString() { |
| 206 |
|
return "GetBeanUtilsBeanThread"; |
| 207 |
|
} |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
|
| 211 |
1
|
GetBeanUtilsBeanThread thread = new GetBeanUtilsBeanThread(); |
| 212 |
1
|
WeakReference threadWeakReference = new WeakReference(thread); |
| 213 |
1
|
thread.setContextClassLoader(loader); |
| 214 |
|
|
| 215 |
1
|
thread.start(); |
| 216 |
1
|
thread.join(); |
| 217 |
|
|
| 218 |
1
|
WeakReference beanUtilsReference = new WeakReference(thread.beanUtils); |
| 219 |
1
|
WeakReference propertyUtilsReference = new WeakReference(thread.propertyUtils); |
| 220 |
1
|
WeakReference convertUtilsReference = new WeakReference(thread.convertUtils); |
| 221 |
|
|
| 222 |
1
|
assertNotNull("Weak reference released early (1)", loaderReference.get()); |
| 223 |
1
|
assertNotNull("Weak reference released early (2)", beanUtilsReference.get()); |
| 224 |
1
|
assertNotNull("Weak reference released early (3)", propertyUtilsReference.get()); |
| 225 |
1
|
assertNotNull("Weak reference released early (4)", convertUtilsReference.get()); |
| 226 |
|
|
| 227 |
|
|
| 228 |
1
|
loader = null; |
| 229 |
1
|
thread.setContextClassLoader(null); |
| 230 |
1
|
thread = null; |
| 231 |
|
|
| 232 |
1
|
int iterations = 0; |
| 233 |
1
|
int bytz = 2; |
| 234 |
1
|
while(true) { |
| 235 |
4
|
BeanUtilsBean.getInstance(); |
| 236 |
4
|
System.gc(); |
| 237 |
4
|
if(iterations++ > MAX_GC_ITERATIONS){ |
| 238 |
0
|
fail("Max iterations reached before resource released."); |
| 239 |
|
} |
| 240 |
|
|
| 241 |
4
|
if( |
| 242 |
4
|
loaderReference.get() == null && |
| 243 |
|
beanUtilsReference.get() == null && |
| 244 |
|
propertyUtilsReference.get() == null && |
| 245 |
|
convertUtilsReference.get() == null) { |
| 246 |
1
|
break; |
| 247 |
|
|
| 248 |
|
} else { |
| 249 |
|
|
| 250 |
3
|
byte[] b = new byte[bytz]; |
| 251 |
3
|
bytz = bytz * 2; |
| 252 |
|
} |
| 253 |
|
} |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1
PASS
|
|
| 260 |
1
|
public void testGetByContextClassLoader() throws Exception {... |
| 261 |
|
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 262 |
|
class GetBeanUtilsBeanThread extends Thread { |
| 263 |
|
|
| 264 |
|
private Signal signal; |
| 265 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 266 |
1
|
GetBeanUtilsBeanThread(Signal signal) {... |
| 267 |
1
|
this.signal = signal; |
| 268 |
|
} |
| 269 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 270 |
1
|
public void run() {... |
| 271 |
1
|
signal.setSignal(2); |
| 272 |
1
|
signal.setBean(BeanUtilsBean.getInstance()); |
| 273 |
1
|
signal.setConvertUtils(ConvertUtilsBean.getInstance()); |
| 274 |
1
|
signal.setPropertyUtils(PropertyUtilsBean.getInstance()); |
| 275 |
|
} |
| 276 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 277 |
0
|
public String toString() {... |
| 278 |
0
|
return "GetBeanUtilsBeanThread"; |
| 279 |
|
} |
| 280 |
|
} |
| 281 |
|
|
| 282 |
1
|
Signal signal = new Signal(); |
| 283 |
1
|
signal.setSignal(1); |
| 284 |
|
|
| 285 |
1
|
GetBeanUtilsBeanThread thread = new GetBeanUtilsBeanThread(signal); |
| 286 |
1
|
thread.setContextClassLoader(new TestClassLoader()); |
| 287 |
|
|
| 288 |
1
|
thread.start(); |
| 289 |
1
|
thread.join(); |
| 290 |
|
|
| 291 |
1
|
assertEquals("Signal not set by test thread", 2, signal.getSignal()); |
| 292 |
1
|
assertTrue( |
| 293 |
|
"Different BeanUtilsBean instances per context classloader", |
| 294 |
|
BeanUtilsBean.getInstance() != signal.getBean()); |
| 295 |
1
|
assertTrue( |
| 296 |
|
"Different ConvertUtilsBean instances per context classloader", |
| 297 |
|
ConvertUtilsBean.getInstance() != signal.getConvertUtils()); |
| 298 |
1
|
assertTrue( |
| 299 |
|
"Different PropertyUtilsBean instances per context classloader", |
| 300 |
|
PropertyUtilsBean.getInstance() != signal.getPropertyUtils()); |
| 301 |
|
} |
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
| 308 |
1
|
public void testContextClassLoaderLocal() throws Exception {... |
| 309 |
|
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 310 |
|
class CCLLTesterThread extends Thread { |
| 311 |
|
|
| 312 |
|
private Signal signal; |
| 313 |
|
private ContextClassLoaderLocal ccll; |
| 314 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 315 |
1
|
CCLLTesterThread(Signal signal, ContextClassLoaderLocal ccll) {... |
| 316 |
1
|
this.signal = signal; |
| 317 |
1
|
this.ccll = ccll; |
| 318 |
|
} |
| 319 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 320 |
1
|
public void run() {... |
| 321 |
1
|
ccll.set(new Integer(1789)); |
| 322 |
1
|
signal.setSignal(2); |
| 323 |
1
|
signal.setMarkerObject(ccll.get()); |
| 324 |
|
} |
| 325 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 326 |
0
|
public String toString() {... |
| 327 |
0
|
return "CCLLTesterThread"; |
| 328 |
|
} |
| 329 |
|
} |
| 330 |
|
|
| 331 |
1
|
ContextClassLoaderLocal ccll = new ContextClassLoaderLocal(); |
| 332 |
1
|
ccll.set(new Integer(1776)); |
| 333 |
1
|
assertEquals("Start thread sets value", new Integer(1776), ccll.get()); |
| 334 |
|
|
| 335 |
1
|
Signal signal = new Signal(); |
| 336 |
1
|
signal.setSignal(1); |
| 337 |
|
|
| 338 |
1
|
CCLLTesterThread thread = new CCLLTesterThread(signal, ccll); |
| 339 |
1
|
thread.setContextClassLoader(new TestClassLoader()); |
| 340 |
|
|
| 341 |
1
|
thread.start(); |
| 342 |
1
|
thread.join(); |
| 343 |
|
|
| 344 |
1
|
assertEquals("Signal not set by test thread", 2, signal.getSignal()); |
| 345 |
1
|
assertEquals("Second thread preserves value", new Integer(1776), ccll.get()); |
| 346 |
1
|
assertEquals("Second thread gets value it set", new Integer(1789), signal.getMarkerObject()); |
| 347 |
|
} |
| 348 |
|
|
| 349 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
| 350 |
1
|
public void testContextClassloaderIndependence() throws Exception {... |
| 351 |
|
|
|
|
|
| 71.4% |
Uncovered Elements: 4 (14) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 352 |
|
class TestIndependenceThread extends Thread { |
| 353 |
|
private Signal signal; |
| 354 |
|
private PrimitiveBean bean; |
| 355 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 356 |
1
|
TestIndependenceThread(Signal signal, PrimitiveBean bean) {... |
| 357 |
1
|
this.signal = signal; |
| 358 |
1
|
this.bean = bean; |
| 359 |
|
} |
| 360 |
|
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 361 |
1
|
public void run() {... |
| 362 |
1
|
try { |
| 363 |
1
|
signal.setSignal(3); |
| 364 |
1
|
ConvertUtils.register(new Converter() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 365 |
1
|
public Object convert(Class type, Object value) {... |
| 366 |
1
|
return new Integer(9); |
| 367 |
|
} |
| 368 |
|
}, Integer.TYPE); |
| 369 |
1
|
BeanUtils.setProperty(bean, "int", new Integer(1)); |
| 370 |
|
} catch (Exception e) { |
| 371 |
0
|
e.printStackTrace(); |
| 372 |
0
|
signal.setException(e); |
| 373 |
|
} |
| 374 |
|
} |
| 375 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 376 |
0
|
public String toString() {... |
| 377 |
0
|
return "TestIndependenceThread"; |
| 378 |
|
} |
| 379 |
|
} |
| 380 |
|
|
| 381 |
1
|
PrimitiveBean bean = new PrimitiveBean(); |
| 382 |
1
|
BeanUtils.setProperty(bean, "int", new Integer(1)); |
| 383 |
1
|
assertEquals("Wrong property value (1)", 1, bean.getInt()); |
| 384 |
|
|
| 385 |
1
|
ConvertUtils.register(new Converter() { |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 386 |
1
|
public Object convert(Class type, Object value) {... |
| 387 |
1
|
return new Integer(5); |
| 388 |
|
} |
| 389 |
|
}, Integer.TYPE); |
| 390 |
1
|
BeanUtils.setProperty(bean, "int", new Integer(1)); |
| 391 |
1
|
assertEquals("Wrong property value(2)", 5, bean.getInt()); |
| 392 |
|
|
| 393 |
1
|
Signal signal = new Signal(); |
| 394 |
1
|
signal.setSignal(1); |
| 395 |
1
|
TestIndependenceThread thread = new TestIndependenceThread(signal, bean); |
| 396 |
1
|
thread.setContextClassLoader(new TestClassLoader()); |
| 397 |
|
|
| 398 |
1
|
thread.start(); |
| 399 |
1
|
thread.join(); |
| 400 |
|
|
| 401 |
1
|
assertNull("Exception thrown by test thread:" + signal.getException(), signal.getException()); |
| 402 |
1
|
assertEquals("Signal not set by test thread", 3, signal.getSignal()); |
| 403 |
1
|
assertEquals("Wrong property value(3)", 9, bean.getInt()); |
| 404 |
|
|
| 405 |
|
} |
| 406 |
|
|
| 407 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
| 408 |
1
|
public void testBeanUtilsBeanSetInstance() throws Exception {... |
| 409 |
|
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 410 |
|
class SetInstanceTesterThread extends Thread { |
| 411 |
|
|
| 412 |
|
private Signal signal; |
| 413 |
|
private BeanUtilsBean bean; |
| 414 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 415 |
1
|
SetInstanceTesterThread(Signal signal, BeanUtilsBean bean) {... |
| 416 |
1
|
this.signal = signal; |
| 417 |
1
|
this.bean = bean; |
| 418 |
|
} |
| 419 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 420 |
1
|
public void run() {... |
| 421 |
1
|
BeanUtilsBean.setInstance(bean); |
| 422 |
1
|
signal.setSignal(21); |
| 423 |
1
|
signal.setBean(BeanUtilsBean.getInstance()); |
| 424 |
|
} |
| 425 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 426 |
0
|
public String toString() {... |
| 427 |
0
|
return "SetInstanceTesterThread"; |
| 428 |
|
} |
| 429 |
|
} |
| 430 |
|
|
| 431 |
1
|
Signal signal = new Signal(); |
| 432 |
1
|
signal.setSignal(1); |
| 433 |
|
|
| 434 |
1
|
BeanUtilsBean beanOne = new BeanUtilsBean(); |
| 435 |
1
|
BeanUtilsBean beanTwo = new BeanUtilsBean(); |
| 436 |
|
|
| 437 |
1
|
SetInstanceTesterThread thread = new SetInstanceTesterThread(signal, beanTwo); |
| 438 |
1
|
thread.setContextClassLoader(new TestClassLoader()); |
| 439 |
|
|
| 440 |
1
|
BeanUtilsBean.setInstance(beanOne); |
| 441 |
1
|
assertEquals("Start thread gets right instance", beanOne, BeanUtilsBean.getInstance()); |
| 442 |
|
|
| 443 |
1
|
thread.start(); |
| 444 |
1
|
thread.join(); |
| 445 |
|
|
| 446 |
1
|
assertEquals("Signal not set by test thread", 21, signal.getSignal()); |
| 447 |
1
|
assertEquals("Second thread preserves value", beanOne, BeanUtilsBean.getInstance()); |
| 448 |
1
|
assertEquals("Second thread gets value it set", beanTwo, signal.getBean()); |
| 449 |
|
} |
| 450 |
|
|
| 451 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
| 452 |
1
|
public void testContextClassLoaderUnset() throws Exception {... |
| 453 |
1
|
BeanUtilsBean beanOne = new BeanUtilsBean(); |
| 454 |
1
|
ContextClassLoaderLocal ccll = new ContextClassLoaderLocal(); |
| 455 |
1
|
ccll.set(beanOne); |
| 456 |
1
|
assertEquals("Start thread gets right instance", beanOne, ccll.get()); |
| 457 |
1
|
ccll.unset(); |
| 458 |
1
|
assertTrue("Unset works", !beanOne.equals(ccll.get())); |
| 459 |
|
} |
| 460 |
|
|
|
|
|
| 60.9% |
Uncovered Elements: 9 (23) |
Complexity: 6 |
Complexity Density: 0.46 |
|
| 461 |
2
|
private boolean isPre14JVM() {... |
| 462 |
|
|
| 463 |
|
|
| 464 |
2
|
String version = System.getProperty("java.specification.version"); |
| 465 |
2
|
StringTokenizer tokenizer = new StringTokenizer(version,"."); |
| 466 |
2
|
if (tokenizer.nextToken().equals("1")) { |
| 467 |
2
|
String minorVersion = tokenizer.nextToken(); |
| 468 |
2
|
if (minorVersion.equals("0")) return true; |
| 469 |
2
|
if (minorVersion.equals("1")) return true; |
| 470 |
2
|
if (minorVersion.equals("2")) return true; |
| 471 |
2
|
if (minorVersion.equals("3")) return true; |
| 472 |
|
} |
| 473 |
2
|
return false; |
| 474 |
|
} |
| 475 |
|
|
| 476 |
|
|
| 477 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 478 |
|
class TestClassLoader extends ClassLoader { |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 479 |
0
|
public String toString() {... |
| 480 |
0
|
return "TestClassLoader"; |
| 481 |
|
} |
| 482 |
|
} |
| 483 |
|
|
|
|
|
| 91.7% |
Uncovered Elements: 2 (24) |
Complexity: 12 |
Complexity Density: 1 |
|
| 484 |
|
class Signal { |
| 485 |
|
private Exception e; |
| 486 |
|
private int signal = 0; |
| 487 |
|
private BeanUtilsBean bean; |
| 488 |
|
private PropertyUtilsBean propertyUtils; |
| 489 |
|
private ConvertUtilsBean convertUtils; |
| 490 |
|
private Object marker; |
| 491 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 492 |
2
|
public Exception getException() {... |
| 493 |
2
|
return e; |
| 494 |
|
} |
| 495 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 496 |
0
|
public void setException(Exception e) {... |
| 497 |
0
|
this.e = e; |
| 498 |
|
} |
| 499 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 500 |
4
|
public int getSignal() {... |
| 501 |
4
|
return signal; |
| 502 |
|
} |
| 503 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 504 |
8
|
public void setSignal(int signal) {... |
| 505 |
8
|
this.signal = signal; |
| 506 |
|
} |
| 507 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 508 |
1
|
public Object getMarkerObject() {... |
| 509 |
1
|
return marker; |
| 510 |
|
} |
| 511 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 512 |
1
|
public void setMarkerObject(Object marker) {... |
| 513 |
1
|
this.marker = marker; |
| 514 |
|
} |
| 515 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 516 |
2
|
public BeanUtilsBean getBean() {... |
| 517 |
2
|
return bean; |
| 518 |
|
} |
| 519 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 520 |
2
|
public void setBean(BeanUtilsBean bean) {... |
| 521 |
2
|
this.bean = bean; |
| 522 |
|
} |
| 523 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 524 |
1
|
public PropertyUtilsBean getPropertyUtils() {... |
| 525 |
1
|
return propertyUtils; |
| 526 |
|
} |
| 527 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 528 |
1
|
public void setPropertyUtils(PropertyUtilsBean propertyUtils) {... |
| 529 |
1
|
this.propertyUtils = propertyUtils; |
| 530 |
|
} |
| 531 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 532 |
1
|
public ConvertUtilsBean getConvertUtils() {... |
| 533 |
1
|
return convertUtils; |
| 534 |
|
} |
| 535 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 536 |
1
|
public void setConvertUtils(ConvertUtilsBean convertUtils) {... |
| 537 |
1
|
this.convertUtils = convertUtils; |
| 538 |
|
} |
| 539 |
|
} |
| 540 |
|
} |
| 541 |
|
|