1
2
3
4
5
6
7 package org.mule.config.spring;
8
9 import org.mule.util.concurrent.Latch;
10 import org.mule.api.MuleEventContext;
11
12 import java.lang.reflect.Method;
13
14 import org.springframework.aop.MethodBeforeAdvice;
15 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
16
17 public class FunctionalTestAdvice implements MethodBeforeAdvice
18 {
19
20 private Latch latch = new Latch();
21 private String message;
22
23 public void before(Method method, Object[] args, Object target) throws Throwable
24 {
25 if (null != args && args.length == 1 && args[0] instanceof MuleEventContext)
26 {
27 message = ((MuleEventContext) args[0]).getMessageAsString();
28 }
29 latch.countDown();
30 }
31
32 public String getMessage(long ms) throws InterruptedException
33 {
34 latch.await(ms, TimeUnit.MILLISECONDS);
35 return message;
36 }
37
38 }