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/17 00:11:11 UTC

svn commit: r496887 - in /incubator/woden/trunk/java/test/org/apache/woden: tests/ wsdl20/ wsdl20/xml/

Author: gturrell
Date: Tue Jan 16 15:11:10 2007
New Revision: 496887

URL: http://svn.apache.org/viewvc?view=rev&rev=496887
Log:
WODEN-51 Correction made to Description Test; also Component tests moved to correct test package.

Added:
    incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java
      - copied, changed from r496733, incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptionTest.java
    incubator/woden/trunk/java/test/org/apache/woden/wsdl20/EndpointTest.java
      - copied, changed from r496669, incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java
    incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ServiceTest.java
      - copied, changed from r496669, incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java
Removed:
    incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptionTest.java
    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=496887&r1=496886&r2=496887
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java Tue Jan 16 15:11:10 2007
@@ -27,6 +27,9 @@
 import org.apache.woden.internal.wsdl20.validation.WSDLComponentValidatorTest;
 import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidatorTest;
 import org.apache.woden.resolver.SimpleURIResolverTest;
+import org.apache.woden.wsdl20.DescriptionTest;
+import org.apache.woden.wsdl20.EndpointTest;
+import org.apache.woden.wsdl20.ServiceTest;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingExtensionsTest;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensionsTest;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensionsTest;
@@ -38,15 +41,12 @@
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensionsTest;
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensionsTest;
 import org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensionsTest;
-import org.apache.woden.wsdl20.xml.DescriptionTest;
 import org.apache.woden.wsdl20.xml.DescriptiontElementTest;
 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;
 

Copied: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java (from r496733, incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptionTest.java)
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java?view=diff&rev=496887&p1=incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptionTest.java&r1=496733&p2=incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java&r2=496887
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/DescriptionTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/DescriptionTest.java Tue Jan 16 15:11:10 2007
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License.
  */
-package org.apache.woden.wsdl20.xml;
+package org.apache.woden.wsdl20;
 
 import javax.xml.namespace.QName;
 
@@ -22,21 +22,26 @@
 import junit.framework.TestSuite;
 
 import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.ServiceImpl;
