You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by gt...@apache.org on 2007/01/13 20:41:49 UTC
svn commit: r495953 - in /incubator/woden/trunk/java/test/org/apache/woden:
tests/AllWodenTestsDOM.java wsdl20/xml/EndpointTest.java
wsdl20/xml/ServiceTest.java
Author: gturrell
Date: Sat Jan 13 11:41:48 2007
New Revision: 495953
URL: http://svn.apache.org/viewvc?view=rev&rev=495953
Log:
WODEN-50 Created unit tests for woden wsdl20 Service and Endpoint.
Added:
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java
Modified:
incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java
Modified: incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java?view=diff&rev=495953&r1=495952&r2=495953
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java Sat Jan 13 11:41:48 2007
@@ -39,10 +39,12 @@
import org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensionsTest;
import org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensionsTest;
import org.apache.woden.wsdl20.xml.EndpointElementTest;
+import org.apache.woden.wsdl20.xml.EndpointTest;
import org.apache.woden.wsdl20.xml.ImportElementTest;
import org.apache.woden.wsdl20.xml.IncludeElementTest;
import org.apache.woden.wsdl20.xml.NameAttributeTest;
import org.apache.woden.wsdl20.xml.ServiceElementTest;
+import org.apache.woden.wsdl20.xml.ServiceTest;
import org.apache.woden.xml.IntOrTokenAttrTest;
import org.apache.woden.xml.TokenAttrTest;
@@ -107,6 +109,8 @@
addTest(SimpleURIResolverTest.suite());
addTest(ImportElementTest.suite());
addTest(IncludeElementTest.suite());
+ addTest(EndpointTest.suite());
+ addTest(ServiceTest.suite());
//TODO in-progress 30May06 tests for BindingOpExt and BindingMsgRefExt
}
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java?view=auto&rev=495953
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java Sat Jan 13 11:41:48 2007
@@ -0,0 +1,151 @@
+/**
+ * Copyright 2005 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.EndpointImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Endpoint;
+
+/**
+ * Unit tests for the ImportElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class EndpointTest extends TestCase {
+
+ private EndpointImpl fEndpointImpl = null;
+ private Endpoint fEndpoint = null;
+ private URI fURI = null;
+ private QName fBindingQName = null;
+ private NCName fBindingNCName = null;
+ private NCName fName = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(EndpointTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fURI = new URI("http://apache.org/endpointURI");
+ fEndpointImpl = new EndpointImpl();
+ fEndpoint = fEndpointImpl;
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ fURI = null;
+ fEndpointImpl = null;
+ fEndpoint = null;
+ fBindingQName = null;
+ fBindingNCName = null;
+ fName = null;
+ }
+
+ /*
+ * Test getAddress() when the (optional) address attribute is set (specified)
+ */
+ public void testGetAddress()
+ {
+ fEndpointImpl.setAddress(fURI);
+ assertEquals(fEndpoint.getAddress(), fURI); // java.net.URI overrides Object.equals()
+ }
+
+ /*
+ * Test getAddress() when the (optional) address attribute is unspecified
+ */
+ public void testDefaultGetAddress()
+ {
+ assertNull(fEndpoint.getAddress());
+ }
+
+ /*
+ * The Binding with fBindingName is obtained from the Description element associated with the Endpoint's Service
+ *
+ */
+ public void testGetBinding()
+ {
+ /*
+ * Test setup : work with the Infoset view for the creation of the
+ * necessary prerequisite partial hierarchy
+ * Note create the minimum necessary wsdl20 objects
+ */
+
+ // Description...
+ DescriptionElement fDescElement = new DescriptionImpl();
+
+ // Binding...
+ fBindingQName = new QName("binding1");
+ BindingElement fBindingElement = fDescElement.addBindingElement();
+ fBindingNCName = new NCName("binding1");
+ NCName fServiceNCName = new NCName("service1");
+ QName fServiceQName = new QName("service1");
+ NCName fEndpointNCname = new NCName("endpoint1");
+ fBindingElement.setName(fBindingNCName);
+
+ // Service... (attach our Endpoint to a Service parented by our Description)
+ ServiceElement fServiceElement = fDescElement.addServiceElement();
+ fServiceElement.setName(fServiceNCName);
+
+ // Endpoint...
+ EndpointElement fEndpointElement = fServiceElement.addEndpointElement();
+ fEndpointElement.setName(fEndpointNCname);
+ fEndpointElement.setParentElement(fServiceElement);
+ fEndpointElement.setBindingName(fBindingQName);
+ fEndpointElement.setParentElement(fServiceElement);
+
+ // Component model creation
+ Description fDesc = fDescElement.toComponent();
+ Endpoint fDerivedEndpoint = fDesc.getService(fServiceQName).getEndpoint(fEndpointNCname);
+
+ assertEquals(fDerivedEndpoint.getBinding().getName(), fBindingQName); // just compare QNames
+ }
+
+ public void testGetName()
+ {
+ fName = new NCName("endpoint_name");
+ fEndpointImpl.setName(fName);
+ assertEquals(fEndpoint.getName(), fName);
+ }
+
+ /*
+ * Tests that the returned class is precisely an EndpointElement (ie not a subclass)
+ *
+ */
+ public void testToElement()
+ {
+ assertTrue(fEndpoint.toElement() instanceof EndpointElement);
+ }
+
+}
\ No newline at end of file
Added: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java?view=auto&rev=495953
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java Sat Jan 13 11:41:48 2007
@@ -0,0 +1,147 @@
+/**
+ * Copyright 2005 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.xml;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.internal.wsdl20.ServiceImpl;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.Service;
+
+/**
+ * Unit tests for the implementation of Service interface.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class ServiceTest extends TestCase {
+
+ private Service fEmptyService = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(ServiceTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fEmptyService = new ServiceImpl();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Test that endpoints associated with a service are correctly returned with
+ * getEndpoint() and getEndpoints().
+ *
+ * Note that a service must have at least one endpoint associated.
+ */
+
+ public void testGetEndpointGetEndpoints()
+ {
+ /* Set up prereqs:
+ * - Service with > 1 endpoints created.
+ */
+ ServiceElement fServiceElement = new ServiceImpl();
+ EndpointElement fEndpointElement1 = fServiceElement.addEndpointElement();
+ fEndpointElement1.setName(new NCName("endpoint1"));
+ EndpointElement fEndpointElement2 = fServiceElement.addEndpointElement();
+ fEndpointElement2.setName(new NCName("endpoint2"));
+ Service fService = (Service) fServiceElement;
+
+ // test getEndpoint()
+ Endpoint e1 = fService.getEndpoint(new NCName("endpoint1"));
+ assertEquals("The retrieved Endpoint object is not that which was set", e1, fEndpointElement1);
+
+ // test getEndpoints()
+ Endpoint[] e = fService.getEndpoints();
+ assertEquals("The incorrect number of endpoints were returned", e.length, 2);
+ assertEquals("First endpoint is not endpoint1", e[0], fEndpointElement1);
+ assertEquals("Second endpoint is not endpoint2", e[1], fEndpointElement2);
+ }
+
+ /*
+ * Test that a service returns its (required) associated interface.
+ *
+ */
+ public void testGetInterface()
+ {
+ /* Set up prereqs:
+ * - Description containing one named Interface;
+ * - Service using that same Interface.
+ */
+
+ // Description...
+ DescriptionElement fDescElement = new DescriptionImpl();
+
+ // Interface
+ InterfaceElement fInterfaceElement = fDescElement.addInterfaceElement();
+ fInterfaceElement.setName(new NCName("interface1"));
+
+ // Service...
+ ServiceElement fServiceElement = fDescElement.addServiceElement();
+ fServiceElement.setName(new NCName("service1"));
+ fServiceElement.setInterfaceName(new QName("interface1"));
+ fServiceElement.setParentElement(fDescElement);
+
+ // "create" the component model to complete the woden object hierachy references
+ Description fDesc = fDescElement.toComponent();
+ fDesc.getServices(); // necessary to set the reference to Description in Service
+
+ /* Test assertions:
+ * (Object equivalence is fine here - we check both refer to same Object)
+ */
+ assertEquals(((Service)fServiceElement).getInterface(), (Interface) fInterfaceElement);
+ }
+
+ /*
+ * Test that getName() correctly returns the assigned service name
+ */
+ public void testGetName()
+ {
+ // for simplicity, the default namespace is used throughout such that the string representation of
+ // QName from the getter will be identical to the NCName of the setter, for the test to succeed.
+ ((ServiceImpl)fEmptyService).setName(new NCName("service1"));
+ assertEquals("The service name from getName() differs from that set.", fEmptyService.getName().toString(), "service1");
+ }
+
+ /*
+ * Tests that the returned class is a ServiceElement
+ *
+ */
+ public void testToElement()
+ {
+ assertTrue(fEmptyService.toElement() instanceof ServiceElement);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org