axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ven...@apache.org
Subject svn commit: r165003 - in /webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj: ./ bin/ src/java/javax/xml/soap/ src/java/org/apache/axis/saaj/ src/test/org/apache/axis/saaj/
Date Wed, 27 Apr 2005 16:09:46 GMT
Author: venkat
Date: Wed Apr 27 09:09:45 2005
New Revision: 165003

URL: http://svn.apache.org/viewcvs?rev=165003&view=rev
Log:
Adding files for SAAJ implementation over OM - from Ashutosh.
This check has some test cases. Thanks Ashu !

Added:
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFactoryImpl.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestHeaders.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestPrefixes.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestSOAPElement.java
Removed:
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/bin/
Modified:
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPFactory.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java
    webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java

Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath?rev=165003&r1=165002&r2=165003&view=diff
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath Wed Apr 27
09:09:45 2005
@@ -3,20 +3,11 @@
 	<classpathentry kind="src" path="src/java"/>
 	<classpathentry kind="src" path="src/test"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/stax-api-1.0.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-core-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-deployment-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-http-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-mail-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-om-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-Samples-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-Tools-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-wsdl-M1.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/commons-fileupload-1.0.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/commons-logging-1.0.3.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/log4j-1.2.8.jar"/>
-	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/stax-1.1.1-dev.jar"/>
 	<classpathentry kind="lib" path="C:/Apache/ws-axis/java/lib/mailapi_1_3_1.jar"/>
 	<classpathentry kind="lib" path="C:/Apache/ws-axis/java/lib/activation.jar"/>
+	<classpathentry kind="lib" path="C:/Apache/ws-axis/java/lib/junit.jar"/>
+	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/stax-1.1.1-dev.jar"/>
+	<classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/stax-api-1.0.jar"/>
+	<classpathentry kind="src" path="/Axis2"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt?rev=165003&r1=165002&r2=165003&view=diff
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt Wed Apr 27
09:09:45 2005
@@ -19,6 +19,10 @@
 13th April 2005
 
 Fixed some bugs related to NullPointerException. Provided test cases to check correctness
