You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by gt...@apache.org on 2007/01/28 21:19:49 UTC
svn commit: r500875 - in /incubator/woden/trunk/java/test/org/apache/woden:
tests/ wsdl20/ wsdl20/xml/
Author: gturrell
Date: Sun Jan 28 12:19:48 2007
New Revision: 500875
URL: http://svn.apache.org/viewvc?view=rev&rev=500875
Log:
[WODEN-55] Part 2 of 2 - Created unit tests for API methods of all the Binding* Component classes (5)
Added:
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultReferenceTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingMessageReferenceTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingOperationTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingTest.java
Modified:
incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java
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/BindingOperationElementTest.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=500875&r1=500874&r2=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java Sun Jan 28 12:19:48 2007
@@ -28,6 +28,11 @@
import org.apache.woden.internal.wsdl20.validation.WSDLComponentValidatorTest;
import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidatorTest;
import org.apache.woden.resolver.SimpleURIResolverTest;
+import org.apache.woden.wsdl20.BindingFaultReferenceTest;
+import org.apache.woden.wsdl20.BindingFaultTest;
+import org.apache.woden.wsdl20.BindingMessageReferenceTest;
+import org.apache.woden.wsdl20.BindingOperationTest;
+import org.apache.woden.wsdl20.BindingTest;
import org.apache.woden.wsdl20.DescriptionTest;
import org.apache.woden.wsdl20.ElementDeclarationTest;
import org.apache.woden.wsdl20.EndpointTest;
@@ -152,6 +157,11 @@
addTest(BindingOperationElementTest.suite());
addTest(BindingFaultReferenceElementTest.suite());
addTest(BindingMessageReferenceElementTest.suite());
+ addTest(BindingTest.suite());
+ addTest(BindingFaultTest.suite());
+ addTest(BindingOperationTest.suite());
+ addTest(BindingFaultReferenceTest.suite());
+ addTest(BindingMessageReferenceTest.suite());
//TODO in-progress 30May06 tests for BindingOpExt and BindingMsgRefExt
}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultReferenceTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultReferenceTest.java?view=auto&rev=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultReferenceTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultReferenceTest.java Sun Jan 28 12:19:48 2007
@@ -0,0 +1,125 @@
+/**
+ * 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;
+
+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;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+
+/**
+ * Unit tests for the BindingFaultReference class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingFaultReferenceTest extends TestCase {
+
+ private BindingFaultReferenceElement fFaultRefElement = null;
+ private BindingFaultReference fFaultRef = null;
+ private ExtensionRegistry fExtensionRegistry = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(BindingFaultReferenceTest.class);
+
+ }
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFaultRefElement = new BindingFaultReferenceImpl();
+ fFaultRef = (BindingFaultReference) fFaultRefElement;
+ fExtensionRegistry = new ExtensionRegistry();
+ fExtensionRegistry.setErrorReporter(new ErrorReporterImpl());
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Test that the (Mandatory) InterfaceFaultReference can be successfully retrieved.
+ * The fault reference is to an Interface Fault associated with the grandparent BindingElement.
+ */
+ public void testGetInterfaceFaultReference()
+ {
+ 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);
+ InterfaceFaultElement ife = interfaceElement.addInterfaceFaultElement();
+ ife.setName(new NCName("Fault1Ref"));
+
+ 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"));
+ fFaultRefElement = bopElement.addBindingFaultReferenceElement();
+ fFaultRefElement.setMessageLabel(new NCName("Fault1MessageLabel"));
+ fFaultRefElement.setRef(new QName("Fault1Ref"));
+
+ Description descComp = descriptionElement.toComponent();
+ descComp.getBindings(); // this triggers setting the link to description in the binding
+
+ fFaultRef = (BindingFaultReference) fFaultRefElement;
+ InterfaceFaultReference retrievedFault = fFaultRef.getInterfaceFaultReference();
+ assertEquals("The retrieved InterfaceFaultReference is not that which was set",
+ iffrElement, retrievedFault);
+ }
+
+ /*
+ * toElement()
+ */
+ public void testToElement()
+ {
+ assertEquals(fFaultRefElement, fFaultRef.toElement());
+ }
+}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultTest.java?view=auto&rev=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingFaultTest.java Sun Jan 28 12:19:48 2007
@@ -0,0 +1,111 @@
+/**
+ * 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;
+
+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;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+
+/**
+ * Unit tests for the BindingFault class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingFaultTest extends TestCase {
+
+ private BindingFaultElement fFaultElement = null;
+ private BindingFault fFault = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(BindingFaultTest.class);
+
+ }
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFaultElement = new BindingFaultImpl();
+ fFault = (BindingFault) fFaultElement;
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Test that the (Mandatory) InterfaceFault can be successfully retrieved.
+ */
+ public void testGetInterfaceFault()
+ {
+ DescriptionElement descriptionElement = new DescriptionImpl();
+
+ // Create the BindingElement<->InterfaceElement->InterfaceFaultElement hierarchy
+ BindingElement bindingElement = descriptionElement.addBindingElement();
+ bindingElement.setInterfaceName(new QName("interface1"));
+ bindingElement.setName(new NCName("binding1"));
+
+ 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"));
+ fFaultElement = bindingElement.addBindingFaultElement();
+ fFaultElement.setRef(new QName("fault1"));
+
+ Description descComp = descriptionElement.toComponent();
+ descComp.getBindings(); // this triggers setting the link to description in the binding
+
+ BindingFault bf = (BindingFault)fFaultElement;
+
+ InterfaceFault retrievedFault = bf.getInterfaceFault();
+ assertEquals("The retrieved InterfaceFaultElement is not that which was set",
+ iffElement, retrievedFault);
+ }
+
+ /*
+ * toElement()
+ */
+ public void testToElement()
+ {
+ assertEquals(fFaultElement, fFault.toElement());
+ }
+
+}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingMessageReferenceTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingMessageReferenceTest.java?view=auto&rev=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingMessageReferenceTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingMessageReferenceTest.java Sun Jan 28 12:19:48 2007
@@ -0,0 +1,122 @@
+/**
+ * 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;
+
+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.BindingMessageReferenceImpl;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+
+/**
+ * Unit tests for the BindingMessageReference class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingMessageReferenceTest extends TestCase {
+
+ private BindingMessageReferenceElement fBindingMessageRefElement = null;
+ private BindingMessageReference fBindingMessageRef = null;
+ private ExtensionRegistry fExtensionRegistry = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(BindingMessageReferenceTest.class);
+
+ }
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fBindingMessageRefElement = new BindingMessageReferenceImpl();
+ fBindingMessageRef = (BindingMessageReference) fBindingMessageRefElement;
+ fExtensionRegistry = new ExtensionRegistry();
+ fExtensionRegistry.setErrorReporter(new ErrorReporterImpl());
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Test that the (Mandatory) InterfaceMessageReference can be successfully retrieved.
+ * - getInterfaceMessageReference()
+ *
+ */
+ public void testGetInterfaceMessageReference()
+ {
+ DescriptionElement descriptionElement = new DescriptionImpl();
+
+ // TODO - should this be strictly necessary for DescriptionElement.toComponent() not to NPE?
+ descriptionElement.setExtensionRegistry(fExtensionRegistry);
+
+ // Create the BindingElement<->InterfaceElement->InterfaceOperationElement->InterfaceMessageReferenceElement 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"));
+ InterfaceMessageReferenceElement ifmrElement = ifopElement.addInterfaceMessageReferenceElement();
+ ifmrElement.setMessageLabel(new NCName("MessageRef1MessageLabel"));
+
+ // Create the BindingOperationElement->BindingMessageReferenceElement hierarchy
+ BindingOperationElement bopElement = bindingElement.addBindingOperationElement();
+ bopElement.setRef(new QName("operation1"));
+ fBindingMessageRefElement = bopElement.addBindingMessageReferenceElement();
+ fBindingMessageRefElement.setMessageLabel(new NCName("MessageRef1MessageLabel"));
+
+ Description descComp = descriptionElement.toComponent();
+ descComp.getBindings(); // this triggers setting the link to description in the binding
+
+ fBindingMessageRef = (BindingMessageReference) fBindingMessageRefElement;
+ InterfaceMessageReference retrievedMessage = fBindingMessageRef.getInterfaceMessageReference();
+ assertEquals("The retrieved InterfaceMessageReference is not that which was set",
+ ifmrElement, retrievedMessage);
+ }
+
+ /*
+ * toElement()
+ */
+ public void testToElement()
+ {
+ assertEquals(fBindingMessageRefElement, fBindingMessageRef.toElement());
+ }
+
+}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingOperationTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingOperationTest.java?view=auto&rev=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingOperationTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingOperationTest.java Sun Jan 28 12:19:48 2007
@@ -0,0 +1,169 @@
+/**
+ * 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;
+
+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.ErrorReporterImpl;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+
+/**
+ * Unit tests for the BindingOperation class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+
+public class BindingOperationTest extends TestCase {
+
+ // create a parent Description to hang the Binding hierarchy off
+ private DescriptionElement fDescriptionElement = null;
+ private BindingElement fBindingElement = null;
+ private BindingOperationElement fBindingOperationElement = null;
+ private BindingOperation fBindingOperation = null;
+ private ExtensionRegistry fExtensionRegistry = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(BindingOperationTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fDescriptionElement = new DescriptionImpl();
+ fBindingElement = fDescriptionElement.addBindingElement();
+ fBindingOperationElement = fBindingElement.addBindingOperationElement();
+ fBindingOperation = (BindingOperation) fBindingOperationElement;
+
+ // TODO - should this be strictly necessary
+ // for DescriptionElement.toComponent() not to NPE?
+ fExtensionRegistry = new ExtensionRegistry();
+ fExtensionRegistry.setErrorReporter(new ErrorReporterImpl());
+ fDescriptionElement.setExtensionRegistry(fExtensionRegistry);
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * References to Optional child elements "infault" and "outfault" in the infoset
+ * - getBindingFaultReferences()
+ */
+ public void testGetBindingFaultReferences()
+ {
+ // create some BindingFaultReferenceElements
+ BindingFaultReferenceElement bfre1 = fBindingOperationElement.addBindingFaultReferenceElement();
+ BindingFaultReferenceElement bfre2 = fBindingOperationElement.addBindingFaultReferenceElement();
+
+ fDescriptionElement.toComponent();
+
+ // getBindingFaultReferences()
+ BindingFaultReference[] bfrArray = fBindingOperation.getBindingFaultReferences();
+ assertNotNull("Expected an array of BindingFaultReference.", bfrArray);
+ assertEquals("Retrieved BindingFaultReference group should be same number as those set -", 2, bfrArray.length);
+
+ // verify all fault references returned
+ List bfreL = Arrays.asList(bfrArray);
+ assertTrue(bfreL.contains(bfre1));
+ assertTrue(bfreL.contains(bfre2));
+ }
+
+ /*
+ * References to Optional child elements "input" and "output" int the infoset
+ * - getBindingMessageReferences()
+ */
+ public void testGetBindingMessageReferences()
+ {
+ // create some BindingMessageReferenceElements
+ BindingMessageReferenceElement bmre1 = fBindingOperationElement.addBindingMessageReferenceElement();
+ BindingMessageReferenceElement bmre2 = fBindingOperationElement.addBindingMessageReferenceElement();
+
+ fDescriptionElement.toComponent();
+
+ // getBindingMessageReferences()
+ BindingMessageReference[] bmrArray = fBindingOperation.getBindingMessageReferences();
+ assertNotNull("Expected an array of BindingMessageReference.", bmrArray);
+ assertEquals("Retrieved BindingMessageReference group should be same number as those set -", 2, bmrArray.length);
+
+ // verify all fault references returned
+ List bmreL = Arrays.asList(bmrArray);
+ assertTrue(bmreL.contains(bmre1));
+ assertTrue(bmreL.contains(bmre2));
+ }
+
+ /*
+ * Utility method to find the InterfaceOperation referenced by the (Mandatory) "ref" attribute in the infoset
+ * - getInterfaceOperation()
+ */
+ public void testGetInterfaceOperation()
+ {
+ // Create and name an Interface Element
+ InterfaceElement interfaceElement = fDescriptionElement.addInterfaceElement();
+ interfaceElement.setName(new NCName("interface1"));
+
+ // Create a binding from the description
+ fBindingElement = fDescriptionElement.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"));
+
+ Description descComp = fDescriptionElement.toComponent();
+ descComp.getBindings(); // this triggers setting the link to description in the binding
+
+ fBindingOperation = (BindingOperation) fBindingOperationElement;
+
+ InterfaceOperation retrievedIntOp = fBindingOperation.getInterfaceOperation();
+ assertEquals("Retrieved Interface Element was not that expected -", intOpElement, retrievedIntOp);
+ }
+
+ /*
+ * toElement()
+ */
+ public void testToElement()
+ {
+ assertEquals(fBindingOperationElement, fBindingOperation.toElement());
+ }
+}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingTest.java?view=auto&rev=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/BindingTest.java Sun Jan 28 12:19:48 2007
@@ -0,0 +1,203 @@
+/**
+ * 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;
+
+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;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+
+/**
+ * Unit tests for the Binding class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingTest extends TestCase {
+
+ // create a parent Description to hang the Bindings off
+ private DescriptionElement fDescriptionElement = null;
+ private BindingElement fBindingElement = null;
+ private Binding fBinding = null;
+ private URI fTypeURI = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(BindingTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fDescriptionElement = new DescriptionImpl();
+ fBindingElement = fDescriptionElement.addBindingElement();
+ fBindingElement.setName(new NCName("binding"));
+ //fBinding = (Binding) fBindingElement;
+ fTypeURI = new URI("http://www.w3.org/0000/00/apacheType");
+ fBinding = fDescriptionElement.toComponent().getBinding(new QName("binding"));
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /* (optional) "interface" attribute
+ * - getInterfaceElement()
+ */
+ public void testGetInterface()
+ {
+ // check the default:
+ Interface retrievedInterface = fBinding.getInterface();
+ assertNull("Retrieved Interface should be null if none set -", retrievedInterface);
+
+ // 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
+ fBindingElement = desc.addBindingElement();
+ fBindingElement.setName(new NCName("binding1"));
+ desc.toComponent();
+ Binding binding = desc.toComponent().getBinding(new QName("binding1"));
+
+ // getInterface() - interface attribute unspecified, but hierarchy in place:
+ retrievedInterface = binding.getInterface();
+ assertNull("Retrieved Interface should be null if interface attribute unspecified -", retrievedInterface);
+
+ // getInterface() - interface attribute specified, and hierarchy in place:
+ // Set the "interface" attribute to reference the new Interface Element
+ // (have to recreate whole desc hierarchy as toComponent() will not rerun if already run!)
+ desc = new DescriptionImpl();
+ interfaceElement = desc.addInterfaceElement();
+ interfaceElement.setName(new NCName("interface1"));
+ fBindingElement = desc.addBindingElement();
+ fBindingElement.setName(new NCName("binding1"));
+ fBindingElement.setInterfaceName(new QName("interface1"));
+
+ //fDescriptionElement.toComponent();
+
+ binding = desc.toComponent().getBinding(new QName("binding1"));
+ //fBinding = (Binding)fBindingElement;
+
+ retrievedInterface = binding.getInterface();
+ assertEquals("Retrieved Interface was not that expected -", interfaceElement, retrievedInterface);
+ }
+
+ /*
+ * Mandatory attribute ("name")
+ * - getName()
+ */
+ public void testGetName()
+ {
+ fBindingElement.setName(new NCName("BindingName"));
+ QName uri = fBinding.getName();
+ assertNotNull(uri);
+ assertEquals("Retrieved Binding name does not match that set -", "BindingName", uri.toString());
+ }
+
+ /*
+ * Mandatory attribute ("type")
+ * - getType()
+ */
+ public void testGetType()
+ {
+ fBindingElement.setType(fTypeURI);
+ URI uri = fBinding.getType();
+ assertEquals("Retrieved Binding type attribute does not match that set -", fTypeURI, uri);
+ }
+
+ /*
+ * Optional element ("fault")
+ * - getBindingFaults()
+ */
+ public void testGetBindingFaults()
+ {
+ // check the default:
+ BindingFault[] bfArray = fBinding.getBindingFaults();
+ assertNotNull("Expected an array of BindingFaults -", bfArray);
+ assertEquals("Retrieved BindingFaultElement group should be empty if none set -", 0, bfArray.length);
+
+ // addBindingFaultElement()
+ BindingFaultElement bfe1 = fBindingElement.addBindingFaultElement();
+ BindingFaultElement bfe2 = fBindingElement.addBindingFaultElement();
+
+ // getBindingFaultElements()
+ bfArray = fBinding.getBindingFaults();
+ assertNotNull("Expected an array of BindingFaults -", bfArray);
+ assertEquals("Incorrect number of retrieved BindingFaults -", 2, bfArray.length);
+
+ // verify all Fault objects returned
+ List bfeL = Arrays.asList(bfArray);
+ assertTrue(bfeL.contains(bfe1));
+ assertTrue(bfeL.contains(bfe2));
+ }
+
+ /*
+ * Optional element ("operation")
+ * - getBindingOperations()
+ */
+ public void testGetBindingOperations()
+ {
+ // check the default:
+ BindingOperation[] bopArray = fBinding.getBindingOperations();
+ assertNotNull("Expected an array of BindingOperations -", bopArray);
+ assertEquals("Retrieved BindingOperation group should be empty if none set -", 0, bopArray.length);
+
+ // addBindingOperationElement()
+ BindingOperationElement bop1 = fBindingElement.addBindingOperationElement();
+ BindingOperationElement bop2 = fBindingElement.addBindingOperationElement();
+
+ // getBindingOperations()
+ bopArray = fBinding.getBindingOperations();
+ assertNotNull("Expected an array of BindingOperation -", bopArray);
+ assertEquals("Incorrect number of retrieved BindingOperations -", 2, bopArray.length);
+
+ // verify all Operation objects returned
+ List ifopL = Arrays.asList(bopArray);
+ assertTrue(ifopL.contains(bop1));
+ assertTrue(ifopL.contains(bop2));
+ }
+
+ /*
+ * toElement()
+ */
+ public void testToElement()
+ {
+ assertEquals(fBindingElement, fBinding.toElement());
+ }
+
+}
Modified: 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=diff&rev=500875&r1=500874&r2=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingElementTest.java Sun Jan 28 12:19:48 2007
@@ -96,7 +96,7 @@
InterfaceElement interfaceElement = desc.addInterfaceElement();
interfaceElement.setName(new NCName("interface1"));
- // Create a binding from the description and
+ // Create a binding from the description
fBindingElement = desc.addBindingElement();
// getInterfaceElement() - interface attribute unspecified, but hierarchy in place:
Modified: 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=diff&rev=500875&r1=500874&r2=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java Sun Jan 28 12:19:48 2007
@@ -69,10 +69,9 @@
}
/*
- * Test that the (Mandatory) InterfaceFaultReference can be successfully retrieved.
- * The fault reference is to an Interface Fault associated with the grandparent BindingElement.
+ * Test that the (Mandatory) InterfaceFault can be successfully retrieved.
*/
- public void testGetInterfaceFaultReferenceElement()
+ public void testGetInterfaceFaultElement()
{
DescriptionElement descriptionElement = new DescriptionImpl();
Modified: 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=diff&rev=500875&r1=500874&r2=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingFaultReferenceElementTest.java Sun Jan 28 12:19:48 2007
@@ -120,7 +120,7 @@
// 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,
+ // TODO Note that neither this, not creating an extension registry is necessary on BindingFaultTest,
// so there is some perceived inconsistency in the API.
InterfaceFaultReferenceElement retrievedFault = fFaultReference.getInterfaceFaultReferenceElement();
Modified: 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=diff&rev=500875&r1=500874&r2=500875
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/BindingOperationElementTest.java Sun Jan 28 12:19:48 2007
@@ -26,6 +26,7 @@
import junit.framework.TestSuite;
import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
/**
* Unit tests for the BindingOperationElement class.
@@ -174,4 +175,34 @@
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 = new DescriptionImpl();
+ 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);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org