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 2006/01/19 19:22:53 UTC
svn commit: r370562 - in /incubator/woden/java/test/org/apache/woden: tests/
wsdl20/ wsdl20/xml/ wsdl20/xml/resources/
Author: jkaputin
Date: Thu Jan 19 10:22:43 2006
New Revision: 370562
URL: http://svn.apache.org/viewcvs?rev=370562&view=rev
Log:
Added junit tests for Service and Endpoint parsing.
Added:
incubator/woden/java/test/org/apache/woden/wsdl20/
incubator/woden/java/test/org/apache/woden/wsdl20/xml/
incubator/woden/java/test/org/apache/woden/wsdl20/xml/EndpointElementTest.java
incubator/woden/java/test/org/apache/woden/wsdl20/xml/ServiceElementTest.java
incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/
incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl
incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/ServiceElementTest.wsdl
Modified:
incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java
Modified: incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java?rev=370562&r1=370561&r2=370562&view=diff
==============================================================================
--- incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java (original)
+++ incubator/woden/java/test/org/apache/woden/tests/AllWodenTests.java Thu Jan 19 10:22:43 2006
@@ -25,6 +25,8 @@
import org.apache.woden.internal.ReaderFeaturesTest;
import org.apache.woden.internal.wsdl20.validation.WSDLComponentValidatorTest;
import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidatorTest;
+import org.apache.woden.wsdl20.xml.EndpointElementTest;
+import org.apache.woden.wsdl20.xml.ServiceElementTest;
public class AllWodenTests extends TestSuite
{
@@ -63,6 +65,8 @@
addTestSuite(ReaderFeaturesTest.class);
addTest(WSDLDocumentValidatorTest.suite());
addTest(WSDLComponentValidatorTest.suite());
+ addTest(ServiceElementTest.suite());
+ addTest(EndpointElementTest.suite());
}
}
Added: incubator/woden/java/test/org/apache/woden/wsdl20/xml/EndpointElementTest.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/wsdl20/xml/EndpointElementTest.java?rev=370562&view=auto
==============================================================================
--- incubator/woden/java/test/org/apache/woden/wsdl20/xml/EndpointElementTest.java (added)
+++ incubator/woden/java/test/org/apache/woden/wsdl20/xml/EndpointElementTest.java Thu Jan 19 10:22:43 2006
@@ -0,0 +1,195 @@
+/**
+ * Copyright 2006 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.net.URL;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.internal.wsdl20.EndpointImpl;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.types.NCName;
+
+/**
+ * Functional verification test of org.apache.woden.wsdl20.xml.EndpointElement.
+ * Checks that the expected API behaviour is supported by the implementation.
+ *
+ * @author jkaputin@apache.org
+ */
+public class EndpointElementTest extends TestCase
+{
+ private WSDLFactory fFactory = null;
+ private WSDLReader fReader = null;
+ private ErrorHandler fHandler = null;
+ private DescriptionElement fParsedDesc = null;
+ private EndpointElement[] fParsedEndpoints = null;
+
+ private String fTargetNS = "http://ws.apache.woden/endpoint";
+
+ public static Test suite()
+ {
+ return new TestSuite(EndpointElementTest.class);
+ }
+
+ protected void setUp() throws Exception
+ {
+ fFactory = WSDLFactory.newInstance();
+ fReader = fFactory.newWSDLReader();
+ fHandler = new TestErrorHandler();
+ fReader.getErrorReporter().setErrorHandler(fHandler);
+
+ URL wsdlURL = getClass().getClassLoader().getResource(
+ "org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl");
+ assertNotNull("Failed to find the WSDL document on the classpath.", wsdlURL);
+
+ fParsedDesc = fReader.readWSDL(wsdlURL.toString());
+ assertNotNull("The reader did not return a description.", fParsedDesc);
+
+ ServiceElement service = fParsedDesc.getServiceElements()[0];
+ assertNotNull("The description does not contain a service.", service);
+
+ fParsedEndpoints = service.getEndpointElements();
+ assertTrue("The service does not contain 3 endpoints as expected.",
+ fParsedEndpoints.length == 3);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ fFactory = null;
+ fReader = null;
+ fHandler = null;
+ fParsedDesc = null;
+ fParsedEndpoints = null;
+ }
+
+ /**
+ * Test that the getName method returns the expected NCName parsed from a WSDL document.
+ */
+ public void testGetNameParsed()
+ {
+ NCName ncName = fParsedEndpoints[0].getName();
+ assertNotNull("EndpointElement.getName() returned null, but an NCName was expected.",
+ ncName);
+
+ assertTrue("NCName returned by EndpointElement.getName() was not the one expected.",
+ "endpoint1".equals(ncName.toString()) );
+ }
+
+ /**
+ * Test that the NCName specified on the setName method is returned by getName.
+ */
+ public void testSetAndGetName()
+ {
+ EndpointElement endpoint = new EndpointImpl();
+ NCName ncName = new NCName("dummy");
+
+ endpoint.setName(ncName);
+ assertTrue("NCName returned by EndpointElement.getName() was not the one set by setName().",
+ ncName.equals(endpoint.getName()));
+ }
+
+ /**
+ * Test that the getBindingName method returns the QName of the binding
+ * associated with this endpoint, as specified by the "binding" attribute
+ * of the <endpoint> element in a parsed WSDL document.
+ */
+ public void testGetBindingNameParsed()
+ {
+ QName qname = fParsedEndpoints[0].getBindingName();
+ assertNotNull("EndpointElement.getBindingName() returned null, but a QName was expected.",
+ qname);
+
+ QName expectedQN = new QName(fTargetNS, "binding1");
+ assertTrue("QName returned by EndpointElement.getBindingName() was not the one expected.",
+ expectedQN.equals(qname));
+ }
+
+ /**
+ * Test that the QName specified on the setBindingName method is returned by
+ * the getBindingName method.
+ */
+ public void testSetAndGetBindingName()
+ {
+ EndpointElement endpoint = new EndpointImpl();
+ QName qname = new QName("urn:woden","dummy");
+ endpoint.setBindingName(qname);
+ QName returnedQN = endpoint.getBindingName();
+ assertTrue("QName returned by EndpointElement.getBindingName() was not the one set by setBindingName().",
+ returnedQN.equals(qname));
+ }
+
+ /**
+ * Test that the getBindingElement method returns a BindingElement
+ * defined within the description, that is referred to by QName in the
+ * "binding" attribute of the <endpoint> element of a parsed WSDL
+ * document. This tests that the QName is correctly dereferenced to an object.
+ */
+ public void testGetBindingElementParsed()
+ {
+ BindingElement bindingDefined = fParsedDesc.getBindingElements()[0];
+ BindingElement bindingReferred = fParsedEndpoints[0].getBindingElement();
+ assertNotNull("EndpointElement.getBindingElement() returned null, but a BindingElement was expected.",
+ bindingReferred);
+
+ assertTrue("The BindingElement returned by EndpointElement.getBindingElement() was not the one expected.",
+ bindingReferred == bindingDefined);
+ }
+
+ /**
+ * Test that the getAddress method returns the expected URI parsed from a WSDL document.
+ */
+ public void testGetAddressParsed()
+ {
+ URI uri = fParsedEndpoints[0].getAddress();
+ assertNotNull("EndpointElement.getAddress() returned null, but a URI was expected.",
+ uri);
+
+ assertTrue("URI returned by EndpointElement.getAddress() was not the one expected.",
+ "urn:abc".equals(uri.toString()) );
+ }
+
+ /**
+ * Test the optionality of the 'address' attribute by invoking the getAddress
+ * method on a parsed <endpoint> element that does not have an
+ * 'address' specified and check that it returns null.
+ */
+ public void testGetAddressParsedOptional()
+ {
+ URI uri = fParsedEndpoints[1].getAddress();
+ assertNull("EndpointElement.getAddress() did not return null, as expected.",
+ uri);
+ }
+
+ /**
+ * Test that the URI specified on the setAddress method is returned by getAddress.
+ */
+ public void testSetAndGetAddress() throws Exception
+ {
+ EndpointElement endpoint = new EndpointImpl();
+ URI uri = new URI("urn:dummy");
+ endpoint.setAddress(uri);
+ assertTrue("URI returned by EndpointElement.getAddress() was not the one set by setAddress().",
+ "urn:dummy".equals(endpoint.getAddress().toString()));
+ }
+}
Added: incubator/woden/java/test/org/apache/woden/wsdl20/xml/ServiceElementTest.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/wsdl20/xml/ServiceElementTest.java?rev=370562&view=auto
==============================================================================
--- incubator/woden/java/test/org/apache/woden/wsdl20/xml/ServiceElementTest.java (added)
+++ incubator/woden/java/test/org/apache/woden/wsdl20/xml/ServiceElementTest.java Thu Jan 19 10:22:43 2006
@@ -0,0 +1,182 @@
+/**
+ * Copyright 2006 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.URL;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.internal.wsdl20.EndpointImpl;
+import org.apache.woden.internal.wsdl20.ServiceImpl;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.types.NCName;
+
+/**
+ * Functional verification test of org.apache.woden.wsdl20.xml.ServiceElement.
+ * Checks that the expected API behaviour is supported by the implementation.
+ *
+ * @author jkaputin@apache.org
+ */
+public class ServiceElementTest extends TestCase
+{
+ private WSDLFactory fFactory = null;
+ private WSDLReader fReader = null;
+ private ErrorHandler fHandler = null;
+ private DescriptionElement fParsedDesc = null;
+ private ServiceElement fParsedService = null;
+
+ private String fTargetNS = "http://ws.apache.woden/service";
+ private QName fQName = new QName("urn:woden","dummy");
+
+ public static Test suite()
+ {
+ return new TestSuite(ServiceElementTest.class);
+ }
+
+ protected void setUp() throws Exception
+ {
+ fFactory = WSDLFactory.newInstance();
+ fReader = fFactory.newWSDLReader();
+ fHandler = new TestErrorHandler();
+ fReader.getErrorReporter().setErrorHandler(fHandler);
+
+ URL wsdlURL = getClass().getClassLoader().getResource(
+ "org/apache/woden/wsdl20/xml/resources/ServiceElementTest.wsdl");
+ assertNotNull("Failed to find the WSDL document on the classpath.", wsdlURL);
+
+ fParsedDesc = fReader.readWSDL(wsdlURL.toString());
+ assertNotNull("The reader did not return a description.", fParsedDesc);
+
+ fParsedService = fParsedDesc.getServiceElements()[0];
+ assertNotNull("The description does not contain a service.", fParsedService);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ fFactory = null;
+ fReader = null;
+ fHandler = null;
+ fParsedDesc = null;
+ fParsedService = null;
+ }
+
+ /**
+ * Test that the getName method returns the expected QName parsed from a WSDL document.
+ */
+ public void testGetNameParsed()
+ {
+ QName qname = fParsedService.getName();
+ assertNotNull("ServiceElement.getName() returned null, but a QName was expected.",
+ qname);
+
+ QName expectedQN = new QName(fTargetNS, "service1");
+ assertTrue("QName returned by ServiceElement.getName() was not the one expected.",
+ expectedQN.equals(qname));
+ }
+
+ /**
+ * Test that the QName specified on the setName method is returned by getName.
+ */
+ public void testSetAndGetName()
+ {
+ ServiceElement service = new ServiceImpl();
+ service.setName(fQName);
+ assertTrue("QName returned by ServiceElement.getName() was not the one set by setName().",
+ fQName.equals(service.getName()));
+ }
+
+ /**
+ * Test that the getInterfaceName method returns the QName of the interface
+ * associated with this service, as specified by the "interface" attribute
+ * of the <service> element in a parsed WSDL document.
+ */
+ public void testGetInterfaceNameParsed()
+ {
+ QName qname = fParsedService.getInterfaceName();
+ assertNotNull("ServiceElement.getInterfaceName() returned null, but a QName was expected.",
+ qname);
+
+ QName expectedQN = new QName(fTargetNS, "interface1");
+ assertTrue("QName returned by ServiceElement.getInterfaceName() was not the one expected.",
+ expectedQN.equals(fParsedService.getInterfaceName()));
+ }
+
+ /**
+ * Test that the QName specified on the setInterfaceName method is returned by
+ * the getInterfaceName method.
+ */
+ public void testSetAndGetInterfaceName()
+ {
+ ServiceElement service = new ServiceImpl();
+ service.setInterfaceName(fQName);
+ QName returnedQN = service.getInterfaceName();
+ assertTrue("QName returned by ServiceElement.getInterfaceName() was not the one set by setInterfaceName().",
+ returnedQN.equals(fQName));
+ }
+
+ /**
+ * Test that the getInterfaceElement method returns an InterfaceElement
+ * defined within the description, that is referred to by QName in the
+ * "interface" attribute of the <service> element of a parsed WSDL
+ * document. This tests that the QName is correctly dereferenced to an object.
+ */
+ public void testGetInterfaceElementParsed()
+ {
+ InterfaceElement interfaceDefined = fParsedDesc.getInterfaceElements()[0];
+ InterfaceElement interfaceReferred = fParsedService.getInterfaceElement();
+ assertNotNull("ServiceElement.getInterfaceElement() returned null, but an InterfaceElement was expected.",
+ interfaceReferred);
+
+ assertTrue("The InterfaceElement returned by ServiceElement.getInterfaceElement() was not the one expected.",
+ interfaceReferred == interfaceDefined);
+ }
+
+ /**
+ * Test that the getEndpointElements method returns an array of the EndpointElements
+ * defined as <endpoint> child elements of the <service> element in
+ * a parsed WSDL document.
+ */
+ public void testGetEndpointElementsParsed()
+ {
+ EndpointElement[] endpoints = fParsedService.getEndpointElements();
+ assertTrue("ServiceElement.getEndpointElements() did not return 3 endpoints, as expected.",
+ endpoints.length == 3);
+ }
+
+ /**
+ * Test that the EndpointElement added by the addEndpointElement method is
+ * present in the array returned by getEndpointElements.
+ */
+ public void testAddAndGetEndpointElement()
+ {
+ EndpointElement endpoint = new EndpointImpl();
+ endpoint.setName(new NCName("endpoint99"));
+ ServiceElement service = new ServiceImpl();
+ service.addEndpointElement(endpoint);
+ assertTrue("The EndpointElement added by the ServiceElement.addEndpointElement method " +
+ "was not returned by ServiceElement.getEndpointElements()",
+ endpoint == service.getEndpointElements()[0]);
+
+ }
+
+}
Added: incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl
URL: http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl?rev=370562&view=auto
==============================================================================
--- incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl (added)
+++ incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl Thu Jan 19 10:22:43 2006
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ * Copyright 2006 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.
+-->
+<description xmlns="http://www.w3.org/2005/08/wsdl"
+ targetNamespace="http://ws.apache.woden/endpoint"
+ xmlns:tns="http://ws.apache.woden/endpoint"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://www.w3.org/2005/08/wsdl http://www.w3.org/2005/08/wsdl/wsdl20.xsd
+ http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd">
+
+ <documentation>
+ Used by EndpointElementTest for FVT of the EndpointElement implementation.
+ </documentation>
+
+ <interface name="interface1" />
+
+ <binding name="binding1" />
+
+ <service name="service1" interface="tns:interface1">
+ <endpoint name="endpoint1" binding="tns:binding1" address="urn:abc" />
+ <endpoint name="endpoint2" binding="tns:binding1" />
+ <endpoint name="endpoint3" binding="tns:binding1" address="urn:xyz" />
+ </service>
+
+</description>
\ No newline at end of file
Added: incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/ServiceElementTest.wsdl
URL: http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/ServiceElementTest.wsdl?rev=370562&view=auto
==============================================================================
--- incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/ServiceElementTest.wsdl (added)
+++ incubator/woden/java/test/org/apache/woden/wsdl20/xml/resources/ServiceElementTest.wsdl Thu Jan 19 10:22:43 2006
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ * Copyright 2006 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.
+-->
+<description xmlns="http://www.w3.org/2005/08/wsdl"
+ targetNamespace="http://ws.apache.woden/service"
+ xmlns:tns="http://ws.apache.woden/service"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://www.w3.org/2005/08/wsdl http://www.w3.org/2005/08/wsdl/wsdl20.xsd
+ http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd">
+
+ <documentation>
+ Used by ServiceElementTest for FVT of the ServiceElement implementation.
+ </documentation>
+
+ <interface name="interface1" />
+ <binding name="binding1" />
+
+ <service name="service1" interface="tns:interface1">
+ <endpoint name="endpoint1" binding="tns:binding1" />
+ <endpoint name="endpoint2" binding="tns:binding1" />
+ <endpoint name="endpoint3" binding="tns:binding1" />
+ </service>
+
+</description>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org