X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fspring%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fconcurrency%2Fspring%2FLockAdviceTest.java;h=e2fc216e8a551e2de312eca3a1b0a387cf0817ab;hb=17775e14ecfb286e59f67117e5cee7e21e95ab1f;hp=b56beacd9c9e7f1c4872a7957566758700d26fad;hpb=6baa1546bf990db7c66e9837bbb23f1070bf81e0;p=utils diff --git a/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java b/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java index b56beacd..e2fc216e 100644 --- a/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java +++ b/support/spring/src/test/java/org/wamblee/concurrency/spring/LockAdviceTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2005 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,31 +12,23 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - + */ package org.wamblee.concurrency.spring; import org.springframework.aop.framework.ProxyFactoryBean; + import org.wamblee.concurrency.AbstractLockTestCase; import org.wamblee.concurrency.JvmLock; import org.wamblee.concurrency.spring.LockAdvice; + import org.wamblee.test.TimingUtils; /** * - * * @author Erik Brakkee */ public class LockAdviceTest extends AbstractLockTestCase { - - private class Runner implements Runnable { - public void run() { - LockAdviceTest.this.getTracker().eventOccurred(ACQUIRED); - TimingUtils.sleep(SLEEP_TIME); - } - } - - private Runnable _target; + private Runnable target; /* * (non-Javadoc) @@ -46,16 +38,15 @@ public class LockAdviceTest extends AbstractLockTestCase { @Override protected void setUp() throws Exception { super.setUp(); - + Runner runner = new Runner(); LockAdvice advice = new LockAdvice(new JvmLock()); - + ProxyFactoryBean support = new ProxyFactoryBean(); - support.setInterfaces(new Class[]{ Runnable.class }); + support.setInterfaces(new Class[] { Runnable.class }); support.setTarget(runner); support.addAdvice(advice); - _target = (Runnable)support.getObject(); - + target = (Runnable) support.getObject(); } /* @@ -69,7 +60,7 @@ public class LockAdviceTest extends AbstractLockTestCase { public void run() { try { getTracker().eventOccurred(STARTED); - _target.run(); + target.run(); getTracker().eventOccurred(RELEASED); } catch (Throwable e) { throw new RuntimeException(e); @@ -77,7 +68,14 @@ public class LockAdviceTest extends AbstractLockTestCase { }; }); t.start(); + return t; } + private class Runner implements Runnable { + public void run() { + LockAdviceTest.this.getTracker().eventOccurred(ACQUIRED); + TimingUtils.sleep(SLEEP_TIME); + } + } }