1 16 package org.apache.axis2.om; 17 18 import org.apache.axis2.soap.SOAPBody; 19 import org.apache.axis2.soap.SOAPEnvelope; 20 import org.apache.axis2.soap.SOAPHeader; 21 import org.apache.axis2.soap.impl.llom.SOAPProcessingException; 22 23 public class OMEnvelopeTest extends OMTestCase { 24 public OMEnvelopeTest(String testName) { 25 super(testName); 26 } 27 28 protected void setUp() throws Exception { 29 super.setUp(); 30 } 31 32 public void testGetHeader1() { 33 SOAPHeader header = soapEnvelope.getHeader(); 34 assertTrue("Header information retrieved not correct", (header != null && header.getLocalName().equalsIgnoreCase("Header"))); 35 } 36 37 public void testGetBody1() { 38 SOAPBody body = soapEnvelope.getBody(); 39 assertTrue("Header information retrieved not correct", (body != null && body.getLocalName().equalsIgnoreCase("Body"))); 40 } 41 42 private SOAPEnvelope getSecondEnvelope() throws Exception { 43 return (SOAPEnvelope) OMTestUtils.getOMBuilder(getTestResourceFile("soap/sample1.xml")).getDocumentElement(); 44 } 45 46 public void testGetHeader2() throws Exception { 47 SOAPHeader header = getSecondEnvelope().getHeader(); 48 assertTrue("Header information retrieved not correct", (header != null && header.getLocalName().equalsIgnoreCase("Header"))); 49 } 50 51 public void testGetBody2() throws Exception { 52 SOAPBody body = getSecondEnvelope().getBody(); 53 assertTrue("Header information retrieved not correct", (body != null && body.getLocalName().equalsIgnoreCase("Body"))); 54 } 55 56 public void testDefaultEnveleope() { 57 SOAPEnvelope env = null; 58 try { 59 env = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); 60 } catch (SOAPProcessingException e) { 61 e.printStackTrace(); 62 fail(e.getMessage()); 63 } 64 assertNotNull(env); 65 assertNotNull("Header should not be null", env.getHeader()); 66 assertNotNull("Body should not be null", env.getBody()); 67 68 } 69 70 } 71 | Popular Tags |