Author: gturrell
Date: Wed Jan 17 09:50:40 2007
New Revision: 497097

URL: http://svn.apache.org/viewvc?view=rev&rev=497097
Log:
WODEN-53 Created unit tests for API methods of woden wsdl20 ElementDeclaration, 
TypeDefinition and TypesElement.

Added:
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ElementDeclarationTest.java
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/TypeDefinitionTest.java
    
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/TypesElementTest.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=497097&r1=497096&r2=497097
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java 
(original)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java 
Wed Jan 17 09:50:40 2007
@@ -28,8 +28,10 @@
 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.ElementDeclarationTest;
 import org.apache.woden.wsdl20.EndpointTest;
 import org.apache.woden.wsdl20.ServiceTest;
+import org.apache.woden.wsdl20.TypeDefinitionTest;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingExtensionsTest;
 import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensionsTest;
 import 
org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensionsTest;
@@ -47,6 +49,7 @@
 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.TypesElementTest;
 import org.apache.woden.xml.IntOrTokenAttrTest;
 import org.apache.woden.xml.TokenAttrTest;
 
@@ -115,6 +118,9 @@
     addTest(ServiceTest.suite());
     addTest(DescriptionTest.suite());
     addTest(DescriptiontElementTest.suite());
+    addTest(TypesElementTest.suite());
+    addTest(ElementDeclarationTest.suite());
+    addTest(TypeDefinitionTest.suite());
     //TODO in-progress 30May06 tests for BindingOpExt and BindingMsgRefExt
   }
 

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ElementDeclarationTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ElementDeclarationTest.java?view=auto&rev=497097
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ElementDeclarationTest.java
 (added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/ElementDeclarationTest.java
 Wed Jan 17 09:50:40 2007
@@ -0,0 +1,101 @@
+/**
+ * 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;
+
+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.ElementDeclarationImpl;
+
+/**
+ * Unit tests for the implementation of ElementDeclaration interface.
+ * 
+ * @author Graham Turrell ([EMAIL PROTECTED])
+ */
+public class ElementDeclarationTest extends TestCase {
+
+       private ElementDeclaration fElementDeclaration = null;
+       private URI fTypeSystem = null;
+       
+       public static Test suite()
+       {
+          return new TestSuite(ElementDeclarationTest.class);
+       }
+          
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+ 
+        fElementDeclaration = new ElementDeclarationImpl();
+               fTypeSystem = new URI("http://www.w3.org/2001/XMLSchema";); 
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+    
+       /*
+        * Test that getContent() correctly returns the assigned 
ElementDeclaration content object
+        */
+       public void testGetContent()
+       {
+               String content = "edContentObject";
+               ((ElementDeclarationImpl) 
fElementDeclaration).setContent(content);
+               assertEquals("The ElementDeclaration content Object differs 
from that set -", content, fElementDeclaration.getContent());
+       }
+       
+       /*
+        * Test that getContentModel() correctly returns the assigned 
ElementDeclaration content model reference
+        */
+       public void testGetContentModel()
+       {
+               String contentModel = ElementDeclaration.API_APACHE_WS_XS; // 
one of the presets available
+               ((ElementDeclarationImpl) 
fElementDeclaration).setContentModel(contentModel);
+               assertEquals("The ElementDeclaration content model String 
differs from that set -", contentModel, fElementDeclaration.getContentModel());
+       }
+       
+       /*
+        * Test that getName() correctly returns the assigned 
ElementDeclaration name
+        */
+       public void testGetName()
+       {       
+               ((ElementDeclarationImpl)fElementDeclaration).setName(new 
QName("edName"));
+               assertEquals("The ElementDeclaration name QName differs from 
that set-", "edName", fElementDeclaration.getName().toString());
+       }
+       
+       /*
+        * Test that getSystem() correctly returns the assigned 
ElementDeclaration type system
+        */
+       public void testGetSystem()
+       {
+               ((ElementDeclarationImpl) 
fElementDeclaration).setSystem(fTypeSystem);
+               assertEquals("The ElementDeclaration type system URI differs 
from that set-", fTypeSystem, fElementDeclaration.getSystem());
+       }
+       
+
+}

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/TypeDefinitionTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/TypeDefinitionTest.java?view=auto&rev=497097
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/TypeDefinitionTest.java 
(added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/TypeDefinitionTest.java 
Wed Jan 17 09:50:40 2007
@@ -0,0 +1,101 @@
+/**
+ * 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;
+
+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.TypeDefinitionImpl;
+
+/**
+ * Unit tests for the implementation of TypeDefinition interface.
+ * 
+ * @author Graham Turrell ([EMAIL PROTECTED])
+ */
+public class TypeDefinitionTest extends TestCase {
+
+       private TypeDefinition fTypeDefinition = null;
+       private URI fTypeSystem = null;
+       
+       public static Test suite()
+       {
+          return new TestSuite(TypeDefinitionTest.class);
+       }
+          
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+ 
+        fTypeDefinition = new TypeDefinitionImpl();
+               fTypeSystem = new URI("http://www.w3.org/2001/XMLSchema";); 
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+    
+       /*
+        * Test that getContent() correctly returns the assigned TypeDefinition 
content object
+        */
+       public void testGetContent()
+       {
+               String content = "tdContentObject";
+               ((TypeDefinitionImpl) fTypeDefinition).setContent(content);
+               assertEquals("The TypeDefinition content Object differs from 
that set -", content, fTypeDefinition.getContent());
+       }
+       
+       /*
+        * Test that getContentModel() correctly returns the assigned 
TypeDefinition content model reference
+        */
+       public void testGetContentModel()
+       {
+               String contentModel = TypeDefinition.API_W3C_DOM; // one of the 
presets available
+               ((TypeDefinitionImpl) 
fTypeDefinition).setContentModel(contentModel);
+               assertEquals("The TypeDefinition content model String differs 
from that set -", contentModel, fTypeDefinition.getContentModel());
+       }
+       
+       /*
+        * Test that getName() correctly returns the assigned TypeDefinition 
name
+        */
+       public void testGetName()
+       {       
+               ((TypeDefinitionImpl)fTypeDefinition).setName(new 
QName("tdName"));
+               assertEquals("The TypeDefinition name QName differs from that 
set-", "tdName", fTypeDefinition.getName().toString());
+       }
+       
+       /*
+        * Test that getSystem() correctly returns the assigned TypeDefinition 
type system
+        */
+       public void testGetSystem()
+       {
+               ((TypeDefinitionImpl) fTypeDefinition).setSystem(fTypeSystem);
+               assertEquals("The TypeDefinition type system URI differs from 
that set-", fTypeSystem, fTypeDefinition.getSystem());
+       }
+       
+
+}

Added: 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/TypesElementTest.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/TypesElementTest.java?view=auto&rev=497097
==============================================================================
--- 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/TypesElementTest.java
 (added)
+++ 
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/TypesElementTest.java
 Wed Jan 17 09:50:40 2007
@@ -0,0 +1,161 @@
+/**
+ * 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.util.Arrays;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.schema.ImportedSchemaImpl;
+import org.apache.woden.internal.schema.InlinedSchemaImpl;
+import org.apache.woden.internal.wsdl20.TypesImpl;
+import org.apache.woden.schema.ImportedSchema;
+import org.apache.woden.schema.InlinedSchema;
+import org.apache.woden.schema.Schema;
+
+/**
+ * Unit tests for the TypesElement class.
+ * 
+ * @author Graham Turrell ([EMAIL PROTECTED])
+ */
+
+public class TypesElementTest extends TestCase {
+
+       private TypesElement fTypesElement = null;
+       private Schema fInlinedSchema1 = null;
+       private Schema fInlinedSchema2 = null;
+       private Schema fImportedSchema1 = null;
+       private Schema fImportedSchema2 = null;
+       
+       public static Test suite()
+       {
+          return new TestSuite(TypesElementTest.class);
+       }
+          
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception 
+    {
+        super.setUp();
+       fTypesElement = new TypesImpl();
+       fInlinedSchema1 = new InlinedSchemaImpl();
+       fInlinedSchema2 = new InlinedSchemaImpl();
+       fImportedSchema1 = new ImportedSchemaImpl();
+       fImportedSchema2 = new ImportedSchemaImpl();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception 
+    {
+        super.tearDown();
+    }
+       
+    /*
+     * Test adding both Inlined and Imported schema objects
+     */
+       public void testAddGetSchemas()
+       {
+               Schema[] schemas = fTypesElement.getSchemas();
+               assertEquals(0, schemas.length);
+       fTypesElement.addSchema(fImportedSchema1);
+               fTypesElement.addSchema(fImportedSchema2);
+               fTypesElement.addSchema(fInlinedSchema1);
+               fTypesElement.addSchema(fInlinedSchema2);
+               schemas = fTypesElement.getSchemas();
+               assertNotNull(schemas);
+               assertEquals(4, schemas.length);
+       }
+
+       public void testRemoveSchema()
+       {
+               Schema[] schemas = null;
+               Schema randomSchema = new ImportedSchemaImpl();
+               
+               // remove from empty list
+               fTypesElement.removeSchema(randomSchema);
+       schemas = fTypesElement.getSchemas();
+               assertEquals(0, schemas.length);
+               
+               
+               fTypesElement.addSchema(fImportedSchema1);
+               fTypesElement.addSchema(fImportedSchema2);
+               fTypesElement.addSchema(fInlinedSchema1);
+               fTypesElement.addSchema(fInlinedSchema2);
+               fTypesElement.removeSchema(fInlinedSchema2);
+               schemas = fTypesElement.getSchemas();
+               assertEquals(3, schemas.length);
+       fTypesElement.removeSchema(fImportedSchema1);
+       schemas = fTypesElement.getSchemas();
+               assertEquals(2, schemas.length);
+               
+               // attempt to remove an un-added schema
+               fTypesElement.removeSchema(randomSchema);
+       schemas = fTypesElement.getSchemas();
+               assertEquals(2, schemas.length); // number should be unchanged
+               
+               fTypesElement.removeSchema(fImportedSchema2);
+               fTypesElement.removeSchema(fInlinedSchema1);
+       schemas = fTypesElement.getSchemas();
+               assertEquals(0, schemas.length);        
+       }
+
+       public void testGetImportedSchemas()
+       {
+       fTypesElement.addSchema(fImportedSchema1);
+               fTypesElement.addSchema(fImportedSchema2);
+               fTypesElement.addSchema(fInlinedSchema1);
+               fTypesElement.addSchema(fInlinedSchema2);
+               
+               ImportedSchema[] schemas = fTypesElement.getImportedSchemas();
+               assertEquals(2, schemas.length);
+               
+               // verify object equivalence
+               List schemaL = Arrays.asList(schemas);
+               assertTrue(schemaL.contains(fImportedSchema1));
+               assertTrue(schemaL.contains(fImportedSchema2));
+               
+       }
+       
+       public void testGetInlinedSchemas()
+       {
+       fTypesElement.addSchema(fImportedSchema1);
+               fTypesElement.addSchema(fImportedSchema2);
+               fTypesElement.addSchema(fInlinedSchema1);
+               fTypesElement.addSchema(fInlinedSchema2);
+               
+               InlinedSchema[] schemas = fTypesElement.getInlinedSchemas();
+               assertEquals(2, schemas.length);
+               
+               // verify object equivalence
+               List schemaL = Arrays.asList(schemas);
+               assertTrue(schemaL.contains(fInlinedSchema1));
+               assertTrue(schemaL.contains(fInlinedSchema2));                  
        
+       }
+       
+       public void testSetGetTypeSystem()
+       {
+               String typeSystem = "http://www.w3.org/2001/XMLSchema";;
+               fTypesElement.setTypeSystem(typeSystem);
+               assertEquals(typeSystem, fTypesElement.getTypeSystem());        
        
+       }
+       
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to