ws-woden-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sag...@apache.org
Subject svn commit: r809833 [7/10] - in /webservices/woden/trunk/java/woden-tests: ./ src/ src/main/ src/main/resources/ src/main/resources/META-INF/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/woden/ src/test...
Date Tue, 01 Sep 2009 05:50:51 GMT
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,123 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.BindingFaultReferenceImpl;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the BindingFaultReferenceElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingFaultReferenceElementTest extends TestCase {
+
+	private BindingFaultReferenceElement fFaultReference = null;
+
+	public static Test suite()
+	{
+	   return new TestSuite(BindingFaultReferenceElementTest.class);
+	   
+	}
+	   /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+    	super.setUp();
+    	fFaultReference = new BindingFaultReferenceImpl();
+    }
+    
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+
+	/*
+	 * Test that the (Mandatory) message label attribute ("messageLabel") can be successfully set and retrieved
+	 */
+	public void testSetGetMessageLabel()
+	{
+		NCName faultRefNCName = new NCName("faultRefName");
+		fFaultReference.setMessageLabel(faultRefNCName);
+		assertEquals("The retrieved Element name is not that which was set", 
+				faultRefNCName, fFaultReference.getMessageLabel());
+	}
+
+	/* 
+	 * Test that the (Mandatory) BindingFault reference attribute ("ref") can be successfully set and retrieved 
+	 */
+	public void testSetGetRef()
+	{
+		QName faultRefName = new QName("faultRefName");
+		fFaultReference.setRef(faultRefName);
+		assertEquals("The retrieved Element name is not that which was set", 
+				faultRefName, fFaultReference.getRef());
+	}
+	
+	/* 
+	 * Test that the (Mandatory) InterfaceFaultReference can be successfully retrieved.
+	 * The fault reference is to an Interface Fault associated with the grandparent BindingElement.
+	 */
+	public void testGetInterfaceFaultReferenceElement()
+	{
+        WSDLFactory factory = null;
+        try {
+            factory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+
+		DescriptionElement descriptionElement = factory.newDescription();
+		
+		// Create the BindingElement<->InterfaceElement->InterfaceOperationElement->InterfaceFaultReferenceElement hierarchy
+		BindingElement bindingElement = descriptionElement.addBindingElement();
+		bindingElement.setInterfaceName(new QName("interface1"));
+		
+		InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
+		interfaceElement.setName(new NCName("interface1"));
+		
+		InterfaceOperationElement ifopElement = interfaceElement.addInterfaceOperationElement();
+		ifopElement.setName(new NCName("operation1"));
+		InterfaceFaultReferenceElement iffrElement = ifopElement.addInterfaceFaultReferenceElement();
+		iffrElement.setMessageLabel(new NCName("Fault1MessageLabel"));
+		iffrElement.setRef(new QName("Fault1Ref"));
+				
+		// Create the BindingOperationElement->BindingFaultReferenceElement hierarchy
+		BindingOperationElement bopElement = bindingElement.addBindingOperationElement();
+		bopElement.setRef(new QName("operation1"));
+		fFaultReference = bopElement.addBindingFaultReferenceElement();
+		fFaultReference.setMessageLabel(new NCName("Fault1MessageLabel"));
+		fFaultReference.setRef(new QName("Fault1Ref"));
+
+		InterfaceFaultReferenceElement retrievedFault = fFaultReference.getInterfaceFaultReferenceElement();
+		assertEquals("The retrieved InterfaceFaultReferenceElement is not that which was set", 
+				iffrElement, retrievedFault);
+	}
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,124 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.BindingMessageReferenceImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.enumeration.Direction;
+
+
+
+/**
+ * Unit tests for the BindingMessageReferenceElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingMessageReferenceElementTest extends TestCase {
+
+	private BindingMessageReferenceElement fMessageReference = null;
+
+	public static Test suite()
+	{
+	   return new TestSuite(BindingMessageReferenceElementTest.class);
+	   
+	}
+	   /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+    	super.setUp(); 	
+    	fMessageReference = new BindingMessageReferenceImpl();
+    }
+    
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+	
+	/*
+	 * Test that a (mandatory) direction can be successfully set and retrieved
+	 */
+	public void testSetGetDirection()
+	{
+		// Default case
+		assertNull("The retrieved Direction when unset should be null", fMessageReference.getDirection());
+		
+		fMessageReference.setDirection(Direction.OUT);
+		assertEquals("The retrieved MessageReference direction is not that which was set", 
+				Direction.OUT, fMessageReference.getDirection());
+	}
+
+	/*
+	 * Test that the (Mandatory) message label attribute ("messageLabel") can be successfully set and retrieved
+	 */
+	public void testSetGetMessageLabel()
+	{
+		NCName messageRefNCName = new NCName("messageRefName");
+		fMessageReference.setMessageLabel(messageRefNCName);
+		assertEquals("The retrieved messageLabel is not that which was set", 
+				messageRefNCName, fMessageReference.getMessageLabel());
+	}
+	
+    /* 
+     * Test that the associated InterfaceMessageReferenceElement can be retrieved.
+     */
+    public void testGetInterfaceMessageReferenceElement()
+    {
+        WSDLFactory factory = null;
+        try {
+            factory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+
+        DescriptionElement descriptionElement = factory.newDescription();
+        
+        // Create the BindingElement->InterfaceElement->InterfaceOperationElement->InterfaceMessageReferenceElement
+        BindingElement bindingElement = descriptionElement.addBindingElement();
+        bindingElement.setInterfaceName(new QName("interface1"));
+        
+        InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
+        interfaceElement.setName(new NCName("interface1"));
+        
+        InterfaceOperationElement ifopElement = interfaceElement.addInterfaceOperationElement();
+        ifopElement.setName(new NCName("operation1"));
+        InterfaceMessageReferenceElement ifmrElement = ifopElement.addInterfaceMessageReferenceElement();
+        ifmrElement.setMessageLabel(new NCName("input1MessageLabel"));
+                
+        // Create the BindingOperationElement->BindingMessageReferenceElement
+        BindingOperationElement bopElement = bindingElement.addBindingOperationElement();
+        bopElement.setRef(new QName("operation1"));
+        fMessageReference = bopElement.addBindingMessageReferenceElement();
+        fMessageReference.setMessageLabel(new NCName("input1MessageLabel"));
+
+        InterfaceMessageReferenceElement retrievedMsgRef = fMessageReference.getInterfaceMessageReferenceElement();
+        assertEquals("The InterfaceMessageReferenceElement is not the expected one.", 
+                ifmrElement, retrievedMsgRef);
+    }
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,218 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the BindingOperationElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+
+public class BindingOperationElementTest extends TestCase {
+
+	// create a parent Description to hang the Bindings off
+	private DescriptionElement fDescriptionElement = null;
+	private BindingElement fBindingElement = null;
+	private BindingOperationElement fBindingOperationElement = null;
+	private final String BOP_NAME = "BindingOperationName";
+    private WSDLFactory fFactory = null;
+
+	public static Test suite()
+	{
+	   return new TestSuite(BindingOperationElementTest.class);
+	}
+	   
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        
+        try {
+            fFactory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+        fDescriptionElement = fFactory.newDescription();
+        fBindingElement = fDescriptionElement.addBindingElement();
+        fBindingOperationElement = fBindingElement.addBindingOperationElement();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+	
+    /*
+     * Mandatory attribute ("ref")
+     * - setRef() 
+     * - getRef() 
+     */
+	public void testGetSetRef() 
+	{	
+		fBindingOperationElement.setRef(new QName(BOP_NAME));
+		QName retrievedName = fBindingOperationElement.getRef();
+		assertEquals("Retrieved BindingOperationElement name does not match that set -", BOP_NAME, retrievedName.toString());
+	}
+	
+	/* 
+     * References to Optional child elements "infault" and "outfault"
+     * - addBindingFaultReferenceElement() 
+     * - getBindingFaultReferenceElements()
+     * - removeBindingFaultReferenceElement() 
+     */
+	public void testAddGetRemoveBindingFaultReferenceElements() 
+	{	
+		// check the default:
+		BindingFaultReferenceElement[] bfreArray = fBindingOperationElement.getBindingFaultReferenceElements();
+		assertNotNull("Expected an array of BindingFaultReferenceElement.", bfreArray);
+		assertEquals("Retrieved BindingFaultReferenceElement group should be empty if none set -", 0, bfreArray.length);
+
+		// addBindingFaultReferenceElement() -  create some BindingFaultReferenceElements
+		BindingFaultReferenceElement bfre1 = fBindingOperationElement.addBindingFaultReferenceElement();
+		BindingFaultReferenceElement bfre2 = fBindingOperationElement.addBindingFaultReferenceElement();
+		
+		// getBindingFaultReferenceElements()
+		bfreArray = fBindingOperationElement.getBindingFaultReferenceElements();
+		assertNotNull("Expected an array of BindingFaultReferenceElement.", bfreArray);
+		assertEquals("Retrieved BindingFaultReferenceElement group should be same number as those set -", 2, bfreArray.length);
+		
+		// verify all fault references returned
+		List bfreL = Arrays.asList(bfreArray);
+		assertTrue(bfreL.contains(bfre1));
+		assertTrue(bfreL.contains(bfre2));
+
+		// removeBindingFaultReferenceElement() 
+		// 1 - attempt to remove an unadded BFRE
+		BindingFaultReferenceElement bfre3 = null;
+		fBindingOperationElement.removeBindingFaultReferenceElement(bfre3);
+		bfreArray = fBindingOperationElement.getBindingFaultReferenceElements();
+		assertNotNull("Expected an array of BindingFaultReferenceElement.", bfreArray);
+		assertEquals("Retrieved BindingFaultReferenceElement group should be same number as those set -", 2, bfreArray.length);
+		
+		// 2- remove all added 
+		fBindingOperationElement.removeBindingFaultReferenceElement(bfre1);
+		fBindingOperationElement.removeBindingFaultReferenceElement(bfre2);
+		bfreArray = fBindingOperationElement.getBindingFaultReferenceElements();
+		assertNotNull("Expected an array of BindingFaultReferenceElement.", bfreArray);
+		assertEquals("Retrieved BindingFaultReferenceElement group should be empty if all removed -", 0, bfreArray.length);
+		
+		//3 - attempt to remove previously removed from empty list
+		fBindingOperationElement.removeBindingFaultReferenceElement(bfre2);
+		bfreArray = fBindingOperationElement.getBindingFaultReferenceElements();
+		assertNotNull("Expected an array of BindingFaultReferenceElement.", bfreArray);
+		assertEquals("Retrieved BindingFaultReferenceElement group should be empty if all removed -", 0, bfreArray.length);
+	}
+	
+	/* 
+     * References to Optional child elements "input" and "output"
+     * - addBindingMessageReferenceElement() 
+     * - getBindingMessageReferenceElements()
+     * - removeBindingMessageReferenceElement() 
+     */
+	public void testAddGetRemoveBindingMessageReferenceElements() 
+	{
+		// check the default:
+		BindingMessageReferenceElement[] bmreArray = fBindingOperationElement.getBindingMessageReferenceElements();
+		assertNotNull("Expected an array of BindingMessageReferenceElement.", bmreArray);
+		assertEquals("Retrieved BindingFaultReferenceElement group should be empty if none set -", 0, bmreArray.length);
+
+		// addBindingMessageReferenceElement() -  create some addBindingMessageReferenceElements
+		BindingMessageReferenceElement bmre1 = fBindingOperationElement.addBindingMessageReferenceElement();
+		BindingMessageReferenceElement bmre2 = fBindingOperationElement.addBindingMessageReferenceElement();
+		
+		// getBindingMessageReferenceElements()
+		bmreArray = fBindingOperationElement.getBindingMessageReferenceElements();
+		assertNotNull("Expected an array of BindingMessageReferenceElement.", bmreArray);
+		assertEquals("Retrieved BindingMessageReferenceElement group should be same number as those set -", 2, bmreArray.length);
+		
+		// verify all fault references returned
+		List bmreL = Arrays.asList(bmreArray);
+		assertTrue(bmreL.contains(bmre1));
+		assertTrue(bmreL.contains(bmre2));
+
+		// removeBindingMessageReferenceElement() 
+		// 1 - attempt to remove an unadded BMRE
+		BindingMessageReferenceElement bmre3 = null;
+		fBindingOperationElement.removeBindingMessageReferenceElement(bmre3);
+		bmreArray = fBindingOperationElement.getBindingMessageReferenceElements();
+		assertNotNull("Expected an array of BindingMessageReferenceElement.", bmreArray);
+		assertEquals("Retrieved BindingMessageReferenceElement group should be same number as those set -", 2, bmreArray.length);
+		
+		// 2- remove all added 
+		fBindingOperationElement.removeBindingMessageReferenceElement(bmre1);
+		fBindingOperationElement.removeBindingMessageReferenceElement(bmre2);
+		bmreArray = fBindingOperationElement.getBindingMessageReferenceElements();
+		assertNotNull("Expected an array of BindingMessageReferenceElement.", bmreArray);
+		assertEquals("Retrieved BindingMessageReferenceElement group should be empty if all removed -", 0, bmreArray.length);
+		
+		//3 - attempt to remove previously removed from empty list
+		fBindingOperationElement.removeBindingMessageReferenceElement(bmre2);
+		bmreArray = fBindingOperationElement.getBindingMessageReferenceElements();
+		assertNotNull("Expected an array of BindingMessageReferenceElement.", bmreArray);
+		assertEquals("Retrieved BindingMessageReferenceElement group should be empty if all removed -", 0, bmreArray.length);
+	}
+	
+	/* 
+     * Utility method to find the InterfaceOperation referenced by the (Mandatory) "ref" attribute
+     * - getInterfaceOperationElement() 
+     */
+	public void testGetInterfaceOperationElement() 
+	{		
+		// check the default:
+		InterfaceOperationElement retrievedIntOpElement = fBindingOperationElement.getInterfaceOperationElement();
+		assertNull("Retrieved Interface Operation Element should be null if none set -", retrievedIntOpElement);
+
+		// Create and name an Interface Element
+		DescriptionElement desc = fFactory.newDescription();
+		InterfaceElement interfaceElement = desc.addInterfaceElement();
+		interfaceElement.setName(new NCName("interface1"));
+		
+		// Create a binding from the description 
+		fBindingElement = desc.addBindingElement();
+		fBindingElement.setInterfaceName(new QName("interface1"));
+		
+		//Create and name an Interface Operation Element
+		InterfaceOperationElement intOpElement = interfaceElement.addInterfaceOperationElement();
+		intOpElement.setName(new NCName("interfaceOperation1"));
+		
+		fBindingOperationElement = fBindingElement.addBindingOperationElement();
+		fBindingOperationElement.setRef(new QName("interfaceOperation1"));
+
+		retrievedIntOpElement = fBindingOperationElement.getInterfaceOperationElement();
+		assertEquals("Retrieved Interface Element was not that expected -", intOpElement, retrievedIntOpElement);
+	}  
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ChildElementCreationTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ChildElementCreationTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ChildElementCreationTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ChildElementCreationTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,155 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.util.Arrays;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+
+/**
+ * Test cases to check when calling XxxxElement.addYyyyElement() that:
+ * a) Xxxx.getYyyyElements() returns an array containing the added YyyyElement
+ * b) The YyyyElement.getParentElement() returns the instance of XxxxElement
+ * 
+ * Do this for all Xxxx and Yyyy
+ */
+public class ChildElementCreationTest extends TestCase {
+
+    private WSDLFactory fFactory = null;
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ChildElementCreationTest.class);
+    }
+
+    public static Test suite() {
+        return new TestSuite(ChildElementCreationTest.class);
+    }
+    
+    public void setUp() {
+        try {
+            fFactory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+    }
+    
+    // Elements addable to Binding
+    public void testBindingFaultElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        BindingElement bindEl = descEl.addBindingElement();
+
+        BindingFaultElement bindFEl = bindEl.addBindingFaultElement();
+        
+        assertTrue("BindingElement doesn't have correct BindingFaultElement",
+                Arrays.asList(bindEl.getBindingFaultElements()).contains(bindFEl));
+        assertTrue("BindingFaultElement has incorrect parent", bindFEl.getParentElement() == bindEl);
+    }
+    
+    public void testBindingOperationElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        BindingElement bindEl = descEl.addBindingElement();
+
+        BindingOperationElement bindOpEl = bindEl.addBindingOperationElement();
+        
+        assertTrue("BindingElement doesn't have correct BindingOperationElement",
+                Arrays.asList(bindEl.getBindingOperationElements()).contains(bindOpEl));
+        assertTrue("BindingOperationElement has incorrect parent", bindOpEl.getParentElement() == bindEl);
+    }
+    
+    public void testBindingFaultReferenceElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        BindingElement bindEl = descEl.addBindingElement();
+        BindingOperationElement bindOpEl = bindEl.addBindingOperationElement();
+        BindingFaultReferenceElement bindFREl = bindOpEl.addBindingFaultReferenceElement();
+        
+        assertTrue("BindingOperationElement doesn't have correct BindingFaultReferenceElement",
+                Arrays.asList(bindOpEl.getBindingFaultReferenceElements()).contains(bindFREl));
+        assertTrue("BindingOperationElement has incorrect parent", bindOpEl.getParentElement() == bindEl);
+    }
+
+    public void testBindingMessageReferenceElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        BindingElement bindEl = descEl.addBindingElement();
+        BindingOperationElement bindOpEl = bindEl.addBindingOperationElement();
+        BindingMessageReferenceElement bindMREl = bindOpEl.addBindingMessageReferenceElement();
+        
+        assertTrue("BindingOperationElement doesn't have correct BindingMessageReferenceElement",
+                Arrays.asList(bindOpEl.getBindingMessageReferenceElements()).contains(bindMREl));
+        assertTrue("BindingOperationElement has incorrect parent", bindOpEl.getParentElement() == bindEl);
+    }
+
+    // Elements addable to Interface
+    public void testInterfaceFaultElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        InterfaceElement interfaceEl = descEl.addInterfaceElement();
+
+        InterfaceFaultElement interfaceFEl = interfaceEl.addInterfaceFaultElement();
+        
+        assertTrue("InterfaceElement doesn't have correct InterfaceFaultElement",
+                Arrays.asList(interfaceEl.getInterfaceFaultElements()).contains(interfaceFEl));
+        assertTrue("InterfaceFaultElement has incorrect parent", interfaceFEl.getParentElement() == interfaceEl);
+    }
+
+    public void testInterfaceOperationElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        InterfaceElement interfaceEl = descEl.addInterfaceElement();
+
+        InterfaceOperationElement interfaceOpEl = interfaceEl.addInterfaceOperationElement();
+        
+        assertTrue("InterfaceElement doesn't have correct InterfaceOperationElement",
+                Arrays.asList(interfaceEl.getInterfaceOperationElements()).contains(interfaceOpEl));
+        assertTrue("InterfaceOperationElement has incorrect parent", interfaceOpEl.getParentElement() == interfaceEl);
+    }
+    
+    public void testInterfaceFaultReferenceElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        InterfaceElement interfaceEl = descEl.addInterfaceElement();
+        InterfaceOperationElement interfaceOpEl = interfaceEl.addInterfaceOperationElement();
+        InterfaceFaultReferenceElement interfaceFREl = interfaceOpEl.addInterfaceFaultReferenceElement();
+        
+        assertTrue("InterfaceOperationElement doesn't have correct InterfaceFaultReferenceElement",
+                Arrays.asList(interfaceOpEl.getInterfaceFaultReferenceElements()).contains(interfaceFREl));
+        assertTrue("InterfaceFaultReferenceElement has incorrect parent", interfaceFREl.getParentElement() == interfaceOpEl);
+    }
+
+    public void testInterfaceMessageReferenceElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        InterfaceElement interfaceEl = descEl.addInterfaceElement();
+        InterfaceOperationElement interfaceOpEl = interfaceEl.addInterfaceOperationElement();
+        InterfaceMessageReferenceElement interfaceMREl = interfaceOpEl.addInterfaceMessageReferenceElement();
+        
+        assertTrue("InterfaceOperationElement doesn't have correct InterfaceMessageReferenceElement",
+                Arrays.asList(interfaceOpEl.getInterfaceMessageReferenceElements()).contains(interfaceMREl));
+        assertTrue("InterfaceMessageReferenceElement has incorrect parent", interfaceMREl.getParentElement() == interfaceOpEl);
+    }
+    
+    public void testEndpointElement() {
+        DescriptionElement descEl = fFactory.newDescription();
+        ServiceElement serviceEl = descEl.addServiceElement();
+        EndpointElement endpointEl = serviceEl.addEndpointElement();
+        
+        assertTrue("ServiceElement doesn't have correct EndpointElement",
+                Arrays.asList(serviceEl.getEndpointElements()).contains(endpointEl));
+        assertTrue("EndpointElement has incorrect parent", endpointEl.getParentElement() == serviceEl);
+    }
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DescriptiontElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,157 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+
+/**
+ * Unit tests for the DescriptionElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class DescriptiontElementTest extends TestCase {
+
+	private DescriptionElement fDescriptionElement = null;
+    private String fPrefix1 = "prefix1";
+    private String fPrefix2 = "prefix2";
+	private URI fNamespace1 = null;	
+	private URI fNamespace2 = null;	
+	private URI fDocBaseUri = null;
+    private WSDLFactory fFactory = null;
+	
+	public static Test suite()
+	{
+	   return new TestSuite(DescriptiontElementTest.class);
+	}
+	   
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        
+        try {
+            fFactory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+        fDescriptionElement = fFactory.newDescription();
+		fNamespace1 = new URI("http://apache.org/namespaceURIa");
+		fNamespace2 = new URI("http://apache.org/namespaceURIb");
+		fDocBaseUri = new URI("http://apache.org/documentbaseURI");
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+	
+	public void testSetGetDocumentBaseURI() {
+		fDescriptionElement.setDocumentBaseURI(fDocBaseUri);
+		URI retrievedUri = fDescriptionElement.getDocumentBaseURI();
+		assertEquals("Retrieved document base URI differs from that set", fDocBaseUri, retrievedUri);
+
+	}
+
+	public void testSetGetTargetNamespace() {
+		fDescriptionElement.setTargetNamespace(fNamespace1);
+		URI retrievedTNS = fDescriptionElement.getTargetNamespace();
+		assertEquals("Retrieved target Namespace URI differs from that set", fNamespace1, retrievedTNS);
+	}
+
+	public void testAddGetImportElements() {
+		ImportElement importElement1 = fDescriptionElement.addImportElement();
+		ImportElement importElement2 = fDescriptionElement.addImportElement();
+		ImportElement[] imports = fDescriptionElement.getImportElements();
+		assertEquals("Expected 2 import elements", 2, imports.length);
+	}
+
+	public void testAddGetIncludeElements() {
+		IncludeElement includeElement1 = fDescriptionElement.addIncludeElement();
+		IncludeElement includeElement2 = fDescriptionElement.addIncludeElement();
+		IncludeElement[] includes = fDescriptionElement.getIncludeElements();
+		assertEquals("Expected 2 include elements", 2, includes.length);
+	}
+
+	public void testAddGetInterfaceElements() {
+		InterfaceElement interfaceElement1 = fDescriptionElement.addInterfaceElement();
+		InterfaceElement interfaceElement2 = fDescriptionElement.addInterfaceElement();
+		InterfaceElement[] interfaces = fDescriptionElement.getInterfaceElements();
+		assertEquals("Expected 2 interface elements", 2, interfaces.length);
+	}
+
+	public void testAddGetBindingElements() {
+		BindingElement bindingElement1 = fDescriptionElement.addBindingElement();
+		BindingElement bindingElement2 = fDescriptionElement.addBindingElement();
+		BindingElement[] bindings = fDescriptionElement.getBindingElements();
+		assertEquals("Expected 2 binding elements", 2, bindings.length);
+	}
+
+	public void testAddGetServiceElements() {
+		ServiceElement serviceElement1 = fDescriptionElement.addServiceElement();
+		ServiceElement serviceElement2 = fDescriptionElement.addServiceElement();
+		ServiceElement[] services = fDescriptionElement.getServiceElements();
+		assertEquals("Expected 2 service elements", 2, services.length);
+	}
+
+	/*
+	 * Call the method once to create a new TypesElement and check that its parent is the
+	 * DescriptionElement under test.
+	 * Call the method again and ensure the same TypesElement object is returned.
+	 */
+	public void testGetTypesElement() {
+		// check first getTypesElement invocation...
+		TypesElement typesElement = fDescriptionElement.getTypesElement();
+		assertNull("Method returned TypesElement but expected null", typesElement);
+		
+		// now create a new TypesElement
+		try {
+		    typesElement = fDescriptionElement.addTypesElement();
+		} catch (WSDLException e) {
+		    fail("Method could not create a new TypesElement as one already exists.");
+		}
+		assertNotNull("Method returned null but expected a TypesElement", typesElement);
+		
+		if (typesElement != null) {
+			assertSame("Expected DescriptionElement to be parent of the TypesElement",
+					typesElement.getParentElement(), fDescriptionElement);
+		}	
+		// check subsequent getTypesElement invocation...
+		assertSame(typesElement, fDescriptionElement.getTypesElement());
+	}
+
+	public void testToComponent() {
+		Description descComponent = fDescriptionElement.toComponent();
+		assertNotNull("Null component object model unexpected", descComponent);
+	}
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DocumentationElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DocumentationElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DocumentationElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/DocumentationElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,130 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.XMLElement;
+
+/**
+ * Unit tests for DocumentationImpl class.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ *
+ */
+public class DocumentationElementTest extends TestCase {
+
+    public static Test suite()
+    {
+       return new TestSuite(DocumentationElementTest.class);
+    }
+    
+    /**
+     * This is a Bare minimum test XMLElement to test the DocumentationElement.
+     */
+    private class TestXMLElement implements XMLElement {
+        public String getAttributeValue(String attrName) {
+            return null;
+        }
+
+        public XMLElement[] getChildElements() {
+            return null;
+        }
+
+        public XMLElement getFirstChildElement() {
+            return null;
+        }
+
+        public String getLocalName() {
+            return null;
+        }
+
+        public URI getNamespaceURI() throws WSDLException {
+            return null;
+        }
+
+        public XMLElement getNextSiblingElement() {
+            return null;
+        }
+
+        public QName getQName() {
+            return null;
+        }
+
+        public QName getQName(String prefixedValue) throws WSDLException {
+            return null;
+        }
+
+        public Object getSource() {
+            return null;
+        }
+
+        public void setSource(Object elem) {            
+        }
+    }
+
+    private WSDLFactory fFactory = null;
+    
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        
+        try {
+            fFactory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+    }
+    
+    /**
+     * Test method for {@link org.apache.woden.internal.wsdl20.DocumentationImpl#setContent(java.lang.Object)}.
+     * Test method for {@link org.apache.woden.internal.wsdl20.DocumentationImpl#setContent(java.lang.Object)}.
+     */
+    public void testSetGetContent() {
+        DescriptionElement descElem = fFactory.newDescription();
+        DocumentationElement docElem = descElem.addDocumentationElement();
+        
+        //check that the doc element is empty when first created
+        assertNull(docElem.getContent());
+        
+        //test the setter and getter methods for doc elem content
+        XMLElement xmlel = new TestXMLElement();
+        docElem.setContent(xmlel);
+        assertEquals(xmlel, docElem.getContent());
+    }
+
+    /**
+     * Test method for {@link org.apache.woden.internal.wsdl20.DocumentationImpl#getParentElement()}.
+     */
+    public void testGetParentElement() {
+        DescriptionElement descElem1 = fFactory.newDescription();
+        DocumentationElement docElem = descElem1.addDocumentationElement();
+        
+        //check the parent
+        assertEquals(descElem1, docElem.getParentElement());
+    }
+
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/EndpointElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/EndpointElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/EndpointElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/EndpointElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,198 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.internal.wsdl20.EndpointImpl;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Description;
+
+/**
+ * Functional verification test of org.apache.woden.wsdl20.xml.EndpointElement.
+ * Checks that the expected API behaviour is supported by the implementation.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class EndpointElementTest extends TestCase 
+{
+    private WSDLFactory fFactory = null;
+    private WSDLReader fReader = null;
+    private ErrorHandler fHandler = null;
+    private DescriptionElement fParsedDesc = null;
+    private EndpointElement[] fParsedEndpoints = null;
+    
+    private String fTargetNS = "http://ws.apache.woden/endpoint";
+
+    public static Test suite()
+    {
+        return new TestSuite(EndpointElementTest.class);
+    }
+
+    protected void setUp() throws Exception 
+    {
+        fFactory = WSDLFactory.newInstance();
+        fReader = fFactory.newWSDLReader();
+        fHandler = new TestErrorHandler();
+        fReader.getErrorReporter().setErrorHandler(fHandler);
+        
+        URL wsdlURL = getClass().getClassLoader().getResource(
+            "org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl");
+        assertNotNull("Failed to find the WSDL document on the classpath.", wsdlURL);
+        
+        Description descComp = fReader.readWSDL(wsdlURL.toString());
+        assertNotNull("The reader did not return a description.", descComp);
+        fParsedDesc = descComp.toElement();
+        
+        ServiceElement service = fParsedDesc.getServiceElements()[0];
+        assertNotNull("The description does not contain a service.", service);
+        
+        fParsedEndpoints = service.getEndpointElements();
+        assertTrue("The service does not contain 3 endpoints as expected.",
+                fParsedEndpoints.length == 3);
+    }
+
+    protected void tearDown() throws Exception 
+    {
+        fFactory = null;
+        fReader = null;
+        fHandler = null;
+        fParsedDesc = null;
+        fParsedEndpoints = null;
+    }
+    
+    /**
+     * Test that the getName method returns the expected NCName parsed from a WSDL document.
+     */
+    public void testGetNameParsed() 
+    {
+        NCName ncName = fParsedEndpoints[0].getName();
+        assertNotNull("EndpointElement.getName() returned null, but an NCName was expected.",
+                ncName);
+        
+        assertTrue("NCName returned by EndpointElement.getName() was not the one expected.",
+                "endpoint1".equals(ncName.toString()) );
+    }
+
+    /**
+     * Test that the NCName specified on the setName method is returned by getName.
+     */
+    public void testSetAndGetName()
+    {
+        EndpointElement endpoint = new EndpointImpl();
+        NCName ncName = new NCName("dummy");
+
+        endpoint.setName(ncName);
+        assertTrue("NCName returned by EndpointElement.getName() was not the one set by setName().",
+                ncName.equals(endpoint.getName()));
+    }
+
+    /**
+     * Test that the getBindingName method returns the QName of the binding
+     * associated with this endpoint, as specified by the "binding" attribute
+     * of the &lt;endpoint&gt; element in a parsed WSDL document.
+     */
+    public void testGetBindingNameParsed()
+    {
+        QName qname = fParsedEndpoints[0].getBindingName();
+        assertNotNull("EndpointElement.getBindingName() returned null, but a QName was expected.",
+                      qname);
+        
+        QName expectedQN = new QName(fTargetNS, "binding1");
+        assertTrue("QName returned by EndpointElement.getBindingName() was not the one expected.",
+                   expectedQN.equals(qname));
+    }
+
+    /**
+     * Test that the QName specified on the setBindingName method is returned by 
+     * the getBindingName method.
+     */
+    public void testSetAndGetBindingName()
+    {
+        EndpointElement endpoint = new EndpointImpl();
+        QName qname = new QName("urn:woden","dummy");
+        endpoint.setBindingName(qname);
+        QName returnedQN = endpoint.getBindingName();
+        assertTrue("QName returned by EndpointElement.getBindingName() was not the one set by setBindingName().",
+                   returnedQN.equals(qname));
+    }
+    
+    /**
+     * Test that the getBindingElement method returns a BindingElement 
+     * defined within the description, that is referred to by QName in the 
+     * "binding" attribute of the &lt;endpoint&gt; element of a parsed WSDL 
+     * document. This tests that the QName is correctly dereferenced to an object.
+     */
+    public void testGetBindingElementParsed()
+    {
+        BindingElement bindingDefined = fParsedDesc.getBindingElements()[0];
+        BindingElement bindingReferred = fParsedEndpoints[0].getBindingElement();
+        assertNotNull("EndpointElement.getBindingElement() returned null, but a BindingElement was expected.",
+                bindingReferred);
+        
+        assertTrue("The BindingElement returned by EndpointElement.getBindingElement() was not the one expected.",
+                bindingReferred == bindingDefined);
+    }
+
+    /**
+     * Test that the getAddress method returns the expected URI parsed from a WSDL document.
+     */
+    public void testGetAddressParsed() 
+    {
+        URI uri = fParsedEndpoints[0].getAddress();
+        assertNotNull("EndpointElement.getAddress() returned null, but a URI was expected.",
+                uri);
+        
+        assertTrue("URI returned by EndpointElement.getAddress() was not the one expected.",
+                "urn:abc".equals(uri.toString()) );
+    }
+
+    /**
+     * Test the optionality of the 'address' attribute by invoking the getAddress
+     * method on a parsed &lt;endpoint&gt; element that does not have an
+     * 'address' specified and check that it returns null.
+     */
+    public void testGetAddressParsedOptional() 
+    {
+        URI uri = fParsedEndpoints[1].getAddress();
+        assertNull("EndpointElement.getAddress() did not return null, as expected.",
+                uri);
+    }
+
+    /**
+     * Test that the URI specified on the setAddress method is returned by getAddress.
+     */
+    public void testSetAndGetAddress() throws Exception
+    {
+        EndpointElement endpoint = new EndpointImpl();
+        URI uri = new URI("urn:dummy");
+        endpoint.setAddress(uri);
+        assertTrue("URI returned by EndpointElement.getAddress() was not the one set by setAddress().",
+                   "urn:dummy".equals(endpoint.getAddress().toString()));
+    }
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ImportElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ImportElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ImportElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/ImportElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,124 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.ImportImpl;
+
+/**
+ * Unit tests for the ImportElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class ImportElementTest extends TestCase {
+
+	private ImportElement fImport = new ImportImpl();
+	private DescriptionElement fDescriptionElement = null;
+	private URI fURI = null;	
+    private WSDLFactory fFactory = null;
+	
+	public static Test suite()
+	{
+	   return new TestSuite(ImportElementTest.class);
+	}
+	   
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        
+        try {
+            fFactory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+        fDescriptionElement = fFactory.newDescription();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+	
+	/**
+	 * Test that a Description Element can be successfully set and retrieved from an ImportElement
+	 */
+	public void testSetGetDescriptionElement()
+	{
+		fImport.setDescriptionElement(fDescriptionElement);
+		assertEquals("The retrieved Description Element object is not that which was set", 
+                fDescriptionElement, fImport.getDescriptionElement());
+	}
+
+	/**
+	 * Test that a Location URI can be successfully set and retrieved from an ImportElement
+	 */
+	public void testSetGetLocation()
+	{
+		try 
+		{
+			fURI = new URI("http://apache.org/test");
+		} catch (URISyntaxException e) {
+			
+		}
+		fImport.setLocation(fURI);
+		assertEquals("The retrieved Location URI object is not that which was set", fURI, fImport.getLocation());
+	}
+	
+	public void testSetGetNamespace()
+	{
+		try 
+		{
+			fURI = new URI("http://apache.org/test");
+		} catch (URISyntaxException e) {
+			
+		}
+		fImport.setNamespace(fURI);
+		assertEquals("The retrieved Location URI object is not that which was set", fURI, fImport.getNamespace());
+	}
+	
+	/**
+	 * Test that an ImportElement without its optional Namespace attribute set, returns null from its getter method
+	 */
+	public void testGetNamespaceDefault()
+	{	
+		assertNull("The namespace was unset but appears set.", fImport.getNamespace());
+	}
+	
+    public void testGetParentElement() {
+        DescriptionElement desc = fFactory.newDescription();
+        ImportElement importEl = desc.addImportElement();
+        DescriptionElement parent = (DescriptionElement)importEl.getParentElement();
+        assertSame("The import's parent should be the description that created it", desc, parent);
+                
+    }
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/IncludeElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/IncludeElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/IncludeElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/IncludeElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,89 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.IncludeImpl;
+
+/**
+ * Unit tests for the IncludeElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class IncludeElementTest extends TestCase {
+
+	private IncludeElement fInclude = new IncludeImpl();
+	private DescriptionElement fDescriptionElement = null;
+	private URI fURI = null;
+    private WSDLFactory fFactory = null;
+	
+	public static Test suite()
+	{
+	   return new TestSuite(IncludeElementTest.class);
+	}
+	
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        
+        try {
+            fFactory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+        fDescriptionElement = fFactory.newDescription();
+    }
+
+	/**
+	 * Test that a Description Element can be successfully set and retrieved from an IncludeElement
+	 */
+	public void testSetGetDescriptionElement()
+	{
+		fInclude.setDescriptionElement(fDescriptionElement);
+		assertEquals("The retrieved Description Element object is not that which was set", 
+                fDescriptionElement, fInclude.getDescriptionElement());
+	}
+
+	/**
+	 * Test that a Location URI can be successfully set and retrieved from an IncludeElement
+	 */
+	public void testSetGetLocation()
+	{
+		try 
+		{
+			fURI = new URI("http://apache.org/test");
+		} catch (URISyntaxException e) {
+			
+		}
+		fInclude.setLocation(fURI);
+		assertEquals("The retrieved Location URI object is not that which was set", fURI, fInclude.getLocation());
+	}
+
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,287 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the InterfaceElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceElementTest extends TestCase {
+
+	// create a parent Description to hang the Interfaces off
+	private DescriptionElement fDescriptionElement = null;
+	private InterfaceElement fInterfaceElement = null;
+	private URI fStyleDefaultURI1 = null;
+	private URI fStyleDefaultURI2 = null;
+	
+	public static Test suite()
+	{
+	   return new TestSuite(InterfaceElementTest.class);
+	}
+	   
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+
+        WSDLFactory factory = null;
+        try {
+            factory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+        fDescriptionElement = factory.newDescription();
+        fInterfaceElement = fDescriptionElement.addInterfaceElement();
+        fStyleDefaultURI1 = new URI("http://www.w3.org/0000/00/apacheStyle");
+        fStyleDefaultURI2 = new URI("http://www.w3.org/0000/00/anotherApacheStyle");
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+	
+    /*
+     * Mandatory attribute ("name")
+     * - setName() 
+     * - getName() 
+     */
+	public void testGetSetName() 
+	{	
+		fInterfaceElement.setName(new NCName("interfaceName"));
+		QName uri = fInterfaceElement.getName();
+		assertEquals("Retrieved InterfaceElement name does not match that set -", "interfaceName", uri.toString());
+	}
+	
+	/*
+	 * Gets InterfaceElements referenced by the "extends" attribute (optional)
+	 */
+	public void testGetExtendedInterfaceElementElements() 
+	{
+		/*
+		 * create some InterfaceElements to extend, add them to parent,
+		 * access them via :
+		 * - getExtendedInterfaceElement()
+		 * - getExtendedInterfaceElements()
+		 */
+		
+		// check the default:
+		InterfaceElement[] ifeArray = fInterfaceElement.getExtendedInterfaceElements();
+		assertEquals("Retrieved Extended InterfaceElement group should be empty if none set -", 0, ifeArray.length);
+	
+		// create further InterfaceElements and name them
+		InterfaceElement xife1 = fDescriptionElement.addInterfaceElement();
+		InterfaceElement xife2 = fDescriptionElement.addInterfaceElement();
+		xife1.setName(new NCName("extendedIE1"));
+		xife2.setName(new NCName("extendedIE2"));
+		fInterfaceElement.addExtendedInterfaceName(new QName("extendedIE1"));
+		fInterfaceElement.addExtendedInterfaceName(new QName("extendedIE2"));
+		
+		// getExtendedInterfaceElements()
+		ifeArray = fInterfaceElement.getExtendedInterfaceElements();
+		assertEquals("Incorrect number of retrieved Extended InterfaceElements -", 2, ifeArray.length);
+		// verify object equivalence
+		List ifeL = Arrays.asList(ifeArray);
+		assertTrue(ifeL.contains(xife1));
+		assertTrue(ifeL.contains(xife2));
+		
+		// getExtendedInterfaceElement()
+		InterfaceElement retrievedIfe = fInterfaceElement.getExtendedInterfaceElement(new QName("extendedIE1"));
+		assertEquals("Retrieved Extended InterfaceElement unexpected -", xife1, retrievedIfe);
+		retrievedIfe = fInterfaceElement.getExtendedInterfaceElement(new QName("randomUnset"));
+		assertNull("The name of a non-existent InterfaceElement should not return one -", retrievedIfe);
+	}
+	
+    /*
+     * Optional attribute ("extends")
+     * - addExtendedInterfaceName() 
+     * - getExtendedInterfaceNames()
+     * - removeExtendedInterfaceName() 
+     */
+	public void testAddGetRemoveExtendedInterfaceNames() 
+	{	
+		// check the default:
+		QName[] ifeQnameArray = fInterfaceElement.getExtendedInterfaceNames();
+		assertEquals("Retrieved Extended InterfaceElement QName group should be empty if none set -", 0, ifeQnameArray.length);
+
+		// create further InterfaceElements and name them
+		InterfaceElement xife1 = fDescriptionElement.addInterfaceElement();
+		InterfaceElement xife2 = fDescriptionElement.addInterfaceElement();
+		xife1.setName(new NCName("extendedIE1"));
+		xife2.setName(new NCName("extendedIE2"));
+		
+		// addExtendedInterfaceName()
+		QName xifeQname1 = new QName("extendedIE1");
+		fInterfaceElement.addExtendedInterfaceName(xifeQname1);
+		QName xifeQname2 = new QName("extendedIE2");
+		fInterfaceElement.addExtendedInterfaceName(xifeQname2);
+		assertNotNull("Retrieved Extended InterfaceElement from a valid name expected.", 
+				fInterfaceElement.getExtendedInterfaceElement(xifeQname1));
+		// Add a qname on a non-existent InterfaceElement
+		QName xifeQname3 = new QName("nonExistentExtendedIE");
+		fInterfaceElement.addExtendedInterfaceName(xifeQname3);		
+		
+		// getExtendedInterfaceNames()
+		QName[] ifeNames = fInterfaceElement.getExtendedInterfaceNames();
+		assertNotNull("Expected an array of QNames.", ifeNames);
+		assertEquals("Incorrect number of retrieved Extended InterfaceElement names -", 3, ifeNames.length);
+		// verify all names returned
+		List ifeL = Arrays.asList(ifeNames);
+		assertTrue(ifeL.contains(xifeQname1));
+		assertTrue(ifeL.contains(xifeQname2));
+		assertTrue(ifeL.contains(xifeQname3));
+		// verify that xifeQname3 does not refer to any InterfaceElement
+		assertNull("Extended InterfaceElement for name " + xifeQname3 + " unexpected.", 
+				fInterfaceElement.getExtendedInterfaceElement(xifeQname3));
+		
+		// removeExtendedInterfaceName() 
+		fInterfaceElement.removeExtendedInterfaceName(xifeQname1);
+		fInterfaceElement.removeExtendedInterfaceName(xifeQname3);
+		fInterfaceElement.removeExtendedInterfaceName(xifeQname2);
+		ifeNames = fInterfaceElement.getExtendedInterfaceNames();
+		assertNotNull("Expected an (empty) array of QNames.", ifeNames);
+		assertEquals("Incorrect number of retrieved Extended InterfaceElement names -", 0, ifeNames.length);
+	}
+	
+	/*
+     * Optional attribute ("styleDefault")
+     * styleDefault comprises a list of URIs (IRIs in the spec)
+     * - getStyleDefault() returns the list
+     * - addStyleDefaultURI() adds to the list
+     */
+	public void testAddGetStyleDefault() 
+	{		
+		// check the default:
+		URI[] styleDefault = fInterfaceElement.getStyleDefault();
+		assertNotNull(styleDefault);
+		assertEquals("Retrieved InterfaceElement style default should be empty if none set -", 0, styleDefault.length);
+		
+		// addStyleDefaultURI() a couple of times
+		fInterfaceElement.addStyleDefaultURI(fStyleDefaultURI1);
+		fInterfaceElement.addStyleDefaultURI(fStyleDefaultURI2);
+		
+		// getStyleDefault()
+		styleDefault = fInterfaceElement.getStyleDefault();
+		assertNotNull(styleDefault);
+		assertEquals("Unexpected number of URIs in the styleDefault -", 2, styleDefault.length);
+		// check that all added URIs appear in the styleDefault
+		List sdL = Arrays.asList(styleDefault);
+		assertTrue(sdL.contains(fStyleDefaultURI1));
+		assertTrue(sdL.contains(fStyleDefaultURI2));
+	}    
+	
+	/*
+     * Optional element ("fault")
+     * - addInterfaceFaultElement() 
+     * - getInterfaceFaultElement() 
+     * - getInterfaceFaultElements() 
+     */
+	public void testAddGetInterfaceFaultElements() 
+	{		
+		// check the default:
+		InterfaceFaultElement[] iffeArray = fInterfaceElement.getInterfaceFaultElements();
+		assertNotNull("Expected an array of InterfaceFaultElements -", iffeArray);
+		assertEquals("Retrieved InterfaceFaultElement group should be empty if none set -", 0, iffeArray.length);
+
+		// addInterfaceFaultElement()
+		InterfaceFaultElement iffe1 = fInterfaceElement.addInterfaceFaultElement();
+		InterfaceFaultElement iffe2 = fInterfaceElement.addInterfaceFaultElement();
+		assertNotNull(iffe1);
+		assertNotNull(iffe2);
+
+		// getInterfaceFaultElements()
+		iffeArray = fInterfaceElement.getInterfaceFaultElements();
+		assertNotNull("Expected an array of InterfaceFaultElements -", iffeArray);
+		assertEquals("Incorrect number of retrieved InterfaceFaultElements -", 2, iffeArray.length);
+
+		// verify all Fault objects returned
+		List iffeL = Arrays.asList(iffeArray);
+		assertTrue(iffeL.contains(iffe1));
+		assertTrue(iffeL.contains(iffe2));
+	
+		// getInterfaceFaultElement()
+		// name one of them
+		iffe1.setName(new NCName("FaultName"));
+		InterfaceFaultElement retrievedIffe = fInterfaceElement.getInterfaceFaultElement(new QName("FaultName"));
+		assertNotNull(retrievedIffe);
+		assertEquals("Retrieved InterfaceFaultElement differs from that expected", iffe1, retrievedIffe);
+		// try a non-existent fault - should return null
+		retrievedIffe = fInterfaceElement.getInterfaceFaultElement(new QName("nonExistentFault"));
+		assertNull(retrievedIffe);
+	}    
+    
+	/*
+     * Optional element ("operation")
+     * - addInterfaceOperationElement() 
+     * - getInterfaceOperationElement() 
+     * - getInterfaceOperationElements() 
+     */
+	public void testAddGetInterfaceOperationElements() 
+	{		
+		// check the default:
+		InterfaceOperationElement[] ifopArray = fInterfaceElement.getInterfaceOperationElements();
+		assertNotNull("Expected an array of InterfaceOperationElements -", ifopArray);
+		assertEquals("Retrieved InterfaceOperationElement group should be empty if none set -", 0, ifopArray.length);
+
+		// addInterfaceOperationElement()
+		InterfaceOperationElement ifop1 = fInterfaceElement.addInterfaceOperationElement();
+		InterfaceOperationElement ifop2 = fInterfaceElement.addInterfaceOperationElement();
+		assertNotNull(ifop1);
+		assertNotNull(ifop2);
+
+		// getInterfaceOperationElements()
+		ifopArray = fInterfaceElement.getInterfaceOperationElements();
+		assertNotNull("Expected an array of InterfaceOperationElements -", ifopArray);
+		assertEquals("Incorrect number of retrieved InterfaceOperationElements -", 2, ifopArray.length);
+
+		// verify all Operation objects returned
+		List ifopL = Arrays.asList(ifopArray);
+		assertTrue(ifopL.contains(ifop1));
+		assertTrue(ifopL.contains(ifop2));
+	
+		// getInterfaceOperationElement()
+		// name one of them
+		ifop1.setName(new NCName("OperationName"));
+		InterfaceOperationElement retrievedIfop = fInterfaceElement.getInterfaceOperationElement(new QName("OperationName"));
+		assertNotNull(retrievedIfop);
+		assertEquals("Retrieved InterfaceOperationElement differs from that expected", ifop1, retrievedIfop);
+		// try a non-existent operation - should return null
+		retrievedIfop = fInterfaceElement.getInterfaceOperationElement(new QName("nonExistentOperation"));
+		assertNull(retrievedIfop);
+	}   
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,177 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.schema.InlinedSchemaImpl;
+import org.apache.woden.schema.InlinedSchema;
+import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.xerces.parsers.DOMParser;
+import org.apache.xerces.xni.parser.XMLInputSource;
+import org.w3c.dom.Document;
+
+/**
+ * Unit tests for the InterfaceFaultElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceFaultElementTest extends TestCase {
+
+    private DescriptionElement fDescriptionElement = null;
+    private InterfaceElement fInterfaceElement = null;
+	private InterfaceFaultElement fFaultElement;
+    private final String TNS = "http://example.org";
+    private final String INTF_NAME = "interfaceName";
+    private final String FAULT_NAME = "faultName";
+
+	public static Test suite()
+	{
+	   return new TestSuite(InterfaceFaultElementTest.class);
+	}
+    
+    public void setUp() {
+
+        WSDLFactory factory = null;
+        try {
+            factory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+        fDescriptionElement = factory.newDescription();
+        fDescriptionElement.setTargetNamespace(URI.create(TNS));
+        fInterfaceElement = fDescriptionElement.addInterfaceElement();
+        fInterfaceElement.setName(new NCName(INTF_NAME));
+        fFaultElement = fInterfaceElement.addInterfaceFaultElement();
+    }
+	
+	/*
+	 * Test that a (Mandatory) Name QName can be successfully set and retrieved
+	 */
+	public void testSetGetName()
+	{
+		QName faultName = new QName(TNS, FAULT_NAME);
+		NCName faultNCName = new NCName(FAULT_NAME);
+		fFaultElement.setName(faultNCName);
+		assertEquals("The retrieved fault name is not that which was set", 
+				faultName, fFaultElement.getName());
+	}
+    
+    /*
+     * Test that the optional attribute ("element") can be successfully set and retrieved
+     */
+    public void testSetGetElement()
+    {
+        //test with type qname.
+        QNameTokenUnion element = new QNameTokenUnion(new QName("ElementName"));
+        fFaultElement.setElement(element);
+        assertEquals("The retrieved 'element' attribute is not that which was set", 
+                element, fFaultElement.getElement());
+        
+        //test with type token.
+        QNameTokenUnion token = QNameTokenUnion.ANY;
+        fFaultElement.setElement(token);
+        assertEquals("The retrieved 'element' attribute is not that which was set", 
+                token, fFaultElement.getElement());
+    }
+    
+    /* 
+     * Test that the optional schema element declaration can be successfully retrieved if 
+     * the QNameTokenUnion is of type qname and if it is of type token, that there is no
+     * element declaration returned.
+     */
+    public void testGetXmlSchemaElement() throws Exception
+    {
+        WSDLFactory factory = null;
+        try {
+            factory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+        // Create the DescriptionElement->InterfaceElement->InterfaceOperationElement->InterfaceMessageReferenceElement hierarchy
+        DescriptionElement descriptionElement = factory.newDescription();
+        InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
+        InterfaceFaultElement faultElement = interfaceElement.addInterfaceFaultElement();
+        
+        // Default case:
+        XmlSchemaElement retrievedElement = faultElement.getXmlSchemaElement();
+        assertNull("Should return null if 'element' attribute is not set", retrievedElement);
+
+        // Case 1 - (with 'element' set to #any)
+        faultElement.setElement(QNameTokenUnion.ANY);
+        retrievedElement = faultElement.getXmlSchemaElement();
+        assertNull("Should return null if 'element' attribute is #any", retrievedElement);
+
+        // Case 2 - (with 'element' set to #none)
+        faultElement.setElement(QNameTokenUnion.NONE);
+        retrievedElement = faultElement.getXmlSchemaElement();
+        assertNull("Should return null if 'element' attribute is #none", retrievedElement);
+
+        // Case 3 - (with 'element' set to #other)
+        faultElement.setElement(QNameTokenUnion.OTHER);
+        retrievedElement = faultElement.getXmlSchemaElement();
+        assertNull("Should return null if 'element' attribute is #other", retrievedElement);
+
+        // Case 4 - (with 'element' set to the qname of a schema element declaration)
+        TypesElement typesElement = descriptionElement.addTypesElement();  //throws WSDLException
+        InlinedSchema schema = new InlinedSchemaImpl();
+        String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+                  + "<complexType name=\"myType\">"     
+                  + "<sequence>"     
+                  + "<element  name=\"element\" type=\"string\"/>"      
+                  + "</sequence>"     
+                  + "</complexType>" 
+                  + "<element name=\"myElement\" type=\"string\"/>"
+                  + "</schema>";
+        DOMParser builder = new DOMParser();
+        Reader reader = new StringReader(schemaString);
+        XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
+        builder.parse(is);  //throws IOException
+        Document schemaDoc1 = builder.getDocument();
+        XmlSchemaCollection xsc = new XmlSchemaCollection();
+        XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
+        schema.setSchemaDefinition(xs1);
+        URI schemaNS = URI.create("http://www.sample.org");
+        schema.setNamespace(schemaNS);
+        typesElement.addSchema(schema);
+        
+        QName elemQN = new QName("http://www.sample.org","myElement");
+        XmlSchemaElement expectedElement = xs1.getElementByName(elemQN);
+        
+        faultElement.setElement(new QNameTokenUnion(elemQN));
+        retrievedElement = faultElement.getXmlSchemaElement();
+        assertEquals("The 'element' qname should resolve to the expected XML Schema element declaration", 
+                expectedElement, retrievedElement);
+    }
+
+}

Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java Tue Sep  1 05:50:45 2009
@@ -0,0 +1,127 @@
+/**
+ * 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.woden.wsdl20.xml;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.InterfaceFaultReferenceImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.enumeration.Direction;
+
+/**
+ * Unit tests for the InterfaceFaultReferenceElement class.
+ * 
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceFaultReferenceElementTest extends TestCase {
+
+	private InterfaceFaultReferenceElement fFaultReference = null;
+
+	public static Test suite()
+	{
+	   return new TestSuite(InterfaceFaultReferenceElementTest.class);
+	   
+	}
+	   /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+    	super.setUp();
+    	fFaultReference = new InterfaceFaultReferenceImpl();
+    }
+    
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+	
+	/*
+	 * Test that a (mandatory) direction can be successfully set and retrieved
+	 */
+	public void testSetGetDirection()
+	{
+		// Default case
+		assertNull("The retrieved Element name when unset should be null", fFaultReference.getDirection());
+		
+		fFaultReference.setDirection(Direction.IN);
+		assertEquals("The retrieved FaultReference direction is not that which was set", 
+				Direction.IN, fFaultReference.getDirection());
+	}
+
+	/*
+	 * Test that the (Mandatory) message label attribute ("messageLabel") can be successfully set and retrieved
+	 */
+	public void testSetGetMessageLabel()
+	{
+		NCName faultRefNCName = new NCName("faultRefName");
+		fFaultReference.setMessageLabel(faultRefNCName);
+		assertEquals("The retrieved Element name is not that which was set", 
+				faultRefNCName, fFaultReference.getMessageLabel());
+	}
+
+	/* 
+	 * Test that the(Mandatory) InterfaceFault reference attribute ("ref") can be successfully set and retrieved 
+	 */
+	public void testSetGetRef()
+	{
+		QName faultRefName = new QName("faultRefName");
+		fFaultReference.setRef(faultRefName);
+		assertEquals("The retrieved Element name is not that which was set", 
+				faultRefName, fFaultReference.getRef());
+	}
+	
+	/* 
+	 * Test that the (Mandatory) InterfaceFault can be successfully retrieved.
+	 * The fault reference is to an Interface Fault associated with the grandparent InterfaceElement.
+	 */
+	public void testGetInterfaceFaultElement()
+	{
+        WSDLFactory factory = null;
+        try {
+            factory = WSDLFactory.newInstance();
+        } catch (WSDLException e) {
+            fail("Can't instantiate the WSDLFactory object.");
+        }
+        
+		// Create the DescriptionElement->InterfaceElement->InterfaceOperationElement->InterfaceFaultReference hierarchy
+        DescriptionElement desc = factory.newDescription();
+		InterfaceElement interfaceElement = desc.addInterfaceElement();
+		InterfaceOperationElement interfaceOperationElement = interfaceElement.addInterfaceOperationElement();
+
+		// Add an InterfaceFault to the InterfaceElement
+		InterfaceFaultElement faultElement = interfaceElement.addInterfaceFaultElement();
+		faultElement.setName(new NCName("Fault1"));
+		
+		// create the InterfaceFaultReference to test
+		InterfaceFaultReferenceElement faultReference = interfaceOperationElement.addInterfaceFaultReferenceElement();
+		faultReference.setRef(new QName("Fault1"));
+		InterfaceFaultElement retrievedFault = faultReference.getInterfaceFaultElement();
+		assertEquals("The retrieved InterfaceFaultElement is not that which was set", 
+				faultElement, retrievedFault);
+	}
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org


Mime
View raw message