diff options
author | wjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-16 08:44:36 +0000 |
---|---|---|
committer | wjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-16 08:44:36 +0000 |
commit | cc8390a108db502b965721392f1df0a7be221754 (patch) | |
tree | b5d7e298439386edc47957605928e98fec098e36 /branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding | |
parent | ce604976d31aba76df48dfd271a3e0c8a1bcac18 (diff) |
Messaging improvements
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@765512 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
2 files changed, 23 insertions, 2 deletions
diff --git a/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java b/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java index 817ba2cefa..fe643fcff6 100644 --- a/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java +++ b/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.binding.erlang.testing; import org.apache.tuscany.sca.binding.erlang.impl.types.TypeHelpersProxy; import com.ericsson.otp.erlang.OtpErlangObject; +import com.ericsson.otp.erlang.OtpErlangPid; import com.ericsson.otp.erlang.OtpErlangTuple; import com.ericsson.otp.erlang.OtpMbox; import com.ericsson.otp.erlang.OtpMsg; @@ -50,10 +51,16 @@ public class MboxListener implements Runnable { try { msg = mbox.receiveMsg(); Thread.sleep(duration); + OtpErlangPid senderPid = null; if (response != null) { Object[] args = new Object[1]; args[0] = response; - mbox.send(msg.getSenderPid(), TypeHelpersProxy.toErlang(args)); + if (msg.getMsg().getClass().equals(OtpErlangTuple.class) && ((OtpErlangTuple) msg.getMsg()).elementAt(0).getClass().equals(OtpErlangPid.class)) { + senderPid = (OtpErlangPid) ((OtpErlangTuple) msg.getMsg()).elementAt(0); + } else { + senderPid = msg.getSenderPid(); + } + mbox.send(senderPid, TypeHelpersProxy.toErlang(args)); } } catch (Exception e) { e.printStackTrace(); diff --git a/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java b/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java index 1d349888e6..3e0a60725e 100644 --- a/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java +++ b/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java @@ -649,6 +649,21 @@ public class ReferenceServiceTestCase { .getMsg(); assertEquals("Hello world !", result.stringValue()); } + + /** + * Tests receiving reply without sending self PID + * @throws Exception + */ + @Test(timeout = 1000) + public void testMsgWithoutPid() throws Exception { + OtpErlangObject[] args = new OtpErlangObject[2]; + args[0] = new OtpErlangString("world"); + args[1] = new OtpErlangString("!"); + refMbox.send("sayHello", "RPCServerMbox", new OtpErlangTuple(args)); + OtpErlangString result = (OtpErlangString) refMbox.receiveMsg() + .getMsg(); + assertEquals("Hello world !", result.stringValue()); + } /** * Tests service mbox receiving complex message @@ -814,7 +829,6 @@ public class ReferenceServiceTestCase { // testing correct cookie cookieModuleReference.sayHellos(); - } } |