summaryrefslogtreecommitdiffstats
path: root/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java')
-rw-r--r--sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java101
1 files changed, 49 insertions, 52 deletions
diff --git a/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java b/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java
index 636cf124d8..6d9d117b0e 100644
--- a/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java
+++ b/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java
@@ -34,9 +34,9 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.osoa.sca.ServiceRuntimeException;
import com.ericsson.otp.erlang.OtpAuthException;
+import com.ericsson.otp.erlang.OtpConnection;
import com.ericsson.otp.erlang.OtpErlangAtom;
import com.ericsson.otp.erlang.OtpErlangBinary;
import com.ericsson.otp.erlang.OtpErlangBoolean;
@@ -49,6 +49,8 @@ import com.ericsson.otp.erlang.OtpErlangString;
import com.ericsson.otp.erlang.OtpErlangTuple;
import com.ericsson.otp.erlang.OtpMbox;
import com.ericsson.otp.erlang.OtpNode;
+import com.ericsson.otp.erlang.OtpPeer;
+import com.ericsson.otp.erlang.OtpSelf;
/**
* Test is annotated with test runner, which will ignore tests if epmd is not
@@ -63,15 +65,12 @@ public class ReferenceServiceTestCase {
private static MboxInterface mboxReference;
private static MboxInterface timeoutMboxReference;
- private static MboxInterface cookieMboxReference;
private static ServiceInterface moduleReference;
private static ServiceInterface cookieModuleReference;
+ private static ServiceInterface invalidCookieModuleReference;
private static ServiceInterface timeoutModuleReference;
- private static ServiceInterface clonedModuleReference;
private static OtpNode serNode;
- private static OtpNode serCookieNode;
private static OtpMbox serMbox;
- private static OtpMbox serCookieMbox;
private static OtpNode refNode;
private static OtpMbox refMbox;
private static Process epmdProcess;
@@ -88,17 +87,14 @@ public class ReferenceServiceTestCase {
mboxReference = component.getMboxReference();
timeoutMboxReference = component.getTimeoutMboxReference();
- cookieMboxReference = component.getCookieMboxReference();
moduleReference = component.getModuleReference();
cookieModuleReference = component.getCookieModuleReference();
+ invalidCookieModuleReference = component
+ .getInvalidCookieModuleReference();
timeoutModuleReference = component.getTimeoutModuleReference();
- clonedModuleReference = component.getClonedModuleReference();
serNode = new OtpNode("MboxServer");
- serCookieNode = new OtpNode("MboxServer");
- serCookieNode.setCookie("cookie");
serMbox = serNode.createMbox("sendArgs");
- serCookieMbox = serCookieNode.createMbox("sendArgs");
refNode = new OtpNode("MboxClient");
refMbox = refNode.createMbox("connector_to_SCA_mbox");
} catch (IOException e) {
@@ -552,7 +548,7 @@ public class ReferenceServiceTestCase {
*
* @throws Exception
*/
- @Test(timeout = 1000)
+ @Test(timeout = 10000000)
public void testRPC() throws Exception {
String[] result = moduleReference.sayHellos();
assertEquals(2, result.length);
@@ -636,38 +632,7 @@ public class ReferenceServiceTestCase {
assertEquals(ErlangException.class, e.getClass());
}
}
-
- /**
- * Tests using multiple Erlang modules on one SCA Erlang node
- *
- * @throws Exception
- */
- @Test(timeout = 1000)
- public void testMultipleModulesOnNode() throws Exception {
- String[] mr = moduleReference.sayHellos();
- String[] cmr = clonedModuleReference.sayHellos();
- assertEquals("1", mr[0]);
- assertEquals("2", mr[1]);
-
- assertEquals("-1", cmr[0]);
- assertEquals("-2", cmr[1]);
- }
-
- /**
- * Tests nodes with duplcated components (the same node and module
- * parameters)
- *
- * @throws Exception
- */
- @Test(timeout = 1000)
- public void testModuleDuplicatedOnNode() throws Exception {
- try {
- SCADomain.newInstance("ErlangServiceModuleDuplicate.composite");
- } catch (ServiceRuntimeException e) {
- assertEquals(ErlangException.class, e.getCause().getClass());
- }
- }
-
+
/**
* Tests mbox with retrieving and answering with basic arguments
*
@@ -679,7 +644,7 @@ public class ReferenceServiceTestCase {
args[0] = new OtpErlangString("world");
args[1] = new OtpErlangString("!");
OtpErlangTuple tuple = new OtpErlangTuple(args);
- refMbox.send("sayHello", "RPCServer", tuple);
+ refMbox.send("sayHello", "RPCServerMbox", tuple);
OtpErlangString result = (OtpErlangString) refMbox.receiveMsg()
.getMsg();
assertEquals("Hello world !", result.stringValue());
@@ -690,7 +655,7 @@ public class ReferenceServiceTestCase {
*
* @throws Exception
*/
- @Test(timeout = 1000)
+ @Test(timeout = 2000)
public void testMboxWithComplexArgs() throws Exception {
int arg1 = 1;
String arg2 = "arg2";
@@ -715,7 +680,7 @@ public class ReferenceServiceTestCase {
argsContent[0] = structuredTuple;
argsContent[1] = list;
OtpErlangTuple args = new OtpErlangTuple(argsContent);
- refMbox.send("passComplexArgs", "RPCServer", args);
+ refMbox.send("passComplexArgs", "RPCServerMbox", args);
OtpErlangObject result = refMbox.receiveMsg().getMsg();
assertEquals(arg1,
((OtpErlangLong) ((OtpErlangTuple) ((OtpErlangTuple) result)
@@ -747,7 +712,7 @@ public class ReferenceServiceTestCase {
try {
// timeout exception expected
timeoutMboxReference.sendArgs("");
- fail();
+ fail("Exception expected");
} catch (Exception e) {
assertEquals(ErlangException.class, e.getClass());
assertEquals(e.getCause().getClass(), InterruptedException.class);
@@ -791,7 +756,7 @@ public class ReferenceServiceTestCase {
// exception, so expecting one
try {
timeoutModuleReference.sayHellos();
- fail();
+ fail("Exception expected");
} catch (Exception e) {
assertEquals(ErlangException.class, e.getClass());
}
@@ -801,19 +766,51 @@ public class ReferenceServiceTestCase {
}
/**
- * Tests timeout feature for reference binding RPC
+ * Tests timeout feature for service side bindings
+ * @throws Exception
+ */
+ @Test(timeout = 4000)
+ public void testServiceTimeouts() throws Exception {
+ OtpSelf self = new OtpSelf("tmp_connector_"
+ + System.currentTimeMillis());
+ OtpPeer peer = new OtpPeer("RPCServerTimeout");
+ OtpConnection connection = self.connect(peer);
+ // delay message sending after connecting
+ Thread.sleep(1000);
+ // service binding timeout set to 500 so after that time it will give up
+ // and close connection
+ try {
+ connection.send("rex", new OtpErlangString("test"));
+ fail("Exception expected");
+ } catch (Exception e) {
+ assertEquals(IOException.class, e.getClass());
+ }
+
+ connection = self.connect(peer);
+ // sending message immediately and encountering no connection close
+ connection.send("rex", new OtpErlangString("test"));
+
+ }
+
+ /**
+ * Tests cookie feature for both reference and service bindings RPC
*
* @throws Exception
*/
@Test(timeout = 1000)
public void testReferenceCookies() throws Exception {
+ // testing wrong cookie
try {
- cookieModuleReference.sayHellos();
- fail();
+ invalidCookieModuleReference.sayHellos();
+ fail("Exception expected");
} catch (Exception e) {
assertEquals(ErlangException.class, e.getClass());
assertEquals(OtpAuthException.class, e.getCause().getClass());
}
- }
+ // testing correct cookie
+ cookieModuleReference.sayHellos();
+
+ }
+
}