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