Added: incubator/woden/java/test/org/apache/woden/tests/OMW3CTestSuiteTest.java URL: http://svn.apache.org/viewvc/incubator/woden/java/test/org/apache/woden/tests/OMW3CTestSuiteTest.java?rev=420800&view=auto ============================================================================== --- incubator/woden/java/test/org/apache/woden/tests/OMW3CTestSuiteTest.java (added) +++ incubator/woden/java/test/org/apache/woden/tests/OMW3CTestSuiteTest.java Tue Jul 11 04:15:45 2006 @@ -0,0 +1,698 @@ +/** + * Copyright 2005, 2006 Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.woden.tests; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.woden.WSDLFactory; +import org.apache.woden.WSDLReader; +import org.apache.woden.wsdl20.xml.DescriptionElement; + +import java.net.URI; + +public class OMW3CTestSuiteTest extends TestCase{ + + private WSDLFactory omWSDLFactory = null; + private WSDLReader omWSDLReader = null; + private TestErrorHandler handler; + private W3CFileRepository wfr = null; + + + public static Test suite(){ + return new TestSuite(OMW3CTestSuiteTest.class); + } + + protected void setUp() throws Exception{ + + wfr = new W3CFileRepository("http://dev.w3.org/cvsweb/~checkout~/", + System.getProperty("user.dir") + "/downloads/w3c-cache/"); + handler = new TestErrorHandler(); + + try{ + omWSDLFactory = WSDLFactory.newInstance("org.apache.woden.internal.OMWSDLFactory"); + omWSDLReader = omWSDLFactory.newWSDLReader(); + omWSDLReader.setFeature(WSDLReader.FEATURE_VALIDATION, true); + } + catch (Exception e){ + } + } + + protected void tearDown() throws Exception{ + handler = null; + omWSDLFactory = null; + omWSDLReader = null; + } + + /** + * BAD TEST CASES + * All of the following test cases should report errors. + * TODO: Add in error checks as the WSDL 2.0 validator is developed. + */ + + /** + * Test for the test-suite/documents/bad/Chameleon-1B W3C test. + */ + public void testChameleon1BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Chameleon-1B/getBalance.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Chameleon-2B W3C test. + */ + public void testChameleon2BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Chameleon-2B/getBalance.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Import-1B W3C test. + */ + public void testImport1BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Import-1B/XSDImport.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Import-2B W3C test. + */ + public void testImport2BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Import-2B/XSDImportInWSDL.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Import-3B W3C test. + */ + public void testImport3BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Import-3B/XSDImport2.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Interface-1B W3C test. + */ + public void testInterface1BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Interface-1B/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Interface-2B W3C test. + */ + public void testInterface2BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Interface-2B/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Interface-3B W3C test. + */ + public void testInterface3BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Interface-3B/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Service-1B W3C test. + */ + public void testService1BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-1B/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Service-2B W3C test. + */ + public void testService2BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-2B/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Service-12B W3C test. + */ + public void testService12BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-12B/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Service-13B W3C test. + */ + public void testService13BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-13B/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Service-14B W3C test. + */ + public void testService14BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-14B/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/Service-15B W3C test. + */ + public void testService15BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/Service-15B/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/bad/TicketAgent-1B W3C test. + */ + public void testTicketAgent1BFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/bad/TicketAgent-1B/TicketAgent-bad.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + // TODO: determine the assertions that should fail for this test. + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * GOOD TEST CASES + * All of the following test cases shouldn't report errors. + * TODO: Add in error checks as the WSDL 2.0 validator is developed. + */ + + /** + * Test for the test-suite/documents/good/Chameleon-1G W3C test. + */ + public void testChameleon1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-1G/getBalance.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Chameleon-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Chameleon-2G W3C test. + */ + public void testChameleon2GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-2G/getBalance.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Chameleon-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Chameleon-3G W3C test. + */ + public void testChameleon3GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-3G/getBalance.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Chameleon-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Chameleon-4G W3C test. + */ + public void testChameleon4GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Chameleon-4G/getBalance.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Chameleon-4G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/CreditCardFaults-1G W3C test. + */ + public void testCreditCardFaults1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/CreditCardFaults-1G/use-credit-card-faults.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good CreditCardFaults-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/GreatH-1G W3C test. + */ + public void testGreatH1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/GreatH-1G/primer-hotelReservationService.wsdl"), handler); + assertTrue("number of binding elements isn't 1", desc.getBindingElements().length == 1); + assertTrue("interfacename is null", desc.toComponent().getBindings()[0].getInterface()!=null); + + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good GreatH-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Import-1G W3C test. + */ + public void testImport1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Import-1G/XSDImport.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Import-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Import-2G W3C test. + */ + public void testImport2GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Import-2G/XSDImport2.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Import-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/ImportedWSDL-1G W3C test. + */ + public void testImportedWSDL1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/ImportedWSDL-1G/updateDetails.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good ImportedWSDL-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Interface-1G W3C test. + */ + public void testInterface1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-1G/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Interface-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Interface-2G W3C test. + */ + public void testInterface2GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-2G/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Interface-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Interface-3G W3C test. + */ + public void testInterface3GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-3G/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Interface-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Interface-4G W3C test. + */ + public void testInterface4GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-4G/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Interface-4G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Interface-5G W3C test. + */ + public void testInterface5GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-5G/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Interface-5G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Interface-6G W3C test. + */ + public void testInterface6GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-6G/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Interface-6G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Interface-7G W3C test. + */ + public void testInterface7GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Interface-7G/Interface.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Interface-7G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/MultipleInlineSchemas-1G W3C test. + */ + public void testMultipleInlineSchemas1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/MultipleInlineSchemas-1G/retrieveItems.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good MultipleInlineSchemas-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/SchemaId-1G W3C test. + */ + public void testSchemaId1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/SchemaId-1G/schemaIds.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good SchemaId-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/SchemaLocationFragment-1G W3C test. + */ + public void testSchemaLocationFragment1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/SchemaLocationFragment-1G/Items.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good SchemaLocationFragment-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Service-1G W3C test. + */ + public void testService1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Service-1G/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Service-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Service-2G W3C test. + */ + public void testService2GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Service-2G/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Service-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/Service-3G W3C test. + */ + public void testService3GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/Service-3G/Service.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good Service-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/ServiceReference-1G W3C test. + */ + public void testServiceReference1G1FromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/ServiceReference-1G/reservationList.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good ServiceReference-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/ServiceReference-1G W3C test. + */ + public void testServiceReference1G2FromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/ServiceReference-1G/reservationDetails.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good ServiceReference-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/TicketAgent-1G W3C test. + */ + public void testTicketAgent1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/TicketAgent-1G/TicketAgent.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good TicketAgent-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/WeathSvc-1G W3C test. + */ + + //////////////////////////////////////////////////////////////////////////////// + //FAILED : due to XmlSchemaException:"No namespace found in given ref" // + // This has been fixed in XMLSchema, but would have to wait for a release to // + // get the jars with the fix // + //////////////////////////////////////////////////////////////////////////////// + public void testWeathSvc1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/WeathSvc-1G/WeathSvc.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + //TODO FIXME + //assertFalse("The good WeathSvc-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/XsImport-1G W3C test. + */ + public void testXsImport1GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/XsImport-1G/reservation.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good XsImport-1G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/XsImport-2G W3C test. + */ + public void testXsImport2GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/XsImport-2G/reservationDetails.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good XsImport-2G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } + + /** + * Test for the test-suite/documents/good/XsImport-3G W3C test. + */ + public void testXsImport3GFromOM(){ + try{ + DescriptionElement desc = omWSDLReader.readWSDL(wfr.getFilePath("http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/documents/good/XsImport-3G/reservationDetails.wsdl"), handler); + assertNotNull("DescriptionElement is null.", desc); + assertFalse("The good XsImport-3G test returned errors. " + handler.getSummaryOfMessageKeys(), handler.messageHasBeenReported()); + } + catch(Exception e){ + fail("Unable to read WSDL document because of " + e); + } + } +}
Modified: incubator/woden/java/test/org/apache/woden/tests/W3CFileRepository.java URL: http://svn.apache.org/viewvc/incubator/woden/java/test/org/apache/woden/tests/W3CFileRepository.java?rev=420800&r1=420799&r2=420800&view=diff ============================================================================== --- incubator/woden/java/test/org/apache/woden/tests/W3CFileRepository.java (original) +++ incubator/woden/java/test/org/apache/woden/tests/W3CFileRepository.java Tue Jul 11 04:15:45 2006 @@ -16,6 +16,7 @@ package org.apache.woden.tests; import java.io.File; +import java.net.MalformedURLException; public class W3CFileRepository { @@ -42,7 +43,8 @@ * * @param path * path of the file in the W3C CVS repository - * @return path to use to get the local file + * @return if the file exists locally then a file URL, otherwise, the path + * parameter value. */ public String getFilePath(String path) { // If we don't have a cache return the server path @@ -59,7 +61,12 @@ String localPath = localBase + path.substring(w3cBase.length()); File localFile = new File(localPath); if (localFile.exists()) { - return localPath; + try { + return localFile.toURL().toString(); + } catch (MalformedURLException mue) { + System.err.println("Got MalformedURLException trying to create a URL from " + localPath); + return path; + } } else { return path; } Added: incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMEndpointElementTest.java URL: http://svn.apache.org/viewvc/incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMEndpointElementTest.java?rev=420800&view=auto ============================================================================== --- incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMEndpointElementTest.java (added) +++ incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMEndpointElementTest.java Tue Jul 11 04:15:45 2006 @@ -0,0 +1,183 @@ +/** + * Copyright 2006 Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.woden.wsdl20.xml; + +import java.net.URI; +import java.net.URL; + +import javax.xml.namespace.QName; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.woden.ErrorHandler; +import org.apache.woden.WSDLFactory; +import org.apache.woden.WSDLReader; +import org.apache.woden.internal.wsdl20.EndpointImpl; +import org.apache.woden.tests.TestErrorHandler; +import org.apache.woden.types.NCName; + +/** + * Functional verification test of org.apache.woden.wsdl20.xml.EndpointElement. + * Checks that the expected API behaviour is supported by the implementation. + */ +public class OMEndpointElementTest extends TestCase{ + + private WSDLFactory fFactory = null; + private WSDLReader fReader = null; + private ErrorHandler fHandler = null; + private DescriptionElement fParsedDesc = null; + private EndpointElement[] fParsedEndpoints = null; + + private String fTargetNS = "http://ws.apache.woden/endpoint"; + + public static Test suite(){ + return new TestSuite(OMEndpointElementTest.class); + } + + protected void setUp() throws Exception { + + fFactory = WSDLFactory.newInstance("org.apache.woden.internal.OMWSDLFactory"); + fReader = fFactory.newWSDLReader(); + fHandler = new TestErrorHandler(); + fReader.getErrorReporter().setErrorHandler(fHandler); + + URL wsdlURL = getClass().getClassLoader().getResource( + "org/apache/woden/wsdl20/xml/resources/EndpointElementTest.wsdl"); + assertNotNull("Failed to find the WSDL document on the classpath.", wsdlURL); + + fParsedDesc = fReader.readWSDL(wsdlURL.toString()); + assertNotNull("The reader did not return a description.", fParsedDesc); + + ServiceElement service = fParsedDesc.getServiceElements()[0]; + assertNotNull("The description does not contain a service.", service); + + fParsedEndpoints = service.getEndpointElements(); + assertTrue("The service does not contain 3 endpoints as expected.", + fParsedEndpoints.length == 3); + } + + protected void tearDown() throws Exception{ + fFactory = null; + fReader = null; + fHandler = null; + fParsedDesc = null; + fParsedEndpoints = null; + } + + /** + * Test that the getName method returns the expected NCName parsed from a WSDL document. + */ + public void testGetNameParsedFromOM(){ + NCName ncName = fParsedEndpoints[0].getName(); + assertNotNull("EndpointElement.getName() returned null, but an NCName was expected.", + ncName); + + assertTrue("NCName returned by EndpointElement.getName() was not the one expected.", + "endpoint1".equals(ncName.toString()) ); + } + + /** + * Test that the NCName specified on the setName method is returned by getName. + */ + public void testSetAndGetNameFromOM(){ + EndpointElement endpoint = new EndpointImpl(); + NCName ncName = new NCName("dummy"); + + endpoint.setName(ncName); + assertTrue("NCName returned by EndpointElement.getName() was not the one set by setName().", + ncName.equals(endpoint.getName())); + } + + /** + * Test that the getBindingName method returns the QName of the binding + * associated with this endpoint, as specified by the "binding" attribute + * of the <endpoint> element in a parsed WSDL document. + */ + public void testGetBindingNameParsedFromOM(){ + QName qname = fParsedEndpoints[0].getBindingName(); + assertNotNull("EndpointElement.getBindingName() returned null, but a QName was expected.", + qname); + + QName expectedQN = new QName(fTargetNS, "binding1"); + assertTrue("QName returned by EndpointElement.getBindingName() was not the one expected.", + expectedQN.equals(qname)); + } + + /** + * Test that the QName specified on the setBindingName method is returned by + * the getBindingName method. + */ + public void testSetAndGetBindingNameFromOM(){ + EndpointElement endpoint = new EndpointImpl(); + QName qname = new QName("urn:woden","dummy"); + endpoint.setBindingName(qname); + QName returnedQN = endpoint.getBindingName(); + assertTrue("QName returned by EndpointElement.getBindingName() was not the one set by setBindingName().", + returnedQN.equals(qname)); + } + + /** + * Test that the getBindingElement method returns a BindingElement + * defined within the description, that is referred to by QName in the + * "binding" attribute of the <endpoint> element of a parsed WSDL + * document. This tests that the QName is correctly dereferenced to an object. + */ + public void testGetBindingElementParsedFromOM(){ + BindingElement bindingDefined = fParsedDesc.getBindingElements()[0]; + BindingElement bindingReferred = fParsedEndpoints[0].getBindingElement(); + assertNotNull("EndpointElement.getBindingElement() returned null, but a BindingElement was expected.", + bindingReferred); + + assertTrue("The BindingElement returned by EndpointElement.getBindingElement() was not the one expected.", + bindingReferred == bindingDefined); + } + + /** + * Test that the getAddress method returns the expected URI parsed from a WSDL document. + */ + public void testGetAddressParsedFromOM(){ + URI uri = fParsedEndpoints[0].getAddress(); + assertNotNull("EndpointElement.getAddress() returned null, but a URI was expected.", + uri); + + assertTrue("URI returned by EndpointElement.getAddress() was not the one expected.", + "urn:abc".equals(uri.toString()) ); + } + + /** + * Test the optionality of the 'address' attribute by invoking the getAddress + * method on a parsed <endpoint> element that does not have an + * 'address' specified and check that it returns null. + */ + public void testGetAddressParsedOptionalFromOM(){ + URI uri = fParsedEndpoints[1].getAddress(); + assertNull("EndpointElement.getAddress() did not return null, as expected.", + uri); + } + + /** + * Test that the URI specified on the setAddress method is returned by getAddress. + */ + public void testSetAndGetAddressFromOM() throws Exception{ + EndpointElement endpoint = new EndpointImpl(); + URI uri = new URI("urn:dummy"); + endpoint.setAddress(uri); + assertTrue("URI returned by EndpointElement.getAddress() was not the one set by setAddress().", + "urn:dummy".equals(endpoint.getAddress().toString())); + } +} Added: incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMServiceElementTest.java URL: http://svn.apache.org/viewvc/incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMServiceElementTest.java?rev=420800&view=auto ============================================================================== --- incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMServiceElementTest.java (added) +++ incubator/woden/java/test/org/apache/woden/wsdl20/xml/OMServiceElementTest.java Tue Jul 11 04:15:45 2006 @@ -0,0 +1,174 @@ +/** + * Copyright 2006 Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.woden.wsdl20.xml; + +import java.net.URI; +import java.net.URL; + +import javax.xml.namespace.QName; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.woden.ErrorHandler; +import org.apache.woden.WSDLFactory; +import org.apache.woden.WSDLReader; +import org.apache.woden.internal.wsdl20.DescriptionImpl; +import org.apache.woden.internal.wsdl20.EndpointImpl; +import org.apache.woden.internal.wsdl20.ServiceImpl; +import org.apache.woden.tests.TestErrorHandler; +import org.apache.woden.types.NCName; + +/** + * Functional verification test of org.apache.woden.wsdl20.xml.ServiceElement. + * Checks that the expected API behaviour is supported by the implementation. + */ +public class OMServiceElementTest extends TestCase{ + + private WSDLFactory fFactory = null; + private WSDLReader fReader = null; + private ErrorHandler fHandler = null; + private DescriptionElement fParsedDesc = null; + private ServiceElement fParsedService = null; + + private String fTargetNS = "http://ws.apache.woden/service"; + private QName fQName = new QName("urn:woden","dummy"); + + public static Test suite(){ + return new TestSuite(OMServiceElementTest.class); + } + + protected void setUp() throws Exception{ + + fFactory = WSDLFactory.newInstance("org.apache.woden.internal.OMWSDLFactory"); + fReader = fFactory.newWSDLReader(); + fHandler = new TestErrorHandler(); + fReader.getErrorReporter().setErrorHandler(fHandler); + + URL wsdlURL = getClass().getClassLoader().getResource( + "org/apache/woden/wsdl20/xml/resources/ServiceElementTest.wsdl"); + assertNotNull("Failed to find the WSDL document on the classpath.", wsdlURL); + + fParsedDesc = fReader.readWSDL(wsdlURL.toString()); + assertNotNull("The reader did not return a description.", fParsedDesc); + + fParsedService = fParsedDesc.getServiceElements()[0]; + assertNotNull("The description does not contain a service.", fParsedService); + } + + protected void tearDown() throws Exception{ + fFactory = null; + fReader = null; + fHandler = null; + fParsedDesc = null; + fParsedService = null; + } + + /** + * Test that the getName method returns the expected QName parsed from a WSDL document. + */ + public void testGetNameParsedFromOM(){ + QName qname = fParsedService.getName(); + assertNotNull("ServiceElement.getName() returned null, but a QName was expected.", + qname); + + QName expectedQN = new QName(fTargetNS, "service1"); + assertTrue("QName returned by ServiceElement.getName() was not the one expected.", + expectedQN.equals(qname)); + } + + /** + * Test that the QName specified on the setName method is returned by getName. + */ + public void testSetAndGetNameFromOM() throws Exception{ + DescriptionElement descElem = new DescriptionImpl(); + descElem.setTargetNamespace(new URI("urn:woden")); + ServiceElement service = new ServiceImpl(); + descElem.addServiceElement(service); + service.setName(new NCName(fQName.getLocalPart())); + assertTrue("QName returned by ServiceElement.getName() was not the one set by setName().", + fQName.equals(service.getName())); + } + + /** + * Test that the getInterfaceName method returns the QName of the interface + * associated with this service, as specified by the "interface" attribute + * of the <service> element in a parsed WSDL document. + */ + public void testGetInterfaceNameParsedFromOM(){ + QName qname = fParsedService.getInterfaceName(); + assertNotNull("ServiceElement.getInterfaceName() returned null, but a QName was expected.", + qname); + + QName expectedQN = new QName(fTargetNS, "interface1"); + assertTrue("QName returned by ServiceElement.getInterfaceName() was not the one expected.", + expectedQN.equals(fParsedService.getInterfaceName())); + } + + /** + * Test that the QName specified on the setInterfaceName method is returned by + * the getInterfaceName method. + */ + public void testSetAndGetInterfaceNameFromOM(){ + ServiceElement service = new ServiceImpl(); + service.setInterfaceName(fQName); + QName returnedQN = service.getInterfaceName(); + assertTrue("QName returned by ServiceElement.getInterfaceName() was not the one set by setInterfaceName().", + returnedQN.equals(fQName)); + } + + /** + * Test that the getInterfaceElement method returns an InterfaceElement + * defined within the description, that is referred to by QName in the + * "interface" attribute of the <service> element of a parsed WSDL + * document. This tests that the QName is correctly dereferenced to an object. + */ + public void testGetInterfaceElementParsedFromOM(){ + InterfaceElement interfaceDefined = fParsedDesc.getInterfaceElements()[0]; + InterfaceElement interfaceReferred = fParsedService.getInterfaceElement(); + assertNotNull("ServiceElement.getInterfaceElement() returned null, but an InterfaceElement was expected.", + interfaceReferred); + + assertTrue("The InterfaceElement returned by ServiceElement.getInterfaceElement() was not the one expected.", + interfaceReferred == interfaceDefined); + } + + /** + * Test that the getEndpointElements method returns an array of the EndpointElements + * defined as <endpoint> child elements of the <service> element in + * a parsed WSDL document. + */ + public void testGetEndpointElementsParsedFromOM(){ + EndpointElement[] endpoints = fParsedService.getEndpointElements(); + assertTrue("ServiceElement.getEndpointElements() did not return 3 endpoints, as expected.", + endpoints.length == 3); + } + + /** + * Test that the EndpointElement added by the addEndpointElement method is + * present in the array returned by getEndpointElements. + */ + public void testAddAndGetEndpointElementFromOM(){ + EndpointElement endpoint = new EndpointImpl(); + endpoint.setName(new NCName("endpoint99")); + ServiceElement service = new ServiceImpl(); + service.addEndpointElement(endpoint); + assertTrue("The EndpointElement added by the ServiceElement.addEndpointElement method " + + "was not returned by ServiceElement.getEndpointElements()", + endpoint == service.getEndpointElements()[0]); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
