1 package org.objectweb.celtix.bus.bindings; 2 3 import java.io.ByteArrayOutputStream ; 4 import java.io.IOException ; 5 import java.io.OutputStream ; 6 import java.net.URL ; 7 8 import javax.xml.ws.handler.MessageContext; 9 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 15 extends MessageContextWrapper 16 implements OutputStreamMessageContext { 17 ByteArrayOutputStream baos; 18 boolean isFaultMsg; 19 20 public TestOutputStreamContext(URL url, MessageContext ctx) throws IOException { 21 super(ctx); 22 } 23 24 void flushHeaders() throws IOException { } 25 26 public void setFault(boolean isFault) { 27 isFaultMsg = isFault; 28 } 29 30 public boolean isFault() { 31 return isFaultMsg; 32 } 33 34 public void setOneWay(boolean isOneWay) { 35 put(ONEWAY_MESSAGE_TF, isOneWay); 36 } 37 38 public boolean isOneWay() { 39 return ((Boolean )get(ONEWAY_MESSAGE_TF)).booleanValue(); 40 } 41 42 public OutputStream getOutputStream() { 43 if (baos == null) { 44 baos = new ByteArrayOutputStream (); 45 } 46 try { 47 baos.flush(); 48 } catch (IOException ioe) { 49 } 51 return baos; 52 } 53 54 public byte[] getOutputStreamBytes() { 55 return baos.toByteArray(); 56 } 57 58 public void setOutputStream(OutputStream o) { } 59 60 public InputStreamMessageContext getCorrespondingInputStreamContext() throws IOException { 61 return new TestInputStreamContext(baos.toByteArray()); 62 } 63 64 65 } 66 | Popular Tags |