Return-Path: Delivered-To: apmail-ws-woden-dev-archive@www.apache.org Received: (qmail 21817 invoked from network); 1 Sep 2009 05:51:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Sep 2009 05:51:18 -0000 Received: (qmail 89986 invoked by uid 500); 1 Sep 2009 05:51:18 -0000 Delivered-To: apmail-ws-woden-dev-archive@ws.apache.org Received: (qmail 89929 invoked by uid 500); 1 Sep 2009 05:51:18 -0000 Mailing-List: contact woden-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: woden-dev@ws.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list woden-dev@ws.apache.org Received: (qmail 89920 invoked by uid 500); 1 Sep 2009 05:51:18 -0000 Delivered-To: apmail-ws-woden-cvs@ws.apache.org Received: (qmail 89917 invoked by uid 99); 1 Sep 2009 05:51:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Sep 2009 05:51:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Sep 2009 05:51:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DFC5C238890B; Tue, 1 Sep 2009 05:50:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r809833 [5/10] - in /webservices/woden/trunk/java/woden-tests: ./ src/ src/main/ src/main/resources/ src/main/resources/META-INF/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/woden/ src/test... Date: Tue, 01 Sep 2009 05:50:51 -0000 To: woden-cvs@ws.apache.org From: sagara@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090901055054.DFC5C238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/InterfaceTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/InterfaceTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/InterfaceTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/InterfaceTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,315 @@ +/** + * 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; + +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.WSDLFactory; +import org.apache.woden.types.NCName; +import org.apache.woden.wsdl20.xml.DescriptionElement; +import org.apache.woden.wsdl20.xml.InterfaceElement; +import org.apache.woden.wsdl20.xml.InterfaceFaultElement; +import org.apache.woden.wsdl20.xml.InterfaceOperationElement; + +/** + * Unit tests for the Interface class. + * + * @author Graham Turrell (gturrell@apache.org) + */ +public class InterfaceTest extends TestCase { + + // create a parent Description to hang the Interfaces off + private DescriptionElement fDescriptionElement = null; + private Description fDescription = null; + private InterfaceElement fInterfaceElement = null; + private Interface fInterface = null; + private final String INTF_NAME = "interfaceName"; + + public static Test suite() + { + return new TestSuite(InterfaceTest.class); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + //fDescriptionElement = new DescriptionImpl(); + fDescriptionElement = WSDLFactory.newInstance().newDescription(); + fInterfaceElement = fDescriptionElement.addInterfaceElement(); + fInterfaceElement.setName(new NCName(INTF_NAME)); + fDescription = fDescriptionElement.toComponent(); + fInterface = fDescription.getInterface(new QName(INTF_NAME)); + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception + { + super.tearDown(); + } + + /* + * Mandatory attribute ("name") + * - getName() + */ + public void testGetName() + { + QName uri = fInterface.getName(); + assertEquals("Retrieved InterfaceElement name does not match that set -", INTF_NAME, uri.toString()); + } + + /* + * Gets Interfaces referenced by the "extends" attribute (optional) + */ + public void testGetExtendedInterfaceInterfaces() + { + /* + * create some InterfaceElements to extend, add them to parent, + * access them via : + * - getExtendedInterface() + * - getExtendedInterfaces() + */ + + // check the default: + Interface[] ifArray = fInterface.getExtendedInterfaces(); + assertEquals("Retrieved Extended Interface group should be empty if none set -", 0, ifArray.length); + + // create further InterfaceElements and name them + InterfaceElement xife1 = fDescriptionElement.addInterfaceElement(); + InterfaceElement xife2 = fDescriptionElement.addInterfaceElement(); + xife1.setName(new NCName("extendedI1")); + xife2.setName(new NCName("extendedI2")); + fInterfaceElement.addExtendedInterfaceName(new QName("extendedI1")); + fInterfaceElement.addExtendedInterfaceName(new QName("extendedI2")); + + // getExtendedInterfaces() + fDescription = fDescriptionElement.toComponent(); + fInterface = fDescription.getInterface(new QName(INTF_NAME)); + ifArray = fInterface.getExtendedInterfaces(); + assertEquals("Incorrect number of retrieved Extended Interfaces -", 2, ifArray.length); + // verify object equivalence + List ifL = Arrays.asList(ifArray); + assertTrue(ifL.contains(xife1)); + assertTrue(ifL.contains(xife2)); + + // getExtendedInterface() + fDescription = fDescriptionElement.toComponent(); + fInterface = fDescription.getInterface(new QName(INTF_NAME)); + Interface retrievedIf = fInterface.getExtendedInterface(new QName("extendedI1")); + assertEquals("Retrieved Extended Interface unexpected -", (Interface)xife1, retrievedIf); + retrievedIf = fInterface.getExtendedInterface(new QName("randomUnset")); + assertNull("The name of a non-existent Interface should not return one -", retrievedIf); + } + + /* + * Optional element ("fault") + * - getInterfaceFault() + * - getInterfaceFaults() + */ + public void testGetInterfaceFaultFaults() + { + // check the default: + InterfaceFault[] iffArray = fInterface.getInterfaceFaults(); + assertNotNull("Expected an array of InterfaceFaults -", iffArray); + assertEquals("Retrieved InterfaceFault group should be empty if none set -", 0, iffArray.length); + + // create some InterfaceFaults + InterfaceFaultElement iffe1 = fInterfaceElement.addInterfaceFaultElement(); + InterfaceFaultElement iffe2 = fInterfaceElement.addInterfaceFaultElement(); + + // getInterfaceFaults() + fDescription = fDescriptionElement.toComponent(); + fInterface = fDescription.getInterface(new QName(INTF_NAME)); + iffArray = fInterface.getInterfaceFaults(); + assertNotNull("Expected an array of InterfaceFaults -", iffArray); + assertEquals("Incorrect number of retrieved InterfaceFaults -", 2, iffArray.length); + + // verify all Fault objects returned + List iffeL = Arrays.asList(iffArray); + assertTrue(iffeL.contains(iffe1)); + assertTrue(iffeL.contains(iffe2)); + + // getInterfaceFault() + // name one of them + iffe1.setName(new NCName("FaultName")); + fDescription = fDescriptionElement.toComponent(); + fInterface = fDescription.getInterface(new QName(INTF_NAME)); + InterfaceFault retrievedIff = fInterface.getInterfaceFault(new QName("FaultName")); + assertNotNull(retrievedIff); + assertEquals("Retrieved InterfaceFault differs from that expected", (InterfaceFault)iffe1, retrievedIff); + // try a non-existent fault - should return null + retrievedIff = fInterface.getInterfaceFault(new QName("nonExistentFault")); + assertNull(retrievedIff); + } + + /* + * Optional element ("operation") + * - getInterfaceOperation() + * - getInterfaceOperations() + */ + public void testGetInterfaceOperationOperations() + { + // check the default: + InterfaceOperation[] ifopArray = fInterface.getInterfaceOperations(); + assertNotNull("Expected an array of InterfaceOperations -", ifopArray); + assertEquals("Retrieved InterfaceOperation group should be empty if none set -", 0, ifopArray.length); + + // create some InterfaceOperationElement() to test + InterfaceOperationElement ifop1 = fInterfaceElement.addInterfaceOperationElement(); + InterfaceOperationElement ifop2 = fInterfaceElement.addInterfaceOperationElement(); + + // getInterfaceOperations() + fDescription = fDescriptionElement.toComponent(); + fInterface = fDescription.getInterface(new QName(INTF_NAME)); + + ifopArray = fInterface.getInterfaceOperations(); + 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)); + + // getInterfaceOperation() + // name one of them + ifop1.setName(new NCName("OperationName")); + fDescription = fDescriptionElement.toComponent(); + fInterface = fDescription.getInterface(new QName(INTF_NAME)); + InterfaceOperation retrievedIfop = fInterface.getInterfaceOperation(new QName("OperationName")); + assertNotNull(retrievedIfop); + assertEquals("Retrieved InterfaceOperationElement differs from that expected", ifop1, retrievedIfop); + // try a non-existent operation - should return null + retrievedIfop = fInterface.getInterfaceOperation(new QName("nonExistentOperation")); + assertNull(retrievedIfop); + } + + /* + * Gets Interface Faults declared and inherited. + */ + public void testGetAllInterfaceFaults() + { + /* + * create some InterfaceElements to extend, add them to parent, + * add some named faults and access them via: + * - getAllInterfaceFaults() + * - getFromAllInterfaceFaults(QName) + */ + + // create InterfaceElements and name them + InterfaceElement ife = fDescriptionElement.addInterfaceElement(); + InterfaceElement xife1 = fDescriptionElement.addInterfaceElement(); + InterfaceElement xife2 = fDescriptionElement.addInterfaceElement(); + ife.setName(new NCName("Interface")); + xife1.setName(new NCName("extendedI1")); + xife2.setName(new NCName("extendedI2")); + ife.addExtendedInterfaceName(new QName("extendedI1")); + ife.addExtendedInterfaceName(new QName("extendedI2")); + + InterfaceFaultElement fault = ife.addInterfaceFaultElement(); + InterfaceFaultElement fault1 = xife1.addInterfaceFaultElement(); + InterfaceFaultElement fault2 = xife2.addInterfaceFaultElement(); + InterfaceFaultElement fault3 = xife2.addInterfaceFaultElement(); + + fault.setName(new NCName("fault")); + fault1.setName(new NCName("fault1")); + fault2.setName(new NCName("fault2")); + fault3.setName(new NCName("fault3")); + + + fDescription = fDescriptionElement.toComponent(); + Interface intface = fDescription.getInterface(new QName("Interface")); + + //test getAllInterfaceFaults() + InterfaceFault[] allFaults = intface.getAllInterfaceFaults(); + assertEquals("Incorrect number of interface faults", 4, allFaults.length); + + //test getFromAllInterfaceFaults(QName) + InterfaceFault intFault1 = intface.getFromAllInterfaceFaults(new QName("fault1")); + assertEquals(fault1, intFault1); + + InterfaceFault intFault3 = intface.getFromAllInterfaceFaults(new QName("fault3")); + assertEquals(fault3, intFault3); + } + + /* + * Gets Interface Operations declared and inherited. + */ + public void testGetAllInterfaceOperations() + { + /* + * create some InterfaceElements to extend, add them to parent, + * add some named operations and access them via: + * - getAllInterfaceOperations() + * - getFromAllInterfaceOperations(QName) + */ + + // create InterfaceElements and name them + InterfaceElement ife = fDescriptionElement.addInterfaceElement(); + InterfaceElement xife1 = fDescriptionElement.addInterfaceElement(); + InterfaceElement xife2 = fDescriptionElement.addInterfaceElement(); + ife.setName(new NCName("Interface")); + xife1.setName(new NCName("extendedI1")); + xife2.setName(new NCName("extendedI2")); + ife.addExtendedInterfaceName(new QName("extendedI1")); + ife.addExtendedInterfaceName(new QName("extendedI2")); + + InterfaceOperationElement oper = ife.addInterfaceOperationElement(); + InterfaceOperationElement oper1 = xife1.addInterfaceOperationElement(); + InterfaceOperationElement oper2 = xife1.addInterfaceOperationElement(); + InterfaceOperationElement oper3 = xife2.addInterfaceOperationElement(); + + oper.setName(new NCName("oper")); + oper1.setName(new NCName("oper1")); + oper2.setName(new NCName("oper2")); + oper3.setName(new NCName("oper3")); + + fDescription = fDescriptionElement.toComponent(); + Interface intface = fDescription.getInterface(new QName("Interface")); + + //test getAllInterfaceOperations() + InterfaceOperation[] allOperations = intface.getAllInterfaceOperations(); + assertEquals("Incorrect number of interface operations", 4, allOperations.length); + + //test getFromAllInterfaceOperations(QName) + InterfaceOperation intOper2 = intface.getFromAllInterfaceOperations(new QName("oper2")); + assertEquals(oper2, intOper2); + + InterfaceOperation intOper3 = intface.getFromAllInterfaceOperations(new QName("oper3")); + assertEquals(oper3, intOper3); + } + + /* + * toElement() + */ + public void testToElement() + { + assertEquals(fInterfaceElement, fInterface.toElement()); + } + +} Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/ServiceTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/ServiceTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/ServiceTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/ServiceTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,166 @@ +/** + * 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; + +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.ServiceImpl; +import org.apache.woden.types.NCName; +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. + * + * @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(); + + WSDLFactory factory = null; + try { + factory = WSDLFactory.newInstance(); + } catch (WSDLException e) { + fail("Can't instantiate the WSDLFactory object."); + } + + DescriptionElement desc = factory.newDescription(); + desc.addServiceElement(); + fEmptyService = desc.toComponent().getServices()[0]; + } + + /* + * @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. + */ + + WSDLFactory factory = null; + try { + factory = WSDLFactory.newInstance(); + } catch (WSDLException e) { + fail("Can't instantiate the WSDLFactory object."); + } + + // Description... + DescriptionElement fDescElement = factory.newDescription(); + + // 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")); + + // "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); + } + +} Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/TypeDefinitionTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/TypeDefinitionTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/TypeDefinitionTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/TypeDefinitionTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,102 @@ +/** + * 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; + +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 (gturrell@apache.org) + */ +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: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/ExtensionRegistryTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/ExtensionRegistryTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/ExtensionRegistryTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/ExtensionRegistryTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,187 @@ +/** + * 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.extensions; + +import java.util.MissingResourceException; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.woden.ErrorReporter; +import org.apache.woden.WSDLFactory; +import org.apache.woden.WSDLReader; + +public class ExtensionRegistryTest extends TestCase { + + private ExtensionRegistry fExtReg; + + public static Test suite() + { + return new TestSuite(ExtensionRegistryTest.class); + } + + protected void setUp() throws Exception { + super.setUp(); + WSDLFactory factory = WSDLFactory.newInstance(); + WSDLReader reader = factory.newWSDLReader(); + fExtReg = reader.getExtensionRegistry(); + } + + //Test for each API method. + + /*TODO remainder of ExtenionRegistryTest methods + public void testExtensionRegistry() { + fail("Not yet implemented"); + } + + public void testGetErrorReporter() { + fail("Not yet implemented"); + } + + public void testSetDefaultSerializer() { + fail("Not yet implemented"); + } + + public void testGetDefaultSerializer() { + fail("Not yet implemented"); + } + + public void testSetDefaultDeserializer() { + fail("Not yet implemented"); + } + + public void testGetDefaultDeserializer() { + fail("Not yet implemented"); + } + + public void testRegisterSerializer() { + fail("Not yet implemented"); + } + + public void testRegisterDeserializer() { + fail("Not yet implemented"); + } + + public void testQuerySerializer() { + fail("Not yet implemented"); + } + + public void testQueryDeserializer() { + fail("Not yet implemented"); + } + + public void testQueryExtElementType() { + fail("Not yet implemented"); + } + + public void testGetAllowableExtensions() { + fail("Not yet implemented"); + } + + public void testRegisterExtElementType() { + fail("Not yet implemented"); + } + + public void testCreateExtElement() { + fail("Not yet implemented"); + } + + public void testRegisterExtAttributeType() { + fail("Not yet implemented"); + } + + public void testQueryExtAttributeType() { + fail("Not yet implemented"); + } + + public void testCreateExtAttribute() { + fail("Not yet implemented"); + } + + public void testRegisterComponentExtension() { + fail("Not yet implemented"); + } + + public void testQueryComponentExtension() { + fail("Not yet implemented"); + } + + public void testQueryComponentExtensionNamespaces() { + fail("Not yet implemented"); + } + + public void testCreateComponentExtension() { + fail("Not yet implemented"); + } + */ + + public void testRegisterQueryResourceBundleNames() { + + //Test that the core resource bundle is pre-registered. + String[] names = fExtReg.queryResourceBundleNames(); + assertEquals("Unexpected number of registered resource bundles", 1, names.length); + assertEquals("Unexpected default resource bundle", "org.apache.woden.internal.Messages", names[0]); + + //Test that all registered resource bundles can be queried and that the core resourece + //bundle is the first one and that extension resource bundles follow. + String resourceBundleName = "org.apache.woden.wsdl20.extensions.resources.ExtensionMessages"; + fExtReg.registerResourceBundle(resourceBundleName); + names = fExtReg.queryResourceBundleNames(); + assertEquals("Unexpected number of registered resource bundles", 2, names.length); + assertEquals("Unexpected default resource bundle", "org.apache.woden.internal.Messages", names[0]); + assertEquals("Unexpected extension resource bundle", resourceBundleName, names[1]); + } + + /** + * Test the formatting of messages. + *
    + *
  • the message format key is in the core resource bundle,
  • + *
  • the key is in the extension resource bundle,
  • + *
  • the key is in the resource bundles for the core and the extension.
  • + *
  • the key is not found in any resource bundle.
  • + *
      + */ + public void testMessageExtension() { + fExtReg.registerResourceBundle("org.apache.woden.wsdl20.extensions.resources.ExtensionMessages"); + ErrorReporter errorReporter = fExtReg.getErrorReporter(); + + // verify formatting of a message in core resource bundle + assertEquals("Unexpected core message", + "The feature name \"foo\" is not recognized.", + errorReporter.getFormattedMessage("WSDL006", new Object[]{"foo"})); + + // verify formatting of a message in extension resource bundle + assertEquals("Unexpected extension message", + "Attribute \"count\" in element \"ext\" must contain \"int\".", + errorReporter.getFormattedMessage("EXT001", new Object[]{"count", "ext", "int"})); + + // verify core format is not overridden by extension resource bundle + assertEquals("Unexpected core message", + "The property name must not be null when attempting to get or set a named property.", + errorReporter.getFormattedMessage("WSDL007", null)); + + // verify exception on unknown format key + String unknownKey = "_UNKNOWN_KEY_"; + try { + errorReporter.getFormattedMessage(unknownKey, new Object[]{}); + fail("Expected MissingResourceException for "+unknownKey); + } catch (MissingResourceException mre) { + assertEquals("Unexpected MissingResourceException key", unknownKey, mre.getKey()); + } + } +} Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingExtensionsTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingExtensionsTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingExtensionsTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingExtensionsTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,193 @@ +/** + * 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.extensions.http; + +import java.net.URL; + +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.tests.TestErrorHandler; +import org.apache.woden.wsdl20.Binding; +import org.apache.woden.wsdl20.Description; + +/** + * Functional verification test of HTTPBindingExtensions. + * Checks that the expected API behaviour is supported by the implementation. + * + * @author John Kaputin (jkaputin@apache.org) + */ +public class HTTPBindingExtensionsTest extends TestCase +{ + private Binding[] fBindings = null; + private String fWsdlPath = "org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingExtensions.wsdl"; + + public static Test suite() + { + return new TestSuite(HTTPBindingExtensionsTest.class); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + WSDLFactory factory = WSDLFactory.newInstance(); + WSDLReader reader = factory.newWSDLReader(); + ErrorHandler handler = new TestErrorHandler(); + //Don't set validation on, as the testcase WSDL is not intended to be a valid WSDL 2.0 doc. + reader.getErrorReporter().setErrorHandler(handler); + + URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath); + assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".", + wsdlURL); + + Description descComp = reader.readWSDL(wsdlURL.toString()); + assertNotNull("The reader did not return a WSDL description.", descComp); + + fBindings = descComp.getBindings(); + assertEquals("The Description should contain 3 Binding components.", 3, fBindings.length); + + } + + /** + * Test that the value for the {http method default} property returned by the getHttpMethodDefault + * method matches the expected value parsed from the WSDL. + */ + public void testGetHttpMethodDefault() + { + Binding binding1 = fBindings[0]; + HTTPBindingExtensions httpBindExts = (HTTPBindingExtensions)binding1 + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + assertNotNull("The Binding '" + binding1.getName() + "' does not contain an HTTPBindingExtensions object.", + httpBindExts); + + String actual = httpBindExts.getHttpMethodDefault(); + assertNotNull("The value for http method default was null", actual); + assertEquals("Unexpected value for http method default.", + "POST", + actual); + } + + + /** + * Test that the value for the {http query parameter separator default} property returned by the + * getHttpQueryParameterSeparatorDefault method matches the expected value parsed + * from the WSDL. + */ + public void testGetHttpQueryParameterSeparatorDefault() + { + Binding binding1 = fBindings[0]; + HTTPBindingExtensions httpBindExts = (HTTPBindingExtensions)binding1 + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + + String actual = httpBindExts.getHttpQueryParameterSeparatorDefault(); + assertNotNull("The value for http query parameter separator default was null", actual); + assertEquals("Unexpected value for http query parameter separator default.", + "$", + actual); + } + + /** + * Test that the value for the {http cookies} property returned by the + * isHttpCookies method matches the expected value parsed + * from the WSDL. + */ + public void testIsHttpCookies() + { + //test that a whttp:cookies value "true" equates to Boolean(true) + Binding binding1 = fBindings[0]; + HTTPBindingExtensions httpBindExts = (HTTPBindingExtensions)binding1 + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + + assertTrue("Expected 'true' for for http cookies.", + httpBindExts.isHttpCookies().booleanValue()); + + //test that a whttp:cookies value "false" equates to Boolean(false) + Binding binding3 = fBindings[2]; + httpBindExts = (HTTPBindingExtensions)binding3 + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + + assertFalse("Expected 'false' for for http cookies.", + httpBindExts.isHttpCookies().booleanValue()); + } + + /** + * Test that the value for the {http content encoding default} property returned by the + * getContentEncodingDefault method matches the expected value parsed + * from the WSDL. + */ + public void testGetHttpContentEncodingDefault() + { + Binding binding1 = fBindings[0]; + HTTPBindingExtensions httpBindExts = (HTTPBindingExtensions)binding1 + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + + String actual = httpBindExts.getHttpContentEncodingDefault(); + assertEquals("Unexpected value for http content encoding default.", + "chunked", + actual); + } + + + /** + * Test that when binding type is "http://www.w3.org/ns/wsdl/http" and the wsdl:binding element + * has no HTTP extension attributes, the Binding component still contains an HTTPBindingExtensions + * object to handle the default values for the REQUIRED extension properties. + *

      + * Test that the REQUIRED property {http query parameter separator default} defaults to "&" + * when the whttp:queryParameterSeparatorDefault attribute is omitted from the WSDL. + *

      + * Test that the REQUIRED property {http cookies} defaults to false + * when the whttp:cookies attribute is omitted from the WSDL. + *

      + * Test that the OPTIONAL property {http method default} defaults to null + * when the whttp:methodDefault attribute is omitted from the WSDL. + *

      + * Test that the OPTIONAL property {http content encoding default} defaults to null + * when the whttp:contentEncodingDefault attribute is omitted from the WSDL. + */ + public void testHttpPropertyDefaults() + { + Binding binding2 = fBindings[1]; + HTTPBindingExtensions httpBindExts = (HTTPBindingExtensions)binding2 + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + assertNotNull("The Binding '" + + binding2.getName() + + "' does not contain an HTTPBindingExtensions object."); + + assertEquals("The {http query parameter separator default} property should default to ampersand '&'", + "&", + httpBindExts.getHttpQueryParameterSeparatorDefault()); + + assertEquals("The {http cookies} property should default to 'false'", + new Boolean(false), + httpBindExts.isHttpCookies()); + + assertNull("The {http method default} property should default to null", + httpBindExts.getHttpMethodDefault()); + + assertNull("The {http content encoding default} property should default to null", + httpBindExts.getHttpContentEncodingDefault()); + } + +} Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingFaultExtensionsTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingFaultExtensionsTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingFaultExtensionsTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingFaultExtensionsTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,197 @@ +/** + * 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.extensions.http; + +import java.net.URL; + +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.tests.TestErrorHandler; +import org.apache.woden.wsdl20.Binding; +import org.apache.woden.wsdl20.BindingFault; +import org.apache.woden.wsdl20.Description; + +/** + * Functional verification test of HTTPBindingFaultExtensions. + * Checks that the expected API behaviour is supported by the implementation. + * + * @author John Kaputin (jkaputin@apache.org) + */ +public class HTTPBindingFaultExtensionsTest extends TestCase +{ + private BindingFault[] fBindFaults = null; + private String fWsdlPath = "org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingFaultExtensions.wsdl"; + + public static Test suite() + { + return new TestSuite(HTTPBindingFaultExtensionsTest.class); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + WSDLFactory factory = WSDLFactory.newInstance(); + WSDLReader reader = factory.newWSDLReader(); + ErrorHandler handler = new TestErrorHandler(); + //Don't set validation on, as the testcase WSDL is not intended to be a valid WSDL 2.0 doc. + reader.getErrorReporter().setErrorHandler(handler); + + URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath); + assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".", + wsdlURL); + + Description descComp = reader.readWSDL(wsdlURL.toString()); + assertNotNull("The reader did not return a WSDL description.", descComp); + + Binding[] bindings = descComp.getBindings(); + assertEquals("The Description should contain 1 Binding component.", 1, bindings.length); + + fBindFaults = bindings[0].getBindingFaults(); + assertEquals("The Binding should contain 4 BindingFault components.", 4, fBindFaults.length); + + } + + /** + * Test that the value for the {http error status code} property returned by the + * getHttpErrorStatusCode method matches the value parsed from the WSDL. + */ + public void testGetHttpErrorStatusCode() + { + BindingFault bindFault = fBindFaults[0]; + HTTPBindingFaultExtensions httpBindFaultExts = (HTTPBindingFaultExtensions)bindFault + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + assertNotNull("The BindingFault does not contain an HTTPBindingFaultExtensions object.", + httpBindFaultExts); + + HTTPErrorStatusCode actual = httpBindFaultExts.getHttpErrorStatusCode(); + assertNotNull("The value for http error status code was null", actual); + assertEquals("Unexpected value for http error status code.", + 123, + actual.getCode().intValue()); + + bindFault = fBindFaults[1]; + httpBindFaultExts = (HTTPBindingFaultExtensions)bindFault + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + assertNotNull("The BindingFault does not contain an HTTPBindingFaultExtensions object.", + httpBindFaultExts); + + actual = httpBindFaultExts.getHttpErrorStatusCode(); + assertNotNull("The value for http error status code was null", actual); + assertEquals("Unexpected value for http error status code.", + HTTPErrorStatusCode.ANY, + actual); + } + + /** + * Test that the value for the {http transfer coding} property returned by the + * getHttpTransferCoding method matches the value from the WSDL. + */ + public void testGetHttpTransferCoding() + { + BindingFault bindFault = fBindFaults[0]; + HTTPBindingFaultExtensions httpBindFaultExts = (HTTPBindingFaultExtensions)bindFault + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + + String actual = httpBindFaultExts.getHttpContentEncoding(); + assertNotNull("The value for http transfer coding was null", actual); + assertEquals("Unexpected value for http transfer coding.", + "compress;chunked", + actual); + } + + /** + * Test that when binding type is "http://www.w3.org/ns/wsdl/http" and the binding's + * wsdl:fault element has no HTTP extension attributes, the BindingFault component still + * contains an HTTPBindingFaultExtensions object to handle the default values for the + * REQUIRED extension properties. + *

      + * Test that the REQUIRED property {http error status code} defaults to "#any" + * when the whttp:code attribute is omitted from the WSDL. + *

      + * TODO {http transfer coding} defaults to null, pending clarification + * on whether it should default to Binding {http transfer coding default}. + * If this is confirmed, then apply the following test too. + * Test that the OPTIONAL property {http transfer coding} defaults to the Binding's + * {http transfer coding default} property when whttp:transferCoding is omitted. + */ + public void testHttpPropertyDefaults() + { + BindingFault bindFault = fBindFaults[2]; + HTTPBindingFaultExtensions httpBindFaultExts = (HTTPBindingFaultExtensions)bindFault + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + assertNotNull("The BindingFault does not contain an HTTPBindingFaultExtensions object.", + httpBindFaultExts); + + HTTPErrorStatusCode actual = httpBindFaultExts.getHttpErrorStatusCode(); + assertNotNull("The value for http error status code was null", actual); + assertEquals("Unexpected value for http error status code.", + HTTPErrorStatusCode.ANY, + actual); + + /* See above TODO about fixing the spec before using this test. + * + * //get the http transfer coding default from the parent Binding + * Binding binding = (Binding)bindFault.getParent(); + * HTTPBindingExtensions httpBindExts = (HTTPBindingExtensions)binding + * .getComponentExtensionsForNamespace(ComponentExtensions.URI_NS_HTTP); + * assertNotNull("The parent Binding does not contain an HTTPBindingExtensions object.", + * httpBindExts); + * String tfrCodingDef = httpBindExts.getHttpTransferCodingDefault(); + * + * //check that the http transfer coding is equal to the default obtained from the parent + * assertEquals("The {http transfer coding} does not match the {http transfer coding default}.", + * tfrCodingDef, + * httpBindFaultExts.getHttpTransferCoding()); + * + * //check that the transfer coding is "chunked" (the default in the parent) + * assertEquals("The {http transfer coding} is not 'chunked' as expected.", + * "chunked", + * httpBindFaultExts.getHttpTransferCoding()); + */ + + //TODO replace the following assertNull with the code above, once it's confirmed. + assertNull("The {http transfer coding} is not null as expected.", + httpBindFaultExts.getHttpContentEncoding()); + } + + /** + * Test that the {http headers} property returned by the getHttpHeaders + * method contains the expected number of HTTPHeader objects parsed from the WSDL. + */ + public void testGetHttpHeaders() + { + BindingFault bindFault = fBindFaults[3]; + HTTPBindingFaultExtensions httpBindFaultExts = (HTTPBindingFaultExtensions)bindFault + .getComponentExtensionContext(HTTPConstants.NS_URI_HTTP); + assertNotNull("The BindingFault does not contain an HTTPBindingFaultExtensions object.", + httpBindFaultExts); + + HTTPHeader[] actual = httpBindFaultExts.getHttpHeaders(); + assertEquals("Unexpected number of HTTPHeader objects.", + 2, + actual.length); + } + +} Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingMessageReferenceExtensionsTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,155 @@ +/** + * 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.extensions.http; + +import java.net.URL; + +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.tests.TestErrorHandler; +import org.apache.woden.wsdl20.Binding; +import org.apache.woden.wsdl20.BindingMessageReference; +import org.apache.woden.wsdl20.BindingOperation; +import org.apache.woden.wsdl20.Description; + +/** + * Functional verification test of HTTPBindingMessageReferenceExtensions. + * Checks that the expected API behaviour is supported by the implementation. + * + * @author John Kaputin (jkaputin@apache.org) + */ +public class HTTPBindingMessageReferenceExtensionsTest extends TestCase { + + private BindingOperation[] fBindOpers = null; + private String fWsdlPath = + "org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingMessageReferenceExtensions.wsdl"; + + public static Test suite() + { + return new TestSuite(HTTPBindingMessageReferenceExtensionsTest.class); + } + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + WSDLFactory factory = WSDLFactory.newInstance(); + WSDLReader reader = factory.newWSDLReader(); + ErrorHandler handler = new TestErrorHandler(); + //Don't set validation on, as the testcase WSDL is not intended to be a valid WSDL 2.0 doc. + reader.getErrorReporter().setErrorHandler(handler); + + URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath); + assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".", + wsdlURL); + + Description descComp = reader.readWSDL(wsdlURL.toString()); + assertNotNull("The reader did not return a WSDL description.", descComp); + + Binding[] bindings = descComp.getBindings(); + assertEquals("The Description should contain 1 Binding component.", 1, bindings.length); + + fBindOpers = bindings[0].getBindingOperations(); + assertEquals("The Binding should contain 2 BindingOperation components.", 2, fBindOpers.length); + } + + /** + * Testcases for the {http content encoding} property returned + * by the getHttpContentEncoding method. + *

      + * 1. Test that the method returns "compress" if the whttp:contentEncoding + * attribute parsed from the WSDL contains "compress". + *

      + * 2. Test that the method returns null if the whttp:contentEncoding + * attribute is absent in the WSDL. + */ + public void testGetHttpContentEncoding() { + + BindingMessageReference[] bindMsgRefs = fBindOpers[0].getBindingMessageReferences(); + assertEquals("The first BindingOperation should contain 2 BindingMessageReference components.", 2, bindMsgRefs.length); + + //1. test that the property is parsed correctly from the WSDL + BindingMessageReference inputMsg = bindMsgRefs[0]; + HTTPBindingMessageReferenceExtensions httpBindMsgRefExts = + (HTTPBindingMessageReferenceExtensions) inputMsg + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpBindMsgRefExts.getHttpContentEncoding(); + assertEquals("Unexpected value for http content encoding.", + "compress", + actual); + + //2. test the default is null + BindingMessageReference outputMsg = bindMsgRefs[1]; + HTTPBindingMessageReferenceExtensions httpBindMsgRefExts2 = + (HTTPBindingMessageReferenceExtensions) outputMsg + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual2 = httpBindMsgRefExts2.getHttpContentEncoding(); + assertNull("Null was expected for http content encoding.", + actual2); + } + + /** + * Testcases for the {http headers} property returned + * by the getHttpHeaders method. + *

      + * 1. Test that the method returns an array size 2 when there are + * two whttp:header extension elements in the WSDL. + *

      + * 2. Test that the method returns an array size 1 when there is + * one whttp:header extension element in the WSDL. + */ + public void testGetHttpHeaders() { + + BindingMessageReference[] bindMsgRefs = fBindOpers[0].getBindingMessageReferences(); + assertEquals("The first BindingOperation should contain 2 BindingMessageReference components.", 2, bindMsgRefs.length); + + //1. test for 2 HTTPHeader components + BindingMessageReference inputMsg = bindMsgRefs[0]; + HTTPBindingMessageReferenceExtensions httpBindMsgRefExts = + (HTTPBindingMessageReferenceExtensions) inputMsg + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + HTTPHeader[] actual = httpBindMsgRefExts.getHttpHeaders(); + assertEquals("Unexpected size of {http headers}.", + 2, + actual.length); + + //2. test the default + BindingMessageReference outputMsg = bindMsgRefs[1]; + HTTPBindingMessageReferenceExtensions httpBindMsgRefExts2 = + (HTTPBindingMessageReferenceExtensions) outputMsg + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + HTTPHeader[] actual2 = httpBindMsgRefExts2.getHttpHeaders(); + assertEquals("Unexpected size of {http headers}.", + 1, + actual2.length); + + } + +} Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingOperationExtensionsTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingOperationExtensionsTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingOperationExtensionsTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPBindingOperationExtensionsTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,455 @@ +/** + * 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.extensions.http; + +import java.net.URL; + +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.tests.TestErrorHandler; +import org.apache.woden.wsdl20.Binding; +import org.apache.woden.wsdl20.BindingOperation; +import org.apache.woden.wsdl20.Description; + +/** + * Functional verification test of HTTPBindingOperationExtensions. + * Checks that the expected API behaviour is supported by the implementation. + * + * @author John Kaputin (jkaputin@apache.org) + */ +public class HTTPBindingOperationExtensionsTest extends TestCase { + + private BindingOperation[] fBindOpers = null; + private String fWsdlPath = "org/apache/woden/wsdl20/extensions/http/resources/HTTPBindingOperationExtensions.wsdl"; + + public static Test suite() + { + return new TestSuite(HTTPBindingOperationExtensionsTest.class); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + WSDLFactory factory = WSDLFactory.newInstance(); + WSDLReader reader = factory.newWSDLReader(); + ErrorHandler handler = new TestErrorHandler(); + //Don't set validation on, as the testcase WSDL is not intended to be a valid WSDL 2.0 doc. + reader.getErrorReporter().setErrorHandler(handler); + + URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath); + assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".", + wsdlURL); + + Description descComp = reader.readWSDL(wsdlURL.toString()); + assertNotNull("The reader did not return a WSDL description.", descComp); + + Binding[] bindings = descComp.getBindings(); + assertEquals("The Description should contain 1 Binding component.", 1, bindings.length); + + fBindOpers = bindings[0].getBindingOperations(); + assertEquals("The Binding should contain 7 BindingOperation components.", 7, fBindOpers.length); + } + + /** + * Testcases for the {http location} property returned by the + * getHttpLocation method. + *

      + * Test that getHttpLocation returns the URI specified + * in the whttp:location attribute parsed from the WSDL. + *

      + * Test that it returns null by default when the attribute is omitted + * from the WSDL. + */ + public void testGetHttpLocation() { + + //test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String expected = "http://ws.apache.woden/location"; + HTTPLocation httpLoc = httpBindOperExts.getHttpLocation(); + String actual = httpLoc.getOriginalLocation(); + assertEquals("Unexpected value for http location", + expected, + actual); + + //test that the property defaults to null + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + HTTPLocation actual2 = httpBindOperExts2.getHttpLocation(); + assertNull("Http location did not default to null", actual2); + } + + /** + * Testcases for the {http location ignore uncited} property returned + * by the isHttpLocationIgnoreUncited method. + *

      + * Test that the method returns True if the whttp:ignoreUncited + * attribute parsed from the WSDL contains "true". + *

      + * Test that it returns False by default when the attribute is omitted + * from the WSDL. + */ + public void testIsHttpLocationIgnoreUncited() { + + //test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + Boolean actual = httpBindOperExts.isHttpLocationIgnoreUncited(); + assertTrue("Http location ignore uncited was not True", + actual.booleanValue()); + + //test that the property defaults to false + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + Boolean actual2 = httpBindOperExts2.isHttpLocationIgnoreUncited(); + assertFalse("Http location ignore uncited did not default to False", + actual2.booleanValue()); + } + + /** + * Testcases for the {http method} property returned + * by the getHttpMethod method. + *

      + * Test that the method returns GET if the whttp:method attribute + * parsed from the WSDL contains "GET". + *

      + * Test that it returns null by default when the attribute is omitted + * from the WSDL. + *

      + * TODO if the spec is updated to move default behaviour from the + * concreate binding into the component model, update this test + * to reflect that change. + */ + public void testGetHttpMethod() { + + //test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpBindOperExts.getHttpMethod(); + assertEquals("Unexpected value for http method.", + "GET", + actual); + + //test that the property defaults to null + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual2 = httpBindOperExts2.getHttpMethod(); + assertNull("Http method was not null by default.", + actual2); + } + + /** + * Testcases for the {http input serialization} property returned + * by the getHttpInputSerialization method. + *

      + * 1. Test that the method returns text/plain if the whttp:inputSerialization + * attribute parsed from the WSDL contains "text/plain". + *

      + * 2. Test that it defaults to application/xml when the attribute is omitted + * from the WSDL and http method defaults to POST (which it will be for + * this operation because whttp:method is omitted so the binding rules + * default it to POST). + *

      + * 3. Test that it defaults to application/x-www-form-urlencoded when the + * attribute is omitted from the WSDL and the http method is GET. + *

      + * 4. Test that it defaults to application/x-www-form-urlencoded when the + * attribute is omitted from the WSDL and the http method is DELETE. + *

      + * 5. Test that it defaults to application/xml when the + * attribute is omitted from the WSDL and the http method is PUT. + *

      + * 6. Test that it defaults to application/xml when the + * attribute is omitted from the WSDL and the http method is POST. + *

      + * 7. Test that it defaults to application/xml when the + * attribute is omitted from the WSDL and the http method is CONNECT + * (i.e. when http method is something other than GET, DELETE, PUT + * or POST). + */ + public void testGetHttpInputSerialization() { + + //1. test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpBindOperExts.getHttpInputSerialization(); + assertEquals("Unexpected value for http input serialization.", + "text/plain", + actual); + + //2. test that the property defaults to application/xml if the http method + //defaults to POST. + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual2 = httpBindOperExts2.getHttpInputSerialization(); + assertEquals("Unexpected default value for http input serialization.", + "application/xml", + actual2); + + //3. test that the property defaults to application/x-www-form-urlencoded + //if the http method is GET. + BindingOperation oper3 = fBindOpers[2]; + HTTPBindingOperationExtensions httpBindOperExts3 = + (HTTPBindingOperationExtensions) oper3 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual3 = httpBindOperExts3.getHttpInputSerialization(); + assertEquals("Unexpected default value for http input serialization.", + "application/x-www-form-urlencoded", + actual3); + + //4. test that the property defaults to application/x-www-form-urlencoded + //if the http method is DELETE. + BindingOperation oper4 = fBindOpers[3]; + HTTPBindingOperationExtensions httpBindOperExts4 = + (HTTPBindingOperationExtensions) oper4 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual4 = httpBindOperExts4.getHttpInputSerialization(); + assertEquals("Unexpected default value for http input serialization.", + "application/x-www-form-urlencoded", + actual4); + + //5. test that the property defaults to application/xml + //if the http method is PUT. + BindingOperation oper5 = fBindOpers[4]; + HTTPBindingOperationExtensions httpBindOperExts5 = + (HTTPBindingOperationExtensions) oper5 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual5 = httpBindOperExts5.getHttpInputSerialization(); + assertEquals("Unexpected default value for http input serialization.", + "application/xml", + actual5); + + //6. test that the property defaults to application/xml + //if the http method is POST. + BindingOperation oper6 = fBindOpers[5]; + HTTPBindingOperationExtensions httpBindOperExts6 = + (HTTPBindingOperationExtensions) oper6 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual6 = httpBindOperExts6.getHttpInputSerialization(); + assertEquals("Unexpected default value for http input serialization.", + "application/xml", + actual6); + + //7. test that the property defaults to application/xml + //if the http method is CONNECT. + BindingOperation oper7 = fBindOpers[6]; + HTTPBindingOperationExtensions httpBindOperExts7 = + (HTTPBindingOperationExtensions) oper7 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual7 = httpBindOperExts7.getHttpInputSerialization(); + assertEquals("Unexpected default value for http input serialization.", + "application/xml", + actual7); + + } + + /** + * Testcases for the {http output serialization} property returned + * by the getHttpOutputSerialization method. + *

      + * 1. Test that the method returns text/plain if the whttp:outputSerialization + * attribute parsed from the WSDL contains "text/plain". + *

      + * 2. Test that it defaults to application/xml when the attribute is omitted + * from the WSDL. + */ + public void testGetHttpOutputSerialization() { + + //1. test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpBindOperExts.getHttpOutputSerialization(); + assertEquals("Unexpected value for http output serialization.", + "text/plain", + actual); + + //2. test that the property defaults to application/xml. + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual2 = httpBindOperExts2.getHttpOutputSerialization(); + assertEquals("Unexpected default value for http output serialization.", + "application/xml", + actual2); + } + + /** + * Testcases for the {http fault serialization} property returned + * by the getHttpFaultSerialization method. + *

      + * 1. Test that the method returns text/html if the whttp:faultSerialization + * attribute parsed from the WSDL contains "text/html". + *

      + * 2. Test that it defaults to application/xml when the attribute is omitted + * from the WSDL. + */ + public void testGetHttpFaultSerialization() { + + //1. test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpBindOperExts.getHttpFaultSerialization(); + assertEquals("Unexpected value for http fault serialization.", + "text/html", + actual); + + //2. test that the property defaults to application/xml. + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual2 = httpBindOperExts2.getHttpFaultSerialization(); + assertEquals("Unexpected default value for http fault serialization.", + "application/xml", + actual2); + } + + /** + * Testcases for the {http query parameter separator} property returned + * by the getHttpQueryParameterSeparator method. + *

      + * 1. Test that the method returns "%" if the whttp:queryParameterSeparator + * attribute parsed from the WSDL contains "%". + *

      + * 2. Test that it defaults to ampersand when the attribute is omitted + * from the WSDL. + */ + public void testGetHttpQueryParameterSeparator() { + + //1. test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpBindOperExts.getHttpQueryParameterSeparator(); + assertEquals("Unexpected value for http query parameter separator.", + "%", + actual); + + //2. test that the property defaults to ampersand. + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual2 = httpBindOperExts2.getHttpQueryParameterSeparator(); + assertNull("Expected a null value for http query parameter separator.", + actual2); + } + + /** + * Testcases for the {http content encoding default} property returned + * by the getHttpContentEncodingDefault method. + *

      + * 1. Test that the method returns "chunked" if the whttp:contentEncodingDefault + * attribute parsed from the WSDL contains "chunked". + *

      + * 2. Test that it defaults to null when the attribute is omitted + * from the WSDL. + */ + public void testGetHttpContentEncodingDefault() { + + //1. test that the property is parsed correctly from the WSDL + BindingOperation oper = fBindOpers[0]; + HTTPBindingOperationExtensions httpBindOperExts = + (HTTPBindingOperationExtensions) oper + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpBindOperExts.getHttpContentEncodingDefault(); + assertEquals("Unexpected value for http content encoding default.", + "chunked", + actual); + + //2. test that the property defaults to null. + BindingOperation oper2 = fBindOpers[1]; + HTTPBindingOperationExtensions httpBindOperExts2 = + (HTTPBindingOperationExtensions) oper2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual2 = httpBindOperExts2.getHttpContentEncodingDefault(); + assertNull("Http content encoding default did not default to null.", + actual2); + } + +} Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPEndpointExtensionsTest.java URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPEndpointExtensionsTest.java?rev=809833&view=auto ============================================================================== --- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPEndpointExtensionsTest.java (added) +++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPEndpointExtensionsTest.java Tue Sep 1 05:50:45 2009 @@ -0,0 +1,149 @@ +/** + * 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.extensions.http; + +import java.net.URL; + +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.tests.TestErrorHandler; +import org.apache.woden.wsdl20.Description; +import org.apache.woden.wsdl20.Endpoint; +import org.apache.woden.wsdl20.Service; + +/** + * Functional verification test of HTTPEndpointExtensions. + * Checks that the expected API behaviour is supported by the implementation. + * + * @author John Kaputin (jkaputin@apache.org) + */ +public class HTTPEndpointExtensionsTest extends TestCase { + + private Endpoint[] fEndpoints = null; + private String fWsdlPath = + "org/apache/woden/wsdl20/extensions/http/resources/HTTPEndpointExtensions.wsdl"; + + public static Test suite() + { + return new TestSuite(HTTPEndpointExtensionsTest.class); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + WSDLFactory factory = WSDLFactory.newInstance(); + WSDLReader reader = factory.newWSDLReader(); + ErrorHandler handler = new TestErrorHandler(); + //Don't set validation on, as the testcase WSDL is not intended to be a valid WSDL 2.0 doc. + reader.getErrorReporter().setErrorHandler(handler); + + URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath); + assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".", + wsdlURL); + + Description descComp = reader.readWSDL(wsdlURL.toString()); + assertNotNull("The reader did not return a WSDL description.", descComp); + + Service service = descComp.getServices()[0]; + assertNotNull("The Description should contain 1 Service component.", + service); + + fEndpoints = service.getEndpoints(); + assertEquals("The Service contained unexpected number of Endpoint components.", 3, fEndpoints.length); + } + + /** + * Testcases for the {http authentication scheme} property returned by the + * getHttpAuthenticationScheme method. + *

      + * Test that the method returns "basic" if the whttp:authenticationScheme + * attribute parsed from the WSDL contains "basic". + *

      + * Test that the method returns "digest" if the whttp:authenticationScheme + * attribute parsed from the WSDL contains "digest". + *

      + * Test that it returns null by default when the attribute is omitted + * from the WSDL. + */ + public void testGetHttpAuthenticationScheme() { + + //test "basic" parsed from WSDL + Endpoint endpoint = fEndpoints[0]; + HTTPEndpointExtensions httpEndpointExts = + (HTTPEndpointExtensions) endpoint + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + HTTPAuthenticationScheme actual = httpEndpointExts.getHttpAuthenticationScheme(); + assertEquals("Unexpected value for http authentication scheme.", + HTTPAuthenticationScheme.BASIC, + actual); + + //test "digest" parsed from WSDL + Endpoint endpoint2 = fEndpoints[1]; + HTTPEndpointExtensions httpEndpointExts2 = + (HTTPEndpointExtensions) endpoint2 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + HTTPAuthenticationScheme actual2 = httpEndpointExts2.getHttpAuthenticationScheme(); + assertEquals("Unexpected value for http authentication scheme.", + HTTPAuthenticationScheme.DIGEST, + actual2); + + //test default to null + Endpoint endpoint3 = fEndpoints[2]; + HTTPEndpointExtensions httpEndpointExts3 = + (HTTPEndpointExtensions) endpoint3 + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + HTTPAuthenticationScheme actual3 = httpEndpointExts3.getHttpAuthenticationScheme(); + assertNull("Http authentication scheme did not default to null.", + actual3); + } + + /** + * Testcases for the {http authentication realm} property returned by the + * getHttpAuthenticationRealm method. + *

      + * Test that the method returns "abc" if the whttp:authenticationRealm + * attribute parsed from the WSDL contains "abc". + */ + public void testGetHttpAuthenticationRealm() { + + //test "abc" parsed from WSDL + Endpoint endpoint = fEndpoints[0]; + HTTPEndpointExtensions httpEndpointExts = + (HTTPEndpointExtensions) endpoint + .getComponentExtensionContext( + HTTPConstants.NS_URI_HTTP); + + String actual = httpEndpointExts.getHttpAuthenticationRealm(); + assertEquals("Unexpected value for http authentication realm.", + "abc", + actual); + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org For additional commands, e-mail: woden-dev-help@ws.apache.org