1
2
3
4
5
6
7 package org.mule.tck.functional;
8
9 import org.mule.api.MuleEventContext;
10
11
12
13
14
15
16
17
18
19
20 public class ResponseWriterCallback extends CounterCallback
21 {
22 @Override
23 public void eventReceived(MuleEventContext context, Object component) throws Exception
24 {
25 if (context.getExchangePattern().hasResponse())
26 {
27 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");
28 }
29 super.eventReceived(context, component);
30
31 String result = context.getMessageAsString() + " Received Async";
32 if (context.getOutputStream() == null)
33 {
34 throw new IllegalArgumentException("event context does not have an OutputStream associated");
35 }
36
37 context.getOutputStream().write(result.getBytes());
38 context.getOutputStream().flush();
39 }
40 }