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 java.lang.reflect.Method;
20 import java.util.ArrayList;
22 import org.aopalliance.intercept.MethodInvocation;
23 import org.springframework.aop.framework.AdvisedSupport;
24 import org.springframework.aop.framework.ProxyFactoryBean;
25 import org.springframework.aop.framework.ReflectiveMethodInvocation;
26 import org.wamblee.test.TimingUtils;
31 public class LockAdviceTest extends AbstractLockTestCase {
33 private class Runner implements Runnable {
35 LockAdviceTest.this.getTracker().eventOccurred(ACQUIRED);
36 TimingUtils.sleep(SLEEP_TIME);
40 private Runnable _target;
45 * @see org.wamblee.concurrency.AbstractLockTestCase#setUp()
48 protected void setUp() throws Exception {
51 Runner runner = new Runner();
52 LockAdvice advice = new LockAdvice(new JvmLock());
54 ProxyFactoryBean support = new ProxyFactoryBean();
55 support.setInterfaces(new Class[]{ Runnable.class });
56 support.setTarget(runner);
57 support.addAdvice(advice);
58 _target = (Runnable)support.getObject();
65 * @see org.wamblee.concurrency.AbstractLockTestCase#runThread()
68 protected Thread runThread() {
69 Thread t = new Thread(new Runnable() {
72 getTracker().eventOccurred(STARTED);
74 getTracker().eventOccurred(RELEASED);
75 } catch (Throwable e) {
76 throw new RuntimeException(e);