of SOAP
-Envelope and SOAP body.
+Envelope
+
+27th April
+Added some more code for some functions and more test cases for soapbody, header, element,
prefixes etc
+
 
 Ashutosh Shahi

Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPFactory.java?rev=165003&r1=165002&r2=165003&view=diff
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPFactory.java
(original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPFactory.java
Wed Apr 27 09:09:45 2005
@@ -143,5 +143,5 @@
     private static final String SF_PROPERTY = "javax.xml.soap.SOAPFactory";
 
     private static final String DEFAULT_SF =
-        "org.apache.axis.soap.SOAPFactoryImpl";
+        "org.apache.axis.saaj.SOAPFactoryImpl";
 }

Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java?rev=165003&r1=165002&r2=165003&view=diff
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java
(original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java
Wed Apr 27 09:09:45 2005
@@ -37,7 +37,8 @@
 	public SOAPMessage createMessage(MimeHeaders mimeheaders,
 			InputStream inputstream) throws IOException, SOAPException {
 		// TODO Auto-generated method stub
-		return null;
+		SOAPMessageImpl message = new SOAPMessageImpl(inputstream, false,mimeheaders);
+		return message;
 	}
 
 }

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFactoryImpl.java?rev=165003&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFactoryImpl.java
(added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFactoryImpl.java
Wed Apr 27 09:09:45 2005
@@ -0,0 +1,75 @@
+/*
+ * Created on Apr 27, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import javax.xml.soap.Detail;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+
+/**
+ * @author shaas02
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SOAPFactoryImpl extends javax.xml.soap.SOAPFactory {
+
+	/* (non-Javadoc)
+	 * @see javax.xml.soap.SOAPFactory#createElement(javax.xml.soap.Name)
+	 */
+	public SOAPElement createElement(Name name) throws SOAPException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String)
+	 */
+	public SOAPElement createElement(String localName) throws SOAPException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.soap.SOAPFactory#createElement(java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public SOAPElement createElement(String localName, String prefix, String uri)
+			throws SOAPException {
+		OMElement newOMElement = OMFactory.newInstance().createOMElement(localName, uri, prefix);
+		return new SOAPElementImpl(newOMElement);
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.soap.SOAPFactory#createDetail()
+	 */
+	public Detail createDetail() throws SOAPException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.soap.SOAPFactory#createName(java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public Name createName(String localName, String prefix, String uri)
+			throws SOAPException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see javax.xml.soap.SOAPFactory#createName(java.lang.String)
+	 */
+	public Name createName(String localName) throws SOAPException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java?rev=165003&r1=165002&r2=165003&view=diff
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java
(original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java
Wed Apr 27 09:09:45 2005
@@ -16,6 +16,8 @@
 import javax.xml.soap.SOAPPart;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPHeader;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axis.transport.http.HTTPConstants;
 
@@ -32,12 +34,24 @@
     private MimeHeaders headers;
 
 	public SOAPMessageImpl(Object initialContents){
+		try{
 		setup(initialContents, false, null, null, null);
+		} catch(SOAPException e){
+			e.printStackTrace();
+		}
 	}
 	
+    public SOAPMessageImpl(Object initialContents, boolean bodyInStream, javax.xml.soap.MimeHeaders
headers) {
+    	try{
+    	setup(initialContents, bodyInStream, null, null, (MimeHeaders)headers);
+		} catch(SOAPException e){
+			e.printStackTrace();
+		}   	
+    }
+	
 	private void setup(Object initialContents, boolean bodyInStream,
 			String contentType, String contentLocation,
-			MimeHeaders mimeHeaders){
+			MimeHeaders mimeHeaders)throws SOAPException{
 		if(null == mSOAPPart)
 			mSOAPPart = new SOAPPartImpl(this, initialContents, bodyInStream);
 		else
@@ -171,8 +185,13 @@
 	 * @see javax.xml.soap.SOAPMessage#writeTo(java.io.OutputStream)
 	 */
 	public void writeTo(OutputStream out) throws SOAPException, IOException {
-		// TODO Auto-generated method stub
-
+		try{
+		XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+		((SOAPEnvelopeImpl)mSOAPPart.getEnvelope()).getOMEnvelope().serialize(writer, true);
+		writer.flush();
+		} catch(Exception e){
+			throw new SOAPException(e);
+		}
 	}
 
 }

Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java?rev=165003&r1=165002&r2=165003&view=diff
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java
(original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java
Wed Apr 27 09:09:45 2005
@@ -6,6 +6,8 @@
  */
 package org.apache.axis.saaj;
 
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.util.Iterator;
 
 import javax.xml.soap.MimeHeaders;
@@ -14,6 +16,10 @@
 import javax.xml.soap.SOAPPart;
 import javax.xml.transform.Source;
 
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import org.apache.axis.om.impl.llom.builder.StAXSOAPModelBuilder;
+
 import org.apache.axis.transport.http.HTTPConstants;
 import org.apache.axis.util.SessionUtils;
 import org.w3c.dom.Attr;
@@ -48,15 +54,28 @@
      */
     private String currentEncoding = "UTF-8";
 	
-	public SOAPPartImpl(SOAPMessageImpl parent, Object initialContents, boolean isBodyStream){
+	public SOAPPartImpl(SOAPMessageImpl parent, Object initialContents, boolean isBodyStream)
throws SOAPException{
 		
         setMimeHeader(HTTPConstants.HEADER_CONTENT_ID , SessionUtils.generateSessionId());
         setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE , "text/xml");
+        StAXSOAPModelBuilder stAXSOAPModelBuilder;
         
         msgObject = parent;
-        if(initialContents instanceof SOAPEnvelope){
-        	((SOAPEnvelopeImpl)initialContents).setOwnerDocument(this);
-        	envelope = initialContents;
+        try{
+        	if(initialContents instanceof SOAPEnvelope){
+        		((SOAPEnvelopeImpl)initialContents).setOwnerDocument(this);
+        		envelope = initialContents;
+        	} else if(initialContents instanceof InputStream){
+        		//XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader((InputStream)initialContents);
+        		InputStreamReader inr = new InputStreamReader((InputStream)initialContents);
+        		stAXSOAPModelBuilder = new StAXSOAPModelBuilder(XMLInputFactory.newInstance().createXMLStreamReader(inr));
+        		org.apache.axis.om.SOAPEnvelope omEnv = stAXSOAPModelBuilder.getSOAPEnvelope();
+        		envelope = new SOAPEnvelopeImpl(omEnv);
+        		((SOAPEnvelopeImpl)envelope).setOwnerDocument(this);
+        	}
+        
+        }catch(Exception e){
+        	throw new SOAPException(e);
         }
 	}
 	

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestHeaders.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestHeaders.java?rev=165003&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestHeaders.java
(added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestHeaders.java
Wed Apr 27 09:09:45 2005
@@ -0,0 +1,57 @@
+/*
+ * Created on Apr 15, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class TestHeaders extends TestCase {
+	
+    private final String actor = "ACTOR#1";
+    private final String localName = "Local1";
+    private final String namespace = "http://ws.apache.org";
+    private final String prefix = "P1";
+	
+    public TestHeaders(String name) {
+        super(name);
+    }
+    
+    public void testAddingHeaderElements() throws Exception {
+        javax.xml.soap.SOAPMessage soapMessage = javax.xml.soap.MessageFactory.newInstance().createMessage();
+        javax.xml.soap.SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
+        javax.xml.soap.SOAPHeader header = soapEnv.getHeader();
+        header.addChildElement("ebxmlms");
+        
+        /*ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        soapMessage.writeTo(baos);
+        String xml = new String(baos.toByteArray());
+        assertTrue(xml.indexOf("ebxmlms") != -1);*/
+        
+        Iterator it = header.getChildElements();
+        boolean b = false;
+        while(it.hasNext()){
+            SOAPElement el = (SOAPElement) it.next();
+            String lName = el.getNodeName();
+            if(lName.equalsIgnoreCase("ebxmlms")){
+            	b = true;
+            	break;
+            }
+        }
+        assertTrue(b);
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestPrefixes.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestPrefixes.java?rev=165003&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestPrefixes.java
(added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestPrefixes.java
Wed Apr 27 09:09:45 2005
@@ -0,0 +1,77 @@
+/*
+ * Created on Apr 26, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+
+/**
+ * @author Ashutosh Shahi
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class TestPrefixes extends TestCase {
+	
+    public TestPrefixes(String name) {
+        super(name);
+    }
+    
+    public void testAddingPrefixesForChildElements() throws Exception {
+    	MessageFactory factory = MessageFactory.newInstance();
+    	SOAPMessage msg = factory.createMessage();
+    	SOAPPart sp = msg.getSOAPPart();
+    	SOAPEnvelope se = sp.getEnvelope();
+    	SOAPBody sb = se.getBody();
+        SOAPElement el1 = sb.addBodyElement(se.createName
+                ("element1", "prefix1", "http://www.sun.com"));
+        SOAPElement el2 = el1.addChildElement(se.createName
+                ("element2", "prefix2", "http://www.apache.org"));
+        
+        org.apache.axis.om.SOAPEnvelope omEnv = ((SOAPEnvelopeImpl)se).getOMEnvelope();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        msg.writeTo(baos);
+        
+        String xml = new String(baos.toByteArray());
+        System.out.println(xml);
+        assertTrue(xml.indexOf("prefix1") != -1);
+        assertTrue(xml.indexOf("prefix2") != -1);
+        assertTrue(xml.indexOf("http://www.sun.com") != -1);
+        assertTrue(xml.indexOf("http://www.apache.org") != -1);
+    }
+    
+    public void testAttribute() throws Exception {
+        String soappacket = "<SOAP-ENV:Envelope xmlns:SOAP-ENV =\"http://schemas.xmlsoap.org/soap/envelope/\""
+ 
+                            "xmlns:xsi =\"http://www.w3.org/1999/XMLSchema-instance\"" +
+                            "xmlns:xsd =\"http://www.w3.org/1999/XMLSchema\">" + 
+                            "<SOAP-ENV:Body>" +
+                            "<helloworld name=\"tester\" />" + 
+                            "</SOAP-ENV:Body>" +
+                            "</SOAP-ENV:Envelope>";
+        SOAPMessage msg = MessageFactory.newInstance().createMessage(new MimeHeaders(), new
ByteArrayInputStream(soappacket.getBytes()));
+        SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();
+        msg.writeTo(System.out);
+
+        SOAPElement ele = (SOAPElement) body.getChildElements().next();
+        java.util.Iterator attit = ele.getAllAttributes();
+
+        System.out.println(attit.next().getClass());
+        
+        //javax.xml.soap.Name n = (javax.xml.soap.Name) attit.next();
+        //assertEquals("Test fail prefix problem",n.getQualifiedName(),"name");
+    }
+
+}

Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestSOAPElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestSOAPElement.java?rev=165003&view=auto
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestSOAPElement.java
(added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestSOAPElement.java
Wed Apr 27 09:09:45 2005
@@ -0,0 +1,57 @@
+/*
+ * Created on Apr 27, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.SOAPElement;
+import java.util.List;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com	
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class TestSOAPElement extends TestCase {
+	
+	private SOAPElement soapElem;
+	
+    protected void setUp() throws Exception
+    {
+        soapElem = SOAPFactoryImpl.newInstance().createElement( "Test", "test", "http://test.apache.org/"
);
+    }
+
+    public void testAddTextNode() throws Exception
+    {
+        assertNotNull( soapElem );
+        final String value = "foo";
+        soapElem.addTextNode( value );
+        assertEquals( value, soapElem.getValue() );
+        TextImpl text = assertContainsText( soapElem );
+        assertEquals( value, text.getValue() );
+    }
+
+    private TextImpl assertContainsText( SOAPElement soapElem ){
+    	assertTrue( soapElem.hasChildNodes() );
+    	List childElems = toList( soapElem.getChildElements() );
+    	assertTrue( childElems.size() == 1 );
+    	NodeImpl node = (NodeImpl) childElems.get( 0 );
+    	assertTrue( node instanceof TextImpl );
+    	return (TextImpl) node;
+    }
+    
+    private List toList( java.util.Iterator iter )
+    {
+        List list = new java.util.ArrayList();
+        while ( iter.hasNext() )
+        {
+            list.add( iter.next() );
+        }
+        return list;
+    }
+}



Mime
View raw message