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 jk...@apache.org on 2007/08/23 13:24:56 UTC
svn commit: r568937 [16/17] - in /incubator/woden/trunk/java/test:
javax/xml/namespace/ org/apache/woden/ org/apache/woden/ant/
org/apache/woden/internal/ org/apache/woden/internal/wsdl20/validation/
org/apache/woden/resolver/ org/apache/woden/resolver...
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/IncludeElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/IncludeElementTest.java?rev=568937&r1=568936&r2=568937&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/IncludeElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/IncludeElementTest.java Thu Aug 23 04:24:51 2007
@@ -1,89 +1,89 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.wsdl20.xml;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.IncludeImpl;
-
-/**
- * Unit tests for the IncludeElement class.
- *
- * @author Graham Turrell (gturrell@apache.org)
- */
-public class IncludeElementTest extends TestCase {
-
- private IncludeElement fInclude = new IncludeImpl();
- private DescriptionElement fDescriptionElement = null;
- private URI fURI = null;
- private WSDLFactory fFactory = null;
-
- public static Test suite()
- {
- return new TestSuite(IncludeElementTest.class);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception
- {
- super.setUp();
-
- try {
- fFactory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- fail("Can't instantiate the WSDLFactory object.");
- }
-
- fDescriptionElement = fFactory.newDescription();
- }
-
- /**
- * Test that a Description Element can be successfully set and retrieved from an IncludeElement
- */
- public void testSetGetDescriptionElement()
- {
- fInclude.setDescriptionElement(fDescriptionElement);
- assertEquals("The retrieved Description Element object is not that which was set",
- fDescriptionElement, fInclude.getDescriptionElement());
- }
-
- /**
- * Test that a Location URI can be successfully set and retrieved from an IncludeElement
- */
- public void testSetGetLocation()
- {
- try
- {
- fURI = new URI("http://apache.org/test");
- } catch (URISyntaxException e) {
-
- }
- fInclude.setLocation(fURI);
- assertEquals("The retrieved Location URI object is not that which was set", fURI, fInclude.getLocation());
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.IncludeImpl;
+
+/**
+ * Unit tests for the IncludeElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class IncludeElementTest extends TestCase {
+
+ private IncludeElement fInclude = new IncludeImpl();
+ private DescriptionElement fDescriptionElement = null;
+ private URI fURI = null;
+ private WSDLFactory fFactory = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(IncludeElementTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ try {
+ fFactory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ fDescriptionElement = fFactory.newDescription();
+ }
+
+ /**
+ * Test that a Description Element can be successfully set and retrieved from an IncludeElement
+ */
+ public void testSetGetDescriptionElement()
+ {
+ fInclude.setDescriptionElement(fDescriptionElement);
+ assertEquals("The retrieved Description Element object is not that which was set",
+ fDescriptionElement, fInclude.getDescriptionElement());
+ }
+
+ /**
+ * Test that a Location URI can be successfully set and retrieved from an IncludeElement
+ */
+ public void testSetGetLocation()
+ {
+ try
+ {
+ fURI = new URI("http://apache.org/test");
+ } catch (URISyntaxException e) {
+
+ }
+ fInclude.setLocation(fURI);
+ assertEquals("The retrieved Location URI object is not that which was set", fURI, fInclude.getLocation());
+ }
+
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/IncludeElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceElementTest.java?rev=568937&r1=568936&r2=568937&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceElementTest.java Thu Aug 23 04:24:51 2007
@@ -1,287 +1,287 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.wsdl20.xml;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.types.NCName;
-
-/**
- * Unit tests for the InterfaceElement class.
- *
- * @author Graham Turrell (gturrell@apache.org)
- */
-public class InterfaceElementTest extends TestCase {
-
- // create a parent Description to hang the Interfaces off
- private DescriptionElement fDescriptionElement = null;
- private InterfaceElement fInterfaceElement = null;
- private URI fStyleDefaultURI1 = null;
- private URI fStyleDefaultURI2 = null;
-
- public static Test suite()
- {
- return new TestSuite(InterfaceElementTest.class);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception
- {
- super.setUp();
-
- WSDLFactory factory = null;
- try {
- factory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- fail("Can't instantiate the WSDLFactory object.");
- }
-
- fDescriptionElement = factory.newDescription();
- fInterfaceElement = fDescriptionElement.addInterfaceElement();
- fStyleDefaultURI1 = new URI("http://www.w3.org/0000/00/apacheStyle");
- fStyleDefaultURI2 = new URI("http://www.w3.org/0000/00/anotherApacheStyle");
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /*
- * Mandatory attribute ("name")
- * - setName()
- * - getName()
- */
- public void testGetSetName()
- {
- fInterfaceElement.setName(new NCName("interfaceName"));
- QName uri = fInterfaceElement.getName();
- assertEquals("Retrieved InterfaceElement name does not match that set -", "interfaceName", uri.toString());
- }
-
- /*
- * Gets InterfaceElements referenced by the "extends" attribute (optional)
- */
- public void testGetExtendedInterfaceElementElements()
- {
- /*
- * create some InterfaceElements to extend, add them to parent,
- * access them via :
- * - getExtendedInterfaceElement()
- * - getExtendedInterfaceElements()
- */
-
- // check the default:
- InterfaceElement[] ifeArray = fInterfaceElement.getExtendedInterfaceElements();
- assertEquals("Retrieved Extended InterfaceElement group should be empty if none set -", 0, ifeArray.length);
-
- // create further InterfaceElements and name them
- InterfaceElement xife1 = fDescriptionElement.addInterfaceElement();
- InterfaceElement xife2 = fDescriptionElement.addInterfaceElement();
- xife1.setName(new NCName("extendedIE1"));
- xife2.setName(new NCName("extendedIE2"));
- fInterfaceElement.addExtendedInterfaceName(new QName("extendedIE1"));
- fInterfaceElement.addExtendedInterfaceName(new QName("extendedIE2"));
-
- // getExtendedInterfaceElements()
- ifeArray = fInterfaceElement.getExtendedInterfaceElements();
- assertEquals("Incorrect number of retrieved Extended InterfaceElements -", 2, ifeArray.length);
- // verify object equivalence
- List ifeL = Arrays.asList(ifeArray);
- assertTrue(ifeL.contains(xife1));
- assertTrue(ifeL.contains(xife2));
-
- // getExtendedInterfaceElement()
- InterfaceElement retrievedIfe = fInterfaceElement.getExtendedInterfaceElement(new QName("extendedIE1"));
- assertEquals("Retrieved Extended InterfaceElement unexpected -", xife1, retrievedIfe);
- retrievedIfe = fInterfaceElement.getExtendedInterfaceElement(new QName("randomUnset"));
- assertNull("The name of a non-existent InterfaceElement should not return one -", retrievedIfe);
- }
-
- /*
- * Optional attribute ("extends")
- * - addExtendedInterfaceName()
- * - getExtendedInterfaceNames()
- * - removeExtendedInterfaceName()
- */
- public void testAddGetRemoveExtendedInterfaceNames()
- {
- // check the default:
- QName[] ifeQnameArray = fInterfaceElement.getExtendedInterfaceNames();
- assertEquals("Retrieved Extended InterfaceElement QName group should be empty if none set -", 0, ifeQnameArray.length);
-
- // create further InterfaceElements and name them
- InterfaceElement xife1 = fDescriptionElement.addInterfaceElement();
- InterfaceElement xife2 = fDescriptionElement.addInterfaceElement();
- xife1.setName(new NCName("extendedIE1"));
- xife2.setName(new NCName("extendedIE2"));
-
- // addExtendedInterfaceName()
- QName xifeQname1 = new QName("extendedIE1");
- fInterfaceElement.addExtendedInterfaceName(xifeQname1);
- QName xifeQname2 = new QName("extendedIE2");
- fInterfaceElement.addExtendedInterfaceName(xifeQname2);
- assertNotNull("Retrieved Extended InterfaceElement from a valid name expected.",
- fInterfaceElement.getExtendedInterfaceElement(xifeQname1));
- // Add a qname on a non-existent InterfaceElement
- QName xifeQname3 = new QName("nonExistentExtendedIE");
- fInterfaceElement.addExtendedInterfaceName(xifeQname3);
-
- // getExtendedInterfaceNames()
- QName[] ifeNames = fInterfaceElement.getExtendedInterfaceNames();
- assertNotNull("Expected an array of QNames.", ifeNames);
- assertEquals("Incorrect number of retrieved Extended InterfaceElement names -", 3, ifeNames.length);
- // verify all names returned
- List ifeL = Arrays.asList(ifeNames);
- assertTrue(ifeL.contains(xifeQname1));
- assertTrue(ifeL.contains(xifeQname2));
- assertTrue(ifeL.contains(xifeQname3));
- // verify that xifeQname3 does not refer to any InterfaceElement
- assertNull("Extended InterfaceElement for name " + xifeQname3 + " unexpected.",
- fInterfaceElement.getExtendedInterfaceElement(xifeQname3));
-
- // removeExtendedInterfaceName()
- fInterfaceElement.removeExtendedInterfaceName(xifeQname1);
- fInterfaceElement.removeExtendedInterfaceName(xifeQname3);
- fInterfaceElement.removeExtendedInterfaceName(xifeQname2);
- ifeNames = fInterfaceElement.getExtendedInterfaceNames();
- assertNotNull("Expected an (empty) array of QNames.", ifeNames);
- assertEquals("Incorrect number of retrieved Extended InterfaceElement names -", 0, ifeNames.length);
- }
-
- /*
- * Optional attribute ("styleDefault")
- * styleDefault comprises a list of URIs (IRIs in the spec)
- * - getStyleDefault() returns the list
- * - addStyleDefaultURI() adds to the list
- */
- public void testAddGetStyleDefault()
- {
- // check the default:
- URI[] styleDefault = fInterfaceElement.getStyleDefault();
- assertNotNull(styleDefault);
- assertEquals("Retrieved InterfaceElement style default should be empty if none set -", 0, styleDefault.length);
-
- // addStyleDefaultURI() a couple of times
- fInterfaceElement.addStyleDefaultURI(fStyleDefaultURI1);
- fInterfaceElement.addStyleDefaultURI(fStyleDefaultURI2);
-
- // getStyleDefault()
- styleDefault = fInterfaceElement.getStyleDefault();
- assertNotNull(styleDefault);
- assertEquals("Unexpected number of URIs in the styleDefault -", 2, styleDefault.length);
- // check that all added URIs appear in the styleDefault
- List sdL = Arrays.asList(styleDefault);
- assertTrue(sdL.contains(fStyleDefaultURI1));
- assertTrue(sdL.contains(fStyleDefaultURI2));
- }
-
- /*
- * Optional element ("fault")
- * - addInterfaceFaultElement()
- * - getInterfaceFaultElement()
- * - getInterfaceFaultElements()
- */
- public void testAddGetInterfaceFaultElements()
- {
- // check the default:
- InterfaceFaultElement[] iffeArray = fInterfaceElement.getInterfaceFaultElements();
- assertNotNull("Expected an array of InterfaceFaultElements -", iffeArray);
- assertEquals("Retrieved InterfaceFaultElement group should be empty if none set -", 0, iffeArray.length);
-
- // addInterfaceFaultElement()
- InterfaceFaultElement iffe1 = fInterfaceElement.addInterfaceFaultElement();
- InterfaceFaultElement iffe2 = fInterfaceElement.addInterfaceFaultElement();
- assertNotNull(iffe1);
- assertNotNull(iffe2);
-
- // getInterfaceFaultElements()
- iffeArray = fInterfaceElement.getInterfaceFaultElements();
- assertNotNull("Expected an array of InterfaceFaultElements -", iffeArray);
- assertEquals("Incorrect number of retrieved InterfaceFaultElements -", 2, iffeArray.length);
-
- // verify all Fault objects returned
- List iffeL = Arrays.asList(iffeArray);
- assertTrue(iffeL.contains(iffe1));
- assertTrue(iffeL.contains(iffe2));
-
- // getInterfaceFaultElement()
- // name one of them
- iffe1.setName(new NCName("FaultName"));
- InterfaceFaultElement retrievedIffe = fInterfaceElement.getInterfaceFaultElement(new QName("FaultName"));
- assertNotNull(retrievedIffe);
- assertEquals("Retrieved InterfaceFaultElement differs from that expected", iffe1, retrievedIffe);
- // try a non-existent fault - should return null
- retrievedIffe = fInterfaceElement.getInterfaceFaultElement(new QName("nonExistentFault"));
- assertNull(retrievedIffe);
- }
-
- /*
- * Optional element ("operation")
- * - addInterfaceOperationElement()
- * - getInterfaceOperationElement()
- * - getInterfaceOperationElements()
- */
- public void testAddGetInterfaceOperationElements()
- {
- // check the default:
- InterfaceOperationElement[] ifopArray = fInterfaceElement.getInterfaceOperationElements();
- assertNotNull("Expected an array of InterfaceOperationElements -", ifopArray);
- assertEquals("Retrieved InterfaceOperationElement group should be empty if none set -", 0, ifopArray.length);
-
- // addInterfaceOperationElement()
- InterfaceOperationElement ifop1 = fInterfaceElement.addInterfaceOperationElement();
- InterfaceOperationElement ifop2 = fInterfaceElement.addInterfaceOperationElement();
- assertNotNull(ifop1);
- assertNotNull(ifop2);
-
- // getInterfaceOperationElements()
- ifopArray = fInterfaceElement.getInterfaceOperationElements();
- assertNotNull("Expected an array of InterfaceOperationElements -", ifopArray);
- assertEquals("Incorrect number of retrieved InterfaceOperationElements -", 2, ifopArray.length);
-
- // verify all Operation objects returned
- List ifopL = Arrays.asList(ifopArray);
- assertTrue(ifopL.contains(ifop1));
- assertTrue(ifopL.contains(ifop2));
-
- // getInterfaceOperationElement()
- // name one of them
- ifop1.setName(new NCName("OperationName"));
- InterfaceOperationElement retrievedIfop = fInterfaceElement.getInterfaceOperationElement(new QName("OperationName"));
- assertNotNull(retrievedIfop);
- assertEquals("Retrieved InterfaceOperationElement differs from that expected", ifop1, retrievedIfop);
- // try a non-existent operation - should return null
- retrievedIfop = fInterfaceElement.getInterfaceOperationElement(new QName("nonExistentOperation"));
- assertNull(retrievedIfop);
- }
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the InterfaceElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceElementTest extends TestCase {
+
+ // create a parent Description to hang the Interfaces off
+ private DescriptionElement fDescriptionElement = null;
+ private InterfaceElement fInterfaceElement = null;
+ private URI fStyleDefaultURI1 = null;
+ private URI fStyleDefaultURI2 = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(InterfaceElementTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ fDescriptionElement = factory.newDescription();
+ fInterfaceElement = fDescriptionElement.addInterfaceElement();
+ fStyleDefaultURI1 = new URI("http://www.w3.org/0000/00/apacheStyle");
+ fStyleDefaultURI2 = new URI("http://www.w3.org/0000/00/anotherApacheStyle");
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Mandatory attribute ("name")
+ * - setName()
+ * - getName()
+ */
+ public void testGetSetName()
+ {
+ fInterfaceElement.setName(new NCName("interfaceName"));
+ QName uri = fInterfaceElement.getName();
+ assertEquals("Retrieved InterfaceElement name does not match that set -", "interfaceName", uri.toString());
+ }
+
+ /*
+ * Gets InterfaceElements referenced by the "extends" attribute (optional)
+ */
+ public void testGetExtendedInterfaceElementElements()
+ {
+ /*
+ * create some InterfaceElements to extend, add them to parent,
+ * access them via :
+ * - getExtendedInterfaceElement()
+ * - getExtendedInterfaceElements()
+ */
+
+ // check the default:
+ InterfaceElement[] ifeArray = fInterfaceElement.getExtendedInterfaceElements();
+ assertEquals("Retrieved Extended InterfaceElement group should be empty if none set -", 0, ifeArray.length);
+
+ // create further InterfaceElements and name them
+ InterfaceElement xife1 = fDescriptionElement.addInterfaceElement();
+ InterfaceElement xife2 = fDescriptionElement.addInterfaceElement();
+ xife1.setName(new NCName("extendedIE1"));
+ xife2.setName(new NCName("extendedIE2"));
+ fInterfaceElement.addExtendedInterfaceName(new QName("extendedIE1"));
+ fInterfaceElement.addExtendedInterfaceName(new QName("extendedIE2"));
+
+ // getExtendedInterfaceElements()
+ ifeArray = fInterfaceElement.getExtendedInterfaceElements();
+ assertEquals("Incorrect number of retrieved Extended InterfaceElements -", 2, ifeArray.length);
+ // verify object equivalence
+ List ifeL = Arrays.asList(ifeArray);
+ assertTrue(ifeL.contains(xife1));
+ assertTrue(ifeL.contains(xife2));
+
+ // getExtendedInterfaceElement()
+ InterfaceElement retrievedIfe = fInterfaceElement.getExtendedInterfaceElement(new QName("extendedIE1"));
+ assertEquals("Retrieved Extended InterfaceElement unexpected -", xife1, retrievedIfe);
+ retrievedIfe = fInterfaceElement.getExtendedInterfaceElement(new QName("randomUnset"));
+ assertNull("The name of a non-existent InterfaceElement should not return one -", retrievedIfe);
+ }
+
+ /*
+ * Optional attribute ("extends")
+ * - addExtendedInterfaceName()
+ * - getExtendedInterfaceNames()
+ * - removeExtendedInterfaceName()
+ */
+ public void testAddGetRemoveExtendedInterfaceNames()
+ {
+ // check the default:
+ QName[] ifeQnameArray = fInterfaceElement.getExtendedInterfaceNames();
+ assertEquals("Retrieved Extended InterfaceElement QName group should be empty if none set -", 0, ifeQnameArray.length);
+
+ // create further InterfaceElements and name them
+ InterfaceElement xife1 = fDescriptionElement.addInterfaceElement();
+ InterfaceElement xife2 = fDescriptionElement.addInterfaceElement();
+ xife1.setName(new NCName("extendedIE1"));
+ xife2.setName(new NCName("extendedIE2"));
+
+ // addExtendedInterfaceName()
+ QName xifeQname1 = new QName("extendedIE1");
+ fInterfaceElement.addExtendedInterfaceName(xifeQname1);
+ QName xifeQname2 = new QName("extendedIE2");
+ fInterfaceElement.addExtendedInterfaceName(xifeQname2);
+ assertNotNull("Retrieved Extended InterfaceElement from a valid name expected.",
+ fInterfaceElement.getExtendedInterfaceElement(xifeQname1));
+ // Add a qname on a non-existent InterfaceElement
+ QName xifeQname3 = new QName("nonExistentExtendedIE");
+ fInterfaceElement.addExtendedInterfaceName(xifeQname3);
+
+ // getExtendedInterfaceNames()
+ QName[] ifeNames = fInterfaceElement.getExtendedInterfaceNames();
+ assertNotNull("Expected an array of QNames.", ifeNames);
+ assertEquals("Incorrect number of retrieved Extended InterfaceElement names -", 3, ifeNames.length);
+ // verify all names returned
+ List ifeL = Arrays.asList(ifeNames);
+ assertTrue(ifeL.contains(xifeQname1));
+ assertTrue(ifeL.contains(xifeQname2));
+ assertTrue(ifeL.contains(xifeQname3));
+ // verify that xifeQname3 does not refer to any InterfaceElement
+ assertNull("Extended InterfaceElement for name " + xifeQname3 + " unexpected.",
+ fInterfaceElement.getExtendedInterfaceElement(xifeQname3));
+
+ // removeExtendedInterfaceName()
+ fInterfaceElement.removeExtendedInterfaceName(xifeQname1);
+ fInterfaceElement.removeExtendedInterfaceName(xifeQname3);
+ fInterfaceElement.removeExtendedInterfaceName(xifeQname2);
+ ifeNames = fInterfaceElement.getExtendedInterfaceNames();
+ assertNotNull("Expected an (empty) array of QNames.", ifeNames);
+ assertEquals("Incorrect number of retrieved Extended InterfaceElement names -", 0, ifeNames.length);
+ }
+
+ /*
+ * Optional attribute ("styleDefault")
+ * styleDefault comprises a list of URIs (IRIs in the spec)
+ * - getStyleDefault() returns the list
+ * - addStyleDefaultURI() adds to the list
+ */
+ public void testAddGetStyleDefault()
+ {
+ // check the default:
+ URI[] styleDefault = fInterfaceElement.getStyleDefault();
+ assertNotNull(styleDefault);
+ assertEquals("Retrieved InterfaceElement style default should be empty if none set -", 0, styleDefault.length);
+
+ // addStyleDefaultURI() a couple of times
+ fInterfaceElement.addStyleDefaultURI(fStyleDefaultURI1);
+ fInterfaceElement.addStyleDefaultURI(fStyleDefaultURI2);
+
+ // getStyleDefault()
+ styleDefault = fInterfaceElement.getStyleDefault();
+ assertNotNull(styleDefault);
+ assertEquals("Unexpected number of URIs in the styleDefault -", 2, styleDefault.length);
+ // check that all added URIs appear in the styleDefault
+ List sdL = Arrays.asList(styleDefault);
+ assertTrue(sdL.contains(fStyleDefaultURI1));
+ assertTrue(sdL.contains(fStyleDefaultURI2));
+ }
+
+ /*
+ * Optional element ("fault")
+ * - addInterfaceFaultElement()
+ * - getInterfaceFaultElement()
+ * - getInterfaceFaultElements()
+ */
+ public void testAddGetInterfaceFaultElements()
+ {
+ // check the default:
+ InterfaceFaultElement[] iffeArray = fInterfaceElement.getInterfaceFaultElements();
+ assertNotNull("Expected an array of InterfaceFaultElements -", iffeArray);
+ assertEquals("Retrieved InterfaceFaultElement group should be empty if none set -", 0, iffeArray.length);
+
+ // addInterfaceFaultElement()
+ InterfaceFaultElement iffe1 = fInterfaceElement.addInterfaceFaultElement();
+ InterfaceFaultElement iffe2 = fInterfaceElement.addInterfaceFaultElement();
+ assertNotNull(iffe1);
+ assertNotNull(iffe2);
+
+ // getInterfaceFaultElements()
+ iffeArray = fInterfaceElement.getInterfaceFaultElements();
+ assertNotNull("Expected an array of InterfaceFaultElements -", iffeArray);
+ assertEquals("Incorrect number of retrieved InterfaceFaultElements -", 2, iffeArray.length);
+
+ // verify all Fault objects returned
+ List iffeL = Arrays.asList(iffeArray);
+ assertTrue(iffeL.contains(iffe1));
+ assertTrue(iffeL.contains(iffe2));
+
+ // getInterfaceFaultElement()
+ // name one of them
+ iffe1.setName(new NCName("FaultName"));
+ InterfaceFaultElement retrievedIffe = fInterfaceElement.getInterfaceFaultElement(new QName("FaultName"));
+ assertNotNull(retrievedIffe);
+ assertEquals("Retrieved InterfaceFaultElement differs from that expected", iffe1, retrievedIffe);
+ // try a non-existent fault - should return null
+ retrievedIffe = fInterfaceElement.getInterfaceFaultElement(new QName("nonExistentFault"));
+ assertNull(retrievedIffe);
+ }
+
+ /*
+ * Optional element ("operation")
+ * - addInterfaceOperationElement()
+ * - getInterfaceOperationElement()
+ * - getInterfaceOperationElements()
+ */
+ public void testAddGetInterfaceOperationElements()
+ {
+ // check the default:
+ InterfaceOperationElement[] ifopArray = fInterfaceElement.getInterfaceOperationElements();
+ assertNotNull("Expected an array of InterfaceOperationElements -", ifopArray);
+ assertEquals("Retrieved InterfaceOperationElement group should be empty if none set -", 0, ifopArray.length);
+
+ // addInterfaceOperationElement()
+ InterfaceOperationElement ifop1 = fInterfaceElement.addInterfaceOperationElement();
+ InterfaceOperationElement ifop2 = fInterfaceElement.addInterfaceOperationElement();
+ assertNotNull(ifop1);
+ assertNotNull(ifop2);
+
+ // getInterfaceOperationElements()
+ ifopArray = fInterfaceElement.getInterfaceOperationElements();
+ assertNotNull("Expected an array of InterfaceOperationElements -", ifopArray);
+ assertEquals("Incorrect number of retrieved InterfaceOperationElements -", 2, ifopArray.length);
+
+ // verify all Operation objects returned
+ List ifopL = Arrays.asList(ifopArray);
+ assertTrue(ifopL.contains(ifop1));
+ assertTrue(ifopL.contains(ifop2));
+
+ // getInterfaceOperationElement()
+ // name one of them
+ ifop1.setName(new NCName("OperationName"));
+ InterfaceOperationElement retrievedIfop = fInterfaceElement.getInterfaceOperationElement(new QName("OperationName"));
+ assertNotNull(retrievedIfop);
+ assertEquals("Retrieved InterfaceOperationElement differs from that expected", ifop1, retrievedIfop);
+ // try a non-existent operation - should return null
+ retrievedIfop = fInterfaceElement.getInterfaceOperationElement(new QName("nonExistentOperation"));
+ assertNull(retrievedIfop);
+ }
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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?rev=568937&r1=568936&r2=568937&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java Thu Aug 23 04:24:51 2007
@@ -1,84 +1,84 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.wsdl20.xml;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.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;
-
- public static Test suite()
- {
- return new TestSuite(InterfaceFaultElementTest.class);
- }
-
- public void setUp() {
-
- WSDLFactory factory = null;
- try {
- factory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- fail("Can't instantiate the WSDLFactory object.");
- }
-
- DescriptionElement desc = factory.newDescription();
- fFault = (desc.addInterfaceElement()).addInterfaceFaultElement();
- }
-
- /*
- * 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());
- }
-
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.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;
+
+ public static Test suite()
+ {
+ return new TestSuite(InterfaceFaultElementTest.class);
+ }
+
+ public void setUp() {
+
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ DescriptionElement desc = factory.newDescription();
+ fFault = (desc.addInterfaceElement()).addInterfaceFaultElement();
+ }
+
+ /*
+ * 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());
+ }
+
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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?rev=568937&r1=568936&r2=568937&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java Thu Aug 23 04:24:51 2007
@@ -1,127 +1,127 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.wsdl20.xml;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.InterfaceFaultReferenceImpl;
-import org.apache.woden.types.NCName;
-import org.apache.woden.wsdl20.enumeration.Direction;
-
-/**
- * Unit tests for the InterfaceFaultReferenceElement class.
- *
- * @author Graham Turrell (gturrell@apache.org)
- */
-public class InterfaceFaultReferenceElementTest extends TestCase {
-
- private InterfaceFaultReferenceElement fFaultReference = null;
-
- public static Test suite()
- {
- return new TestSuite(InterfaceFaultReferenceElementTest.class);
-
- }
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception
- {
- super.setUp();
- fFaultReference = new InterfaceFaultReferenceImpl();
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /*
- * Test that a (mandatory) direction can be successfully set and retrieved
- */
- public void testSetGetDirection()
- {
- // Default case
- assertNull("The retrieved Element name when unset should be null", fFaultReference.getDirection());
-
- fFaultReference.setDirection(Direction.IN);
- assertEquals("The retrieved FaultReference direction is not that which was set",
- Direction.IN, fFaultReference.getDirection());
- }
-
- /*
- * Test that the (Mandatory) message label attribute ("messageLabel") can be successfully set and retrieved
- */
- public void testSetGetMessageLabel()
- {
- NCName faultRefNCName = new NCName("faultRefName");
- fFaultReference.setMessageLabel(faultRefNCName);
- assertEquals("The retrieved Element name is not that which was set",
- faultRefNCName, fFaultReference.getMessageLabel());
- }
-
- /*
- * Test that the(Mandatory) InterfaceFault reference attribute ("ref") can be successfully set and retrieved
- */
- public void testSetGetRef()
- {
- QName faultRefName = new QName("faultRefName");
- fFaultReference.setRef(faultRefName);
- assertEquals("The retrieved Element name is not that which was set",
- faultRefName, fFaultReference.getRef());
- }
-
- /*
- * Test that the (Mandatory) InterfaceFault can be successfully retrieved.
- * The fault reference is to an Interface Fault associated with the grandparent InterfaceElement.
- */
- public void testGetInterfaceFaultElement()
- {
- WSDLFactory factory = null;
- try {
- factory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- fail("Can't instantiate the WSDLFactory object.");
- }
-
- // Create the DescriptionElement->InterfaceElement->InterfaceOperationElement->InterfaceFaultReference hierarchy
- DescriptionElement desc = factory.newDescription();
- InterfaceElement interfaceElement = desc.addInterfaceElement();
- InterfaceOperationElement interfaceOperationElement = interfaceElement.addInterfaceOperationElement();
-
- // Add an InterfaceFault to the InterfaceElement
- InterfaceFaultElement faultElement = interfaceElement.addInterfaceFaultElement();
- faultElement.setName(new NCName("Fault1"));
-
- // create the InterfaceFaultReference to test
- InterfaceFaultReferenceElement faultReference = interfaceOperationElement.addInterfaceFaultReferenceElement();
- faultReference.setRef(new QName("Fault1"));
- InterfaceFaultElement retrievedFault = faultReference.getInterfaceFaultElement();
- assertEquals("The retrieved InterfaceFaultElement is not that which was set",
- faultElement, retrievedFault);
- }
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.InterfaceFaultReferenceImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.enumeration.Direction;
+
+/**
+ * Unit tests for the InterfaceFaultReferenceElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceFaultReferenceElementTest extends TestCase {
+
+ private InterfaceFaultReferenceElement fFaultReference = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(InterfaceFaultReferenceElementTest.class);
+
+ }
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFaultReference = new InterfaceFaultReferenceImpl();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Test that a (mandatory) direction can be successfully set and retrieved
+ */
+ public void testSetGetDirection()
+ {
+ // Default case
+ assertNull("The retrieved Element name when unset should be null", fFaultReference.getDirection());
+
+ fFaultReference.setDirection(Direction.IN);
+ assertEquals("The retrieved FaultReference direction is not that which was set",
+ Direction.IN, fFaultReference.getDirection());
+ }
+
+ /*
+ * Test that the (Mandatory) message label attribute ("messageLabel") can be successfully set and retrieved
+ */
+ public void testSetGetMessageLabel()
+ {
+ NCName faultRefNCName = new NCName("faultRefName");
+ fFaultReference.setMessageLabel(faultRefNCName);
+ assertEquals("The retrieved Element name is not that which was set",
+ faultRefNCName, fFaultReference.getMessageLabel());
+ }
+
+ /*
+ * Test that the(Mandatory) InterfaceFault reference attribute ("ref") can be successfully set and retrieved
+ */
+ public void testSetGetRef()
+ {
+ QName faultRefName = new QName("faultRefName");
+ fFaultReference.setRef(faultRefName);
+ assertEquals("The retrieved Element name is not that which was set",
+ faultRefName, fFaultReference.getRef());
+ }
+
+ /*
+ * Test that the (Mandatory) InterfaceFault can be successfully retrieved.
+ * The fault reference is to an Interface Fault associated with the grandparent InterfaceElement.
+ */
+ public void testGetInterfaceFaultElement()
+ {
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ // Create the DescriptionElement->InterfaceElement->InterfaceOperationElement->InterfaceFaultReference hierarchy
+ DescriptionElement desc = factory.newDescription();
+ InterfaceElement interfaceElement = desc.addInterfaceElement();
+ InterfaceOperationElement interfaceOperationElement = interfaceElement.addInterfaceOperationElement();
+
+ // Add an InterfaceFault to the InterfaceElement
+ InterfaceFaultElement faultElement = interfaceElement.addInterfaceFaultElement();
+ faultElement.setName(new NCName("Fault1"));
+
+ // create the InterfaceFaultReference to test
+ InterfaceFaultReferenceElement faultReference = interfaceOperationElement.addInterfaceFaultReferenceElement();
+ faultReference.setRef(new QName("Fault1"));
+ InterfaceFaultElement retrievedFault = faultReference.getInterfaceFaultElement();
+ assertEquals("The retrieved InterfaceFaultElement is not that which was set",
+ faultElement, retrievedFault);
+ }
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultReferenceElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java?rev=568937&r1=568936&r2=568937&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java Thu Aug 23 04:24:51 2007
@@ -1,199 +1,199 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.wsdl20.xml;
-
-import java.net.URI;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.internal.wsdl20.Constants;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.ElementDeclarationImpl;
-import org.apache.woden.internal.wsdl20.InterfaceMessageReferenceImpl;
-import org.apache.woden.types.NCName;
-import org.apache.woden.wsdl20.ElementDeclaration;
-import org.apache.woden.wsdl20.enumeration.Direction;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-
-
-
-/**
- * Unit tests for the InterfaceMessageReferenceElement class.
- *
- * @author Graham Turrell (gturrell@apache.org)
- */
-public class InterfaceMessageReferenceElementTest extends TestCase {
-
- private InterfaceMessageReferenceElement fMessageReference = null;
- private URI fNamespace = null;
-
- public static Test suite()
- {
- return new TestSuite(InterfaceMessageReferenceElementTest.class);
-
- }
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception
- {
- super.setUp();
- fMessageReference = new InterfaceMessageReferenceImpl();
- fNamespace = new URI("http://apache.org/testns");
- }
-
- /*
- * @see TestCase#tearDown()
- */
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /*
- * Test that a (mandatory) direction can be successfully set and retrieved
- */
- public void testSetGetDirection()
- {
- // Default case
- assertNull("The retrieved Direction when unset should be null", fMessageReference.getDirection());
-
- fMessageReference.setDirection(Direction.OUT);
- assertEquals("The retrieved MessageReference direction is not that which was set",
- Direction.OUT, fMessageReference.getDirection());
- }
-
- /*
- * Test that the (Mandatory) message label attribute ("messageLabel") can be successfully set and retrieved
- */
- public void testSetGetMessageLabel()
- {
- NCName messageRefNCName = new NCName("messageRefName");
- fMessageReference.setMessageLabel(messageRefNCName);
- assertEquals("The retrieved messageLabel is not that which was set",
- messageRefNCName, fMessageReference.getMessageLabel());
- }
-
- /*
- * Test that the (Mandatory) Message Content Model property can be successfully set and retrieved
- */
- public void testSetGetMessageContentModel()
- {
- fMessageReference.setMessageContentModel("contentModel");
- assertEquals("The retrieved Message Content Model is not that which was set",
- "contentModel", fMessageReference.getMessageContentModel());
- }
-
-
- /*
- * Test that the (Mandatory) Element Name attribute ("element") can be successfully set and retrieved
- */
- public void testSetGetElementName()
- {
- QName elementName = new QName("ElementName");
- fMessageReference.setElementName(elementName);
- assertEquals("The retrieved Element Name attribute is not that which was set",
- elementName, fMessageReference.getElementName());
- }
-
- /*
- * Test that the (Optional) Element Declaration property can be successfully retrieved.
- * The element reference is to an Element Declaration associated with a TypeDef below the ancestor Description,
- * of the name set in setElementName().
- *
- * TODO Need to check model structure for XmlSchema
- */
-
- public void testGetElement()
- {
- WSDLFactory factory = null;
- try {
- factory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- fail("Can't instantiate the WSDLFactory object.");
- }
-
- // Create the DescriptionElement->InterfaceElement->InterfaceOperationElement->InterfaceMessageReferenceElement hierarchy
- DescriptionElement descriptionElement = factory.newDescription();
- InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
- InterfaceOperationElement interfaceOperationElement = interfaceElement.addInterfaceOperationElement();
-
- // create the InterfaceMessageReferenceElement to test
- InterfaceMessageReferenceElement messageReference = interfaceOperationElement.addInterfaceMessageReferenceElement();
-
- // Default case:
- XmlSchemaElement retrievedElement = messageReference.getElement();
- assertNull("Unset Element Declaration should return null", retrievedElement);
-
- // populated case 1 - (with Message Content Model set to #ANY or #NONE).
- ElementDeclaration ed = new ElementDeclarationImpl();
- ((DescriptionImpl)descriptionElement).addElementDeclaration(ed);
- messageReference.setMessageContentModel(Constants.NMTOKEN_NONE);
-
- descriptionElement.toComponent();
-
- retrievedElement = messageReference.getElement();
- assertNull("The retrieved Element Declation should return null when message content model is #NONE",
- retrievedElement);
-
- messageReference.setMessageContentModel(Constants.NMTOKEN_ANY);
- descriptionElement.toComponent();
- retrievedElement = messageReference.getElement();
- assertNull("The retrieved Element Declaration should return null when message content model is #ANY",
- retrievedElement);
-
- /* TODO following populated case (with Message Content Model set) requires XmlSchema "element" field to be set.
- * (probably via org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement())
- */
-/*
- // populated case 2 - success:
-
- // Add a TypesElement to the Description
- TypesElement typesElement = descriptionElement.getTypesElement();
-
- // Add a namespace-identified schema element declaration to the Types element
- XmlSchemaCollection xsc = new XmlSchemaCollection();
- XmlSchema xmlSchema = new XmlSchema("ElementName", xsc);
- Schema schema = new ImportedSchemaImpl(); // arbitrary schema
- schema.setNamespace(fNamespace);
- schema.setSchemaDefinition(xmlSchema);
- typesElement.addSchema(schema);
-
- fExtensionRegistry.registerComponentExtension(InterfaceOperation.class,
- InterfaceOperationExtensionsImpl.URI_NS_EXTENSIONS, InterfaceOperationExtensionsImpl.class);
-
- descriptionElement.setExtensionRegistry(fExtensionRegistry);
-
- // set the element name reference
- QName elementName = new QName("http://apache.org/testns", "ElementName");
- messageReference.setElementName(elementName);
- messageReference.setMessageContentModel(Constants.NMTOKEN_ELEMENT);
-
- //descriptionElement.toComponent(); // quick test of model integrity for testing purposes
-
- retrievedElement = messageReference.getElement();
- assertEquals("The retrieved Element is not that which was set",
- schema, retrievedElement);
-*/
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.ElementDeclarationImpl;
+import org.apache.woden.internal.wsdl20.InterfaceMessageReferenceImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.ElementDeclaration;
+import org.apache.woden.wsdl20.enumeration.Direction;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+
+
+
+/**
+ * Unit tests for the InterfaceMessageReferenceElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class InterfaceMessageReferenceElementTest extends TestCase {
+
+ private InterfaceMessageReferenceElement fMessageReference = null;
+ private URI fNamespace = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(InterfaceMessageReferenceElementTest.class);
+
+ }
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fMessageReference = new InterfaceMessageReferenceImpl();
+ fNamespace = new URI("http://apache.org/testns");
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Test that a (mandatory) direction can be successfully set and retrieved
+ */
+ public void testSetGetDirection()
+ {
+ // Default case
+ assertNull("The retrieved Direction when unset should be null", fMessageReference.getDirection());
+
+ fMessageReference.setDirection(Direction.OUT);
+ assertEquals("The retrieved MessageReference direction is not that which was set",
+ Direction.OUT, fMessageReference.getDirection());
+ }
+
+ /*
+ * Test that the (Mandatory) message label attribute ("messageLabel") can be successfully set and retrieved
+ */
+ public void testSetGetMessageLabel()
+ {
+ NCName messageRefNCName = new NCName("messageRefName");
+ fMessageReference.setMessageLabel(messageRefNCName);
+ assertEquals("The retrieved messageLabel is not that which was set",
+ messageRefNCName, fMessageReference.getMessageLabel());
+ }
+
+ /*
+ * Test that the (Mandatory) Message Content Model property can be successfully set and retrieved
+ */
+ public void testSetGetMessageContentModel()
+ {
+ fMessageReference.setMessageContentModel("contentModel");
+ assertEquals("The retrieved Message Content Model is not that which was set",
+ "contentModel", fMessageReference.getMessageContentModel());
+ }
+
+
+ /*
+ * Test that the (Mandatory) Element Name attribute ("element") can be successfully set and retrieved
+ */
+ public void testSetGetElementName()
+ {
+ QName elementName = new QName("ElementName");
+ fMessageReference.setElementName(elementName);
+ assertEquals("The retrieved Element Name attribute is not that which was set",
+ elementName, fMessageReference.getElementName());
+ }
+
+ /*
+ * Test that the (Optional) Element Declaration property can be successfully retrieved.
+ * The element reference is to an Element Declaration associated with a TypeDef below the ancestor Description,
+ * of the name set in setElementName().
+ *
+ * TODO Need to check model structure for XmlSchema
+ */
+
+ public void testGetElement()
+ {
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ // Create the DescriptionElement->InterfaceElement->InterfaceOperationElement->InterfaceMessageReferenceElement hierarchy
+ DescriptionElement descriptionElement = factory.newDescription();
+ InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
+ InterfaceOperationElement interfaceOperationElement = interfaceElement.addInterfaceOperationElement();
+
+ // create the InterfaceMessageReferenceElement to test
+ InterfaceMessageReferenceElement messageReference = interfaceOperationElement.addInterfaceMessageReferenceElement();
+
+ // Default case:
+ XmlSchemaElement retrievedElement = messageReference.getElement();
+ assertNull("Unset Element Declaration should return null", retrievedElement);
+
+ // populated case 1 - (with Message Content Model set to #ANY or #NONE).
+ ElementDeclaration ed = new ElementDeclarationImpl();
+ ((DescriptionImpl)descriptionElement).addElementDeclaration(ed);
+ messageReference.setMessageContentModel(Constants.NMTOKEN_NONE);
+
+ descriptionElement.toComponent();
+
+ retrievedElement = messageReference.getElement();
+ assertNull("The retrieved Element Declation should return null when message content model is #NONE",
+ retrievedElement);
+
+ messageReference.setMessageContentModel(Constants.NMTOKEN_ANY);
+ descriptionElement.toComponent();
+ retrievedElement = messageReference.getElement();
+ assertNull("The retrieved Element Declaration should return null when message content model is #ANY",
+ retrievedElement);
+
+ /* TODO following populated case (with Message Content Model set) requires XmlSchema "element" field to be set.
+ * (probably via org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement())
+ */
+/*
+ // populated case 2 - success:
+
+ // Add a TypesElement to the Description
+ TypesElement typesElement = descriptionElement.getTypesElement();
+
+ // Add a namespace-identified schema element declaration to the Types element
+ XmlSchemaCollection xsc = new XmlSchemaCollection();
+ XmlSchema xmlSchema = new XmlSchema("ElementName", xsc);
+ Schema schema = new ImportedSchemaImpl(); // arbitrary schema
+ schema.setNamespace(fNamespace);
+ schema.setSchemaDefinition(xmlSchema);
+ typesElement.addSchema(schema);
+
+ fExtensionRegistry.registerComponentExtension(InterfaceOperation.class,
+ InterfaceOperationExtensionsImpl.URI_NS_EXTENSIONS, InterfaceOperationExtensionsImpl.class);
+
+ descriptionElement.setExtensionRegistry(fExtensionRegistry);
+
+ // set the element name reference
+ QName elementName = new QName("http://apache.org/testns", "ElementName");
+ messageReference.setElementName(elementName);
+ messageReference.setMessageContentModel(Constants.NMTOKEN_ELEMENT);
+
+ //descriptionElement.toComponent(); // quick test of model integrity for testing purposes
+
+ retrievedElement = messageReference.getElement();
+ assertEquals("The retrieved Element is not that which was set",
+ schema, retrievedElement);
+*/
+ }
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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?rev=568937&r1=568936&r2=568937&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.java Thu Aug 23 04:24:51 2007
@@ -1,241 +1,241 @@
-/**
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.woden.wsdl20.xml;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.types.NCName;
-
-/**
- * Unit tests for the InterfaceOperationElement 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();
-
- WSDLFactory factory = null;
- try {
- factory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- fail("Can't instantiate the WSDLFactory object.");
- }
-
- fDescriptionElement = factory.newDescription();
- 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);
- }
-
- /*
- * 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);
- }
-
- /*
- * References to Optional child elements "input" and "output"
- * - addInterfaceMessageReferenceElement()
- * - getInterfaceMessageReferenceElements()
- * - removeInterfaceMessageReferenceElement()
- */
- public void testAddGetRemoveInterfaceMessageReferenceElements()
- {
- // 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);
- }
-}
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the InterfaceOperationElement 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();
+
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ fDescriptionElement = factory.newDescription();
+ 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);
+ }
+
+ /*
+ * 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);
+ }
+
+ /*
+ * References to Optional child elements "input" and "output"
+ * - addInterfaceMessageReferenceElement()
+ * - getInterfaceMessageReferenceElements()
+ * - removeInterfaceMessageReferenceElement()
+ */
+ public void testAddGetRemoveInterfaceMessageReferenceElements()
+ {
+ // 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);
+ }
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceOperationElementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/NameAttributeTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/NameAttributeTest.java?rev=568937&r1=568936&r2=568937&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/NameAttributeTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/NameAttributeTest.java Thu Aug 23 04:24:51 2007
@@ -1,58 +1,58 @@
-/**
+/**
* 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 junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.woden.WSDLException;
-import org.apache.woden.WSDLFactory;
-import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.types.NCName;
-
-public class NameAttributeTest extends TestCase {
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(NameAttributeTest.class);
- }
-
- public static Test suite()
- {
- return new TestSuite(NameAttributeTest.class);
- }
-
- /**
- * Create an InterfaceElement but don't add it to a DescriptionElement
- * and ensure that getQName() returns a QName with a namespace value
- * of the emptystring.
- */
- public void testNamespaceOfGetNameReturnValue() {
- WSDLFactory factory = null;
- try {
- factory = WSDLFactory.newInstance();
- } catch (WSDLException e) {
- fail("Can't instantiate the WSDLFactory object.");
- }
-
- DescriptionElement de = factory.newDescription();
- InterfaceElement ie = de.addInterfaceElement();
- ie.setName(new NCName("foo"));
- String namespace = ie.getName().getNamespaceURI();
- assertTrue("namespace value should be \"\" but is " + namespace, namespace.equals(""));
- }
-}
+ *
+ * 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.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+public class NameAttributeTest extends TestCase {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(NameAttributeTest.class);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(NameAttributeTest.class);
+ }
+
+ /**
+ * Create an InterfaceElement but don't add it to a DescriptionElement
+ * and ensure that getQName() returns a QName with a namespace value
+ * of the emptystring.
+ */
+ public void testNamespaceOfGetNameReturnValue() {
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ DescriptionElement de = factory.newDescription();
+ InterfaceElement ie = de.addInterfaceElement();
+ ie.setName(new NCName("foo"));
+ String namespace = ie.getName().getNamespaceURI();
+ assertTrue("namespace value should be \"\" but is " + namespace, namespace.equals(""));
+ }
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/NameAttributeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org