FileDocCategorySizeDatePackage
TestSOAPEnvelope.javaAPI DocApache Axis 1.44383Sat Apr 22 18:57:28 BST 2006test.message

TestSOAPEnvelope

public class TestSOAPEnvelope extends junit.framework.TestCase
Test SOAPEnvelope class.
author
Glyn Normington (glyn@apache.org)

Fields Summary
Constructors Summary
public TestSOAPEnvelope(String name)

        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        TestSOAPEnvelope tester = new TestSOAPEnvelope("TestSOAPEnvelope");
        tester.testNullpointer();
        tester.testNullpointerInHeader();
    
public voidtestBody()

        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        SOAPBody b1 = env.getBody();
        assertTrue("null initial body", b1 != null);
        b1.detachNode();
        assertTrue("body not freed", env.getBody() == null);
        SOAPBody b2 = env.addBody();
        assertTrue("null created body", b2 != null);
        assertEquals("wrong body retrieved", b2, env.getBody());
        assertEquals("body parent incorrect", env, b2.getParentElement());
        try {
            env.addBody();
            assertTrue("second body added", false);
        } catch (SOAPException e) {
        }
    
public voidtestHeader()

        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        SOAPHeader h1 = env.getHeader();
        assertTrue("null initial header", h1 != null);
        h1.detachNode();
        assertTrue("header not freed", env.getHeader() == null);
        SOAPHeader h2 = env.addHeader();
        assertTrue("null created header", h2 != null);
        assertEquals("wrong header retrieved", h2, env.getHeader());
        assertEquals("header parent incorrect", env, h2.getParentElement());
        try {
            env.addHeader();
            assertTrue("second header added", false);
        } catch (SOAPException e) {
        }
    
public voidtestName()

        SOAPEnvelope env = new org.apache.axis.message.SOAPEnvelope();
        Name n = env.createName("local", "pref", "urn:blah");
        assertEquals("local part of name did not match", "local",
                     n.getLocalName());
        assertEquals("qname of name did not match", "pref:local",
                     n.getQualifiedName());
        assertEquals("prefix of name did not match", "pref",
                     n.getPrefix());
        assertEquals("uri of name did not match", "urn:blah",
                     n.getURI());
        Name n2 = env.createName("loc");
        assertEquals("local part of name2 did not match", "loc",
                     n2.getLocalName());
    
public voidtestNullpointer()

		org.apache.axis.message.SOAPEnvelope env=new org.apache.axis.message.SOAPEnvelope();
		SOAPBodyElement bdy=new SOAPBodyElement();
		bdy.setName("testResponse");
		env.addBodyElement(bdy);
		Message msg=new Message(env);
		SOAPBodyElement sbe = msg.getSOAPEnvelope().getBodyByName(null,"testResponse");
        assertTrue(sbe != null);
	
public voidtestNullpointerInHeader()

		org.apache.axis.message.SOAPEnvelope env=new org.apache.axis.message.SOAPEnvelope();
		SOAPHeaderElement hdr=new SOAPHeaderElement("", "testHeader");
		env.addHeader(hdr);
		Message msg=new Message(env);
		SOAPHeaderElement she = msg.getSOAPEnvelope().getHeaderByName(null,"testHeader");
        assertTrue(she != null);