From bc2c7212b74937345e3b6288157678e192f6550f Mon Sep 17 00:00:00 2001 From: fmoga Date: Wed, 25 May 2011 23:20:48 +0000 Subject: Update testcase for binding-comet-runtime with callbacks. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1127722 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/test/StockService.java | 7 ++++++- .../org/apache/tuscany/sca/test/StockServiceImpl.java | 19 ++++++++++++------- .../src/test/resources/test.composite | 6 +++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java index 6d23479f30..2c104611ff 100644 --- a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java +++ b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java @@ -18,11 +18,16 @@ */ package org.apache.tuscany.sca.test; +import org.apache.tuscany.sca.binding.comet.runtime.callback.CometCallback; +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.OneWay; import org.oasisopen.sca.annotation.Remotable; +@Callback(CometCallback.class) @Remotable public interface StockService { - String getQuotes(); + @OneWay + void subscribeForQuotes(); } diff --git a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java index 359d7dec0b..bbbbbb78ba 100644 --- a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java +++ b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java @@ -22,18 +22,23 @@ import java.text.DecimalFormat; import java.util.Date; import java.util.Random; +import org.apache.tuscany.sca.binding.comet.runtime.callback.CometCallback; +import org.oasisopen.sca.annotation.Callback; import org.oasisopen.sca.annotation.Service; @Service(StockService.class) public class StockServiceImpl implements StockService { - public static final int MAX_VALUE = 1000; - private final Random random = new Random(new Date().getTime()); + @Callback + protected CometCallback callback; - @Override - public String getQuotes() { - final Double value = Math.abs(this.random.nextDouble() * this.random.nextInt(StockServiceImpl.MAX_VALUE)); - return "ASF" + "#" + Double.valueOf(new DecimalFormat("#.##").format(value)); - } + public static final int MAX_VALUE = 1000; + private final Random random = new Random(new Date().getTime()); + + @Override + public void subscribeForQuotes() { + final Double value = Math.abs(this.random.nextDouble() * this.random.nextInt(StockServiceImpl.MAX_VALUE)); + callback.sendMessage("ASF" + "#" + Double.valueOf(new DecimalFormat("#.##").format(value))); + } } diff --git a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite index 15026167be..e2996d2572 100644 --- a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite +++ b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite @@ -25,8 +25,12 @@ - + + + + -- cgit v1.2.3