1 16 17 package org.apache.axis2.soap; 18 19 import org.apache.axis2.om.AbstractTestCase; 20 import org.apache.axis2.om.OMAbstractFactory; 21 import org.apache.axis2.om.OMFactory; 22 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder; 23 24 import javax.xml.stream.XMLInputFactory; 25 import javax.xml.stream.XMLStreamException; 26 import javax.xml.stream.XMLStreamReader; 27 import java.io.FileNotFoundException ; 28 import java.io.FileReader ; 29 30 public class SOAPTestCase extends AbstractTestCase { 31 protected SOAPFactory soap11Factory; 32 protected SOAPFactory soap12Factory; 33 protected OMFactory omFactory; 34 35 protected SOAPEnvelope soap11Envelope; 36 protected SOAPEnvelope soap12Envelope; 37 38 protected SOAPEnvelope soap11EnvelopeWithParser; 39 protected SOAPEnvelope soap12EnvelopeWithParser; 40 41 protected static final String SOAP11_FILE_NAME = "soap/soap11/soap11message.xml"; 42 protected static final String SOAP12_FILE_NAME = "soap/soap12message.xml"; 43 44 47 public SOAPTestCase(String testName) { 48 super(testName); 49 soap11Factory = OMAbstractFactory.getSOAP11Factory(); 50 soap12Factory = OMAbstractFactory.getSOAP12Factory(); 51 omFactory = OMAbstractFactory.getOMFactory(); 52 } 53 54 protected void setUp() throws Exception { 55 super.setUp(); 56 57 soap11Envelope = soap11Factory.createSOAPEnvelope(); 58 soap12Envelope = soap12Factory.createSOAPEnvelope(); 59 60 soap11EnvelopeWithParser = (SOAPEnvelope)this.getSOAPBuilder(SOAP11_FILE_NAME).getDocumentElement(); 61 soap12EnvelopeWithParser = (SOAPEnvelope)this.getSOAPBuilder(SOAP12_FILE_NAME).getDocumentElement(); 62 } 63 64 protected StAXSOAPModelBuilder getSOAPBuilder(String fileName) { 65 XMLStreamReader parser = null; 66 try { 67 parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader (getTestResourceFile(fileName))); 68 } catch (XMLStreamException e) { 69 e.printStackTrace(); 70 } catch (FileNotFoundException e) { 71 e.printStackTrace(); 72 } 73 return new StAXSOAPModelBuilder(parser); 74 } 75 76 } 77 | Popular Tags |