Author: gturrell
Date: Sat Jan 27 15:35:39 2007
New Revision: 500689

URL: http://svn.apache.org/viewvc?view=rev&rev=500689
Log:
[WODEN-55] Part 1 - Created unit tests for API methods of all the 
Binding*Element classes (5)

Added:
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingElementTest.java
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java
Modified:
    incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java

Modified: 
incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java?view=diff&rev=500689&r1=500688&r2=500689
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java 
(original)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java 
Sat Jan 27 15:35:39 2007
@@ -49,6 +49,11 @@
 import 
org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensionsTest;
 import 
org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensionsTest;
 import 
org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensionsTest;
+import org.apache.woden.wsdl20.xml.BindingElementTest;
+import org.apache.woden.wsdl20.xml.BindingFaultElementTest;
+import org.apache.woden.wsdl20.xml.BindingFaultReferenceElementTest;
+import org.apache.woden.wsdl20.xml.BindingMessageReferenceElementTest;
+import org.apache.woden.wsdl20.xml.BindingOperationElementTest;
 import org.apache.woden.wsdl20.xml.DescriptiontElementTest;
 import org.apache.woden.wsdl20.xml.EndpointElementTest;
 import org.apache.woden.wsdl20.xml.ImportElementTest;
@@ -142,6 +147,11 @@
     addTest(InterfaceOperationTest.suite());
     addTest(InterfaceFaultReferenceTest.suite());
     addTest(InterfaceMessageReferenceTest.suite());
