2 * Copyright 2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.wamblee.concurrency;
19 import org.springframework.aop.framework.ProxyFactoryBean;
20 import org.wamblee.test.TimingUtils;
25 public class LockAdviceTest extends AbstractLockTestCase {
27 private class Runner implements Runnable {
29 LockAdviceTest.this.getTracker().eventOccurred(ACQUIRED);
30 TimingUtils.sleep(SLEEP_TIME);
34 private Runnable _target;
39 * @see org.wamblee.concurrency.AbstractLockTestCase#setUp()
42 protected void setUp() throws Exception {
45 Runner runner = new Runner();
46 LockAdvice advice = new LockAdvice(new JvmLock());
48 ProxyFactoryBean support = new ProxyFactoryBean();
49 support.setInterfaces(new Class[]{ Runnable.class });
50 support.setTarget(runner);
51 support.addAdvice(advice);
52 _target = (Runnable)support.getObject();
59 * @see org.wamblee.concurrency.AbstractLockTestCase#runThread()
62 protected Thread runThread() {
63 Thread t = new Thread(new Runnable() {
66 getTracker().eventOccurred(STARTED);
68 getTracker().eventOccurred(RELEASED);
69 } catch (Throwable e) {
70 throw new RuntimeException(e);