X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fspring%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fconcurrency%2Fspring%2FLockAdviceTest.java;h=ab4e7ad611996bc3259071170cf778fd4912af0c;hb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;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..ab4e7ad6 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,42 +1,34 @@ /* * Copyright 2005 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * 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); + } + } }