+    addTest(BindingElementTest.suite());
+    addTest(BindingFaultElementTest.suite());
+    addTest(BindingOperationElementTest.suite());
+    addTest(BindingFaultReferenceElementTest.suite());
+    addTest(BindingMessageReferenceElementTest.suite());
     //TODO in-progress 30May06 tests for BindingOpExt and BindingMsgRefExt
   }
 

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingElementTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingElementTest.java?view=auto&rev=500689
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingElementTest.java
 (added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingElementTest.java
 Sat Jan 27 15:35:39 2007
@@ -0,0 +1,196 @@
+/**
+ * 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.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the BindingElement class.
+ * 
+ * @author Graham Turrell ([EMAIL PROTECTED])
+ */
+public class BindingElementTest extends TestCase {
+
+       // create a parent Description to hang the Bindings off
+       private DescriptionElement fDescriptionElement = null;
+       private BindingElement fBindingElement = null;
+       private URI fTypeURI = null;
+       
+       public static Test suite()
+       {
+          return new TestSuite(BindingElementTest.class);
+       }
+          
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        fDescriptionElement = new DescriptionImpl();
+        fBindingElement = fDescriptionElement.addBindingElement();
+        fTypeURI = new URI("http://www.w3.org/0000/00/apacheType";);
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+       
+    /*
+     * Optional attribute ("interface")
+     * - setInterfaceName() 
+     * - getInterfaceName() 
+     */
+       public void testGetSetInterfaceName() 
+       {       
+               // check the default
+               QName uri = fBindingElement.getInterfaceName();
+               assertNull("Retrieved BindingElement interface name should be 
null if none set -", uri);
+               
+               fBindingElement.setInterfaceName(new QName("InterfaceName"));
+               uri = fBindingElement.getInterfaceName();
+               assertNotNull(uri);
+               assertEquals("Retrieved BindingElement interface name does not 
match that set -", "InterfaceName", uri.toString());
+       }
+       
+       /* Utility method to obtain the InterfaceElement referenced by the 
(optional) "interface" attribute 
+     * - getInterfaceElement() 
+     */
+       public void testGetInterfaceElement() 
+       {               
+               // check the default:
+               InterfaceElement retrievedInterfaceElement = 
fBindingElement.getInterfaceElement();
+               assertNull("Retrieved Interface Element should be null if none 
set -", retrievedInterfaceElement);
+
+               // Create and name an Interface Element
+               DescriptionElement desc = new DescriptionImpl();
+               InterfaceElement interfaceElement = desc.addInterfaceElement();
+               interfaceElement.setName(new NCName("interface1"));
+               
+               // Create a binding from the description and 
+               fBindingElement = desc.addBindingElement();
+       
+               // getInterfaceElement() - interface attribute unspecified, but 
hierarchy in place:
+               retrievedInterfaceElement = 
fBindingElement.getInterfaceElement();
+               assertNull("Retrieved Interface Element should be null if 
interface attribute unspecified -", retrievedInterfaceElement);
+               
+               // getInterfaceElement() - interface attribute specified, and 
hierarchy in place:
+               // Set the "interface" attribute to reference the new Interface 
Element
+               fBindingElement.setInterfaceName(new QName("interface1"));
+               retrievedInterfaceElement = 
fBindingElement.getInterfaceElement();
+               assertEquals("Retrieved Interface Element was not that expected 
-", interfaceElement, retrievedInterfaceElement);
+       }   
+       
+    /*
+     * Mandatory attribute ("name")
+     * - setName() 
+     * - getName() 
+     */
+       public void testGetSetName() 
+       {       
+               fBindingElement.setName(new NCName("BindingName"));
+               QName uri = fBindingElement.getName();
+               assertNotNull(uri);
+               assertEquals("Retrieved BindingElement name does not match that 
set -", "BindingName", uri.toString());
+       }
+
+    /*
+     * Mandatory attribute ("type")
+     * - setType() 
+     * - getType() 
+     */
+       public void testGetSetType() 
+       {       
+               fBindingElement.setType(fTypeURI);
+               URI uri = fBindingElement.getType();
+               assertEquals("Retrieved BindingElement type attribute does not 
match that set -", fTypeURI, uri);
+       }
+       
+       
+       /*
+     * Optional element ("fault")
+     * - addBindingFaultElement() 
+     * - getBindingFaultElements() 
+     */
+       public void testAddGetBindingFaultElements() 
+       {               
+               // check the default:
+               BindingFaultElement[] bfeArray = 
fBindingElement.getBindingFaultElements();
+               assertNotNull("Expected an array of BindingFaultElements -", 
bfeArray);
+               assertEquals("Retrieved BindingFaultElement group should be 
empty if none set -", 0, bfeArray.length);
+
+               // addBindingFaultElement()
+               BindingFaultElement bfe1 = 
fBindingElement.addBindingFaultElement();
+               BindingFaultElement bfe2 = 
fBindingElement.addBindingFaultElement();
+               assertNotNull(bfe1);
+               assertNotNull(bfe2);
+
+               // getBindingFaultElements()
+               bfeArray = fBindingElement.getBindingFaultElements();
+               assertNotNull("Expected an array of BindingFaultElements -", 
bfeArray);
+               assertEquals("Incorrect number of retrieved 
BindingFaultElements -", 2, bfeArray.length);
+
+               // verify all Fault objects returned
+               List bfeL = Arrays.asList(bfeArray);
+               assertTrue(bfeL.contains(bfe1));
+               assertTrue(bfeL.contains(bfe2));
+       }    
+    
+       /*
+     * Optional element ("operation")
+     * - addBindingOperationElement() 
+     * - getBindingOperationElements() 
+     */
+       public void testAddGetBindingOperationElements() 
+       {               
+               // check the default:
+               BindingOperationElement[] bopArray = 
fBindingElement.getBindingOperationElements();
+               assertNotNull("Expected an array of BindingOperationElements 
-", bopArray);
+               assertEquals("Retrieved BindingOperationElement group should be 
empty if none set -", 0, bopArray.length);
+
+               // addBindingOperationElement()
+               BindingOperationElement bop1 = 
fBindingElement.addBindingOperationElement();
+               BindingOperationElement bop2 = 
fBindingElement.addBindingOperationElement();
+               assertNotNull(bop1);
+               assertNotNull(bop2);
+
+               // getBindingOperationElements()
+               bopArray = fBindingElement.getBindingOperationElements();
+               assertNotNull("Expected an array of BindingOperationElements 
-", bopArray);
+               assertEquals("Incorrect number of retrieved 
BindingOperationElements -", 2, bopArray.length);
+
+               // verify all Operation objects returned
+               List ifopL = Arrays.asList(bopArray);
+               assertTrue(ifopL.contains(bop1));
+               assertTrue(ifopL.contains(bop2));
+       }   
+}

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java?view=auto&rev=500689
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java
 (added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java
 Sat Jan 27 15:35:39 2007
@@ -0,0 +1,100 @@
+/**
+ * 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.internal.wsdl20.BindingFaultImpl;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the BindingFaultElement class.
+ * 
+ * @author Graham Turrell ([EMAIL PROTECTED])
+ */
+public class BindingFaultElementTest extends TestCase {
+
+       private BindingFaultElement fFault = null;
+
+       public static Test suite()
+       {
+          return new TestSuite(BindingFaultElementTest.class);
+          
+       }
+          /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+       super.setUp();
+       fFault = new BindingFaultImpl();
+    }
+    
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+
+       /* 
+        * Test that the (Mandatory) BindingFault reference attribute ("ref") 
can be successfully set and retrieved 
+        */
+       public void testSetGetRef()
+       {
+               QName faultRefName = new QName("faultRefName");
+               fFault.setRef(faultRefName);
+               assertEquals("The retrieved BindingFault reference is not that 
which was set", 
+                               faultRefName, fFault.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()
+       {
+               DescriptionElement descriptionElement = new DescriptionImpl();
+
+               // Create the 
BindingElement<->InterfaceElement->InterfaceFaultElement hierarchy
+               BindingElement bindingElement = 
descriptionElement.addBindingElement();
+               bindingElement.setInterfaceName(new QName("interface1"));
+               
+               InterfaceElement interfaceElement = 
descriptionElement.addInterfaceElement();
+               interfaceElement.setName(new NCName("interface1"));
+               interfaceElement.setParentElement(bindingElement);
+               
+               InterfaceFaultElement iffElement = 
interfaceElement.addInterfaceFaultElement();
+               iffElement.setName(new NCName("fault1"));
+
+               // Create the 
BindingOperationElement->BindingFaultReferenceElement hierarchy
+               BindingOperationElement bopElement = 
bindingElement.addBindingOperationElement();
+               bopElement.setRef(new QName("operation1"));
+               fFault = bindingElement.addBindingFaultElement();
+               fFault.setRef(new QName("fault1"));
+       
+               InterfaceFaultElement retrievedFault = 
fFault.getInterfaceFaultElement();
+               assertEquals("The retrieved InterfaceFaultElement is not that 
which was set", 
+                               iffElement, retrievedFault);
+       }
+}

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java?view=auto&rev=500689
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java
 (added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java
 Sat Jan 27 15:35:39 2007
@@ -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 javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.ErrorReporterImpl;
+import org.apache.woden.internal.wsdl20.BindingFaultReferenceImpl;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+
+/**
+ * Unit tests for the BindingFaultReferenceElement class.
+ * 
+ * @author Graham Turrell ([EMAIL PROTECTED])
+ */
+public class BindingFaultReferenceElementTest extends TestCase {
+
+       private BindingFaultReferenceElement fFaultReference = null;
+       private ExtensionRegistry fExtensionRegistry = null;
+
+       public static Test suite()
+       {
+          return new TestSuite(BindingFaultReferenceElementTest.class);
+          
+       }
+          /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+       super.setUp();
+       fFaultReference = new BindingFaultReferenceImpl();
+       fExtensionRegistry = new ExtensionRegistry();
+        fExtensionRegistry.setErrorReporter(new ErrorReporterImpl());          
+    }
+    
+    /*
+     * @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()
+       {
+               DescriptionElement descriptionElement = new DescriptionImpl();
+               
+               // TODO - should this be strictly necessary for 
DescriptionElement.toComponent() not to NPE?
+        descriptionElement.setExtensionRegistry(fExtensionRegistry);   
+               
+               // 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"));
+               interfaceElement.setParentElement(bindingElement);
+               
+               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"));
+
+               descriptionElement.toComponent();
+               // Note : Description's list of interfaces does not get setup 
until toComponent() is invoked.
+               // therefore cannot successfully traverse the element model 
without creating the component model.
+               // Creating the component model requires that the extension 
registry is instantiated. 
+               // TODO Note that neither this, not creating an extension 
registry is necessary on BindingFaultElementTest,
+               // so there is some perceived inconsistency in the API.
+               
+               InterfaceFaultReferenceElement retrievedFault = 
fFaultReference.getInterfaceFaultReferenceElement();
+               assertEquals("The retrieved InterfaceFaultReferenceElement is 
not that which was set", 
+                               iffrElement, retrievedFault);
+       }
+}

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java?view=auto&rev=500689
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java
 (added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingMessageReferenceElementTest.java
 Sat Jan 27 15:35:39 2007
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2005 Apache Software Foundation 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+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 ([EMAIL PROTECTED])
+ */
+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());
+       }
+}

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java?view=auto&rev=500689
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java
 (added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java
 Sat Jan 27 15:35:39 2007
@@ -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.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.internal.wsdl20.DescriptionImpl;
+
+/**
+ * Unit tests for the BindingOperationElement class.
+ * 
+ * @author Graham Turrell ([EMAIL PROTECTED])
+ */
+
+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";
+
+       public static Test suite()
+       {
+          return new TestSuite(BindingOperationElementTest.class);
+       }
+          
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+        fDescriptionElement = new DescriptionImpl();
+        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);
+       }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to