From 0032658a4a6b4552b997fb144403196a0f5cb3ad Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 8 May 2009 12:27:46 +0000 Subject: TUSCANY-2900 - Add code to generate JMS binding and service/port to generated wsdl. Add itest to explore the different ways of configuring generated WSDL. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@772957 13f79535-47bb-0310-9956-ffa450edef68 --- branches/sca-java-1.x/itest/wsdlgen/pom.xml | 92 ++++++++++++++++ .../wsdlgen/src/main/java/helloworld/ABean.java | 42 +++++++ .../src/main/java/helloworld/HelloWorldImpl.java | 48 ++++++++ .../main/java/helloworld/HelloWorldService.java | 36 ++++++ .../src/main/java/helloworld/package-info.java | 20 ++++ .../wsdlgen/src/main/resources/definitions.xml | 66 +++++++++++ .../src/main/resources/helloworld.composite | 71 ++++++++++++ .../src/main/resources/wsdl/helloworld.wsdl | 105 ++++++++++++++++++ .../test/java/helloworld/JmsTransportTestCase.java | 121 +++++++++++++++++++++ 9 files changed, 601 insertions(+) create mode 100644 branches/sca-java-1.x/itest/wsdlgen/pom.xml create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/ABean.java create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/package-info.java create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/main/resources/definitions.xml create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/main/resources/helloworld.composite create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/main/resources/wsdl/helloworld.wsdl create mode 100644 branches/sca-java-1.x/itest/wsdlgen/src/test/java/helloworld/JmsTransportTestCase.java (limited to 'branches/sca-java-1.x/itest/wsdlgen') diff --git a/branches/sca-java-1.x/itest/wsdlgen/pom.xml b/branches/sca-java-1.x/itest/wsdlgen/pom.xml new file mode 100644 index 0000000000..92b361bf07 --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6-SNAPSHOT + ../../pom.xml + + itest-wsdlgen + Apache Tuscany SCA iTest runtime WSDL generation + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + compile + + + + org.apache.activemq + activemq-core + 5.2.0 + compile + + + backport-util-concurrent + backport-util-concurrent + 3.1 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/ABean.java b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/ABean.java new file mode 100644 index 0000000000..8a99a81132 --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/ABean.java @@ -0,0 +1,42 @@ +/* + * 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 helloworld; + +public class ABean { + + protected String field1; + protected String field2; + + public String getField1() { + return field1; + } + + public void setField1(String field1) { + this.field1 = field1; + } + + public String getField2() { + return field2; + } + + public void setField2(String field2) { + this.field2 = field2; + } +} + diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldImpl.java b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..83165307af --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,48 @@ +/* + * 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 helloworld; + +import java.util.Vector; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldImpl implements HelloWorldService { + + public String getGreetings(String name) { + return "Hello " + name; + } + + public String getGreetingsBean(ABean bean){ + return "Hello " + bean.getField1() + " " + bean.getField2(); + } + + public String getGreetingsBeanArray(ABean[] bean){ + return "Hello " + bean[0].getField1() + " " + bean[0].getField2(); + } + + /* + public String getGreetingsBeanVector(Vector bean){ + return "Hello " + bean.get(0).getField1() + " " + bean.get(0).getField2(); + } + */ +} diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldService.java b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..6f3d57e6f7 --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,36 @@ +/* + * 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 helloworld; + +import java.util.Vector; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldService { + + public String getGreetings(String name); + public String getGreetingsBean(ABean bean); + public String getGreetingsBeanArray(ABean[] bean); + //public String getGreetingsBeanVector(Vector bean); +} + diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/package-info.java b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/package-info.java new file mode 100644 index 0000000000..45bc473320 --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/main/java/helloworld/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ +@javax.xml.bind.annotation.XmlSchema(namespace="http://test") +package helloworld; diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/definitions.xml b/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/definitions.xml new file mode 100644 index 0000000000..e1b316dcc6 --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/definitions.xml @@ -0,0 +1,66 @@ + + + + + + + The general intent that a transport is available over which SOAP messages flow + + + + + + A JMS transport is required + + + + + + An HTTP transport is required + + + + + + + An HTTPS transport is required + + + + + + + org.apache.activemq.jndi.ActiveMQInitialContextFactory + tcp://localhost:61982 + QueueConnectionFactory + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/helloworld.composite b/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..2b5d51b71e --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/helloworld.composite @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/wsdl/helloworld.wsdl b/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..3dfee5414a --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.x/itest/wsdlgen/src/test/java/helloworld/JmsTransportTestCase.java b/branches/sca-java-1.x/itest/wsdlgen/src/test/java/helloworld/JmsTransportTestCase.java new file mode 100644 index 0000000000..b175e27b02 --- /dev/null +++ b/branches/sca-java-1.x/itest/wsdlgen/src/test/java/helloworld/JmsTransportTestCase.java @@ -0,0 +1,121 @@ +/* + * 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 helloworld; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.io.IOException; + +import org.apache.activemq.broker.BrokerService; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Tests that the helloworld server is available + */ +public class JmsTransportTestCase{ + + private SCADomain scaDomain; + private BrokerService jmsBroker; + + @Before + public void startServer() throws Exception { + startBroker(); + scaDomain = SCADomain.newInstance("helloworld.composite"); + } + + protected void startBroker() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:51293"); + jmsBroker.start(); + } + + //@Ignore + @Test + public void testComponent1() throws IOException { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent1/HelloWorldService"); + assertNotNull(helloWorldService); + + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + } + + @Ignore + @Test + public void testComponent2() throws IOException { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent2/HelloWorldService"); + assertNotNull(helloWorldService); + + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + } + + @Ignore + @Test + public void testComponent3() throws IOException { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent3/HelloWorldService"); + assertNotNull(helloWorldService); + + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + } + + @Ignore + @Test + public void testComponent4() throws IOException { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent4/HelloWorldService"); + assertNotNull(helloWorldService); + + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + } + + @Ignore + @Test + public void testComponent5() throws IOException { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent5/HelloWorldService"); + assertNotNull(helloWorldService); + + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + } + + @Ignore + @Test + public void testWaitForInput() { + System.out.println("Press a key to end"); + try { + System.in.read(); + } catch (Exception ex) { + } + System.out.println("Shutting down"); + } + + @After + public void stopServer() throws Exception { + if (scaDomain != null) { + scaDomain.close(); + } + if (jmsBroker != null) { + jmsBroker.stop(); + } + } + +} -- cgit v1.2.3