From d11112aa19abf73861e051a982af54236023989f Mon Sep 17 00:00:00 2001 From: nash Date: Thu, 21 Jan 2010 10:26:28 +0000 Subject: Add new contribution buildingblocks-client git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@901638 13f79535-47bb-0310-9956-ffa450edef68 --- .../contributions/buildingblocks-client/build.xml | 22 ++++ .../contributions/buildingblocks-client/pom.xml | 111 +++++++++++++++++++++ .../src/main/java/scatours/Bookings.java | 26 +++++ .../src/main/java/scatours/Checkout.java | 28 ++++++ .../main/java/scatours/impl/ApplClientImpl.java | 52 ++++++++++ .../main/java/scatours/impl/ToursClientImpl.java | 47 +++++++++ .../main/resources/META-INF/sca-contribution.xml | 26 +++++ .../src/main/resources/tours-appl-client.composite | 40 ++++++++ .../src/main/resources/tours-impl-client.composite | 32 ++++++ .../resources/tours-impl-include-client.composite | 32 ++++++ .../java/scatours/BuildingBlocksApplTestCase.java | 77 ++++++++++++++ .../BuildingBlocksImplIncludeTestCase.java | 59 +++++++++++ .../java/scatours/BuildingBlocksImplTestCase.java | 58 +++++++++++ .../src/test/resources/jndi.properties | 39 ++++++++ 14 files changed, 649 insertions(+) create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/build.xml create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/pom.xml create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Bookings.java create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Checkout.java create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ApplClientImpl.java create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ToursClientImpl.java create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-appl-client.composite create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-client.composite create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-include-client.composite create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksApplTestCase.java create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplTestCase.java create mode 100644 sandbox/travelsample/contributions/buildingblocks-client/src/test/resources/jndi.properties (limited to 'sandbox/travelsample') diff --git a/sandbox/travelsample/contributions/buildingblocks-client/build.xml b/sandbox/travelsample/contributions/buildingblocks-client/build.xml new file mode 100644 index 0000000000..9ea7438516 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/build.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks-client/pom.xml b/sandbox/travelsample/contributions/buildingblocks-client/pom.xml new file mode 100644 index 0000000000..de4a711af0 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/pom.xml @@ -0,0 +1,111 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + scatours + 1.0-SNAPSHOT + ../../pom.xml + 1.0-SNAPSHOT + scatours-contribution-buildingblocks-client + Apache Tuscany SCA Tours Building Blocks Client Contribution + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + ${tuscany.version} + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + ${tuscany.version} + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + ${tuscany.version} + runtime + + + + org.apache.tuscany.sca + tuscany-node-api + ${tuscany.version} + test + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + ${tuscany.version} + test + + + + org.apache.tuscany.sca + tuscany-host-jetty + ${tuscany.version} + test + + + + org.apache.tuscany.sca + tuscany-host-jms-asf + ${tuscany.version} + test + + + + org.apache.activemq + activemq-all + 5.2.0 + + + org.apache.activemq + activemq-web-demo + + + test + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Bookings.java b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Bookings.java new file mode 100644 index 0000000000..e5e994b73c --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Bookings.java @@ -0,0 +1,26 @@ +/* + * 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 scatours; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Bookings { + String newBooking(String trip, int people); +} diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Checkout.java b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Checkout.java new file mode 100644 index 0000000000..519b7779fa --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/Checkout.java @@ -0,0 +1,28 @@ +/* + * 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 scatours; + +import java.math.BigDecimal; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Checkout { + void makePayment(BigDecimal amount, String cardInfo); +} diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ApplClientImpl.java b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ApplClientImpl.java new file mode 100644 index 0000000000..278673c67d --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ApplClientImpl.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 scatours.impl; + +import java.math.BigDecimal; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import scatours.Bookings; +import scatours.Checkout; + +@Service(Runnable.class) +public class ApplClientImpl { + @Reference + protected Bookings bookings1, bookings2; + + @Reference + protected Checkout checkout1, checkout2; + + public ApplClientImpl() { + } + + public void run() { + String bookingCode = bookings1.newBooking("FS1APR4", 1); + System.out.println("Booking code is " + bookingCode); + + checkout1.makePayment(new BigDecimal("1995.00"), "1234567843218765 10/10"); + + bookingCode = bookings2.newBooking("AC3MAY9", 2); + System.out.println("Booking code is " + bookingCode); + + checkout2.makePayment(new BigDecimal("2295.00"), "9876123456784321 11/11"); + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ToursClientImpl.java b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ToursClientImpl.java new file mode 100644 index 0000000000..16934872b9 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/java/scatours/impl/ToursClientImpl.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 scatours.impl; + +import java.math.BigDecimal; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import scatours.Bookings; +import scatours.Checkout; + +@Service(Runnable.class) +public class ToursClientImpl { + @Reference + protected Bookings bookings; + + @Reference + protected Checkout checkout; + + public ToursClientImpl() { + } + + public void run() { + String bookingCode = bookings.newBooking("FS1APR4", 1); + System.out.println("Booking code is " + bookingCode); + + checkout.makePayment(new BigDecimal("1995.00"), "1234567843218765 10/10"); + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e3f6effcee --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-appl-client.composite b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-appl-client.composite new file mode 100644 index 0000000000..b9f9d59f43 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-appl-client.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-client.composite b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-client.composite new file mode 100644 index 0000000000..f8f0b3d4d1 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-client.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-include-client.composite b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-include-client.composite new file mode 100644 index 0000000000..7310d0540d --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/main/resources/tours-impl-include-client.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksApplTestCase.java b/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksApplTestCase.java new file mode 100644 index 0000000000..2cf08ec420 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksApplTestCase.java @@ -0,0 +1,77 @@ +/* + * 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 scatours; + +import org.apache.activemq.broker.BrokerService; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests the Building Blocks Composite Application scenario + */ +public class BuildingBlocksApplTestCase { + + private BrokerService jmsBroker; + private SCANode node1, node2; + + @Before + public void startServer() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + + node1 = SCANodeFactory.newInstance().createSCANode("tours-appl.composite", + new SCAContribution("introducing-trips", "../introducing-trips/target/classes"), + new SCAContribution("buildingblocks", "../buildingblocks/target/classes")); + + node2 = SCANodeFactory.newInstance().createSCANode("tours-appl-client.composite", + new SCAContribution("buildingblocks-client", "./target/classes")); + + jmsBroker.start(); + node1.start(); + node2.start(); + } + + @Test + public void testAppl() { + Runnable client = ((SCAClient)node2).getService(Runnable.class, "ApplClient/Runnable"); + client.run(); + } + + @After + public void stopServer() throws Exception { + if (node2 != null) { + node2.stop(); + } + if (node1 != null) { + node1.stop(); + } + if (jmsBroker != null) { + jmsBroker.stop(); + } + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java b/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java new file mode 100644 index 0000000000..ad48db5616 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java @@ -0,0 +1,59 @@ +/* + * 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 scatours; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests the Building Blocks Composite Implementation Include scenario + */ +public class BuildingBlocksImplIncludeTestCase { + + private SCANode node; + + @Before + public void startServer() throws Exception { + node = SCANodeFactory.newInstance().createSCANode("tours-impl-include-client.composite", + new SCAContribution("introducing-trips", "../introducing-trips/target/classes"), + new SCAContribution("buildingblocks", "../buildingblocks/target/classes"), + new SCAContribution("buildingblocks-client", "./target/classes")); + + node.start(); + } + + @Test + public void testImplInclude() { + Runnable client = ((SCAClient)node).getService(Runnable.class, "ToursClient/Runnable"); + client.run(); + } + + @After + public void stopServer() throws Exception { + if (node != null) { + node.stop(); + } + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplTestCase.java b/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplTestCase.java new file mode 100644 index 0000000000..c4cffa3e02 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/test/java/scatours/BuildingBlocksImplTestCase.java @@ -0,0 +1,58 @@ +/* + * 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 scatours; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests the Building Blocks Composite Implementation scenario + */ +public class BuildingBlocksImplTestCase { + + private SCANode node; + + @Before + public void startServer() throws Exception { + node = SCANodeFactory.newInstance().createSCANode("tours-impl-client.composite", + new SCAContribution("buildingblocks", "../buildingblocks/target/classes"), + new SCAContribution("buildingblocks-client", "./target/classes")); + + node.start(); + } + + @Test + public void testImpl() { + Runnable client = ((SCAClient)node).getService(Runnable.class, "ToursClient/Runnable"); + client.run(); + } + + @After + public void stopServer() throws Exception { + if (node != null) { + node.stop(); + } + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks-client/src/test/resources/jndi.properties b/sandbox/travelsample/contributions/buildingblocks-client/src/test/resources/jndi.properties new file mode 100644 index 0000000000..88270fd1e0 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks-client/src/test/resources/jndi.properties @@ -0,0 +1,39 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# START SNIPPET: jndi + +java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory + +# use the following property to configure the default connector +java.naming.provider.url = vm://localhost?broker.persistent=false + +# use the following property to specify the JNDI name the connection factory +# should appear as. +#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry +connectionFactoryNames = ConnectionFactory + +# register some queues in JNDI using the form +# queue.[jndiName] = [physicalName] +queue.BookTrip = BookTripRequestQueue +queue.Checkout = CheckoutRequestQueue + +# register some topics in JNDI using the form +# topic.[jndiName] = [physicalName] +#topic.MyTopic = example.MyTopic + +# END SNIPPET: jndi -- cgit v1.2.3