1
2
3
4
5
6
7
8
9
10 package org.mule.tck.functional;
11
12 import org.mule.api.MuleEventContext;
13
14
15
16
17
18
19
20
21
22
23 public class ResponseWriterCallback extends CounterCallback
24 {
25
26 public void eventReceived(MuleEventContext context, Object component) throws Exception
27 {
28 if (context.isSynchronous())
29 {
30 throw new IllegalStateException("The ResponseWriterCallback should not be used for synchronous tests as it will cause two copies of the message to be written back to the client");
31 }
32 super.eventReceived(context, component);
33
34 String result = context.getMessageAsString() + " Received Async";
35 if (context.getOutputStream() == null)
36 {
37 throw new IllegalArgumentException("event context does not have an OutputStream associated");
38 }
39
40 context.getOutputStream().write(result.getBytes());
41 context.getOutputStream().flush();
42 }
43
44 }