You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC

svn commit: r289289 [92/134] - in /webservices/axis2/trunk/java: ./ etc/ modules/addressing/ modules/addressing/src/META-INF/ modules/addressing/src/org/apache/axis2/handlers/addressing/ modules/addressing/test-resources/ modules/addressing/test/org/ap...

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/IOUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/IOUtils.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/IOUtils.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/IOUtils.java Thu Sep 15 11:52:11 2005
@@ -1,63 +1,63 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Utility class containing IO helper methods
- */
-public class IOUtils {
-    private IOUtils() {
-    }
-
-    /**
-     * Read into a byte array; tries to ensure that the the
-     * full buffer is read.
-     * <p/>
-     * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
-     *
-     * @see #readFully(java.io.InputStream, byte[], int, int)
-     */
-    public static int readFully(InputStream in, byte[] b)
-            throws IOException {
-        return readFully(in, b, 0, b.length);
-    }
-
-    /**
-     * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure that
-     * the entire len number of bytes is read.
-     * <p/>
-     *
-     * @returns the number of bytes read, or -1 if the end of file is
-     * reached before any bytes are read
-     */
-    public static int readFully(InputStream in, byte[] b, int off, int len)
-            throws IOException {
-        int total = 0;
-        for (; ;) {
-            int got = in.read(b, off + total, len - total);
-            if (got < 0) {
-                return (total == 0) ? -1 : total;
-            } else {
-                total += got;
-                if (total == len)
-                    return total;
-            }
-        }
-    }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Utility class containing IO helper methods
+ */
+public class IOUtils {
+    private IOUtils() {
+    }
+
+    /**
+     * Read into a byte array; tries to ensure that the the
+     * full buffer is read.
+     * <p/>
+     * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
+     *
+     * @see #readFully(java.io.InputStream, byte[], int, int)
+     */
+    public static int readFully(InputStream in, byte[] b)
+            throws IOException {
+        return readFully(in, b, 0, b.length);
+    }
+
+    /**
+     * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure that
+     * the entire len number of bytes is read.
+     * <p/>
+     *
+     * @returns the number of bytes read, or -1 if the end of file is
+     * reached before any bytes are read
+     */
+    public static int readFully(InputStream in, byte[] b, int off, int len)
+            throws IOException {
+        int total = 0;
+        for (; ;) {
+            int got = in.read(b, off + total, len - total);
+            if (got < 0) {
+                return (total == 0) ? -1 : total;
+            } else {
+                total += got;
+                if (total == len)
+                    return total;
+            }
+        }
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/IOUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/SessionUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/SessionUtils.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/SessionUtils.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/SessionUtils.java Thu Sep 15 11:52:11 2005
@@ -1,108 +1,108 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.util;
-
-import java.util.Random;
-
-/**
- * Code borrowed from AuthenticatorBase.java for generating a secure id's.
- */
-public class SessionUtils {
-
-    /**
-     * The number of random bytes to include when generating a
-     * session identifier.
-     */
-    protected static final int SESSION_ID_BYTES = 16;
-
-    /**
-     * A random number generator to use when generating session identifiers.
-     */
-    protected static Random random = null;
-
-    /**
-     * The Java class name of the random number generator class to be used
-     * when generating session identifiers.
-     */
-    protected static String randomClass = "java.security.SecureRandom";
-
-    /**
-     * Host name/ip.
-     */
-    private static String thisHost = null;
-
-    /**
-     * Generate and return a new session identifier.
-     *
-     * @return a new session id
-     */
-    public static synchronized String generateSessionId() {
-        // Generate a byte array containing a session identifier
-        byte bytes[] = new byte[SESSION_ID_BYTES];
-
-        getRandom().nextBytes(bytes);
-
-        // Render the result as a String of hexadecimal digits
-        StringBuffer result = new StringBuffer();
-
-        for (int i = 0; i < bytes.length; i++) {
-            byte b1 = (byte) ((bytes[i] & 0xf0) >> 4);
-            byte b2 = (byte) (bytes[i] & 0x0f);
-
-            if (b1 < 10) {
-                result.append((char) ('0' + b1));
-            } else {
-                result.append((char) ('A' + (b1 - 10)));
-            }
-            if (b2 < 10) {
-                result.append((char) ('0' + b2));
-            } else {
-                result.append((char) ('A' + (b2 - 10)));
-            }
-        }
-        return (result.toString());
-    }
-
-    /**
-     * Generate and return a new session identifier.
-     *
-     * @return a new session.
-     */
-    public static synchronized Long generateSession() {
-        return new Long(getRandom().nextLong());
-    }
-
-    /**
-     * Return the random number generator instance we should use for
-     * generating session identifiers.  If there is no such generator
-     * currently defined, construct and seed a new one.
-     *
-     * @return Random object
-     */
-    private static synchronized Random getRandom() {
-        if (random == null) {
-            try {
-                Class clazz = Class.forName(randomClass);
-                random = (Random) clazz.newInstance();
-            } catch (Exception e) {
-                random = new java.util.Random();
-            }
-        }
-        return (random);
-    }
-
-}
-
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.util;
+
+import java.util.Random;
+
+/**
+ * Code borrowed from AuthenticatorBase.java for generating a secure id's.
+ */
+public class SessionUtils {
+
+    /**
+     * The number of random bytes to include when generating a
+     * session identifier.
+     */
+    protected static final int SESSION_ID_BYTES = 16;
+
+    /**
+     * A random number generator to use when generating session identifiers.
+     */
+    protected static Random random = null;
+
+    /**
+     * The Java class name of the random number generator class to be used
+     * when generating session identifiers.
+     */
+    protected static String randomClass = "java.security.SecureRandom";
+
+    /**
+     * Host name/ip.
+     */
+    private static String thisHost = null;
+
+    /**
+     * Generate and return a new session identifier.
+     *
+     * @return a new session id
+     */
+    public static synchronized String generateSessionId() {
+        // Generate a byte array containing a session identifier
+        byte bytes[] = new byte[SESSION_ID_BYTES];
+
+        getRandom().nextBytes(bytes);
+
+        // Render the result as a String of hexadecimal digits
+        StringBuffer result = new StringBuffer();
+
+        for (int i = 0; i < bytes.length; i++) {
+            byte b1 = (byte) ((bytes[i] & 0xf0) >> 4);
+            byte b2 = (byte) (bytes[i] & 0x0f);
+
+            if (b1 < 10) {
+                result.append((char) ('0' + b1));
+            } else {
+                result.append((char) ('A' + (b1 - 10)));
+            }
+            if (b2 < 10) {
+                result.append((char) ('0' + b2));
+            } else {
+                result.append((char) ('A' + (b2 - 10)));
+            }
+        }
+        return (result.toString());
+    }
+
+    /**
+     * Generate and return a new session identifier.
+     *
+     * @return a new session.
+     */
+    public static synchronized Long generateSession() {
+        return new Long(getRandom().nextLong());
+    }
+
+    /**
+     * Return the random number generator instance we should use for
+     * generating session identifiers.  If there is no such generator
+     * currently defined, construct and seed a new one.
+     *
+     * @return Random object
+     */
+    private static synchronized Random getRandom() {
+        if (random == null) {
+            try {
+                Class clazz = Class.forName(randomClass);
+                random = (Random) clazz.newInstance();
+            } catch (Exception e) {
+                random = new java.util.Random();
+            }
+        }
+        return (random);
+    }
+
+}
+

Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/SessionUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/XMLUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/XMLUtils.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/XMLUtils.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/XMLUtils.java Thu Sep 15 11:52:11 2005
@@ -1,65 +1,65 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.util;
-
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Some XML utility functions
- */
-public class XMLUtils {
-
-    /**
-     * Get an empty new Document
-     *
-     * @return Document
-     * @throws ParserConfigurationException if construction problems occur
-     */
-    public static Document newDocument()
-            throws ParserConfigurationException {
-        DocumentBuilder db = null;
-
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        dbf.setNamespaceAware(true);
-        db = dbf.newDocumentBuilder();
-        return db.newDocument();
-    }
-
-    /**
-     * Method newDocument
-     *
-     * @param in
-     * @return
-     * @throws ParserConfigurationException
-     * @throws SAXException
-     * @throws IOException
-     */
-    public static Document newDocument(InputStream in)
-            throws ParserConfigurationException, SAXException, IOException {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        dbf.setNamespaceAware(true);
-        DocumentBuilder db = dbf.newDocumentBuilder();
-        return db.parse(in);
-    }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.util;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Some XML utility functions
+ */
+public class XMLUtils {
+
+    /**
+     * Get an empty new Document
+     *
+     * @return Document
+     * @throws ParserConfigurationException if construction problems occur
+     */
+    public static Document newDocument()
+            throws ParserConfigurationException {
+        DocumentBuilder db = null;
+
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        db = dbf.newDocumentBuilder();
+        return db.newDocument();
+    }
+
+    /**
+     * Method newDocument
+     *
+     * @param in
+     * @return
+     * @throws ParserConfigurationException
+     * @throws SAXException
+     * @throws IOException
+     */
+    public static Document newDocument(InputStream in)
+            throws ParserConfigurationException, SAXException, IOException {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        return db.parse(in);
+    }
+
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/util/XMLUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java Thu Sep 15 11:52:11 2005
@@ -1,94 +1,94 @@
-package org.apache.axis2.saaj;
-
-import junit.framework.TestCase;
-
-import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
-import javax.xml.soap.*;
-import javax.xml.soap.MimeHeaders;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-public class AttachmentSerializationTest extends TestCase {
-
-    public AttachmentSerializationTest(String name) {
-        super(name);
-    }
-
-    public static void main(String args[]) throws Exception {
-        AttachmentSerializationTest tester = new AttachmentSerializationTest("tester");
-        tester.testAttachments();
-    }
-
-    public void testAttachments() throws Exception {
-        try {
-            ByteArrayOutputStream bais = new ByteArrayOutputStream();
-            int count = saveMsgWithAttachments(bais);
-            assertEquals(count, 2);
-        } catch (Exception e) {
-            throw new Exception("Fault returned from test: " + e);
-        }
-    }
-
-    public static final String MIME_MULTIPART_RELATED = "multipart/related";
-    public static final String MIME_APPLICATION_DIME = "application/dime";
-    public static final String NS_PREFIX = "jaxmtst";
-    public static final String NS_URI = "http://www.jcommerce.net/soap/jaxm/TestJaxm";
-
-    public int saveMsgWithAttachments(OutputStream os) throws Exception {
-        MessageFactory mf = MessageFactory.newInstance();
-        SOAPMessage msg = mf.createMessage();
-
-        SOAPPart sp = msg.getSOAPPart();
-        SOAPEnvelope envelope = sp.getEnvelope();
-        SOAPHeader header = envelope.getHeader();
-        SOAPBody body = envelope.getBody();
-
-        SOAPElement el = header.addHeaderElement(envelope.createName("field4", NS_PREFIX, NS_URI));
-        SOAPElement el2 = el.addChildElement("field4b", NS_PREFIX);
-        SOAPElement el3 = el2.addTextNode("field4value");
-
-        el = body.addBodyElement(envelope.createName("bodyfield3", NS_PREFIX, NS_URI));
-        el2 = el.addChildElement("bodyfield3a", NS_PREFIX);
-        el2.addTextNode("bodyvalue3a");
-        el2 = el.addChildElement("bodyfield3b", NS_PREFIX);
-        el2.addTextNode("bodyvalue3b");
-        el2 = el.addChildElement("datefield", NS_PREFIX);
-
-        AttachmentPart ap = msg.createAttachmentPart();
-        ap.setContent("some attachment text...", "text/plain");
-        msg.addAttachmentPart(ap);
-
-        String jpgfilename = "./test-resources/axis.jpg";
-        File myfile = new File(jpgfilename);
-        FileDataSource fds = new FileDataSource(myfile);
-        DataHandler dh = new DataHandler(fds);
-        AttachmentPart ap2 = msg.createAttachmentPart(dh);
-        ap2.setContentType("image/jpg");
-        msg.addAttachmentPart(ap2);
-
-        MimeHeaders headers = msg.getMimeHeaders();
-        assertTrue(headers != null);
-        String [] contentType = headers.getHeader("Content-Type");  
-        assertTrue(contentType != null);
-        
-        msg.writeTo(os);
-        os.flush();
-        msg.writeTo(System.out);
-        return msg.countAttachments();
-    }
-
-    public int loadMsgWithAttachments(InputStream is) throws Exception {
-        MimeHeaders headers = new MimeHeaders();
-        headers.setHeader("Content-Type", MIME_MULTIPART_RELATED);
-        MessageFactory mf = MessageFactory.newInstance();
-        SOAPMessage msg = mf.createMessage(headers, is);
-        SOAPPart sp = msg.getSOAPPart();
-        SOAPEnvelope envelope = sp.getEnvelope();
-        assertTrue(sp != null);
-        assertTrue(envelope != null);
-        return msg.countAttachments();
-    }
-}
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.xml.soap.*;
+import javax.xml.soap.MimeHeaders;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class AttachmentSerializationTest extends TestCase {
+
+    public AttachmentSerializationTest(String name) {
+        super(name);
+    }
+
+    public static void main(String args[]) throws Exception {
+        AttachmentSerializationTest tester = new AttachmentSerializationTest("tester");
+        tester.testAttachments();
+    }
+
+    public void testAttachments() throws Exception {
+        try {
+            ByteArrayOutputStream bais = new ByteArrayOutputStream();
+            int count = saveMsgWithAttachments(bais);
+            assertEquals(count, 2);
+        } catch (Exception e) {
+            throw new Exception("Fault returned from test: " + e);
+        }
+    }
+
+    public static final String MIME_MULTIPART_RELATED = "multipart/related";
+    public static final String MIME_APPLICATION_DIME = "application/dime";
+    public static final String NS_PREFIX = "jaxmtst";
+    public static final String NS_URI = "http://www.jcommerce.net/soap/jaxm/TestJaxm";
+
+    public int saveMsgWithAttachments(OutputStream os) throws Exception {
+        MessageFactory mf = MessageFactory.newInstance();
+        SOAPMessage msg = mf.createMessage();
+
+        SOAPPart sp = msg.getSOAPPart();
+        SOAPEnvelope envelope = sp.getEnvelope();
+        SOAPHeader header = envelope.getHeader();
+        SOAPBody body = envelope.getBody();
+
+        SOAPElement el = header.addHeaderElement(envelope.createName("field4", NS_PREFIX, NS_URI));
+        SOAPElement el2 = el.addChildElement("field4b", NS_PREFIX);
+        SOAPElement el3 = el2.addTextNode("field4value");
+
+        el = body.addBodyElement(envelope.createName("bodyfield3", NS_PREFIX, NS_URI));
+        el2 = el.addChildElement("bodyfield3a", NS_PREFIX);
+        el2.addTextNode("bodyvalue3a");
+        el2 = el.addChildElement("bodyfield3b", NS_PREFIX);
+        el2.addTextNode("bodyvalue3b");
+        el2 = el.addChildElement("datefield", NS_PREFIX);
+
+        AttachmentPart ap = msg.createAttachmentPart();
+        ap.setContent("some attachment text...", "text/plain");
+        msg.addAttachmentPart(ap);
+
+        String jpgfilename = "./test-resources/axis.jpg";
+        File myfile = new File(jpgfilename);
+        FileDataSource fds = new FileDataSource(myfile);
+        DataHandler dh = new DataHandler(fds);
+        AttachmentPart ap2 = msg.createAttachmentPart(dh);
+        ap2.setContentType("image/jpg");
+        msg.addAttachmentPart(ap2);
+
+        MimeHeaders headers = msg.getMimeHeaders();
+        assertTrue(headers != null);
+        String [] contentType = headers.getHeader("Content-Type");  
+        assertTrue(contentType != null);
+        
+        msg.writeTo(os);
+        os.flush();
+        msg.writeTo(System.out);
+        return msg.countAttachments();
+    }
+
+    public int loadMsgWithAttachments(InputStream is) throws Exception {
+        MimeHeaders headers = new MimeHeaders();
+        headers.setHeader("Content-Type", MIME_MULTIPART_RELATED);
+        MessageFactory mf = MessageFactory.newInstance();
+        SOAPMessage msg = mf.createMessage(headers, is);
+        SOAPPart sp = msg.getSOAPPart();
+        SOAPEnvelope envelope = sp.getEnvelope();
+        assertTrue(sp != null);
+        assertTrue(envelope != null);
+        return msg.countAttachments();
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentSerializationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java Thu Sep 15 11:52:11 2005
@@ -1,128 +1,128 @@
-package org.apache.axis2.saaj;
-
-import javax.xml.soap.AttachmentPart;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPConnectionFactory;
-import javax.xml.soap.SOAPMessage;
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.ByteArrayInputStream;
-
-import junit.framework.TestCase;
-
-public class AttachmentTest extends TestCase {
-
-    public AttachmentTest(String name) {
-        super(name);
-    }
-    
-    public void testStringAttachment() throws Exception {
-    	SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
-    	SOAPConnection con = scFactory.createConnection();
-    	
-    	MessageFactory factory = MessageFactory.newInstance();
-    	SOAPMessage message = factory.createMessage();
-    	AttachmentPart attachment = message.createAttachmentPart();
-    	String stringContent = "Update address for Sunny Skies " +
-    			"Inc., to 10 Upbeat Street, Pleasant Grove, CA 95439";
-    	
-    	attachment.setContent(stringContent, "text/plain");
-    	attachment.setContentId("update_address");
-    	message.addAttachmentPart(attachment);
-    	
-    	assertTrue(message.countAttachments()==1);
-    	
-    	java.util.Iterator it = message.getAttachments();
-    	while (it.hasNext()) {
-    		attachment = (AttachmentPart) it.next();
-    		Object content = attachment.getContent();
-    		String id = attachment.getContentId();
-    		System.out.println("Attachment " + id + " contains: " + content);
-    		assertEquals(content,stringContent);
-    	}
-    	System.out.println("Here is what the XML message looks like:");
-    	message.writeTo(System.out);
-    	
-    	message.removeAllAttachments();
-    	assertTrue(message.countAttachments()==0);
-    }
-    
-    public void testMultipleAttachments() throws Exception {
-        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
-        SOAPConnection con = scFactory.createConnection();
-
-        MessageFactory factory = MessageFactory.newInstance();
-        SOAPMessage msg = factory.createMessage();
-        java.net.URL url1 = new java.net.URL("http://slashdot.org/slashdot.xml");
-        java.net.URL url2 = new java.net.URL("http://www.apache.org/LICENSE.txt");
-
-        AttachmentPart a1 = msg.createAttachmentPart(new javax.activation.DataHandler(url1));
-        a1.setContentType("text/xml");
-        msg.addAttachmentPart(a1);
-        AttachmentPart a2 = msg.createAttachmentPart(new javax.activation.DataHandler(url1));
-        a2.setContentType("text/xml");
-        msg.addAttachmentPart(a2);
-        AttachmentPart a3 = msg.createAttachmentPart(new javax.activation.DataHandler(url2));
-        a3.setContentType("text/plain");
-        msg.addAttachmentPart(a3);
-
-        assertTrue(msg.countAttachments()==3);
-
-        javax.xml.soap.MimeHeaders mimeHeaders = new javax.xml.soap.MimeHeaders();
-        mimeHeaders.addHeader("Content-Type", "text/xml");
-
-        int nAttachments = 0;
-        java.util.Iterator iterator = msg.getAttachments(mimeHeaders);
-	    while (iterator.hasNext()) {
-            nAttachments++;
-	        AttachmentPart ap = (AttachmentPart)iterator.next();
-	        assertTrue(ap.equals(a1) || ap.equals(a2));
-	    }
-        assertTrue(nAttachments==2);
-    }
-    
-    public void testBadAttSize() throws Exception {
-        MessageFactory factory = MessageFactory.newInstance();
-        SOAPMessage message = factory.createMessage();
-
-        ByteArrayInputStream ins=new ByteArrayInputStream(new byte[5]);
-        DataHandler dh=new DataHandler(new Src(ins,"text/plain"));
-        AttachmentPart part = message.createAttachmentPart(dh);
-        assertEquals("Size should match",5,part.getSize());
-    }
-
-    class Src implements DataSource{
-        InputStream m_src;
-        String m_type;
-
-        public Src(InputStream data, String type){
-            m_src=data;
-            m_type=type;
-        }
-        public String getContentType(){
-            return m_type;
-        }
-        public InputStream getInputStream() throws IOException{
-            m_src.reset();
-            return m_src;
-        }
-        public String getName(){
-            return "Some-Data";
-        }
-        public OutputStream getOutputStream(){
-            throw new UnsupportedOperationException("I don't give output streams");
-        }
-    }
-    
-    public static void main(String[] args) throws Exception {
-        AttachmentTest tester = new AttachmentTest("TestSAAJ");
-        tester.testMultipleAttachments();
-        tester.testStringAttachment();
-        tester.testBadAttSize();
-    }
-
-}
+package org.apache.axis2.saaj;
+
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPMessage;
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ByteArrayInputStream;
+
+import junit.framework.TestCase;
+
+public class AttachmentTest extends TestCase {
+
+    public AttachmentTest(String name) {
+        super(name);
+    }
+    
+    public void testStringAttachment() throws Exception {
+    	SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
+    	SOAPConnection con = scFactory.createConnection();
+    	
+    	MessageFactory factory = MessageFactory.newInstance();
+    	SOAPMessage message = factory.createMessage();
+    	AttachmentPart attachment = message.createAttachmentPart();
+    	String stringContent = "Update address for Sunny Skies " +
+    			"Inc., to 10 Upbeat Street, Pleasant Grove, CA 95439";
+    	
+    	attachment.setContent(stringContent, "text/plain");
+    	attachment.setContentId("update_address");
+    	message.addAttachmentPart(attachment);
+    	
+    	assertTrue(message.countAttachments()==1);
+    	
+    	java.util.Iterator it = message.getAttachments();
+    	while (it.hasNext()) {
+    		attachment = (AttachmentPart) it.next();
+    		Object content = attachment.getContent();
+    		String id = attachment.getContentId();
+    		System.out.println("Attachment " + id + " contains: " + content);
+    		assertEquals(content,stringContent);
+    	}
+    	System.out.println("Here is what the XML message looks like:");
+    	message.writeTo(System.out);
+    	
+    	message.removeAllAttachments();
+    	assertTrue(message.countAttachments()==0);
+    }
+    
+    public void testMultipleAttachments() throws Exception {
+        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
+        SOAPConnection con = scFactory.createConnection();
+
+        MessageFactory factory = MessageFactory.newInstance();
+        SOAPMessage msg = factory.createMessage();
+        java.net.URL url1 = new java.net.URL("http://slashdot.org/slashdot.xml");
+        java.net.URL url2 = new java.net.URL("http://www.apache.org/LICENSE.txt");
+
+        AttachmentPart a1 = msg.createAttachmentPart(new javax.activation.DataHandler(url1));
+        a1.setContentType("text/xml");
+        msg.addAttachmentPart(a1);
+        AttachmentPart a2 = msg.createAttachmentPart(new javax.activation.DataHandler(url1));
+        a2.setContentType("text/xml");
+        msg.addAttachmentPart(a2);
+        AttachmentPart a3 = msg.createAttachmentPart(new javax.activation.DataHandler(url2));
+        a3.setContentType("text/plain");
+        msg.addAttachmentPart(a3);
+
+        assertTrue(msg.countAttachments()==3);
+
+        javax.xml.soap.MimeHeaders mimeHeaders = new javax.xml.soap.MimeHeaders();
+        mimeHeaders.addHeader("Content-Type", "text/xml");
+
+        int nAttachments = 0;
+        java.util.Iterator iterator = msg.getAttachments(mimeHeaders);
+	    while (iterator.hasNext()) {
+            nAttachments++;
+	        AttachmentPart ap = (AttachmentPart)iterator.next();
+	        assertTrue(ap.equals(a1) || ap.equals(a2));
+	    }
+        assertTrue(nAttachments==2);
+    }
+    
+    public void testBadAttSize() throws Exception {
+        MessageFactory factory = MessageFactory.newInstance();
+        SOAPMessage message = factory.createMessage();
+
+        ByteArrayInputStream ins=new ByteArrayInputStream(new byte[5]);
+        DataHandler dh=new DataHandler(new Src(ins,"text/plain"));
+        AttachmentPart part = message.createAttachmentPart(dh);
+        assertEquals("Size should match",5,part.getSize());
+    }
+
+    class Src implements DataSource{
+        InputStream m_src;
+        String m_type;
+
+        public Src(InputStream data, String type){
+            m_src=data;
+            m_type=type;
+        }
+        public String getContentType(){
+            return m_type;
+        }
+        public InputStream getInputStream() throws IOException{
+            m_src.reset();
+            return m_src;
+        }
+        public String getName(){
+            return "Some-Data";
+        }
+        public OutputStream getOutputStream(){
+            throw new UnsupportedOperationException("I don't give output streams");
+        }
+    }
+    
+    public static void main(String[] args) throws Exception {
+        AttachmentTest tester = new AttachmentTest("TestSAAJ");
+        tester.testMultipleAttachments();
+        tester.testStringAttachment();
+        tester.testBadAttSize();
+    }
+
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/AttachmentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java Thu Sep 15 11:52:11 2005
@@ -1,243 +1,243 @@
-package org.apache.axis2.saaj;
-
-import junit.framework.TestCase;
-
-import javax.xml.soap.*;
-import javax.xml.soap.MimeHeaders;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
-
-public class EnvelopeTest extends TestCase {
-	
-    public EnvelopeTest(String name) {
-        super(name);
-    }
-
-    String xmlString =
-        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
-        "                   xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
-        "                   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
-        " <soapenv:Header>\n" +
-        "  <shw:Hello xmlns:shw=\"http://www.jcommerce.net/soap/ns/SOAPHelloWorld\">\n" +
-        "    <shw:Myname>Tony</shw:Myname>\n" +
-        "  </shw:Hello>\n" +
-        " </soapenv:Header>\n" +
-        " <soapenv:Body>\n" +
-        "  <shw:Address xmlns:shw=\"http://www.jcommerce.net/soap/ns/SOAPHelloWorld\">\n" +
-        "    <shw:City>GENT</shw:City>\n" +
-        "  </shw:Address>\n" +
-        " </soapenv:Body>\n" +
-        "</soapenv:Envelope>";
-    
-   public void testEnvelope() throws Exception{
-    	MessageFactory mf = MessageFactory.newInstance();
-    	SOAPMessage smsg = 
-    		mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
-    	SOAPPart sp = smsg.getSOAPPart();
-    	SOAPEnvelope se = sp.getEnvelope();
-    	//smsg.writeTo(System.out);
-    	assertTrue(se != null);
-    }
-    
-    public void testEnvelope2() throws Exception{
-    	MessageFactory mf = MessageFactory.newInstance();
-    	SOAPMessage smsg =
-    		mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
-        //It seems that the aim of this writing is to completely build the object tree. The
-        smsg.writeTo(System.out);
-
-        SOAPEnvelope envelope = smsg.getSOAPPart().getEnvelope();
-
-        SOAPBody body = envelope.getBody();
-    	assertTrue(body != null);
-    }
-  
-    
-    public void testEnvelopeWithLeadingComment() throws Exception {
-    	String soapMessageWithLeadingComment =
-    		"<?xml version='1.0' encoding='UTF-8'?>" + 
-    		"<!-- Comment -->" +
-			"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
-			"<env:Body><echo><arg0>Hello</arg0></echo></env:Body>" +
-			"</env:Envelope>";
-    	
-    	SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
-    	SOAPConnection con = scFactory.createConnection();
-    	
-    	MessageFactory factory = MessageFactory.newInstance();
-    	SOAPMessage message =
-    		factory.createMessage(new MimeHeaders(),
-    				new ByteArrayInputStream(soapMessageWithLeadingComment.getBytes()));
-    	SOAPPart part = message.getSOAPPart();
-    	SOAPEnvelope envelope = part.getEnvelope();
-    	message.writeTo(System.out);
-    	assertTrue(envelope != null);
-    }
-    
-    
-    private SOAPEnvelope getSOAPEnvelope() throws Exception {
-        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
-        SOAPConnection con = scFactory.createConnection();
-
-        MessageFactory factory = MessageFactory.newInstance();
-        SOAPMessage message = factory.createMessage();
-        return message.getSOAPPart().getEnvelope();
-    }
-    
-    public void testFaults() throws Exception {
-        SOAPEnvelope envelope = getSOAPEnvelope();
-        SOAPBody body = envelope.getBody();
-        SOAPFault sf = body.addFault();
-        //sf.setFaultCode("myFault");
-        //String fc = sf.getFaultCode();
-        sf.setFaultString("myFault");
-        String fc = sf.getFaultString(); //Chk the same for FaultCode as well
-        							// currently not done in SAAJ
-        assertTrue(fc.equals("myFault"));
-    }
-    
-    private int getIteratorCount(java.util.Iterator i) {
-        int count = 0;
-        while (i.hasNext()) {
-            count++;
-            i.next();
-        }
-        return count;
-    }
-    
-    public void testFaults2() throws Exception {
-    
-    	SOAPEnvelope envelope = getSOAPEnvelope();
-    	SOAPBody body = envelope.getBody();
-    	SOAPFault sf = body.addFault();
-    	
-    	assertTrue(body.getFault() != null);
-    	
-    	Detail d1 = sf.addDetail();
-    	Name name = envelope.createName("GetLastTradePrice", "WOMBAT",
-    	"http://www.wombat.org/trader");
-    	d1.addDetailEntry(name);
-    	
-    	Detail d2 = sf.getDetail();
-    	assertTrue(d2 != null);
-    	Iterator i = d2.getDetailEntries();
-    	assertTrue(getIteratorCount(i) == 1);
-    	i = d2.getDetailEntries();
-    	//message.writeTo(System.out);
-    	while(i.hasNext()) {
-    		DetailEntry de = (DetailEntry)i.next();
-    		assertEquals(de.getElementName(),name);
-    	}
-    }
-    
-    public void testHeaderElements() throws Exception {
-    	SOAPEnvelope envelope = getSOAPEnvelope();
-    	SOAPBody body = envelope.getBody();
-    	SOAPHeader hdr = envelope.getHeader();
-
-    	SOAPHeaderElement she1 = hdr.addHeaderElement(envelope.createName("foo1", "f1", "foo1-URI"));
-    	she1.setActor("actor-URI");
-    	java.util.Iterator iterator = hdr.extractHeaderElements("actor-URI");
-    	int cnt = 0;
-    	while (iterator.hasNext()) {
-    		cnt++;
-    		SOAPHeaderElement she = (SOAPHeaderElement) iterator.next();
-    		assertTrue(she.equals(she1));
-    	}
-    	assertTrue(cnt == 1);
-    	iterator = hdr.extractHeaderElements("actor-URI");
-    	assertTrue(!iterator.hasNext());
-    }
-    
-    public void testText1() throws Exception {
-    	SOAPEnvelope envelope = getSOAPEnvelope();
-    	SOAPBody body = envelope.getBody();
-     	Iterator iStart = body.getChildElements();
-    	int countStart = getIteratorCount(iStart);
-    	SOAPElement se = body.addTextNode("<txt>This is text</txt>");
-    	assertTrue(se != null);
-    	assertTrue(body.getValue().equals("<txt>This is text</txt>"));
-    	Iterator i = body.getChildElements();
-    	int count = getIteratorCount(i);
-    	assertTrue(count == countStart + 1);
-    }
-    
-    public void testText2() throws Exception {
-    	SOAPEnvelope envelope = getSOAPEnvelope();
-    	SOAPBody body = envelope.getBody();
-    	SOAPElement se = body.addTextNode("This is text");
-    	Iterator iterator = se.getChildElements();
-    	Node n = null;
-    	while (iterator.hasNext()) {
-    		n = (Node)iterator.next();
-    		if (n instanceof Text){
-    			break;
-    		}
-    	}
-    	assertTrue(n instanceof Text);
-    	Text t = (Text)n;
-    	assertTrue(!t.isComment());
-    }
-    
-    public void testText3() throws Exception {
-    	SOAPEnvelope envelope = getSOAPEnvelope();
-    	SOAPBody body = envelope.getBody();
-    	SOAPElement se = body.addTextNode("<!-- This is a comment -->");
-    	Iterator iterator = se.getChildElements();
-    	Node n = null;
-    	while (iterator.hasNext()) {
-    		n = (Node)iterator.next();
-    		if (n instanceof Text)
-    			break;
-    	}
-    	assertTrue(n instanceof Text);
-    	Text t = (Text)n;
-    	assertTrue(t.isComment());
-    }
-    
-    public void testAttributes() throws Exception {
-    	SOAPEnvelope envelope = getSOAPEnvelope();
-    	SOAPBody body = envelope.getBody();
-    	
-    	Name name1 = envelope.createName("MyAttr1");
-    	String value1 = "MyValue1";
-    	Name name2 = envelope.createName("MyAttr2");
-    	String value2 = "MyValue2";
-    	Name name3 = envelope.createName("MyAttr3");
-    	String value3 = "MyValue3";
-    	body.addAttribute(name1, value1);
-    	body.addAttribute(name2, value2);
-    	body.addAttribute(name3, value3);
-    	java.util.Iterator iterator = body.getAllAttributes();
-    	assertTrue(getIteratorCount(iterator) == 3);
-    	iterator = body.getAllAttributes();
-    	boolean foundName1 = false;
-    	boolean foundName2 = false;
-    	boolean foundName3 = false;
-    	while (iterator.hasNext()) {
-    		Name name = (Name) iterator.next();
-    		if (name.equals(name1))
-    			foundName1 = true;
-    		else if (name.equals(name2))
-    			foundName2 = true;
-    		else if (name.equals(name3))
-    			foundName3 = true;
-    	}
-    }
-    
-    public static void main(String[] args) throws Exception {
-    	EnvelopeTest tester = new EnvelopeTest("EnvelopeTest");
-    	tester.testEnvelope();
-    	tester.testEnvelope2();
-    	tester.testFaults();
-    	tester.testFaults2();
-//    	tester.testHeaderElements();
-    	tester.testText1();
-    	tester.testText2();
-    	tester.testText3();
-    	tester.testAttributes();
-    	tester.testEnvelopeWithLeadingComment();
-    }
-}
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.*;
+import javax.xml.soap.MimeHeaders;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+
+public class EnvelopeTest extends TestCase {
+	
+    public EnvelopeTest(String name) {
+        super(name);
+    }
+
+    String xmlString =
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
+        "                   xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
+        "                   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+        " <soapenv:Header>\n" +
+        "  <shw:Hello xmlns:shw=\"http://www.jcommerce.net/soap/ns/SOAPHelloWorld\">\n" +
+        "    <shw:Myname>Tony</shw:Myname>\n" +
+        "  </shw:Hello>\n" +
+        " </soapenv:Header>\n" +
+        " <soapenv:Body>\n" +
+        "  <shw:Address xmlns:shw=\"http://www.jcommerce.net/soap/ns/SOAPHelloWorld\">\n" +
+        "    <shw:City>GENT</shw:City>\n" +
+        "  </shw:Address>\n" +
+        " </soapenv:Body>\n" +
+        "</soapenv:Envelope>";
+    
+   public void testEnvelope() throws Exception{
+    	MessageFactory mf = MessageFactory.newInstance();
+    	SOAPMessage smsg = 
+    		mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
+    	SOAPPart sp = smsg.getSOAPPart();
+    	SOAPEnvelope se = sp.getEnvelope();
+    	//smsg.writeTo(System.out);
+    	assertTrue(se != null);
+    }
+    
+    public void testEnvelope2() throws Exception{
+    	MessageFactory mf = MessageFactory.newInstance();
+    	SOAPMessage smsg =
+    		mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
+        //It seems that the aim of this writing is to completely build the object tree. The
+        smsg.writeTo(System.out);
+
+        SOAPEnvelope envelope = smsg.getSOAPPart().getEnvelope();
+
+        SOAPBody body = envelope.getBody();
+    	assertTrue(body != null);
+    }
+  
+    
+    public void testEnvelopeWithLeadingComment() throws Exception {
+    	String soapMessageWithLeadingComment =
+    		"<?xml version='1.0' encoding='UTF-8'?>" + 
+    		"<!-- Comment -->" +
+			"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+			"<env:Body><echo><arg0>Hello</arg0></echo></env:Body>" +
+			"</env:Envelope>";
+    	
+    	SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
+    	SOAPConnection con = scFactory.createConnection();
+    	
+    	MessageFactory factory = MessageFactory.newInstance();
+    	SOAPMessage message =
+    		factory.createMessage(new MimeHeaders(),
+    				new ByteArrayInputStream(soapMessageWithLeadingComment.getBytes()));
+    	SOAPPart part = message.getSOAPPart();
+    	SOAPEnvelope envelope = part.getEnvelope();
+    	message.writeTo(System.out);
+    	assertTrue(envelope != null);
+    }
+    
+    
+    private SOAPEnvelope getSOAPEnvelope() throws Exception {
+        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
+        SOAPConnection con = scFactory.createConnection();
+
+        MessageFactory factory = MessageFactory.newInstance();
+        SOAPMessage message = factory.createMessage();
+        return message.getSOAPPart().getEnvelope();
+    }
+    
+    public void testFaults() throws Exception {
+        SOAPEnvelope envelope = getSOAPEnvelope();
+        SOAPBody body = envelope.getBody();
+        SOAPFault sf = body.addFault();
+        //sf.setFaultCode("myFault");
+        //String fc = sf.getFaultCode();
+        sf.setFaultString("myFault");
+        String fc = sf.getFaultString(); //Chk the same for FaultCode as well
+        							// currently not done in SAAJ
+        assertTrue(fc.equals("myFault"));
+    }
+    
+    private int getIteratorCount(java.util.Iterator i) {
+        int count = 0;
+        while (i.hasNext()) {
+            count++;
+            i.next();
+        }
+        return count;
+    }
+    
+    public void testFaults2() throws Exception {
+    
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPFault sf = body.addFault();
+    	
+    	assertTrue(body.getFault() != null);
+    	
+    	Detail d1 = sf.addDetail();
+    	Name name = envelope.createName("GetLastTradePrice", "WOMBAT",
+    	"http://www.wombat.org/trader");
+    	d1.addDetailEntry(name);
+    	
+    	Detail d2 = sf.getDetail();
+    	assertTrue(d2 != null);
+    	Iterator i = d2.getDetailEntries();
+    	assertTrue(getIteratorCount(i) == 1);
+    	i = d2.getDetailEntries();
+    	//message.writeTo(System.out);
+    	while(i.hasNext()) {
+    		DetailEntry de = (DetailEntry)i.next();
+    		assertEquals(de.getElementName(),name);
+    	}
+    }
+    
+    public void testHeaderElements() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPHeader hdr = envelope.getHeader();
+
+    	SOAPHeaderElement she1 = hdr.addHeaderElement(envelope.createName("foo1", "f1", "foo1-URI"));
+    	she1.setActor("actor-URI");
+    	java.util.Iterator iterator = hdr.extractHeaderElements("actor-URI");
+    	int cnt = 0;
+    	while (iterator.hasNext()) {
+    		cnt++;
+    		SOAPHeaderElement she = (SOAPHeaderElement) iterator.next();
+    		assertTrue(she.equals(she1));
+    	}
+    	assertTrue(cnt == 1);
+    	iterator = hdr.extractHeaderElements("actor-URI");
+    	assertTrue(!iterator.hasNext());
+    }
+    
+    public void testText1() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+     	Iterator iStart = body.getChildElements();
+    	int countStart = getIteratorCount(iStart);
+    	SOAPElement se = body.addTextNode("<txt>This is text</txt>");
+    	assertTrue(se != null);
+    	assertTrue(body.getValue().equals("<txt>This is text</txt>"));
+    	Iterator i = body.getChildElements();
+    	int count = getIteratorCount(i);
+    	assertTrue(count == countStart + 1);
+    }
+    
+    public void testText2() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPElement se = body.addTextNode("This is text");
+    	Iterator iterator = se.getChildElements();
+    	Node n = null;
+    	while (iterator.hasNext()) {
+    		n = (Node)iterator.next();
+    		if (n instanceof Text){
+    			break;
+    		}
+    	}
+    	assertTrue(n instanceof Text);
+    	Text t = (Text)n;
+    	assertTrue(!t.isComment());
+    }
+    
+    public void testText3() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPElement se = body.addTextNode("<!-- This is a comment -->");
+    	Iterator iterator = se.getChildElements();
+    	Node n = null;
+    	while (iterator.hasNext()) {
+    		n = (Node)iterator.next();
+    		if (n instanceof Text)
+    			break;
+    	}
+    	assertTrue(n instanceof Text);
+    	Text t = (Text)n;
+    	assertTrue(t.isComment());
+    }
+    
+    public void testAttributes() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	
+    	Name name1 = envelope.createName("MyAttr1");
+    	String value1 = "MyValue1";
+    	Name name2 = envelope.createName("MyAttr2");
+    	String value2 = "MyValue2";
+    	Name name3 = envelope.createName("MyAttr3");
+    	String value3 = "MyValue3";
+    	body.addAttribute(name1, value1);
+    	body.addAttribute(name2, value2);
+    	body.addAttribute(name3, value3);
+    	java.util.Iterator iterator = body.getAllAttributes();
+    	assertTrue(getIteratorCount(iterator) == 3);
+    	iterator = body.getAllAttributes();
+    	boolean foundName1 = false;
+    	boolean foundName2 = false;
+    	boolean foundName3 = false;
+    	while (iterator.hasNext()) {
+    		Name name = (Name) iterator.next();
+    		if (name.equals(name1))
+    			foundName1 = true;
+    		else if (name.equals(name2))
+    			foundName2 = true;
+    		else if (name.equals(name3))
+    			foundName3 = true;
+    	}
+    }
+    
+    public static void main(String[] args) throws Exception {
+    	EnvelopeTest tester = new EnvelopeTest("EnvelopeTest");
+    	tester.testEnvelope();
+    	tester.testEnvelope2();
+    	tester.testFaults();
+    	tester.testFaults2();
+//    	tester.testHeaderElements();
+    	tester.testText1();
+    	tester.testText2();
+    	tester.testText3();
+    	tester.testAttributes();
+    	tester.testEnvelopeWithLeadingComment();
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/HeadersTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/HeadersTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/HeadersTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/HeadersTest.java Thu Sep 15 11:52:11 2005
@@ -1,63 +1,63 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import junit.framework.TestCase;
-
-import javax.xml.soap.SOAPElement;
-import java.util.Iterator;
-
-/**
- * @author Ashutosh Shahi ashutosh.shahi@gmail.com
- */
-public class HeadersTest 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 HeadersTest(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);
-    }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.SOAPElement;
+import java.util.Iterator;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ */
+public class HeadersTest 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 HeadersTest(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);
+    }
+
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/HeadersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/JUnitTestAttachmentIntegration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/JUnitTestAttachmentIntegration.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/JUnitTestAttachmentIntegration.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/JUnitTestAttachmentIntegration.java Thu Sep 15 11:52:11 2005
@@ -1,88 +1,88 @@
-package org.apache.axis2.saaj;
-
-import junit.framework.TestCase;
-import org.apache.axis2.attachments.utils.ImageDataSource;
-
-import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
-import javax.xml.soap.*;
-import java.awt.Image;
-import java.awt.Toolkit;
-import java.io.File;
-import java.util.Iterator;
-//import javax.activation.FileDataSource;
-
-public class JUnitTestAttachmentIntegration extends TestCase {
-	
-    public JUnitTestAttachmentIntegration(String name) {
-        super(name);
-    }
-    
-    public static void main(String args[]) throws Exception {
-    	JUnitTestAttachmentIntegration tester = new JUnitTestAttachmentIntegration("tester");
-        testSendReceive();
-    }
-
-	public static void testSendReceive() throws Exception{
-		MessageFactory mf = MessageFactory.newInstance();
-		SOAPMessage message = mf.createMessage();
-		
-		//create the SOAPPart
-		createSOAPPart(message);
-		
-		//Attach a text/plain object with the SOAP message
-		String sampleMessage = "Sample Message: Hello World!";
-		AttachmentPart textAttach = message.createAttachmentPart(sampleMessage,"text/plain");
-		textAttach.addMimeHeader("Content-Transfer-Encoding", "binary");
-		textAttach.setContentId("submitSampleText@apache.org");
-		message.addAttachmentPart(textAttach);
-		
-		//Attach a java.awt.Image object to the SOAP message
-        String jpgfilename = "./test-resources/axis.jpg";
-        File myfile = new File(jpgfilename);
-        FileDataSource fds = new FileDataSource(myfile);
-		DataHandler imageDH = new DataHandler(fds);
-		AttachmentPart jpegAttach = message.createAttachmentPart(imageDH);
-		jpegAttach.addMimeHeader("Content-Transfer-Encoding", "binary");
-		jpegAttach.setContentId("submitSampleImage@apache.org");
-		message.addAttachmentPart(jpegAttach);
-		
-		SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
-		
-		SOAPMessage sMsg =  sCon.call(message,"http://localhost:8080/axis2/services/Echo");
-		int attachmentCount = sMsg.countAttachments();
-		assertTrue(attachmentCount == 2);
-
-		Iterator attachIter = sMsg.getAttachments();		
-		//Of the two attachments first should be of type text/plain and 
-		//second of content-type image/jpeg
-		
-		//Underlying MTOM is converting all contentTypes to application/octet-stream
-		//Thats something to be fixed, I guess. Till then commenting out
-		//these two asserts
-		/*
-		AttachmentPart ap1 = (AttachmentPart)attachIter.next();
-		assertTrue(ap1.getContentType().equals("text/plain"));
-		AttachmentPart ap2 = (AttachmentPart)attachIter.next();
-		assertTrue(ap2.getContentType().equals("image/jpeg"));
-		*/
-	}
-	
-	private static void createSOAPPart(SOAPMessage message) throws SOAPException {
-		SOAPPart sPart = message.getSOAPPart();
-		SOAPEnvelope env = sPart.getEnvelope();
-		SOAPBody body = env.getBody();
-		
-		Name ns = env.createName("echo","swa","http://fakeNamespace.org");
-		SOAPBodyElement sbe = body.addBodyElement(ns);
-		
-		Name ns2 = env.createName("text");
-		SOAPElement textReference = sbe.addChildElement(ns2);
-		Name hrefAttr = env.createName("href");
-		textReference.addAttribute(hrefAttr, "cid:submitSampleText@apache.org");
-		
-		Name ns3 = env.createName("image");
-		SOAPElement imageReference = sbe.addChildElement(ns3);
-		imageReference.addAttribute(hrefAttr, "cid:submitSampleImage@apache.org");
-	}
-}
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+import org.apache.axis2.attachments.utils.ImageDataSource;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+import javax.xml.soap.*;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.File;
+import java.util.Iterator;
+//import javax.activation.FileDataSource;
+
+public class JUnitTestAttachmentIntegration extends TestCase {
+	
+    public JUnitTestAttachmentIntegration(String name) {
+        super(name);
+    }
+    
+    public static void main(String args[]) throws Exception {
+    	JUnitTestAttachmentIntegration tester = new JUnitTestAttachmentIntegration("tester");
+        testSendReceive();
+    }
+
+	public static void testSendReceive() throws Exception{
+		MessageFactory mf = MessageFactory.newInstance();
+		SOAPMessage message = mf.createMessage();
+		
+		//create the SOAPPart
+		createSOAPPart(message);
+		
+		//Attach a text/plain object with the SOAP message
+		String sampleMessage = "Sample Message: Hello World!";
+		AttachmentPart textAttach = message.createAttachmentPart(sampleMessage,"text/plain");
+		textAttach.addMimeHeader("Content-Transfer-Encoding", "binary");
+		textAttach.setContentId("submitSampleText@apache.org");
+		message.addAttachmentPart(textAttach);
+		
+		//Attach a java.awt.Image object to the SOAP message
+        String jpgfilename = "./test-resources/axis.jpg";
+        File myfile = new File(jpgfilename);
+        FileDataSource fds = new FileDataSource(myfile);
+		DataHandler imageDH = new DataHandler(fds);
+		AttachmentPart jpegAttach = message.createAttachmentPart(imageDH);
+		jpegAttach.addMimeHeader("Content-Transfer-Encoding", "binary");
+		jpegAttach.setContentId("submitSampleImage@apache.org");
+		message.addAttachmentPart(jpegAttach);
+		
+		SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
+		
+		SOAPMessage sMsg =  sCon.call(message,"http://localhost:8080/axis2/services/Echo");
+		int attachmentCount = sMsg.countAttachments();
+		assertTrue(attachmentCount == 2);
+
+		Iterator attachIter = sMsg.getAttachments();		
+		//Of the two attachments first should be of type text/plain and 
+		//second of content-type image/jpeg
+		
+		//Underlying MTOM is converting all contentTypes to application/octet-stream
+		//Thats something to be fixed, I guess. Till then commenting out
+		//these two asserts
+		/*
+		AttachmentPart ap1 = (AttachmentPart)attachIter.next();
+		assertTrue(ap1.getContentType().equals("text/plain"));
+		AttachmentPart ap2 = (AttachmentPart)attachIter.next();
+		assertTrue(ap2.getContentType().equals("image/jpeg"));
+		*/
+	}
+	
+	private static void createSOAPPart(SOAPMessage message) throws SOAPException {
+		SOAPPart sPart = message.getSOAPPart();
+		SOAPEnvelope env = sPart.getEnvelope();
+		SOAPBody body = env.getBody();
+		
+		Name ns = env.createName("echo","swa","http://fakeNamespace.org");
+		SOAPBodyElement sbe = body.addBodyElement(ns);
+		
+		Name ns2 = env.createName("text");
+		SOAPElement textReference = sbe.addChildElement(ns2);
+		Name hrefAttr = env.createName("href");
+		textReference.addAttribute(hrefAttr, "cid:submitSampleText@apache.org");
+		
+		Name ns3 = env.createName("image");
+		SOAPElement imageReference = sbe.addChildElement(ns3);
+		imageReference.addAttribute(hrefAttr, "cid:submitSampleImage@apache.org");
+	}
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/JUnitTestAttachmentIntegration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/PrefixesTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/PrefixesTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/PrefixesTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/PrefixesTest.java Thu Sep 15 11:52:11 2005
@@ -1,77 +1,77 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import junit.framework.TestCase;
-
-import javax.xml.soap.*;
-import java.io.ByteArrayOutputStream;
-
-/**
- * @author Ashutosh Shahi
- */
-public class PrefixesTest extends TestCase {
-
-    public PrefixesTest(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.axis2.soap.SOAPEnvelope omEnv = ((SOAPEnvelopeImpl) se).getOMEnvelope();
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        msg.writeTo(baos);
-
-        String xml = new String(baos.toByteArray());
-        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");
-     }*/
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.*;
+import java.io.ByteArrayOutputStream;
+
+/**
+ * @author Ashutosh Shahi
+ */
+public class PrefixesTest extends TestCase {
+
+    public PrefixesTest(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.axis2.soap.SOAPEnvelope omEnv = ((SOAPEnvelopeImpl) se).getOMEnvelope();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        msg.writeTo(baos);
+
+        String xml = new String(baos.toByteArray());
+        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");
+     }*/
+
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/PrefixesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java Thu Sep 15 11:52:11 2005
@@ -1,99 +1,99 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import junit.framework.TestCase;
-
-import javax.xml.soap.*;
-import java.util.Iterator;
-
-/**
- * @author Ashutosh Shahi ashutosh.shahi@gmail.com
- */
-public class SOAPBodyTest extends TestCase {
-
-    /**
-     * Method suite
-     *                                                         
-     * @return
-     */
-    /*  public static Test suite() {
-          return new TestSuite(test.message.TestSOAPBody.class);
-      }
-    */
-    /**
-     * Method main
-     *
-     * @param argv
-     */
-    public static void main(String[] argv) throws Exception {
-        SOAPBodyTest tester = new SOAPBodyTest("TestSOAPBody");
-        tester.testSoapBodyBUG();
-    }
-
-    /**
-     * Constructor TestSOAPBody
-     *
-     * @param name
-     */
-    public SOAPBodyTest(String name) {
-        super(name);
-    }
-
-    /**
-     * Method testSoapBodyBUG
-     *
-     * @throws Exception
-     */
-    public void testSoapBodyBUG() throws Exception {
-
-        MessageFactory fact = MessageFactory.newInstance();
-        SOAPMessage message = fact.createMessage();
-        SOAPPart soapPart = message.getSOAPPart();
-        SOAPEnvelopeImpl env = (SOAPEnvelopeImpl) soapPart.getEnvelope();
-        SOAPHeader header = env.getHeader();
-        Name hns = env.createName("Hello",
-                "shw",
-                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
-        SOAPElement headElmnt = header.addHeaderElement(hns);
-        Name hns1 = env.createName("Myname",
-                "shw",
-                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
-        SOAPElement myName = headElmnt.addChildElement(hns1);
-        myName.addTextNode("Tony");
-        Name ns = env.createName("Address",
-                "shw",
-                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
-        SOAPBody body = env.getBody();
-        SOAPElement bodyElmnt = body.addBodyElement(ns);
-        Name ns1 = env.createName("City",
-                "shw",
-                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
-        SOAPElement city = bodyElmnt.addChildElement(ns1);
-        city.addTextNode("GENT");
-
-        Iterator it = body.getChildElements();
-        int count = 0;
-
-        while (it.hasNext()) {
-            SOAPElement el = (SOAPElement) it.next();
-            count++;
-            Name name = el.getElementName();
-        }
-        assertTrue(count == 1);
-    }
-
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.*;
+import java.util.Iterator;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ */
+public class SOAPBodyTest extends TestCase {
+
+    /**
+     * Method suite
+     *                                                         
+     * @return
+     */
+    /*  public static Test suite() {
+          return new TestSuite(test.message.TestSOAPBody.class);
+      }
+    */
+    /**
+     * Method main
+     *
+     * @param argv
+     */
+    public static void main(String[] argv) throws Exception {
+        SOAPBodyTest tester = new SOAPBodyTest("TestSOAPBody");
+        tester.testSoapBodyBUG();
+    }
+
+    /**
+     * Constructor TestSOAPBody
+     *
+     * @param name
+     */
+    public SOAPBodyTest(String name) {
+        super(name);
+    }
+
+    /**
+     * Method testSoapBodyBUG
+     *
+     * @throws Exception
+     */
+    public void testSoapBodyBUG() throws Exception {
+
+        MessageFactory fact = MessageFactory.newInstance();
+        SOAPMessage message = fact.createMessage();
+        SOAPPart soapPart = message.getSOAPPart();
+        SOAPEnvelopeImpl env = (SOAPEnvelopeImpl) soapPart.getEnvelope();
+        SOAPHeader header = env.getHeader();
+        Name hns = env.createName("Hello",
+                "shw",
+                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
+        SOAPElement headElmnt = header.addHeaderElement(hns);
+        Name hns1 = env.createName("Myname",
+                "shw",
+                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
+        SOAPElement myName = headElmnt.addChildElement(hns1);
+        myName.addTextNode("Tony");
+        Name ns = env.createName("Address",
+                "shw",
+                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
+        SOAPBody body = env.getBody();
+        SOAPElement bodyElmnt = body.addBodyElement(ns);
+        Name ns1 = env.createName("City",
+                "shw",
+                "http://www.jcommerce.net/soap/ns/SOAPHelloWorld");
+        SOAPElement city = bodyElmnt.addChildElement(ns1);
+        city.addTextNode("GENT");
+
+        Iterator it = body.getChildElements();
+        int count = 0;
+
+        while (it.hasNext()) {
+            SOAPElement el = (SOAPElement) it.next();
+            count++;
+            Name name = el.getElementName();
+        }
+        assertTrue(count == 1);
+    }
+
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPBodyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java Thu Sep 15 11:52:11 2005
@@ -1,62 +1,62 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.saaj;
-
-import junit.framework.TestCase;
-
-import javax.xml.soap.SOAPElement;
-import java.util.List;
-
-/**
- * @author Ashutosh Shahi ashutosh.shahi@gmail.com
- */
-public class SOAPElementTest 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;
-    }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.SOAPElement;
+import java.util.List;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ */
+public class SOAPElementTest 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;
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/test/org/apache/axis2/saaj/SOAPElementTest.java
------------------------------------------------------------------------------
    svn:eol-style = native