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/23 00:29:46 UTC
svn commit: r498849 - in /incubator/woden/trunk/java/test/org/apache/woden:
tests/AllWodenTestsDOM.java wsdl20/xml/InterfaceFaultElementTest.java
wsdl20/xml/InterfaceFaultReferenceElementTest.java
wsdl20/xml/InterfaceOperationElementTest.java
Author: gturrell
Date: Mon Jan 22 15:29:38 2007
New Revision: 498849
URL: http://svn.apache.org/viewvc?view=rev&rev=498849
Log:
[WODEN-54] Part 2 - Created unit tests for all API methods of InterfaceFaultElement,
InterfaceFaultReferenceElement, InterfaceOperationElement.
Added:
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.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=498849&r1=498848&r2=498849
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java Mon Jan 22 15:29:38 2007
@@ -48,6 +48,9 @@
import org.apache.woden.wsdl20.xml.ImportElementTest;
import org.apache.woden.wsdl20.xml.IncludeElementTest;
import org.apache.woden.wsdl20.xml.InterfaceElementTest;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElementTest;
+import org.apache.woden.wsdl20.xml.InterfaceFaultReferenceElementTest;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElementTest;
import org.apache.woden.wsdl20.xml.NameAttributeTest;
import org.apache.woden.wsdl20.xml.ServiceElementTest;
import org.apache.woden.wsdl20.xml.TypesElementTest;
@@ -123,6 +126,9 @@
addTest(ElementDeclarationTest.suite());
addTest(TypeDefinitionTest.suite());
addTest(InterfaceElementTest.suite());
+ addTest(InterfaceFaultElementTest.suite());
+ addTest(InterfaceOperationElementTest.suite());
+ addTest(InterfaceFaultReferenceElementTest.suite());
//TODO in-progress 30May06 tests for BindingOpExt and BindingMsgRefExt
}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java?view=auto&rev=498849
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java Mon Jan 22 15:29:38 2007
@@ -0,0 +1,67 @@
+/**
+ * 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 javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.wsdl20.InterfaceFaultImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the InterfaceFaultElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceFaultElementTest extends TestCase {
+
+ private InterfaceFaultElement fFault = new InterfaceFaultImpl();
+
+ public static Test suite()
+ {
+ return new TestSuite(InterfaceFaultElementTest.class);
+ }
+
+ /*
+ * Test that an (optional) ElementName QName can be successfully set and retrieved
+ */
+ public void testSetGetElementName()
+ {
+ // Default case
+ assertNull("The retrieved Element name when unset should be null", fFault.getElementName());
+
+ QName elementName = new QName("elementName");
+ fFault.setElementName(elementName);
+ assertEquals("The retrieved Element name is not that which was set",
+ elementName, fFault.getElementName());
+ }
+
+ /*
+ * Test that a (Mandatory) Name QName can be successfully set and retrieved
+ */
+ public void testSetGetName()
+ {
+ QName faultName = new QName("faultName");
+ NCName faultNCName = new NCName("faultName");
+ fFault.setName(faultNCName);
+ assertEquals("The retrieved Element name is not that which was set",
+ faultName, fFault.getName());
+ }
+
+}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java?view=auto&rev=498849
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java Mon Jan 22 15:29:38 2007
@@ -0,0 +1,119 @@
+/**
+ * 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 javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.wsdl20.InterfaceFaultReferenceImpl;
+import org.apache.woden.internal.wsdl20.InterfaceImpl;
+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()
+ {
+ // Create the InterfaceElement->InterfaceOperationElement->InterfaceFaultReference hierarchy
+ InterfaceElement interfaceElement = new InterfaceImpl();
+ 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 InterfaceFault is not that which was set",
+ faultElement, retrievedFault);
+ }
+
+
+}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.java?view=auto&rev=498849
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.java Mon Jan 22 15:29:38 2007
@@ -0,0 +1,228 @@
+/**
+ * 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 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 InterfaceOperationElementTest class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceOperationElementTest extends TestCase {
+
+ // create a parent Description to hang the Interfaces off
+ private DescriptionElement fDescriptionElement = null;
+ private InterfaceElement fInterfaceElement = null;
+ private InterfaceOperationElement fInterfaceOperationElement = null;
+ private URI fStyleURI1 = null;
+ private URI fStyleURI2 = null;
+ private URI fPattern = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(InterfaceOperationElementTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fDescriptionElement = new DescriptionImpl();
+ fInterfaceElement = fDescriptionElement.addInterfaceElement();
+ fInterfaceOperationElement = fInterfaceElement.addInterfaceOperationElement();
+ fStyleURI1 = new URI("http://www.w3.org/0000/00/apacheStyle");
+ fStyleURI2 = new URI("http://www.w3.org/0000/00/anotherApacheStyle");
+ fPattern = new URI("http://www.w3.org/0000/00/wsdl/in-out");
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Mandatory attribute ("name")
+ * - setName()
+ * - getName()
+ */
+ public void testGetSetName() {
+
+ fInterfaceOperationElement.setName(new NCName("interfaceOperationName"));
+ QName retrievedName = fInterfaceOperationElement.getName();
+ assertEquals("Retrieved InterfaceOperationElement name does not match that set -", "interfaceOperationName", retrievedName.toString());
+ }
+
+ /*
+ * Mandatory attribute ("pattern") (message exchange pattern)
+ * - setPattern()
+ * - getPattern()
+ */
+ public void testGetSetPattern() {
+
+ fInterfaceOperationElement.setPattern(fPattern);
+ URI uri = fInterfaceOperationElement.getPattern();
+ assertEquals("Retrieved InterfaceOperationElement mep does not match that set -", fPattern, uri);
+ }
+
+ /*
+ * Optional attribute ("style")
+ * style comprises a list of URIs
+ * - getStyle() returns the list
+ * - addStyleURI() adds to the list
+ * - removeStyleURI() removes from the list
+ */
+ public void testAddGetRemoveStyle() {
+ // check the default:
+ URI[] style = fInterfaceOperationElement.getStyle();
+ assertNotNull(style);
+ assertEquals("Retrieved InterfaceOperationElement style should be empty if none set -", 0, style.length);
+
+ // addStyleURI() a couple of times
+ fInterfaceOperationElement.addStyleURI(fStyleURI1);
+ fInterfaceOperationElement.addStyleURI(fStyleURI2);
+
+ // getStyle()
+ style = fInterfaceOperationElement.getStyle();
+ assertNotNull(style);
+ assertEquals("Unexpected number of URIs in the style -", 2, style.length);
+ // check that all added URIs appear in the style
+ List sdL = Arrays.asList(style);
+ assertTrue(sdL.contains(fStyleURI1));
+ assertTrue(sdL.contains(fStyleURI2));
+
+ // removeStyleURI()
+ fInterfaceOperationElement.removeStyleURI(fStyleURI1);
+ fInterfaceOperationElement.removeStyleURI(fStyleURI2);
+ style = fInterfaceOperationElement.getStyle();
+ assertNotNull(style);
+ assertEquals("Unexpected number of URIs in the style -", 0, style.length);
+ }
+
+ /* TODO
+ * References to Optional child elements "infault" and "outfault"
+ * - addInterfaceFaultReferenceElement()
+ * - getInterfaceFaultReferenceElements()
+ * - removeInterfaceFaultReferenceElement()
+ */
+ public void testAddGetRemoveInterfaceFaultReferenceElements() {
+
+ // check the default:
+ InterfaceFaultReferenceElement[] ifreArray = fInterfaceOperationElement.getInterfaceFaultReferenceElements();
+ assertNotNull("Expected an array of InterfaceFaultReferenceElement.", ifreArray);
+ assertEquals("Retrieved InterfaceFaultReferenceElement group should be empty if none set -", 0, ifreArray.length);
+
+ // addInterfaceFaultReferenceElement() - create some InterfaceFaultReferenceElements
+ InterfaceFaultReferenceElement ifre1 = fInterfaceOperationElement.addInterfaceFaultReferenceElement();
+ InterfaceFaultReferenceElement ifre2 = fInterfaceOperationElement.addInterfaceFaultReferenceElement();
+
+ // getInterfaceFaultReferenceElements()
+ ifreArray = fInterfaceOperationElement.getInterfaceFaultReferenceElements();
+ assertNotNull("Expected an array of InterfaceFaultReferenceElement.", ifreArray);
+ assertEquals("Retrieved InterfaceFaultReferenceElement group should be same number as those set -", 2, ifreArray.length);
+
+ // verify all fault references returned
+ List ifreL = Arrays.asList(ifreArray);
+ assertTrue(ifreL.contains(ifre1));
+ assertTrue(ifreL.contains(ifre2));
+
+ // removeInterfaceFaultReferenceElement()
+ // 1 - attempt to remove an unadded IFRE
+ InterfaceFaultReferenceElement ifre3 = null;
+ fInterfaceOperationElement.removeInterfaceFaultReferenceElement(ifre3);
+ ifreArray = fInterfaceOperationElement.getInterfaceFaultReferenceElements();
+ assertNotNull("Expected an array of InterfaceFaultReferenceElement.", ifreArray);
+ assertEquals("Retrieved InterfaceFaultReferenceElement group should be same number as those set -", 2, ifreArray.length);
+
+ // 2- remove all added
+ fInterfaceOperationElement.removeInterfaceFaultReferenceElement(ifre1);
+ fInterfaceOperationElement.removeInterfaceFaultReferenceElement(ifre2);
+ ifreArray = fInterfaceOperationElement.getInterfaceFaultReferenceElements();
+ assertNotNull("Expected an array of InterfaceFaultReferenceElement.", ifreArray);
+ assertEquals("Retrieved InterfaceFaultReferenceElement group should be empty if all removed -", 0, ifreArray.length);
+
+ //3 - attempt to remove previously removed from empty list
+ fInterfaceOperationElement.removeInterfaceFaultReferenceElement(ifre2);
+ ifreArray = fInterfaceOperationElement.getInterfaceFaultReferenceElements();
+ assertNotNull("Expected an array of InterfaceFaultReferenceElement.", ifreArray);
+ assertEquals("Retrieved InterfaceFaultReferenceElement group should be empty if all removed -", 0, ifreArray.length);
+ }
+
+ /* TODO
+ * References to Optional child elements "input" and "output"
+ * - addInterfaceMessageReferenceElement()
+ * - getInterfaceMessageReferenceElements()
+ * - removeInterfaceMessageReferenceElement()
+ */
+ public void testAddGetRemoveInterfaceMessageReferenceElements() {
+ // base on testAddGetRemoveInterfaceFaultReferenceElements
+ // check the default:
+ InterfaceMessageReferenceElement[] imreArray = fInterfaceOperationElement.getInterfaceMessageReferenceElements();
+ assertNotNull("Expected an array of InterfaceMessageReferenceElement.", imreArray);
+ assertEquals("Retrieved InterfaceFaultReferenceElement group should be empty if none set -", 0, imreArray.length);
+
+ // addInterfaceMessageReferenceElement() - create some addInterfaceMessageReferenceElements
+ InterfaceMessageReferenceElement imre1 = fInterfaceOperationElement.addInterfaceMessageReferenceElement();
+ InterfaceMessageReferenceElement imre2 = fInterfaceOperationElement.addInterfaceMessageReferenceElement();
+
+ // getInterfaceMessageReferenceElements()
+ imreArray = fInterfaceOperationElement.getInterfaceMessageReferenceElements();
+ assertNotNull("Expected an array of InterfaceMessageReferenceElement.", imreArray);
+ assertEquals("Retrieved InterfaceMessageReferenceElement group should be same number as those set -", 2, imreArray.length);
+
+ // verify all fault references returned
+ List imreL = Arrays.asList(imreArray);
+ assertTrue(imreL.contains(imre1));
+ assertTrue(imreL.contains(imre2));
+
+ // removeInterfaceMessageReferenceElement()
+ // 1 - attempt to remove an unadded IMRE
+ InterfaceMessageReferenceElement imre3 = null;
+ fInterfaceOperationElement.removeInterfaceMessageReferenceElement(imre3);
+ imreArray = fInterfaceOperationElement.getInterfaceMessageReferenceElements();
+ assertNotNull("Expected an array of InterfaceMessageReferenceElement.", imreArray);
+ assertEquals("Retrieved InterfaceMessageReferenceElement group should be same number as those set -", 2, imreArray.length);
+
+ // 2- remove all added
+ fInterfaceOperationElement.removeInterfaceMessageReferenceElement(imre1);
+ fInterfaceOperationElement.removeInterfaceMessageReferenceElement(imre2);
+ imreArray = fInterfaceOperationElement.getInterfaceMessageReferenceElements();
+ assertNotNull("Expected an array of InterfaceMessageReferenceElement.", imreArray);
+ assertEquals("Retrieved InterfaceMessageReferenceElement group should be empty if all removed -", 0, imreArray.length);
+
+ //3 - attempt to remove previously removed from empty list
+ fInterfaceOperationElement.removeInterfaceMessageReferenceElement(imre2);
+ imreArray = fInterfaceOperationElement.getInterfaceMessageReferenceElements();
+ assertNotNull("Expected an array of InterfaceMessageReferenceElement.", imreArray);
+ assertEquals("Retrieved InterfaceMessageReferenceElement group should be empty if all removed -", 0, imreArray.length);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org