summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test
diff options
context:
space:
mode:
authorscottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68>2011-01-19 19:34:23 +0000
committerscottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68>2011-01-19 19:34:23 +0000
commit3efd5583fca4216ac67c91de7be46eb26cdc0e77 (patch)
treec3bdea41c4f9fc3c853433a31af589848b3bec8c /sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test
parent4791c83a7ae4d5a1817b2c975623cde9a27721df (diff)
Add multiple output (Holder) itests.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1060924 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test')
-rw-r--r--sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceBareTestCase.java204
-rw-r--r--sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceTestCase.java305
2 files changed, 509 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceBareTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceBareTestCase.java
new file mode 100644
index 0000000000..f8d06697a6
--- /dev/null
+++ b/sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceBareTestCase.java
@@ -0,0 +1,204 @@
+/*
+ * 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.example.orderservice;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import javax.xml.ws.Holder;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests that the order server responds.
+ */
+public class OrderServiceBareTestCase {
+
+ private Node node;
+
+ @Before
+ public void startServer() throws Exception {
+ try {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(OrderServiceBare.class);
+ node = factory.createNode("ordersca.bare.composite", new Contribution("order.bare", contribution)).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testOrderReviewBareApprovedSCA() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewApproved(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewBareApprovedWS() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareForwardComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewApproved(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewBareRejectedSCA() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewRejected(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewBareRejectedWS() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareForwardComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewRejected(orderServiceBare);
+ }
+
+
+ @Test
+ public void testOrderReviewInOutBareApprovedSCA() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewApprovedInOutHolder(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewInOutBareApprovedWS() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareForwardComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewApprovedInOutHolder(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewInOutBareRejectedSCA() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewRejectedInOutHolder(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewInOutBareRejectedWS() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareForwardComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewRejectedInOutHolder(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewOutHolderSCA() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewOutHolder(orderServiceBare);
+ }
+
+ @Test
+ public void testOrderReviewOutHolderWS() throws IOException {
+ OrderServiceBare orderServiceBare =
+ node.getService(OrderServiceBare.class, "OrderServiceBareForwardComponent/OrderServiceBare");
+ assertNotNull(orderServiceBare);
+ testOrderReviewOutHolder(orderServiceBare);
+ }
+
+ private void testOrderReviewApproved(OrderServiceBare orderServiceBare) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust1234");
+ order.setTotal( 50.0 );
+
+ Order returnValue = null;
+ returnValue = orderServiceBare.bareReviewOrder(order);
+ assertTrue( returnValue.getStatus() == Status.APPROVED );
+ }
+
+ private void testOrderReviewRejected(OrderServiceBare orderServiceBare) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust1234");
+ order.setTotal( 50000.0 );
+
+ Order returnValue = null;
+ returnValue = orderServiceBare.bareReviewOrder(order);
+ assertTrue( returnValue.getStatus() == Status.REJECTED );
+ }
+
+ private void testOrderReviewApprovedInOutHolder(OrderServiceBare orderServiceBare) throws IOException {
+ String customerId = "cust1234";
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId(customerId);
+ order.setTotal( 50.0 );
+
+ Holder<Order> holder = new Holder<Order>(order);
+ orderServiceBare.bareReviewOrderInOutHolder(holder);
+ assertTrue( holder.value.getStatus() == Status.APPROVED );
+ assertTrue( holder.value.getCustomerId().equals(customerId));
+ }
+
+ private void testOrderReviewRejectedInOutHolder(OrderServiceBare orderServiceBare) throws IOException {
+ String customerId = "cust1234";
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId(customerId);
+ order.setTotal( 50000.0 );
+
+ Holder<Order> holder = new Holder<Order>(order);
+ orderServiceBare.bareReviewOrderInOutHolder(holder);
+ assertTrue( holder.value.getStatus() == Status.REJECTED );
+ assertTrue( holder.value.getCustomerId().equals(customerId));
+ }
+
+ private void testOrderReviewOutHolder(OrderServiceBare orderServiceBare) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust1234");
+ order.setTotal( 50.0 );
+ Holder<Order> holder = new Holder<Order>(order);
+ orderServiceBare.bareReviewOrderOutHolder(holder);
+ assertTrue( holder.value.getStatus() == Status.APPROVED );
+ assertTrue( holder.value.getCustomerId().equals("approved.1234"));
+ }
+
+
+ @After
+ public void stopServer() throws Exception {
+ if (node != null)
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceTestCase.java b/sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceTestCase.java
new file mode 100644
index 0000000000..17db43b4e8
--- /dev/null
+++ b/sca-java-2.x/trunk/testing/itest/ws/holder-ws-service-multiple-outputs/src/test/java/org/example/orderservice/OrderServiceTestCase.java
@@ -0,0 +1,305 @@
+/*
+ * 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.example.orderservice;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import javax.xml.ws.Holder;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests that the order server responds.
+ */
+public class OrderServiceTestCase {
+
+ private Node node;
+
+ @Before
+ public void startServer() throws Exception {
+ try {
+
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(OrderService.class);
+ node = factory.createNode("ordersca.composite", new Contribution("order", contribution)).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testOrderReviewApprovedSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(57.4));
+ testOrderReviewApproved(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewApprovedWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(57.4));
+ testOrderReviewApproved(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRejectedSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(57.4));
+ testOrderReviewRejected(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRejectedWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(57.4));
+ testOrderReviewRejected(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRandomSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(57.4));
+ testOrderReviewRandom(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRandomWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(57.4));
+ testOrderReviewRandom(orderService, outParam);
+ }
+
+
+
+ @Test
+ public void testOrderReviewApprovedTwoInOutsSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(111));
+ testOrderReviewApproved(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewApprovedTwoInOutsWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(111));
+ testOrderReviewApproved(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRejectedTwoInOutsSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(111));
+ testOrderReviewRejected(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRejectedTwoInOutsWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(111));
+ testOrderReviewRejected(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRandomTwoInOutsSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(111));
+ testOrderReviewRandom(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewRandomTwoInOutsWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ Holder<Float> outParam = new Holder<Float>(new Float(111));
+ testOrderReviewRandom(orderService, outParam);
+ }
+
+ @Test
+ public void testOrderReviewTwoOutHoldersSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ testOrderReviewTwoOutHolders(orderService);
+ }
+
+ @Test
+ public void testOrderReviewTwoOutHoldersWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ testOrderReviewTwoOutHolders(orderService);
+ }
+
+ @Test
+ public void testOrderReviewTwoInOutsThenInSCA() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceComponent/OrderService");
+ assertNotNull(orderService);
+ testOrderReviewOrderTwoInOutsThenIn(orderService);
+ }
+
+ @Test
+ public void testOrderReviewTwoInOutsThenInWS() throws IOException {
+ OrderService orderService =
+ node.getService(OrderService.class, "OrderServiceForwardComponent/OrderService");
+ assertNotNull(orderService);
+ testOrderReviewOrderTwoInOutsThenIn(orderService);
+ }
+
+ private void testOrderReviewApproved(OrderService orderService, Holder<Float> outParam) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust1234");
+ order.setTotal( 50.0 );
+
+ System.out.println( ">>> Order submitted=" + order );
+ Holder<Order> holder = new Holder<Order>( order );
+ String[] returnValue = null;
+ if (outParam.value.equals(new Float("111"))) {
+ returnValue = orderService.reviewOrderTwoInOuts( holder, outParam );
+ } else {
+ returnValue = orderService.reviewOrder( holder, outParam );
+ }
+ System.out.println( ">>> Order returned=" + holder.value );
+ assertTrue( holder.value.getStatus() == Status.APPROVED );
+ assertEquals("retval1", returnValue[0]);
+ assertEquals("retval2", returnValue[1]);
+ assertTrue(outParam.value.floatValue() == 97);
+ }
+
+ private void testOrderReviewRejected(OrderService orderService, Holder<Float> outParam) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust2345");
+ order.setTotal( 50000.0 );
+
+ System.out.println( ">>> Order submitted=" + order );
+ Holder<Order> holder = new Holder<Order>( order );
+ String[] returnValue = null;
+ if (outParam.value.equals(new Float("111"))) {
+ returnValue = orderService.reviewOrderTwoInOuts( holder, outParam );
+ } else {
+ returnValue = orderService.reviewOrder( holder, outParam );
+ }
+ System.out.println( ">>> Order returned=" + holder.value );
+ System.out.println( ">>> return values: " + returnValue[0] + " " + returnValue[1]);
+ assertTrue( holder.value.getStatus() == Status.REJECTED );
+ assertEquals("retval1", returnValue[0]);
+ assertEquals("retval2", returnValue[1]);
+ assertTrue(outParam.value.floatValue() == 97);
+ }
+
+ private void testOrderReviewRandom(OrderService orderService, Holder<Float> outParam) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust3456");
+ order.setTotal( 600.0 );
+
+ System.out.println( ">>> Order submitted=" + order );
+ Holder<Order> holder = new Holder<Order>( order );
+ String[] returnValue = null;
+ if (outParam.value.equals(new Float("111"))) {
+ returnValue = orderService.reviewOrderTwoInOuts( holder, outParam );
+ } else {
+ returnValue = orderService.reviewOrder( holder, outParam );
+ }
+ System.out.println( ">>> Order returned=" + holder.value );
+ assertTrue( holder.value.getStatus() != Status.CREATED );
+ assertEquals("retval1", returnValue[0]);
+ assertEquals("retval2", returnValue[1]);
+ assertTrue(outParam.value.floatValue() == 97);
+ }
+
+ private void testOrderReviewTwoOutHolders(OrderService orderService) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust3456");
+ order.setTotal( 600.0 );
+
+ System.out.println( ">>> Order submitted=" + order );
+ Holder<Order> holder = new Holder<Order>( order );
+ Holder<Float> outParam = new Holder<Float>(new Float(57.4));
+ String[] returnValue = orderService.reviewOrderTwoOutHolders( holder, outParam );
+ System.out.println( ">>> Order returned=" + holder.value );
+ assertTrue( holder.value.getStatus() == Status.REJECTED );
+ assertEquals("retval1", returnValue[0]);
+ assertEquals("retval2", returnValue[1]);
+ assertTrue(outParam.value.floatValue() == 97);
+ }
+
+ private void testOrderReviewOrderTwoInOutsThenIn(OrderService orderService) throws IOException {
+ Order order = new Order();
+ order.setStatus( Status.CREATED );
+ order.setCustomerId("cust1234");
+ order.setTotal( 50.0 );
+
+ System.out.println( ">>> Order submitted=" + order );
+ Holder<Order> holder = new Holder<Order>( order );
+ Holder<Float> outParam = new Holder<Float>( new Float("1820.234"));
+ String[] returnValue = null;
+ Integer checkForMe = new Integer("23");
+ returnValue = orderService.reviewOrderTwoInOutsThenIn( holder, outParam, checkForMe);
+ System.out.println( ">>> Order returned=" + holder.value );
+ assertTrue( holder.value.getStatus() == Status.APPROVED );
+ assertEquals("retval1", returnValue[0]);
+ assertEquals("retval2", returnValue[1]);
+ assertTrue(outParam.value.floatValue() == 97);
+ }
+
+ @After
+ public void stopServer() throws Exception {
+ if (node != null)
+ node.stop();
+ }
+
+}