From e9e5a7d96999a6d04c18f9c2e66fa6b9da72bd07 Mon Sep 17 00:00:00 2001 From: nash Date: Thu, 21 Jan 2010 10:38:07 +0000 Subject: Add new contribution buildingblocks git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@901645 13f79535-47bb-0310-9956-ffa450edef68 --- .../contributions/buildingblocks/build.xml | 22 +++++++ .../contributions/buildingblocks/pom.xml | 70 ++++++++++++++++++++++ .../src/main/java/com/budgettours/Tours.java | 26 ++++++++ .../com/budgettours/impl/TourProviderImpl.java | 28 +++++++++ .../src/main/java/com/goodvaluetrips/Trips.java | 26 ++++++++ .../com/goodvaluetrips/impl/TripProviderImpl.java | 28 +++++++++ .../main/java/com/tuscanyscatours/Bookings.java | 26 ++++++++ .../main/java/com/tuscanyscatours/Checkout.java | 28 +++++++++ .../src/main/java/com/tuscanyscatours/Updates.java | 26 ++++++++ .../com/tuscanyscatours/impl/ShoppingCartImpl.java | 49 +++++++++++++++ .../com/tuscanyscatours/impl/TripBookingImpl.java | 39 ++++++++++++ .../main/resources/META-INF/sca-contribution.xml | 27 +++++++++ .../src/main/resources/tours-appl.composite | 54 +++++++++++++++++ .../main/resources/tours-impl-include.composite | 33 ++++++++++ .../src/main/resources/tours-impl.composite | 35 +++++++++++ .../src/main/resources/tours.composite | 43 +++++++++++++ .../BuildingBlocksImplIncludeTestCase.java | 66 ++++++++++++++++++++ .../java/scatours/BuildingBlocksImplTestCase.java | 65 ++++++++++++++++++++ 18 files changed, 691 insertions(+) create mode 100644 sandbox/travelsample/contributions/buildingblocks/build.xml create mode 100644 sandbox/travelsample/contributions/buildingblocks/pom.xml create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/Tours.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/impl/TourProviderImpl.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/Trips.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/impl/TripProviderImpl.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Bookings.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Checkout.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Updates.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/ShoppingCartImpl.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/TripBookingImpl.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-appl.composite create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl-include.composite create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl.composite create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours.composite create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java create mode 100644 sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplTestCase.java (limited to 'sandbox/travelsample') diff --git a/sandbox/travelsample/contributions/buildingblocks/build.xml b/sandbox/travelsample/contributions/buildingblocks/build.xml new file mode 100644 index 0000000000..1e23144229 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/build.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks/pom.xml b/sandbox/travelsample/contributions/buildingblocks/pom.xml new file mode 100644 index 0000000000..bb29e70011 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + scatours + 1.0-SNAPSHOT + ../../pom.xml + 1.0-SNAPSHOT + scatours-contribution-buildingblocks + Apache Tuscany SCA Tours Building Blocks 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-node-api + ${tuscany.version} + test + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + ${tuscany.version} + test + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/Tours.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/Tours.java new file mode 100644 index 0000000000..38ddc1f099 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/Tours.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 com.budgettours; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Tours { + String checkAvailability(String trip, int people); +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/impl/TourProviderImpl.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/impl/TourProviderImpl.java new file mode 100644 index 0000000000..8e48625f0c --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/budgettours/impl/TourProviderImpl.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 com.budgettours.impl; + +import com.budgettours.Tours; + +public class TourProviderImpl implements Tours { + public String checkAvailability(String trip, int people) { + // call non-SCA code to reserve trip and return booking code + return "5Q87X"; + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/Trips.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/Trips.java new file mode 100644 index 0000000000..365a210368 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/Trips.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 com.goodvaluetrips; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Trips { + String checkAvailability(String trip, int people); +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/impl/TripProviderImpl.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/impl/TripProviderImpl.java new file mode 100644 index 0000000000..06f93f2637 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/goodvaluetrips/impl/TripProviderImpl.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 com.goodvaluetrips.impl; + +import com.goodvaluetrips.Trips; + +public class TripProviderImpl implements Trips { + public String checkAvailability(String trip, int people) { + // call non-SCA code to reserve trip and return booking code + return "6R98Y"; + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Bookings.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Bookings.java new file mode 100644 index 0000000000..9d54d46bb6 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/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 com.tuscanyscatours; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Bookings { + String newBooking(String trip, int people); +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Checkout.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Checkout.java new file mode 100644 index 0000000000..29c84d2bc0 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/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 com.tuscanyscatours; + +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/src/main/java/com/tuscanyscatours/Updates.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Updates.java new file mode 100644 index 0000000000..e33b0399cb --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/Updates.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 com.tuscanyscatours; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Updates { + void addTrip(String resCode); +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/ShoppingCartImpl.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/ShoppingCartImpl.java new file mode 100644 index 0000000000..629ea7b5ec --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/ShoppingCartImpl.java @@ -0,0 +1,49 @@ +/* + * 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 com.tuscanyscatours.impl; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import com.tuscanyscatours.Checkout; +import com.tuscanyscatours.Updates; + +public class ShoppingCartImpl implements Checkout, Updates { + private static List bookedTrips = new ArrayList(); + + protected String currency = "USD"; + + public void makePayment(BigDecimal amount, String cardInfo) { + System.out.print("Charged " + currency + " " + amount + + " to card " + + cardInfo + + " for " + + (bookedTrips.size() > 1 ? "trips" : "trip")); + for (String trip : bookedTrips) { + System.out.print(" " + trip); + } + System.out.println(); + bookedTrips.clear(); + } + + public void addTrip(String resCode) { + bookedTrips.add(resCode); + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/TripBookingImpl.java b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/TripBookingImpl.java new file mode 100644 index 0000000000..f2884f87c5 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/java/com/tuscanyscatours/impl/TripBookingImpl.java @@ -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. + */ +package com.tuscanyscatours.impl; + +import org.osoa.sca.annotations.Reference; + +import com.goodvaluetrips.Trips; +import com.tuscanyscatours.Bookings; +import com.tuscanyscatours.Updates; + +public class TripBookingImpl implements Bookings { + @Reference + protected Trips mytrips; + + @Reference + protected Updates cart; + + public String newBooking(String trip, int people) { + String resCode = mytrips.checkAvailability(trip, people); + cart.addTrip(resCode); + return "GV" + resCode; + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/resources/META-INF/sca-contribution.xml b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..028c41e415 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-appl.composite b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-appl.composite new file mode 100644 index 0000000000..8733c79c5d --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-appl.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl-include.composite b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl-include.composite new file mode 100644 index 0000000000..4080523309 --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl-include.composite @@ -0,0 +1,33 @@ + + + + + + + + GBP + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl.composite b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl.composite new file mode 100644 index 0000000000..31dd7d474e --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours-impl.composite @@ -0,0 +1,35 @@ + + + + + + + + GBP + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours.composite b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours.composite new file mode 100644 index 0000000000..b66d2344cd --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/main/resources/tours.composite @@ -0,0 +1,43 @@ + + + + + + + + USD + + + + + + + + + + + + + + + diff --git a/sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java b/sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java new file mode 100644 index 0000000000..ccdd2a73bd --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplIncludeTestCase.java @@ -0,0 +1,66 @@ +/* + * 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 com.tuscanyscatours.Bookings; +import com.tuscanyscatours.Checkout; + +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.composite", + new SCAContribution("introducing-trips", "../introducing-trips/target/classes"), + new SCAContribution("buildingblocks", "./target/classes")); + node.start(); + } + + @Test + public void testImplInclude() { + Bookings bookings = ((SCAClient)node).getService(Bookings.class, "MyTours/BookTrip"); + String bookingCode = bookings.newBooking("FS1APR4", 1); + System.out.println("Booking code is " + bookingCode); + + Checkout checkout = ((SCAClient)node).getService(Checkout.class, "MyTours/Checkout"); + checkout.makePayment(new BigDecimal("1995.00"), "1234567801234567 11/10"); + } + + @After + public void stopServer() throws Exception { + if (node != null) { + node.stop(); + } + } +} diff --git a/sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplTestCase.java b/sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplTestCase.java new file mode 100644 index 0000000000..35271bc5aa --- /dev/null +++ b/sandbox/travelsample/contributions/buildingblocks/src/test/java/scatours/BuildingBlocksImplTestCase.java @@ -0,0 +1,65 @@ +/* + * 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 com.tuscanyscatours.Bookings; +import com.tuscanyscatours.Checkout; + +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.composite", + new SCAContribution("buildingblocks", "./target/classes")); + node.start(); + } + + @Test + public void testImpl() { + Bookings bookings = ((SCAClient)node).getService(Bookings.class, "MyTours/BookTrip"); + String bookingCode = bookings.newBooking("FS1APR4", 1); + System.out.println("Booking code is " + bookingCode); + + Checkout checkout = ((SCAClient)node).getService(Checkout.class, "MyTours/Checkout"); + checkout.makePayment(new BigDecimal("1995.00"), "1234567843218765 10/10"); + } + + @After + public void stopServer() throws Exception { + if (node != null) { + node.stop(); + } + } +} -- cgit v1.2.3