01: package org.objectweb.celtix.bus.bindings;
02:
03: import java.io.ByteArrayOutputStream;
04: import java.io.IOException;
05: import java.io.OutputStream;
06: import java.net.URL;
07:
08: import javax.xml.ws.handler.MessageContext;
09:
10: import org.objectweb.celtix.context.InputStreamMessageContext;
11: import org.objectweb.celtix.context.MessageContextWrapper;
12: import org.objectweb.celtix.context.OutputStreamMessageContext;
13:
14: public class TestOutputStreamContext extends MessageContextWrapper
15: implements OutputStreamMessageContext {
16: ByteArrayOutputStream baos;
17: boolean isFaultMsg;
18:
19: public TestOutputStreamContext(URL url, MessageContext ctx)
20: throws IOException {
21: super (ctx);
22: }
23:
24: void flushHeaders() throws IOException {
25: }
26:
27: public void setFault(boolean isFault) {
28: isFaultMsg = isFault;
29: }
30:
31: public boolean isFault() {
32: return isFaultMsg;
33: }
34:
35: public void setOneWay(boolean isOneWay) {
36: put(ONEWAY_MESSAGE_TF, isOneWay);
37: }
38:
39: public boolean isOneWay() {
40: return ((Boolean) get(ONEWAY_MESSAGE_TF)).booleanValue();
41: }
42:
43: public OutputStream getOutputStream() {
44: if (baos == null) {
45: baos = new ByteArrayOutputStream();
46: }
47: try {
48: baos.flush();
49: } catch (IOException ioe) {
50: //to do nothing
51: }
52: return baos;
53: }
54:
55: public byte[] getOutputStreamBytes() {
56: return baos.toByteArray();
57: }
58:
59: public void setOutputStream(OutputStream o) {
60: }
61:
62: public InputStreamMessageContext getCorrespondingInputStreamContext()
63: throws IOException {
64: return new TestInputStreamContext(baos.toByteArray());
65: }
66:
67: }
|