diff options
Diffstat (limited to 'java/sca/modules/binding-rmi-runtime/src/test')
8 files changed, 88 insertions, 189 deletions
diff --git a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java index e4af1b92ec..cbc860ecc6 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java +++ b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java @@ -24,37 +24,37 @@ package helloworld; */ public class HelloException extends Exception { - /** - * - */ - private static final long serialVersionUID = 2570611055132507470L; - - /** - * - */ - public HelloException() { - } - - /** - * @param message - */ - public HelloException(String message) { - super(message); - } - - /** - * @param cause - */ - public HelloException(Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - */ - public HelloException(String message, Throwable cause) { - super(message, cause); - } + /** + * + */ + private static final long serialVersionUID = 2570611055132507470L; + + /** + * + */ + public HelloException() { + } + + /** + * @param message + */ + public HelloException(String message) { + super(message); + } + + /** + * @param cause + */ + public HelloException(Throwable cause) { + super(cause); + } + + /** + * @param message + * @param cause + */ + public HelloException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java index 64745639b1..0a1f4283db 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java +++ b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java @@ -20,23 +20,23 @@ package helloworld; import org.osoa.sca.annotations.Service; + /** * This class implements the HelloWorld service. - * + * * @version $Rev$ $Date$ */ @Service(HelloWorldService.class) public class HelloWorldImpl implements HelloWorldService { - public String sayHello(String name) { - return "Hello from the RMI Service to - " + name; - } - - public String sayHi(String name, String greeter) throws HelloException { - if (name == null || greeter == null) { - throw new HelloException("Invalid name or greeter: name=" + name - + " greeter=" + greeter); - } - return "Hi from " + greeter + " in RMI Service to - " + name; - } + public String sayHello(String name) { + return "Hello from the RMI Service to - " + name; + } + + public String sayHi(String name, String greeter) throws HelloException { + if (name == null || greeter == null) { + throw new HelloException("Invalid name or greeter: name=" + name + " greeter=" + greeter); + } + return "Hi from " + greeter + " in RMI Service to - " + name; + } } diff --git a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java index c0c49da215..5b20d17c83 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java +++ b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java @@ -19,70 +19,32 @@ package helloworld; import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Scope; import org.osoa.sca.annotations.Service; /** - * This class implements the HelloWorld service. The Scope is CONVERSATION to - * test the RMI Conversational Service and Conversational in interface and - * Scope("CONVERSATION") in Implementation keep the same instance of the - * references. But only references conversational are Stateful. - * HelloWorldService is stateless is keep stateless. - * HelloWorldConversationalService is stateful. - * - * When BindingTestCase take a instance of HelloWorldRmiImpl it is use the same - * instance of the HelloWorldRmiImpl to all method invocation, how - * extConversationService is conversational (stateful) too, your state is keep - * between call, differently of the extService that is stateless. - * + * This class implements the HelloWorld service. + * * @version $Rev$ $Date$ */ @Service(HelloWorldRmiService.class) -@Scope("CONVERSATION") public class HelloWorldRmiImpl implements HelloWorldRmiService { - private HelloWorldService extService; - private HelloWorldConversationalService extConversationalService; - private static final String COMPLEMENT = " thro the RMI Reference"; - - public HelloWorldService getExtService() { - return extService; - } - - @Reference - public void setExtService(HelloWorldService extService) { - this.extService = extService; - } - - @Reference - public void setExtConversationalService( - HelloWorldConversationalService extConversationalService) { - this.extConversationalService = extConversationalService; - } - - public String sayRmiHello(String name) { - return extService.sayHello(name) + COMPLEMENT; - } - - public String sayRmiHi(String name, String greeter) throws HelloException { - return extService.sayHi(name, greeter) + COMPLEMENT; - } - - public String getConversationalHello() { - return extConversationalService.getHello() + COMPLEMENT; - } - - public String getConversationalHi() { - return extConversationalService.getHi() + COMPLEMENT; - } - - public void sayRmiConversationalHello(String name) { - extConversationalService.sayHello(name); - - } - - public void sayRmiConversationalHi(String name, String greeter) - throws HelloException { - extConversationalService.sayHi(name, greeter); - } + private HelloWorldService extService; + + public HelloWorldService getExtService() { + return extService; + } + + @Reference + public void setExtService(HelloWorldService extService) { + this.extService = extService; + } + + public String sayRmiHello(String name) { + return extService.sayHello(name) + " thro the RMI Reference"; + } + + public String sayRmiHi(String name, String greeter) throws HelloException { + return extService.sayHi(name, greeter) + " thro the RMI Reference"; + } } diff --git a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java index 2742ab14c0..461c176e1e 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java +++ b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java @@ -18,36 +18,14 @@ */ package helloworld; -import org.osoa.sca.annotations.Conversational; - /** - * This is the business interface of the HelloWorld greetings service. This - * interface is Conversational to test the RMI Conversational Service and - * Conversational in interface and Scope("CONVERSATION") in Implementation keep - * the same instance of the references. But only references conversational are - * Stateful. HelloWorldService is stateless is keep stateless. - * HelloWorldConversationalService is stateful. - * - * When BindingTestCase take a instance of HelloWorldRmiImpl it is use the same - * instance of the HelloWorldRmiImpl in all method invocation, how - * extConversationService is conversational (stateful) too, your state is keep - * between call, differently of the extService that is stateless. - * + * This is the business interface of the HelloWorld greetings service. + * * @version $Rev$ $Date$ */ -@Conversational public interface HelloWorldRmiService { - String sayRmiHello(String name); - - String sayRmiHi(String name, String greeter) throws HelloException; - - void sayRmiConversationalHello(String name); - - void sayRmiConversationalHi(String name, String greeter) - throws HelloException; - - String getConversationalHello(); + String sayRmiHello(String name); + String sayRmiHi(String name, String greeter) throws HelloException; - String getConversationalHi(); } diff --git a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java index 999dfc2052..3b705d2c97 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java +++ b/java/sca/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java @@ -20,13 +20,12 @@ package helloworld; /** * This is the business interface of the HelloWorld greetings service. - * + * * @version $Rev$ $Date$ */ public interface HelloWorldService { - String sayHello(String name); - - String sayHi(String name, String greeter) throws HelloException; + String sayHello(String name); + String sayHi(String name, String greeter) throws HelloException; } diff --git a/java/sca/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java b/java/sca/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java index a59507c144..c62e3a6b8b 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java +++ b/java/sca/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java @@ -39,26 +39,8 @@ public class BindingTestCase { private static HelloWorldRmiService helloWorldRmiService; private static Node node; - @BeforeClass - public static void init() throws Exception { - try { - String contribution = ContributionLocationHelper.getContributionLocation(BindingTestCase.class); - node = NodeFactory.newInstance().createNode("RMIBindingTest.composite", new Contribution("test", contribution)); - node.start(); - helloWorldRmiService = node.getService(HelloWorldRmiService.class, "HelloWorldRmiServiceComponent"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @AfterClass - public static void destroy() throws Exception { - node.stop(); - node.destroy(); - } - @Test - public void performRmiNormalService() { + public void testRmiService() { String msg = helloWorldRmiService.sayRmiHello("Tuscany World!"); System.out.println(msg); Assert.assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference", msg); @@ -78,28 +60,22 @@ public class BindingTestCase { } } - @Test - public void performRmiConversationalService() { - helloWorldRmiService.sayRmiConversationalHello("Tuscany World!"); - String msg = helloWorldRmiService.getConversationalHello(); - System.out.println(msg); - Assert.assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference", msg); - - try { - helloWorldRmiService.sayRmiConversationalHi("Tuscany World!", "Apache World"); - msg = helloWorldRmiService.getConversationalHi(); - System.out.println(msg); - Assert.assertEquals("Hi from Apache World in RMI Service to - Tuscany World! thro the RMI Reference", msg); - } catch (HelloException e) { - Assert.fail(e.getMessage()); - } + @BeforeClass + public static void init() throws Exception { try { - helloWorldRmiService.sayRmiConversationalHi(null, "Apache World"); - Assert.fail("HelloException should have been thrown"); - } catch (HelloException e) { - System.out.println("Expected exception :" + e.getClass().getName()); + String contribution = ContributionLocationHelper.getContributionLocation(BindingTestCase.class); + node = NodeFactory.newInstance().createNode("RMIBindingTest.composite", new Contribution("test", contribution)); + node.start(); + helloWorldRmiService = node.getService(HelloWorldRmiService.class, "HelloWorldRmiServiceComponent"); + } catch (Exception e) { + e.printStackTrace(); } } + @AfterClass + public static void destroy() throws Exception { + node.stop(); + node.destroy(); + } } diff --git a/java/sca/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType b/java/sca/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType index 6857c03802..a83e7e6d1d 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType +++ b/java/sca/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType @@ -24,7 +24,4 @@ <reference name="extService"> <interface.java interface="helloworld.HelloWorldService"/> </reference> - <reference name="extConversationalService"> - <interface.java interface="helloworld.HelloWorldConversationalService"/> - </reference> </componentType> diff --git a/java/sca/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite b/java/sca/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite index 8d19d92036..2a0bcf0f76 100644 --- a/java/sca/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite +++ b/java/sca/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite @@ -20,37 +20,24 @@ <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" name="HelloWorldRmiComposite"> - - <!-- PROVIDER --> + <service name="HelloWorldRmiService" promote="HelloWorldServiceComponent"> <interface.java interface="helloworld.HelloWorldService"/> <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" /> </service> + <component name="HelloWorldServiceComponent"> <implementation.java class="helloworld.HelloWorldImpl"/> </component> - <service name="HelloWorldRmiConversationalService" promote="HelloWorldConversationalServiceComponent"> - <interface.java interface="helloworld.HelloWorldConversationalService"/> - <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteConversationalService"/> - </service> - <component name="HelloWorldConversationalServiceComponent"> - <implementation.java class="helloworld.HelloWorldConversationalImpl"/> - </component> - - <!-- CONSUMER --> <component name="HelloWorldRmiServiceComponent"> <implementation.java class="helloworld.HelloWorldRmiImpl"/> <reference name="extService"></reference> - <reference name="extConversationalService"></reference> </component> <reference name="HelloWorldRmiReference" promote="HelloWorldRmiServiceComponent/extService"> <interface.java interface="helloworld.HelloWorldService"/> <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteService" /> </reference> - <reference name="HelloWorldRmiConversationalReference" promote="HelloWorldRmiServiceComponent/extConversationalService"> - <interface.java interface="helloworld.HelloWorldConversationalService"/> - <tuscany:binding.rmi uri="rmi://localhost:8099/HelloWorldRemoteConversationalService" /> - </reference> + </composite> |