1 16 package org.apache.axis2.saaj; 17 18 import junit.framework.TestCase; 19 20 import javax.xml.soap.*; 21 import java.io.ByteArrayOutputStream ; 22 23 27 public class PrefixesTest extends TestCase { 28 29 public PrefixesTest(String name) { 30 super(name); 31 } 32 33 public void testAddingPrefixesForChildElements() throws Exception { 34 MessageFactory factory = MessageFactory.newInstance(); 35 SOAPMessage msg = factory.createMessage(); 36 SOAPPart sp = msg.getSOAPPart(); 37 SOAPEnvelope se = sp.getEnvelope(); 38 SOAPBody sb = se.getBody(); 39 SOAPElement el1 = sb.addBodyElement(se.createName 40 ("element1", "prefix1", "http://www.sun.com")); 41 SOAPElement el2 = el1.addChildElement(se.createName 42 ("element2", "prefix2", "http://www.apache.org")); 43 44 org.apache.axis2.soap.SOAPEnvelope omEnv = ((SOAPEnvelopeImpl)se).getOMEnvelope(); 45 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 46 msg.writeTo(baos); 47 48 String xml = new String (baos.toByteArray()); 49 System.out.println(xml); 50 assertTrue(xml.indexOf("prefix1") != -1); 51 assertTrue(xml.indexOf("prefix2") != -1); 52 assertTrue(xml.indexOf("http://www.sun.com") != -1); 53 assertTrue(xml.indexOf("http://www.apache.org") != -1); 54 } 55 56 76 77 } 78 | Popular Tags |