You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ru...@apache.org on 2008/08/27 03:06:55 UTC

svn commit: r689316 [3/3] - in /webservices/commons/trunk/modules/axiom/modules/axiom-c14n: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/axiom/ src/main/java/org/apache/axiom/c14n/ src/main/java...

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Node.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Node.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Node.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Node.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.omwrapper.interfaces;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public interface Node {
+// some of these may not be actually necessary for the wrappers
+// but I kept them for the sake of future modifications
+     public static final short ELEMENT_NODE              = 1;
+    /**
+     * The node is an <code>AttrImpl</code>.
+     */
+    public static final short ATTRIBUTE_NODE            = 2;
+    /**
+     * The node is a <code>Text</code> node.
+     */
+    public static final short TEXT_NODE                 = 3;
+    /**
+     * The node is a <code>CDATASection</code>.
+     */
+    public static final short CDATA_SECTION_NODE        = 4;
+    /**
+     * The node is an <code>EntityReference</code>.
+     */
+    public static final short ENTITY_REFERENCE_NODE     = 5;
+    /**
+     * The node is an <code>Entity</code>.
+     */
+    public static final short ENTITY_NODE               = 6;
+    /**
+     * The node is a <code>ProcessingInstruction</code>.
+     */
+    public static final short PROCESSING_INSTRUCTION_NODE = 7;
+    /**
+     * The node is a <code>Comment</code>.
+     */
+    public static final short COMMENT_NODE              = 8;
+    /**
+     * The node is a <code>Document</code>.
+     */
+    public static final short DOCUMENT_NODE             = 9;
+    /**
+     * The node is a <code>DocumentType</code>.
+     */
+    public static final short DOCUMENT_TYPE_NODE        = 10;
+    /**
+     * The node is a <code>DocumentFragment</code>.
+     */
+    public static final short DOCUMENT_FRAGMENT_NODE    = 11;
+    /**
+     * The node is a <code>Notation</code>.
+     */
+    public static final short NOTATION_NODE             = 12;
+
+
+// this should be overridden as appropriate
+    public short getNodeType();
+
+// this should be overridden as appropriate
+    public String getNodeValue();
+
+// this should be overridden as appropriate
+    public String getNodeName();
+
+// this should be overridden as appropriate
+    public Node getFirstChild();
+
+// this should be overridden as appropriate
+    public Node getNextSibling();
+
+// this should be overridden as appropriate
+    public Node getPreviousSibling();
+
+// this should be overridden as appropriate
+    public Node getParentNode();
+
+// this should be overridden as appropriate
+    public NodeList getChildNodes();
+
+// this should be overridden as appropriate
+    public String getNamespaceURI();
+
+// this should be overridden as appropriate
+    public String getPrefix();
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/NodeList.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/NodeList.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/NodeList.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/NodeList.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.omwrapper.interfaces;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public interface NodeList {
+    public Node item(int index);
+
+    public int getLength();
+}
\ No newline at end of file

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/ProcessingInstruction.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/ProcessingInstruction.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/ProcessingInstruction.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/ProcessingInstruction.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.omwrapper.interfaces;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public interface ProcessingInstruction extends Node{
+    public String getTarget();
+
+    public String getData();
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Text.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Text.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Text.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/omwrapper/interfaces/Text.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.omwrapper.interfaces;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public interface Text extends Node{
+    public char[] getText();
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/Constants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/Constants.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/Constants.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/Constants.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.utils;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class Constants {
+    /**
+     * The URI for XML spec
+     */
+    public static final String XML_LANG_SPACE_SpecNS = "http://www.w3.org/XML/1998/namespace";
+    /**
+     * The URI for XMLNS spec
+     */
+    public static final String NamespaceSpecNS = "http://www.w3.org/2000/xmlns/";
+    
+    private Constants() {
+        // we don't allow instantiation
+    }
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/PropLoader.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/PropLoader.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/PropLoader.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/PropLoader.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.utils;
+
+import java.io.File;
+import java.util.ResourceBundle;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class PropLoader {
+    public static final String C14N_EXCEPTION_PROP = "META-INF" + File.separator;
+
+    public static String getExceptionProperty(String key, String baseName){
+        return ResourceBundle.getBundle(C14N_EXCEPTION_PROP+baseName).getString(key);
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/UnsyncByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/UnsyncByteArrayOutputStream.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/UnsyncByteArrayOutputStream.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/java/org/apache/axiom/c14n/utils/UnsyncByteArrayOutputStream.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.utils;
+import java.io.OutputStream;
+
+/**
+ * A simple Unsynced ByteArryOutputStream
+ *
+ * @author raul
+ */
+public class UnsyncByteArrayOutputStream extends OutputStream {
+    private static ThreadLocal bufCahce = new ThreadLocal() {
+        protected synchronized Object initialValue() {
+            return new byte[8 * 1024];
+        }
+    };
+    byte[] buf;
+    int size = 8 * 1024;//buf.length;
+    int pos = 0;
+
+    /**
+     * @inheritDoc
+     */
+    public UnsyncByteArrayOutputStream() {
+        buf = (byte[]) bufCahce.get();
+    }
+
+    public void write(byte[] arg0) {
+        int newPos = pos + arg0.length;
+        if (newPos > size) {
+            expandSize();
+        }
+        System.arraycopy(arg0, 0, buf, pos, arg0.length);
+        pos = newPos;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void write(byte[] arg0, int arg1, int arg2) {
+        int newPos = pos + arg2;
+        if (newPos > size) {
+            expandSize();
+        }
+        System.arraycopy(arg0, arg1, buf, pos, arg2);
+        pos = newPos;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void write(int arg0) {
+        if (pos >= size) {
+            expandSize();
+        }
+        buf[pos++] = (byte) arg0;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public byte[] toByteArray() {
+        byte result[] = new byte[pos];
+        System.arraycopy(buf, 0, result, 0, pos);
+        return result;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void reset() {
+        pos = 0;
+    }
+
+    /** @inheritDoc */
+    void expandSize() {
+        int newSize = size << 2;
+        byte newBuf[] = new byte[newSize];
+        System.arraycopy(buf, 0, newBuf, 0, pos);
+        buf = newBuf;
+        size = newSize;
+
+	}
+}
+

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/resources/META-INF/exceptions.properties
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/resources/META-INF/exceptions.properties?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/resources/META-INF/exceptions.properties (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/main/resources/META-INF/exceptions.properties Tue Aug 26 18:06:53 2008
@@ -0,0 +1,4 @@
+algorithm.alreadyRegistered = URI {0} is already assigned to class {1}
+c14n.Canonicalizer.RelativeNamespace = Element {0} has a relative namespace: {1} = "{2}"
+empty = {0}
+c14n.Canonicalizer.UnknownCanonicalizer = Unknown canonicalizer. No handler installed for URI {0}
\ No newline at end of file

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/AllC14NTests.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/AllC14NTests.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/AllC14NTests.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/AllC14NTests.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class AllC14NTests extends TestCase {
+    public AllC14NTests(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("All org.apache.axiom.c14n JUnit Tests");
+        suite.addTest(ImplTest.suite());
+        suite.addTest(WrapperTest.suite());
+        return suite;
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite()); 
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/DataParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/DataParser.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/DataParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/DataParser.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n;
+
+import org.apache.axiom.c14n.omwrapper.factory.WrapperFactory;
+import org.apache.axiom.c14n.omwrapper.interfaces.Document;
+import org.apache.axiom.c14n.omwrapper.interfaces.Element;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
+
+import java.net.URL;
+import java.io.RandomAccessFile;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class DataParser {
+    private String fileName = null;
+    private StAXOMBuilder builder = null;
+    private byte [] bytes;
+
+    public WrapperFactory fac = null;
+    public Document doc = null;
+    public Element docEle = null;
+    public OMDocument omDoc = null;
+    public OMElement omDocEle = null;
+
+    public DataParser(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public void init() throws Exception {
+        builder = new StAXOMBuilder(this.getClass().getResourceAsStream(fileName));
+        fac = new WrapperFactory();
+        omDoc = builder.getDocument();
+        omDocEle = omDoc.getOMDocumentElement();
+        doc = (Document) fac.getNode(omDoc);
+        docEle = doc.getDocumentElement();
+    }
+
+    public void initWithNewFile(String fileName) throws Exception{
+        this.fileName = fileName;
+        init();
+    }
+
+    public byte[] getBytes() throws Exception{
+        URL uri = getClass().getResource(fileName);
+        RandomAccessFile raf = new RandomAccessFile(uri.getFile(),"r");
+        byte[] bytes = new byte[(int)raf.length()];
+        raf.readFully(bytes);
+        return bytes;
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/ImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/ImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/ImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/ImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.axiom.c14n.impl.Canonicalizer20010315OmitCommentTest;
+import org.apache.axiom.c14n.impl.Canonicalizer20010315WithCommentTest;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class ImplTest extends TestCase {
+    public ImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite(){
+        TestSuite suite = new TestSuite("All org.apache.axiom.c14n.impl JUnit Tests");
+        suite.addTest(Canonicalizer20010315OmitCommentTest.suite());
+        suite.addTest(Canonicalizer20010315WithCommentTest.suite());
+        return suite;
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/WrapperTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/WrapperTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/WrapperTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/WrapperTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.apache.axiom.c14n.omwrapper.*;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class WrapperTest extends TestCase {
+    public WrapperTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        TestSuite suite =  new TestSuite("All org.apache.axiom.c14n.omwrapper JUnit Tests");
+        suite.addTest(AttrImplTest.suite());
+        suite.addTest(CommentImplTest.suite());
+        suite.addTest(DocumentImplTest.suite());
+        suite.addTest(ElementImplTest.suite());
+        suite.addTest(NamedNodeMapImplTest.suite());
+        suite.addTest(NodeListImplTest.suite());
+        suite.addTest(TextImplTest.suite());
+        return suite;
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/AbstractCanonicalizerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/AbstractCanonicalizerTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/AbstractCanonicalizerTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/AbstractCanonicalizerTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.impl;
+
+import junit.framework.TestCase;
+import org.apache.axiom.c14n.DataParser;
+import org.apache.axiom.c14n.Canonicalizer;
+import org.apache.axiom.c14n.exceptions.AlgorithmAlreadyRegisteredException;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class AbstractCanonicalizerTest extends TestCase {
+    protected DataParser dp = null;
+    protected Canonicalizer c14n = null;
+
+    public AbstractCanonicalizerTest(){}
+
+    public AbstractCanonicalizerTest(String name){
+        super(name);
+    }
+
+       static {
+        Canonicalizer.init();
+        try {
+            Canonicalizer.register("http://www.w3.org/TR/2001/REC-xml-c14n-20010315",
+                    "org.apache.axiom.c14n.impl.Canonicalizer20010315OmitComments");
+
+            Canonicalizer.register("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments",
+                    "org.apache.axiom.c14n.impl.Canonicalizer20010315WithComments");
+
+
+            Canonicalizer.register("http://www.w3.org/2001/10/xml-exc-c14n#",
+                    "org.apache.axiom.c14n.impl.Canonicalizer20010315ExclOmitComments");
+
+            Canonicalizer.register("http://www.w3.org/2001/10/xml-exc-c14n#WithComments",
+                    "org.apache.axiom.c14n.impl.Canonicalizer20010315ExclWithComments");
+
+        } catch (AlgorithmAlreadyRegisteredException e) {
+            fail(e.getMessage());
+        }
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315OmitCommentTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315OmitCommentTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315OmitCommentTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315OmitCommentTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.impl;
+
+import org.apache.axiom.c14n.DataParser;
+import org.apache.axiom.c14n.Canonicalizer;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class Canonicalizer20010315OmitCommentTest
+        extends AbstractCanonicalizerTest {
+
+    public Canonicalizer20010315OmitCommentTest(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(Canonicalizer20010315OmitCommentTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    private byte[] bytes = null;
+
+    private String sample5Result = "<doc attrExtEnt=\"entExt\">\n" +
+            "   Hello, world!\n" +
+            "</doc>";
+
+    private String sample6Result = "<doc>©</doc>";
+
+    public void setUp() throws Exception {
+        // parse data of sample5.xml
+        dp = new DataParser("/sample5.xml");
+        // get canonicalizer which omits comments
+        c14n = Canonicalizer.getInstance(
+                "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
+    }
+
+    public void testSample5() throws Exception {
+        // get the canonicalized byte[]
+        bytes = c14n.canonicalize(dp.getBytes());
+        // check against sample2Result
+        assertEquals(sample5Result, new String(bytes));
+    }
+
+     public void testSample6() throws Exception {
+         // parse data of sample6.xml
+        dp.initWithNewFile("/sample6.xml");
+        // get the canonicalized byte[]
+        bytes = c14n.canonicalize(dp.getBytes());
+        // check against sample6Result
+        assertEquals(sample6Result, new String(bytes));
+    }
+
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315WithCommentTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315WithCommentTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315WithCommentTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/impl/Canonicalizer20010315WithCommentTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axiom.c14n.impl;
+
+import org.apache.axiom.c14n.DataParser;
+import org.apache.axiom.c14n.Canonicalizer;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class Canonicalizer20010315WithCommentTest
+        extends AbstractCanonicalizerTest {
+
+    public Canonicalizer20010315WithCommentTest(String name){
+        super(name);
+    }
+
+    public static Test suite(){
+        return new TestSuite(Canonicalizer20010315WithCommentTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    private byte[] bytes = null;
+
+    private String sample2Result = "<doc>\n" +
+            "   <clean>   </clean>\n" +
+            "   <dirty>   A   B   </dirty>\n" +
+            "   <mixed>\n" +
+            "      A\n" +
+            "      <clean>   </clean>\n" +
+            "      B\n" +
+            "      <dirty>   A   B   </dirty>\n" +
+            "      C\n" +
+            "   </mixed>\n" +
+            "</doc>";
+
+    private String sample3Result = "<doc>\n" +
+            "   <e1></e1>\n" +
+            "   <e2></e2>\n" +
+            "   <e3 id=\"elem3\" name=\"elem3\"></e3>\n" +
+            "   <e4 id=\"elem4\" name=\"elem4\"></e4>\n" +
+            "   <e5 xmlns=\"http://example.org\" xmlns:a=\"http://www.w3.org\" xmlns:b=\"http://www.ietf.org\" attr=\"I'm\" attr2=\"all\" b:attr=\"sorted\" a:attr=\"out\"></e5>\n" +
+            "   <e6 xmlns:a=\"http://www.w3.org\">\n" +
+            "      <e7 xmlns=\"http://www.ietf.org\">\n" +
+            "         <e8 xmlns=\"\">\n" +
+            "            <e9 xmlns:a=\"http://www.ietf.org\" attr=\"default\"></e9>\n" +
+            "         </e8>\n" +
+            "      </e7>\n" +
+            "   </e6>\n" +
+            "</doc>";
+
+    private String sample4Result = "<doc>\n" +
+            "   <text>First line&#xD;\n" +
+            "Second line</text>\n" +
+            "   <value>2</value>\n" +
+            "   <compute>value&gt;\"0\" &amp;&amp; value&lt;\"10\" ?\"valid\":\"error\"</compute>\n" +
+            "   <compute expr=\"value>&quot;0&quot; &amp;&amp; value&lt;&quot;10&quot; ?&quot;valid&quot;:&quot;error&quot;\">valid</compute>\n" +
+            "   <norm attr=\" '    &#xD;&#xA;&#x9;   ' \"></norm>\n" +
+            "   <normNames attr=\"A &#xD;&#xA;&#x9; B\"></normNames>\n" +
+            "   <normId id=\"' &#xD;&#xA;&#x9; '\"></normId>\n" +
+            "</doc>";
+
+    public void setUp() throws Exception {
+        // parse data of sample2.xml
+        dp = new DataParser("/sample2.xml");
+        // get canonicalizer with comment
+        c14n = Canonicalizer.getInstance(
+                "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments");
+    }
+
+    public void testSample2() throws Exception{
+        // get the canonicalized byte[]
+        bytes = c14n.canonicalize(dp.getBytes());
+        // check against sample2Result
+        assertEquals(sample2Result, new String(bytes));
+    }
+
+    public void testSample3() throws Exception{
+        // parse data of sample3.xml
+        dp.initWithNewFile("/sample3.xml");
+        // get the canonicalized byte[]
+        bytes = c14n.canonicalize(dp.getBytes());
+        // check against sample3Result
+        assertEquals(sample3Result, new String(bytes));
+    }
+
+    public void testSample4() throws Exception {
+        // parse data of sample3.xml
+        dp.initWithNewFile("/sample4.xml");
+        // get the canonicalized byte[]
+        bytes = c14n.canonicalize(dp.getBytes());
+        // check against sample3Result
+        assertEquals(sample4Result, new String(bytes));
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/AttrImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/AttrImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/AttrImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/AttrImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,126 @@
+package org.apache.axiom.c14n.omwrapper;
+
+import org.apache.axiom.c14n.omwrapper.factory.WrapperFactory;
+import org.apache.axiom.c14n.omwrapper.interfaces.Document;
+import org.apache.axiom.c14n.omwrapper.interfaces.Element;
+import org.apache.axiom.c14n.omwrapper.interfaces.NamedNodeMap;
+import org.apache.axiom.c14n.omwrapper.interfaces.Attr;
+import org.apache.axiom.c14n.DataParser;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class AttrImplTest extends TestCase {
+    private DataParser dp;
+    private NamedNodeMap nnm;
+    private Attr attr;
+
+    public AttrImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(AttrImplTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public void setUp() throws Exception{
+        dp = new DataParser("/sample1.xml");
+        dp.init();
+        // get e5
+        OMElement e5 = dp.omDocEle.getFirstChildWithName(new QName("http://example.org","e5"));
+        // get the wrapped element of e5
+        Element e = (Element)dp.fac.getNode(e5);
+        nnm = e.getAttributes();
+
+    }
+
+    public void testAttrProperties(){
+        // e5 has 7 attributes
+        assertEquals(7, nnm.getLength());
+        //attr is a:attr="out"
+        attr = (Attr)nnm.item(0);
+        assertEquals("attr", attr.getLocalName());
+        assertEquals("a:attr", attr.getName());
+        assertEquals("a:attr", attr.getNodeName());
+        assertEquals("a", attr.getPrefix());
+        assertEquals("http://www.w3.org", attr.getNamespaceURI());
+
+        // attr is attr2="all"
+        attr = (Attr)nnm.item(2);
+        assertEquals("attr2", attr.getLocalName());
+        assertEquals("attr2", attr.getName());
+        assertEquals("attr2", attr.getNodeName());
+        assertNull("prefix of attr2=\"all\" is null", attr.getPrefix());
+        assertNull("Namespace URI of attr2=\"all\" is null", attr.getNamespaceURI());
+        assertEquals("all", attr.getValue());
+        assertEquals("all", attr.getNodeValue());
+
+        // attr is xmlns:a="http://www.w3.org"
+        attr = (Attr)nnm.item(4);
+        assertEquals("a", attr.getLocalName());
+        assertEquals("xmlns:a", attr.getName());
+        assertEquals("xmlns:a", attr.getNodeName());
+        assertEquals("xmlns", attr.getPrefix());
+        // the namespace URI of xmlns is "http://www.w3.org/2000/xmlns/"
+        assertEquals("http://www.w3.org/2000/xmlns/", attr.getNamespaceURI());
+        assertEquals("http://www.w3.org", attr.getValue());
+        assertEquals("http://www.w3.org", attr.getNodeValue());
+
+        // attr is xmlns="http://example.org"
+        attr = (Attr)nnm.item(6);
+        assertEquals("xmlns", attr.getLocalName());
+        assertEquals("xmlns", attr.getName());
+        assertEquals("xmlns", attr.getNodeName());
+        assertNull("prefix of xmlns=\"http://example.org\" is null", attr.getPrefix());
+        // the namespace URI of xmlns is "http://www.w3.org/2000/xmlns/"
+        assertEquals("http://www.w3.org/2000/xmlns/", attr.getNamespaceURI());
+        assertEquals("http://example.org", attr.getValue());
+        assertEquals("http://example.org", attr.getNodeValue());
+    }
+
+    public void testOwnerElement() {
+        // get e5
+        OMElement e5 = dp.omDocEle.getFirstChildWithName(new QName("http://example.org","e5"));
+        // get the wrapped element of e5
+        Element e = (Element)dp.fac.getNode(e5);
+        // attr is a:attr="out"
+        attr = (Attr)e.getAttributes().item(0);
+        // the getOwnerElement() should provide a reference to the same object pointed by reference e
+        assertEquals(e, attr.getOwnerElement());
+    }
+
+    public void testGetNextSibling() {
+        // attr is a:attr="out"
+        attr = (Attr)nnm.item(0);
+        assertNull("getNextSibling() should return null", attr.getNextSibling());
+    }
+
+    public void testGetPreviousSibling(){
+        // attr is a:attr="out"
+        attr = (Attr)nnm.item(0);
+        assertNull("getPreviousSibling() should return null", attr.getPreviousSibling());
+    }
+
+    public void testGetParentNode(){
+        // attr is a:attr="out"
+        attr = (Attr)nnm.item(0);
+        assertNull("getParentNode() should return null", attr.getParentNode());
+
+    }
+
+
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/CommentImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/CommentImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/CommentImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/CommentImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,57 @@
+package org.apache.axiom.c14n.omwrapper;
+
+import org.apache.axiom.c14n.omwrapper.interfaces.Comment;
+import org.apache.axiom.c14n.omwrapper.interfaces.Node;
+import org.apache.axiom.c14n.DataParser;
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class CommentImplTest extends TestCase {
+    private DataParser dp = null;
+    private Comment comment = null;
+
+    public CommentImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(CommentImplTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public void setUp() throws Exception{
+        dp = new DataParser("/sample1.xml");
+        dp.init();
+        // <!-- Comment 2 -->
+        comment = (Comment)dp.doc.getFirstChild().getNextSibling();
+    }
+
+    public void testGetData() {
+        assertEquals(" Comment 2 ", comment.getData());
+    }
+
+    public void testGetParent(){
+        assertEquals(Node.DOCUMENT_NODE, comment.getParentNode().getNodeType());
+    }
+
+    public void testGetNextSibling(){
+        // this comment is inside the document so we don't want the next newline character
+        // to get as a node
+        assertEquals(Node.ELEMENT_NODE, comment.getNextSibling().getNodeType());
+    }
+
+    public void testGetPreviousSibling(){
+        // this comment is inside the document so we don't want the previous newline character
+        // to get as a node
+        assertEquals(Node.DOCUMENT_TYPE_NODE, comment.getPreviousSibling().getNodeType());
+    }
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/DocumentImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/DocumentImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/DocumentImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/DocumentImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,65 @@
+package org.apache.axiom.c14n.omwrapper;
+
+import org.apache.axiom.c14n.omwrapper.interfaces.NodeList;
+import org.apache.axiom.c14n.omwrapper.interfaces.Node;
+import org.apache.axiom.c14n.DataParser;
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class DocumentImplTest extends TestCase {
+    private DataParser dp = null;
+
+    public DocumentImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(DocumentImplTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public void setUp() throws Exception{
+        dp = new DataParser("/sample1.xml");
+        dp.init();
+    }
+
+    public void testGetChildNode() {
+        // this nl should not contain any text node
+        NodeList nl = dp.doc.getChildNodes();
+        for (int i = 0; i < nl.getLength(); i++) {
+            assertFalse("node type can't be Text", (Node.TEXT_NODE == nl.item(i).getNodeType()));
+        }
+    }
+
+    public void testGetNextSibling() {
+        assertNull("getNextSibling() should return null", dp.doc.getNextSibling());
+    }
+
+    public void testGetPreviousSibling() {
+        assertNull("getPreviousSibling() should return null", dp.doc.getPreviousSibling());
+    }
+
+    public void testGetParentNode() {
+        assertNull("getParentNode() should return null", dp.doc.getParentNode());
+    }
+
+    public void testGetFirstChild(){
+        assertFalse("document should not return Text nodes",
+                (Node.TEXT_NODE == dp.doc.getFirstChild().getNodeType()));
+
+        assertEquals(Node.DOCUMENT_TYPE_NODE, dp.doc.getFirstChild().getNodeType());
+    }
+
+    public void testGetDocumentElement() {
+        assertEquals(Node.ELEMENT_NODE, dp.doc.getDocumentElement().getNodeType());
+        assertEquals("doc", dp.doc.getDocumentElement().getNodeName());
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/ElementImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/ElementImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/ElementImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/ElementImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,126 @@
+package org.apache.axiom.c14n.omwrapper;
+
+import org.apache.axiom.c14n.omwrapper.interfaces.Element;
+import org.apache.axiom.c14n.omwrapper.interfaces.Node;
+import org.apache.axiom.c14n.DataParser;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class ElementImplTest extends TestCase {
+    private DataParser dp = null;
+
+    public ElementImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(ElementImplTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public void setUp() throws Exception{
+        dp = new DataParser("/sample1.xml");
+        dp.init();
+    }
+
+    public void testHasAttributes() {
+        // first child of docEle is of Text type. So we get the next sibling of that,i.e. e1
+        Element e = (Element) dp.docEle.getFirstChild().getNextSibling();
+        // e1 has one attribute which is in fact a namespace declaration
+        assertEquals(true, e.hasAttributes());
+        // get e2
+        e = (Element) e.getNextSibling().getNextSibling();
+        // e2 has the default namespace declaration
+        assertEquals(true, e.hasAttributes());
+        // get e2child
+        e = (Element) e.getFirstChild();
+        // e2child gets the default namespace from parent, but it's not an attribute of it
+        assertEquals(false, e.hasAttributes());
+    }
+
+    public void testGetNamespaceURI() {
+        // <e2   xmlns="http://www.blankns.com" ><e2child>I've no attributes</e2child></e2>
+        OMElement e2 = dp.omDocEle.getFirstChildWithName(new QName("http://www.blankns.com", "e2"));
+        // get the wrapped element
+        Element e = (Element) dp.fac.getNode(e2);
+        assertEquals("http://www.blankns.com", e.getNamespaceURI());
+        // <e2child>I've no attributes</e2child>
+        e = (Element) e.getFirstChild();
+        // e2child inherits the default namespace of e2
+        assertEquals("http://www.blankns.com", e.getNamespaceURI());
+
+        // <e3   name =    "elem3" id="elem3"/>
+        OMElement e3 = dp.omDocEle.getFirstChildWithName(new QName("e3"));
+        // get the wrapped element
+        e = (Element) dp.fac.getNode(e3);
+        assertNull("Namespace URI of e3 is null", e.getNamespaceURI());
+    }
+
+    public void testGetPrefix() {
+        // <e2   xmlns="http://www.blankns.com" ><e2child>I've no attributes</e2child></e2>
+        OMElement e2 = dp.omDocEle.getFirstChildWithName(new QName("http://www.blankns.com", "e2"));
+        // get the wrapped element
+        Element e = (Element) dp.fac.getNode(e2);
+        assertNull("prefix of e2 is null", e.getPrefix());
+        // <a:e1 xmlns:a="http://www.nonamespace.com"  />
+        e = (Element) e.getPreviousSibling().getPreviousSibling();
+        assertEquals("a", e.getPrefix());
+    }
+
+    public void testGetNodeName() {
+        // <a:e1 xmlns:a="http://www.nonamespace.com"  />
+        OMElement e1 = dp.omDocEle.getFirstElement();
+        // get the wrapped element
+        Element e = (Element) dp.fac.getNode(e1);
+        assertEquals("a:e1", e.getNodeName());
+        // <e2   xmlns="http://www.blankns.com" ><e2child>I've no attributes</e2child></e2>
+        e = (Element) e.getNextSibling().getNextSibling();
+        assertEquals("e2", e.getNodeName());
+    }
+
+    public void testGetFirstChild() {
+        Element e = (Element) dp.fac.getNode(dp.omDocEle);
+        // first child of root element represents the newline character so it's a text node
+        assertEquals(Node.TEXT_NODE, e.getFirstChild().getNodeType());
+    }
+
+
+    // there is a difference when it comes to CDATA. Axiom treats it as OMText. Eg.,
+    // <e1/>
+    // <![CDATA[<don't><process><this>:)]]>
+    // <e2/>
+    // getNextSibling() of e1 would return "\n<don't><process><this>:)\n"
+    // in DOM it would be just "\n". Taking the next sibling of that would be
+    // <don't><process><this>:) and taking the next sibling of that would be "\n"
+    // so Axiom put all these three into one OMText node. This wasn't a issue yet :)
+    // but thought to mention it for clarity.
+    public void testGetNextSibling() {
+        Element e = (Element) dp.fac.getNode(dp.omDocEle);
+        // first child of root element represents the newline character so it's a text node
+        // the getNextSibling() of that should return element e1
+        assertEquals(Node.ELEMENT_NODE, (e = (Element)e.getFirstChild().getNextSibling()).getNodeType());
+        assertEquals("a:e1", e.getNodeName());
+    }
+
+    public void testGetPreviousSibling() {
+        // <a:e1 xmlns:a="http://www.nonamespace.com"  />
+        Element e = (Element) dp.fac.getNode(dp.omDocEle.getFirstElement());
+        // this n is a text node representing the newline character
+        Node n = e.getPreviousSibling();
+        assertEquals(Node.TEXT_NODE, n.getNodeType());
+    }
+
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NamedNodeMapImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NamedNodeMapImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NamedNodeMapImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NamedNodeMapImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,55 @@
+package org.apache.axiom.c14n.omwrapper;
+
+import org.apache.axiom.c14n.omwrapper.interfaces.NamedNodeMap;
+import org.apache.axiom.c14n.omwrapper.interfaces.Element;
+import org.apache.axiom.c14n.DataParser;
+import org.apache.axiom.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class NamedNodeMapImplTest extends TestCase {
+    private DataParser dp = null;
+    private NamedNodeMap nnm = null;
+
+    public NamedNodeMapImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(NamedNodeMapImplTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public void setUp() throws Exception {
+        dp = new DataParser("/sample1.xml");
+        dp.init();
+        // get e5
+        OMElement e5 = dp.omDocEle.getFirstChildWithName(new QName("http://example.org", "e5"));
+        // get the wrapped element of e5
+        Element e = (Element) dp.fac.getNode(e5);
+        nnm = e.getAttributes();
+    }
+
+    public void testGetLength(){
+        assertEquals(7, nnm.getLength());
+    }
+
+    public void testItem(){
+        assertNotNull("valid index should not return null", nnm.item(nnm.getLength() - 1));
+        assertNull("invalid index should return null", nnm.item(-2));
+        assertNull("invalid index should return null", nnm.item(nnm.getLength()));
+    }
+
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NodeListImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NodeListImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NodeListImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/NodeListImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,44 @@
+package org.apache.axiom.c14n.omwrapper;
+
+import org.apache.axiom.c14n.omwrapper.interfaces.NodeList;
+import org.apache.axiom.c14n.DataParser;
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class NodeListImplTest extends TestCase {
+    private DataParser dp = null;
+    private NodeList nl = null;
+
+    public NodeListImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(NodeListImplTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public void setUp() throws Exception{
+        dp = new DataParser("/sample1.xml");
+        dp.init();
+        nl = dp.docEle.getChildNodes();
+    }
+
+    public void testGetLength() {
+        assertEquals(15, nl.getLength());
+    }
+
+    public void testItem(){
+        assertNotNull("valid index should not return null", nl.item(nl.getLength() - 1));
+        assertNull("invalid index should return null", nl.item(-2));
+        assertNull("invalid index should return null", nl.item(nl.getLength()));
+    }
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/TextImplTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/TextImplTest.java?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/TextImplTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/java/org/apache/axiom/c14n/omwrapper/TextImplTest.java Tue Aug 26 18:06:53 2008
@@ -0,0 +1,54 @@
+package org.apache.axiom.c14n.omwrapper;
+
+import org.apache.axiom.c14n.omwrapper.interfaces.NodeList;
+import org.apache.axiom.c14n.omwrapper.interfaces.Node;
+import org.apache.axiom.c14n.DataParser;
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author Saliya Ekanayake (esaliya@gmail.com)
+ */
+public class TextImplTest extends TestCase {
+    private DataParser dp = null;
+    private Node n = null;
+
+    public TextImplTest(String name){
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TextImplTest.class);
+    }
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public void setUp() throws Exception{
+        dp = new DataParser("/sample1.xml");
+        dp.init();
+        NodeList nl = dp.docEle.getChildNodes();
+        n = null;
+        for (int i = 0; i < nl.getLength(); i++) {
+            n = nl.item(i);
+            if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals("e6")){
+                break;
+            }
+        }
+    }
+
+    public void testGetNodeType(){
+        // here n is e6
+        assertEquals(Node.TEXT_NODE, n.getNextSibling().getNodeType());
+    }
+
+    // see issue mentioned with the testGetNextSibling() method in ElementImplTest
+    public void testGetNodeValue() {
+        // here n is e6
+        assertEquals("\n    <don't><process><this>:)\n", n.getNextSibling().getNodeValue());
+    }
+
+}

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample1.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample1.xml?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample1.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample1.xml Tue Aug 26 18:06:53 2008
@@ -0,0 +1,22 @@
+<!DOCTYPE doc [<!ATTLIST e9 attr CDATA "default">]>
+<!-- Comment 2 -->
+<doc      >
+    <a:e1 xmlns:a="http://www.nonamespace.com"  />
+    <e2   xmlns="http://www.blankns.com" ><e2child>I've no attributes</e2child></e2>
+    <e3   name =    "elem3" id="elem3"/>
+    <e4 name="elem4" id="elem4"></e4>
+    <!-- Comment before e5 and after e4 -->
+    <e5 a:attr="out" b:attr="sorted" attr2="all" attr="I'm"
+        xmlns:b="http://www.ietf.org"
+        xmlns:a="http://www.w3.org"
+        xmlns="http://example.org"/>
+    <e6 xmlns="" xmlns:a="http://www.w3.org">
+        <e7 xmlns="http://www.ietf.org">
+            <e8 xmlns="" xmlns:a="http://www.w3.org">
+                <e9 xmlns="" xmlns:a="http://www.ietf.org"/>
+                <text>&#169;</text>
+            </e8>
+        </e7>
+    </e6>
+    <![CDATA[<don't><process><this>:)]]>
+</doc><!-- Comment 3 -->
\ No newline at end of file

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample2.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample2.xml?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample2.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample2.xml Tue Aug 26 18:06:53 2008
@@ -0,0 +1,11 @@
+<doc>
+   <clean>   </clean>
+   <dirty>   A   B   </dirty>
+   <mixed>
+      A
+      <clean>   </clean>
+      B
+      <dirty>   A   B   </dirty>
+      C
+   </mixed>
+</doc>
\ No newline at end of file

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample3.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample3.xml?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample3.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample3.xml Tue Aug 26 18:06:53 2008
@@ -0,0 +1,18 @@
+<!DOCTYPE doc [<!ATTLIST e9 attr CDATA "default">]>
+<doc>
+   <e1   />
+   <e2   ></e2>
+   <e3   name = "elem3"   id="elem3"   />
+   <e4   name="elem4"   id="elem4"   ></e4>
+   <e5 a:attr="out" b:attr="sorted" attr2="all" attr="I'm"
+      xmlns:b="http://www.ietf.org"
+      xmlns:a="http://www.w3.org"
+      xmlns="http://example.org"/>
+   <e6 xmlns="" xmlns:a="http://www.w3.org">
+      <e7 xmlns="http://www.ietf.org">
+         <e8 xmlns="" xmlns:a="http://www.w3.org">
+            <e9 xmlns="" xmlns:a="http://www.ietf.org"/>
+         </e8>
+      </e7>
+   </e6>
+</doc>
\ No newline at end of file

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample4.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample4.xml?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample4.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample4.xml Tue Aug 26 18:06:53 2008
@@ -0,0 +1,13 @@
+<!DOCTYPE doc [
+<!ATTLIST normId id ID #IMPLIED>
+<!ATTLIST normNames attr NMTOKENS #IMPLIED>
+]>
+<doc>
+   <text>First line&#x0d;&#10;Second line</text>
+   <value>&#x32;</value>
+   <compute><![CDATA[value>"0" && value<"10" ?"valid":"error"]]></compute>
+   <compute expr='value>"0" &amp;&amp; value&lt;"10" ?"valid":"error"'>valid</compute>
+   <norm attr=' &apos;   &#x20;&#13;&#xa;&#9;   &apos; '/>
+   <normNames attr='   A   &#x20;&#13;&#xa;&#9;   B   '/>
+   <normId id=' &apos;   &#x20;&#13;&#xa;&#9;   &apos; '/>
+</doc>
\ No newline at end of file

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample5.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample5.xml?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample5.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample5.xml Tue Aug 26 18:06:53 2008
@@ -0,0 +1,10 @@
+<!DOCTYPE doc [
+<!ATTLIST doc attrExtEnt ENTITY #IMPLIED>
+<!ENTITY ent1 "Hello">
+<!ENTITY ent2 "world">
+]>
+<doc attrExtEnt="entExt">
+   &ent1;, &ent2;!
+</doc>
+
+<!-- comment goes here -->
\ No newline at end of file

Added: webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample6.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample6.xml?rev=689316&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample6.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-c14n/src/test/resources/META-INF/sample6.xml Tue Aug 26 18:06:53 2008
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<doc>&#169;</doc>
\ No newline at end of file