+import org.apache.woden.internal.wsdl20.ElementDeclarationImpl;
+import org.apache.woden.internal.wsdl20.TypeDefinitionImpl;
 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;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.ServiceElement;
 
 /**
- * Unit tests for the implementation of Service interface.
+ * Unit tests for the Description component API.
  * 
  * @author Graham Turrell (gturrell@apache.org)
  */
 public class DescriptionTest extends TestCase {
 
-	private Service fEmptyService = null;
+	private Description fDescription = null;
+	private DescriptionElement fDescriptionElement = null;
+	private BindingElement fBindingElement = null;
+	private InterfaceElement fInterfaceElement = null;
+	private ServiceElement fServiceElement = null;
 	
 	public static Test suite()
 	{
@@ -49,7 +54,28 @@
     protected void setUp() throws Exception 
     {
         super.setUp();
-    	fEmptyService = new ServiceImpl();
+    	fDescriptionElement = new DescriptionImpl();
+    	fBindingElement = fDescriptionElement.addBindingElement();
+    	fBindingElement.setName(new NCName("bindingName"));
+    	fInterfaceElement = fDescriptionElement.addInterfaceElement();
+    	fInterfaceElement.setName(new NCName("interfaceName"));
+    	fServiceElement = fDescriptionElement.addServiceElement();
+    	fServiceElement.setName(new NCName("serviceName"));
+    	fDescriptionElement.getTypesElement(); // create a TypesElement	
+    	
+    	// TODO check the following are not too contrived...
+    	// 1:
+    	ElementDeclarationImpl refEd = new ElementDeclarationImpl();
+    	refEd.setName(new QName("myEd"));
+    	((DescriptionImpl)fDescriptionElement).addElementDeclaration(refEd);
+    	
+    	// 2:
+    	TypeDefinitionImpl typeDef = new TypeDefinitionImpl();
+    	typeDef.setName(new QName("myTypeDef"));
+    	((DescriptionImpl)fDescriptionElement).addTypeDefinition(typeDef);
+    	
+    	fDescription = fDescriptionElement.toComponent();
+    
     }
 
     /*
@@ -60,34 +86,46 @@
         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()
+	public void testGetBinding()
+	{
+		Binding retrievedBinding = fDescription.getBinding(new QName("bindingName"));
+		assertNotNull(retrievedBinding);
+		assertEquals(fBindingElement, retrievedBinding.toElement());
+		
+		Binding noBinding = fDescription.getBinding(new QName("noBinding"));
+		assertNull(noBinding);
+		
+		QName nullQName = null;
+		Binding nullBinding = fDescription.getBinding(nullQName);
+		assertNull(nullBinding);
+	}
+	
+	public void testGetBindings()
 	{
-		/* 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);
+		Binding[] retrievedBindings = fDescription.getBindings();
+		assertNotNull(retrievedBindings);
+		assertEquals(retrievedBindings.length, 1);
+	}
+	
+	public void testGetElementDeclaration()
+	{
+		ElementDeclaration ed = fDescription.getElementDeclaration(new QName("myEd")); 
+		assertNotNull(ed);
+		
+		// non-existent ElementDeclaration...
+		ed = fDescription.getElementDeclaration(new QName("doesNotExist"));
+		assertNull(ed);	
+	}
+	
+	
+	public void testGetElementDeclarations()
+	{
+		ElementDeclaration[] eds = fDescription.getElementDeclarations();
+		assertNotNull(eds);
+		assertEquals(eds.length, 1);
+		
+		// TODO - test for when no Element Declarations ?
 	}
 	
 	/*
@@ -96,52 +134,71 @@
 	 */
 	public void testGetInterface()
 	{	
-		/* Set up prereqs:
-		 * - Description containing one named Interface;
-		 * - Service using that same Interface.
-		 */
+		Interface retrievedIf = fDescription.getInterface(new QName("interfaceName"));
+		assertNotNull(retrievedIf);
+		assertEquals(retrievedIf.toElement(), fInterfaceElement); // TODO - a fair test or a rash assumption?!
 		
-	   	// 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);
+		// non-existent interface
+		retrievedIf = fDescription.getInterface(new QName("noSuchInterface"));
+		assertNull(retrievedIf);
+		
+		// null interface name
+		QName nullQName = null;
+		retrievedIf = fDescription.getInterface(nullQName);
+		assertNull(retrievedIf);
 	}
 	
-	/*
-	 * 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");
+	public void testGetInterfaces()
+	{
+		Interface[] retrievedIfs = fDescription.getInterfaces();
+		assertEquals(retrievedIfs.length, 1);
+	}
+	
+	public void testGetService()
+	{
+		Service retrievedService = fDescription.getService(new QName("serviceName"));
+		assertNotNull(retrievedService);
+		
+		// non-existent service
+		retrievedService = fDescription.getService(new QName("noSuchService"));
+		assertNull(retrievedService);
+		
+		// null service name
+		QName nullQName = null;
+		retrievedService = fDescription.getService(nullQName);
+		assertNull(retrievedService);
 	}
 	
+	public void testGetServices()
+	{
+		Service[] services = fDescription.getServices();
+		assertEquals(services.length, 1);
+	}
+	
+	public void testGetTypeDefinition()
+	{
+		TypeDefinition td = fDescription.getTypeDefinition(new QName("myTypeDef"));
+		assertNotNull(td);
+		
+		// non-existent TypeDefinition...
+		td = fDescription.getTypeDefinition(new QName("doesNotExist"));
+		assertNull(td);
+	}
+	
+	public void testGetTypeDefinitions()
+	{
+		TypeDefinition[] tds = fDescription.getTypeDefinitions();
+		assertNotNull(tds);
+		assertEquals(tds.length, 1);
+	}
+
 	/*
-     * Tests that the returned class is a ServiceElement
+     * Tests that the returned class is a DescriptionElement
      *
      */
     public void testToElement()
 	{
-    	assertTrue(fEmptyService.toElement() instanceof ServiceElement);
+    	assertTrue(fDescription.toElement() instanceof DescriptionElement);
 	}
 
 }

Copied: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/EndpointTest.java (from r496669, 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/EndpointTest.java?view=diff&rev=496887&p1=incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java&r1=496669&p2=incubator/woden/trunk/java/test/org/apache/woden/wsdl20/EndpointTest.java&r2=496887
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/EndpointTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/EndpointTest.java Tue Jan 16 15:11:10 2007
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License.
  */
-package org.apache.woden.wsdl20.xml;
+package org.apache.woden.wsdl20;
 
 import java.net.URI;
 
@@ -26,8 +26,10 @@
 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;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.EndpointElement;
+import org.apache.woden.wsdl20.xml.ServiceElement;
 
 /**
  * Unit tests for the ImportElement class.

Copied: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ServiceTest.java (from r496669, 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/ServiceTest.java?view=diff&rev=496887&p1=incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java&r1=496669&p2=incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ServiceTest.java&r2=496887
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/ServiceTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ServiceTest.java Tue Jan 16 15:11:10 2007
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and 
  * limitations under the License.
  */
-package org.apache.woden.wsdl20.xml;
+package org.apache.woden.wsdl20;
 
 import javax.xml.namespace.QName;
 
@@ -24,10 +24,10 @@
 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;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.EndpointElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.ServiceElement;
 
 /**
  * Unit tests for the implementation of Service interface.



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org