From 4e13586bc791d71c41760cf4d0a5cc908973de3e Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:09:18 +0000 Subject: Moving 2.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835134 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/binding/ws/xml/ReadTestCase.java | 112 +++++++++++++++++ .../tuscany/sca/binding/ws/xml/WriteTestCase.java | 79 ++++++++++++ .../ws/xml/Calculator-bad-wsdlElement.composite | 59 +++++++++ .../sca/binding/ws/xml/Calculator.composite | 63 ++++++++++ .../binding/ws/xml/CalculatorImpl.componentType | 45 +++++++ .../binding/ws/xml/PoliciedCalculator.composite | 60 +++++++++ .../apache/tuscany/sca/binding/ws/xml/example.wsdl | 26 ++++ .../sca/binding/ws/xml/invalid-stockquote.wsdl | 58 +++++++++ .../org/apache/tuscany/sca/binding/ws/xml/ipo.xsd | 136 +++++++++++++++++++++ .../tuscany/sca/binding/ws/xml/stockquote.wsdl | 58 +++++++++ .../apache/tuscany/sca/binding/ws/xml/test1.wsdl | 45 +++++++ .../apache/tuscany/sca/binding/ws/xml/test1.xsd | 33 +++++ .../apache/tuscany/sca/binding/ws/xml/test2.wsdl | 63 ++++++++++ .../sca/binding/ws/xml/unwrapped-stockquote.wsdl | 76 ++++++++++++ 14 files changed, 913 insertions(+) create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl create mode 100644 sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl (limited to 'sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test') diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java new file mode 100644 index 0000000000..72d0236e46 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java @@ -0,0 +1,112 @@ +/* + * 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.tuscany.sca.binding.ws.xml; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.fail; + +import java.io.InputStream; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test reading WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +public class ReadTestCase { + + private static XMLInputFactory inputFactory; + private static StAXArtifactProcessor staxProcessor; + private static CompositeBuilder compositeBuilder; + + @BeforeClass + public static void setUp() throws Exception { + DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + inputFactory = XMLInputFactory.newInstance(); + StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null); + compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder"); + } + + @Test + public void testReadComponentType() throws Exception { + InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + ComponentType componentType = (ComponentType)staxProcessor.read(reader); + assertNotNull(componentType); + } + + @Test + public void testReadComposite() throws Exception { + InputStream is = getClass().getResourceAsStream("Calculator.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + Composite composite = (Composite)staxProcessor.read(reader); + assertNotNull(composite); + + compositeBuilder.build(composite, null, null); + } + + @Test + public void testReadPolicies() throws Exception { + InputStream is = getClass().getResourceAsStream("PoliciedCalculator.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + Composite composite = (Composite)staxProcessor.read(reader); + assertNotNull(composite); + + compositeBuilder.build(composite, null, null); + + } + + /** + * This test makes sure that an exception is thrown when a bad wsdlElement is present along with EndpointReference. + * + * Ref: Web Service Binding Specification v1.0 - Sec 2.1 - Lines 61 to 65. + * When an EndpointReference is present along with the wsdlElement attribute on the parent element, the wsdlElement attribute value MUST + * be of the 'Binding' form. + */ + @Test + public void testReadBadWsdlElement() throws Exception { + InputStream is = getClass().getResourceAsStream("Calculator-bad-wsdlElement.composite"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + try { + staxProcessor.read(reader); + fail("ContributionReadException expected."); + } catch(ContributionReadException e) { + // Expected + assertNotSame(-1, e.getMessage().indexOf("must use wsdl.binding when using wsa:EndpointReference")); + } + } +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java new file mode 100644 index 0000000000..2b3f314fb1 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java @@ -0,0 +1,79 @@ +/* + * 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.tuscany.sca.binding.ws.xml; + +import static org.junit.Assert.assertNotNull; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; + +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test reading/write WSDL interfaces. + * + * @version $Rev$ $Date$ + */ +public class WriteTestCase { + + private static XMLInputFactory inputFactory; + private static XMLOutputFactory outputFactory; + private static StAXArtifactProcessor staxProcessor; + + @BeforeClass + public static void setUp() throws Exception { + DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + inputFactory = XMLInputFactory.newInstance(); + outputFactory = XMLOutputFactory.newInstance(); + StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null); + } + + @Test + public void testReadWriteComponentType() throws Exception { + InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType"); + ComponentType componentType = (ComponentType)staxProcessor.read(inputFactory.createXMLStreamReader(is)); + assertNotNull(componentType); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos)); + } + + @Test + public void testReadWriteComposite() throws Exception { + InputStream is = getClass().getResourceAsStream("Calculator.composite"); + Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is)); + assertNotNull(composite); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + System.out.println(bos.toString()); + } + +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite new file mode 100644 index 0000000000..5019278210 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite @@ -0,0 +1,59 @@ + + + + + + + + + http://localhost:8085/Calculator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite new file mode 100644 index 0000000000..1952d83755 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite @@ -0,0 +1,63 @@ + + + + + + + + + + + + + http://localhost:8085/services/HelloWorldWebService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType new file mode 100644 index 0000000000..6d36198124 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + myURI + + + + + + \ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite new file mode 100644 index 0000000000..b1e3b11e99 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl new file mode 100644 index 0000000000..5e8e5dad0d --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl new file mode 100644 index 0000000000..ad81fc7867 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd new file mode 100644 index 0000000000..241ec15d36 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd @@ -0,0 +1,136 @@ + + + + + + International Purchase order schema for Example.com + Copyright 2000 Example.com. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl new file mode 100644 index 0000000000..39cd5547d9 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl new file mode 100644 index 0000000000..8e26f7b4b5 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd new file mode 100644 index 0000000000..c2210f4a94 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl new file mode 100644 index 0000000000..529b395fd5 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl new file mode 100644 index 0000000000..666a7e4069 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M2/modules/binding-ws-xml/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3