1 16 package org.apache.axis2.om; 17 18 import org.apache.axis2.soap.SOAPEnvelope; 19 import org.apache.axis2.soap.SOAPFactory; 20 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder; 21 22 import javax.xml.stream.*; 23 import java.io.FileReader ; 24 import java.io.InputStream ; 25 import java.io.OutputStream ; 26 27 public abstract class OMTestCase extends AbstractTestCase { 28 protected static final String IN_FILE_NAME = "soap/soapmessage.xml"; 29 protected StAXSOAPModelBuilder builder; 30 protected OMFactory ombuilderFactory; 31 protected SOAPFactory soapFactory; 32 33 protected SOAPEnvelope soapEnvelope; 34 35 public OMTestCase(String testName) { 36 super(testName); 37 ombuilderFactory = OMAbstractFactory.getOMFactory(); 38 soapFactory = OMAbstractFactory.getSOAP11Factory(); 39 } 40 41 protected void setUp() throws Exception { 42 super.setUp(); 43 soapEnvelope = (SOAPEnvelope) getOMBuilder("").getDocumentElement(); 44 } 45 46 protected StAXSOAPModelBuilder getOMBuilder(String fileName) throws Exception { 47 if (fileName == "" || fileName == null) { 48 fileName = IN_FILE_NAME; 49 } 50 XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader (getTestResourceFile(fileName))); 51 builder = new StAXSOAPModelBuilder(parser); 52 return builder; 53 } 54 55 protected StAXSOAPModelBuilder getOMBuilder(InputStream in) throws Exception { 56 XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in); 57 builder = new StAXSOAPModelBuilder(parser); 58 return builder; 59 } 60 61 protected XMLStreamWriter getStAXStreamWriter(OutputStream out) throws XMLStreamException { 62 return XMLOutputFactory.newInstance().createXMLStreamWriter(out); 63 } 64 65 66 } 67 | Popular Tags |