diff options
Diffstat (limited to 'branches/sca-java-integration/testing/sca/itest/databindings/sdo/src')
8 files changed, 435 insertions, 0 deletions
diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterService.java b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterService.java new file mode 100644 index 0000000000..61def7f9f6 --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterService.java @@ -0,0 +1,34 @@ +/* + * 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.itest.sdodatabinding; + +import org.apache.tuscany.sca.itest.databinding.types.PersonType; +import org.osoa.sca.annotations.Remotable; + +/** + * + */ +@Remotable +public interface GreeterService { + + // @DataType(name = "commonj.sdo.DataObject") + PersonType greet(PersonType who); + +} diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClient.java b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClient.java new file mode 100644 index 0000000000..87de5f5d3b --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClient.java @@ -0,0 +1,34 @@ +/* + * 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.itest.sdodatabinding; + +import org.apache.tuscany.sca.itest.databinding.types.PersonType; +import org.osoa.sca.annotations.AllowsPassByReference; + +/** + * + */ +@AllowsPassByReference +public interface GreeterServiceClient { + + // @DataType(name = "commonj.sdo.DataObject") + PersonType greet(PersonType who); + +} diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClientImpl.java b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClientImpl.java new file mode 100644 index 0000000000..3dcf34bb59 --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClientImpl.java @@ -0,0 +1,47 @@ +/* + * 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.itest.sdodatabinding; + +import org.apache.tuscany.sca.itest.databinding.types.PersonType; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +/** + * + */ +@Service(GreeterServiceClient.class) +public class GreeterServiceClientImpl implements GreeterServiceClient { + private GreeterService service; + + @Reference + public void setGreeterService(GreeterService service) { + this.service = service; + } + + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.sca.itest.sdodatabinding.GreeterServiceClient#greet(org.apache.tuscany.sca.itest.sdodatabinding.generated.PersonType) + */ + public PersonType greet(PersonType who) { + return service.greet(who); + } + +} diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceImpl.java b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceImpl.java new file mode 100644 index 0000000000..6bbc957a0b --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.itest.sdodatabinding; + +import org.apache.tuscany.sca.itest.databinding.types.PersonType; +import org.apache.tuscany.spi.annotation.Autowire; +import org.osoa.sca.annotations.Service; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.HelperContext; + +/** + * + */ +@Service(GreeterService.class) +public class GreeterServiceImpl implements GreeterService { + /** + * It will be injected with a HelperContext for the composite + */ + @Autowire + protected HelperContext helperContext; + /* + * (non-Javadoc) + * + * @see org.apache.tuscany.sca.itest.sdodatabinding.GreeterService#greet(org.apache.tuscany.sca.itest.sdodatabinding.generated.PersonType) + */ + public PersonType greet(PersonType who) { + System.out.println(helperContext.getXMLHelper().save((DataObject) who, "http://person/", "person")); + PersonType copy = (PersonType) helperContext.getCopyHelper().copy((DataObject) who); + copy.setGreeting("Hello"); + System.out.println(who.toString()); + return copy; + } + +} diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/greetersdo.composite b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/greetersdo.composite new file mode 100644 index 0000000000..e419e1487a --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/greetersdo.composite @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"
+ xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0"
+ name="SDOGreeterService">
+
+ <!-- SDO factory classes -->
+ <dbsdo:import.sdo factory="org.apache.tuscany.sca.itest.databinding.services.ServicesFactory"/>
+ <dbsdo:import.sdo factory="org.apache.tuscany.sca.itest.databinding.types.TypesFactory"/>
+
+ <!-- Services Exposed via different bindings -->
+ <service name="SDOGreeterServiceDefaultBinding">
+ <interface.java class="org.apache.tuscany.sca.itest.sdodatabinding.GreeterService" />
+ <reference>SDOGreeterServiceComponent</reference>
+ </service>
+
+ <service name="SDOGreeterServiceWebServiceBinding">
+ <interface.wsdl interface="http://apache.org/tuscany/sca/itest/databinding/services#wsdl.interface(GreeterPortType)"
+ wsdli:wsdlLocation="http://apache.org/tuscany/sca/itest/databinding/services wsdl/Greeter.wsdl" />
+ <binding.ws
+ endpoint="http://apache.org/tuscany/sca/itest/databinding/services#wsdl.endpoint(GreeterService/GreeterPort)"
+ location="wsdl/Greeter.wsdl" />
+ <reference>SDOGreeterServiceComponent</reference>
+ </service>
+
+ <!-- Components used to implement the services -->
+ <component name="SDOGreeterServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.sdodatabinding.GreeterServiceImpl" />
+ </component>
+
+
+ <!-- Clients to test the services -->
+ <component name="DefaultSDOGreeterServiceClient">
+ <implementation.java class="org.apache.tuscany.sca.itest.sdodatabinding.GreeterServiceClientImpl" />
+ <reference name="greeterService">SDOGreeterServiceComponent</reference>
+ </component>
+
+
+ <component name="WSSDOGreeterServiceClient">
+ <implementation.java class="org.apache.tuscany.sca.itest.sdodatabinding.GreeterServiceClientImpl" />
+ <reference name="greeterService">SDOGreeterServiceWSRef</reference>
+ </component>
+
+ <reference name="SDOGreeterServiceWSRef">
+ <interface.wsdl interface="http://apache.org/tuscany/sca/itest/databinding/services#wsdl.interface(GreeterPortType)"
+ wsdli:wsdlLocation="http://apache.org/tuscany/sca/itest/databinding/services wsdl/Greeter.wsdl" />
+ <binding.ws
+ endpoint="http://apache.org/tuscany/sca/itest/databinding/services#wsdl.endpoint(GreeterService/GreeterPort)"
+ location="wsdl/Greeter.wsdl" />
+ </reference>
+
+</composite>
diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/wsdl/Greeter.wsdl b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/wsdl/Greeter.wsdl new file mode 100644 index 0000000000..6960178f2a --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/wsdl/Greeter.wsdl @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<wsdl:definitions targetNamespace="http://apache.org/tuscany/sca/itest/databinding/services"
+ xmlns:tns="http://apache.org/tuscany/sca/itest/databinding/services" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Greeter">
+
+ <wsdl:types>
+ <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:p="http://apache.org/tuscany/sca/itest/databinding/types"
+ targetNamespace="http://apache.org/tuscany/sca/itest/databinding/services" elementFormDefault="qualified">
+
+ <xsd:import namespace="http://apache.org/tuscany/sca/itest/databinding/types" schemaLocation="../xsd/Person.xsd" />
+ <!--
+ <xsd:element name="Person" type="p:PersonType" />
+ -->
+
+ <element name="greet">
+ <complexType>
+ <sequence>
+ <element name="parm" type="p:PersonType" />
+ </sequence>
+ </complexType>
+ </element>
+
+
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="request">
+ <wsdl:part element="tns:greet" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="response">
+ <wsdl:part element="tns:greet" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="GreeterPortType">
+ <wsdl:operation name="greet">
+ <wsdl:input message="tns:request" name="requestMsg" />
+ <wsdl:output message="tns:response" name="responseMsg" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+
+ <wsdl:binding name="GreeterBinding" type="tns:GreeterPortType">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="greet">
+ <wsdlsoap:operation soapAction="" />
+ <wsdl:input name="requestMsg">
+ <wsdlsoap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output name="responseMsg">
+ <wsdlsoap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="GreeterService">
+ <wsdl:port name="GreeterPort" binding="tns:GreeterBinding">
+ <wsdlsoap:address location="http://localhost:8080/services/SDOGreeterServiceWebServiceBinding" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/xsd/Person.xsd b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/xsd/Person.xsd new file mode 100644 index 0000000000..5f5021b15e --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/xsd/Person.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://apache.org/tuscany/sca/itest/databinding/types"> + + <xsd:complexType name="PersonType"> + <xsd:sequence> + <xsd:element name="firstName" type="xsd:string" /> + <xsd:element name="lastName" type="xsd:string" /> + <xsd:element name="greeting" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> +</xsd:schema> diff --git a/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/test/java/org/apache/tuscany/sca/itest/SdoDatabindingTestCase.java b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/test/java/org/apache/tuscany/sca/itest/SdoDatabindingTestCase.java new file mode 100644 index 0000000000..c2df998f4b --- /dev/null +++ b/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/test/java/org/apache/tuscany/sca/itest/SdoDatabindingTestCase.java @@ -0,0 +1,88 @@ +/* + * 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.itest; + +import junit.framework.TestCase; + +import org.apache.tuscany.api.SCARuntime; +import org.apache.tuscany.sca.itest.databinding.types.PersonType; +import org.apache.tuscany.sca.itest.databinding.types.TypesFactory; +import org.apache.tuscany.sca.itest.sdodatabinding.GreeterServiceClient; +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * + */ +public class SdoDatabindingTestCase extends TestCase { + + GreeterServiceClient greeterClient; + private static boolean initalised = false; + + protected void setUp() throws Exception { + if (!initalised) { + SCARuntime.start("greetersdo.composite"); + initalised = true; + } + } + + protected void tearDown() { + + } + + private void setUpClient(String ext) throws Exception { + CompositeContext ctx = CurrentCompositeContext.getContext(); + greeterClient = ctx.locateService(GreeterServiceClient.class, ext + "SDOGreeterServiceClient"); + } + + /** + * Invokes the SDO Greet service using web service bindings with SDO payload + * + * @throws Exception + */ + public void testWSGreet() throws Exception { + setUpClient("WS"); + greet(); + } + + /** + * Invokes the SDO Greet service using default bindings with SDO payload + * + * @throws Exception + */ + public void testDefaultGreet() throws Exception { + setUpClient("Default"); + greet(); + } + + public void greet() { + TypesFactory factory = TypesFactory.INSTANCE; + PersonType person = factory.createPersonType(); + person.setFirstName("George"); + person.setLastName("Doors"); + // System.out.println("Client side: " + person.getFirstName() + " " + + // person.getLastName() + " " + person.getGreeting()); + PersonType greetedPerson = greeterClient.greet(person); + // System.out.println("Client side: " + greetedPerson.getFirstName() + " + // " + greetedPerson.getLastName() + " " + greetedPerson.getGreeting()); + assertNotSame("greetedPerson.getGreeting() not set", "", greetedPerson.getGreeting()); + } + +} |