diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo')
9 files changed, 583 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/pom.xml b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/pom.xml new file mode 100644 index 0000000000..25de0f25d6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/pom.xml @@ -0,0 +1,148 @@ +<?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. +--> +<project> + <parent> + <groupId>org.apache.tuscany.testing</groupId> + <artifactId>databindings</artifactId> + <version>0.1-integration-incubating-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>iTest-sdoDatabinding</artifactId> + <version>${testing.version}</version> + <packaging>jar</packaging> + <name>Test Suite for SDO Databindings</name> + + <repositories> + <repository> + <snapshots> + <enabled>true</enabled> + </snapshots> + <id>java.net</id> + <name>java.net Maven 1.x Repository</name> + <url>https://maven-repository.dev.java.net/nonav/repository</url> + <layout>legacy</layout> + </repository> + </repositories> + + <pluginRepositories> + <pluginRepository> + <snapshots> + <enabled>true</enabled> + </snapshots> + <id>java.net</id> + <name>java.net Maven 1.x Repository</name> + <url>https://maven-repository.dev.java.net/repository</url> + <layout>legacy</layout> + </pluginRepository> + </pluginRepositories> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca.services.databinding</groupId> + <artifactId>databinding-jaxb</artifactId> + <version>0.1-integration-incubating-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca.services.databinding</groupId> + <artifactId>databinding-sdo</artifactId> + <version>${pom.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca.extensions.axis2</groupId> + <artifactId>databinding-axiom</artifactId> + <version>${pom.version}</version> + <scope>compile</scope> + </dependency> + <!-- dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.1</version> + <scope>compile</scope> + </dependency --> + <!-- dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-impl</artifactId> + <version>2.1</version> + <scope>runtime</scope> + </dependency --> + <!-- dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-rt</artifactId> + <version>2.1</version> + </dependency --> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <id>add-test-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>target/sdo-source</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.tuscany.sdo</groupId> + <artifactId>tuscany-sdo-plugin</artifactId> + <version>1.0-incubator-SNAPSHOT</version> + <executions> + <execution> + <id>generate-sdo</id> + <phase>generate-sources</phase> + <configuration> + <schemaFiles> + <configuration> + <fileName>${basedir}/src/main/resources/wsdl/Greeter.wsdl</fileName> + <javaPackage>org.apache.tuscany.sca.itest.databinding.services</javaPackage> + </configuration> + <configuration> + <fileName>${basedir}/src/main/resources/xsd/Person.xsd</fileName> + <javaPackage>org.apache.tuscany.sca.itest.databinding.types</javaPackage> + </configuration> + </schemaFiles> + <noNotification>true</noNotification> + <noContainment>true</noContainment> + <noUnsettable>true</noUnsettable> + </configuration> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterService.java b/sca-java-1.x/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/sca-java-1.x/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/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClient.java b/sca-java-1.x/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/sca-java-1.x/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/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceClientImpl.java b/sca-java-1.x/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/sca-java-1.x/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/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/java/org/apache/tuscany/sca/itest/sdodatabinding/GreeterServiceImpl.java b/sca-java-1.x/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/sca-java-1.x/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/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/greetersdo.composite b/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/greetersdo.composite new file mode 100644 index 0000000000..e419e1487a --- /dev/null +++ b/sca-java-1.x/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/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/wsdl/Greeter.wsdl b/sca-java-1.x/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/sca-java-1.x/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/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/main/resources/xsd/Person.xsd b/sca-java-1.x/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/sca-java-1.x/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/sca-java-1.x/branches/sca-java-integration/testing/sca/itest/databindings/sdo/src/test/java/org/apache/tuscany/sca/itest/SdoDatabindingTestCase.java b/sca-java-1.x/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/sca-java-1.x/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()); + } + +} |