1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.tck.testmodels.services; |
12 | |
|
13 | |
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; |
14 | |
import org.apache.commons.logging.Log; |
15 | |
import org.apache.commons.logging.LogFactory; |
16 | |
|
17 | 0 | public class TestComponent implements ITestComponent |
18 | |
{ |
19 | |
public static final String EXCEPTION_MESSAGE = "Test Component fired an Exception"; |
20 | |
|
21 | 0 | protected static final Log logger = LogFactory.getLog(TestComponent.class); |
22 | |
|
23 | 0 | protected AtomicInteger count = new AtomicInteger(0); |
24 | |
|
25 | |
public String receive(String message) throws Exception |
26 | |
{ |
27 | 0 | logger.info("Received: " + message + " number: " + inc() + " in thread: " |
28 | |
+ Thread.currentThread().getName()); |
29 | 0 | return "Received: " + message; |
30 | |
} |
31 | |
|
32 | |
public String receiveBytes(byte[] message) throws Exception |
33 | |
{ |
34 | 0 | return receive(new String(message)); |
35 | |
} |
36 | |
|
37 | |
public String throwsException(String message) throws Exception |
38 | |
{ |
39 | 0 | throw new TestComponentException(EXCEPTION_MESSAGE); |
40 | |
} |
41 | |
|
42 | |
protected int inc() |
43 | |
{ |
44 | 0 | return count.incrementAndGet(); |
45 | |
} |
46 | |
|
47 | |
} |