summaryrefslogtreecommitdiffstats
path: root/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany')
-rw-r--r--sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java145
-rw-r--r--sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java10
-rw-r--r--sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java19
3 files changed, 164 insertions, 10 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 04adb60adb..34efb04812 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
@@ -33,6 +33,7 @@ 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.OtpErlangAtom;
import com.ericsson.otp.erlang.OtpErlangDouble;
@@ -43,6 +44,7 @@ import com.ericsson.otp.erlang.OtpErlangTuple;
import com.ericsson.otp.erlang.OtpMbox;
import com.ericsson.otp.erlang.OtpNode;
+//this test runner will ignore tests if epmd is not available
@RunWith(IgnorableRunner.class)
public class ReferenceServiceTestCase {
@@ -50,6 +52,7 @@ public class ReferenceServiceTestCase {
private static MboxInterface mboxReference;
private static ServiceInterface moduleReference;
+ private static ServiceInterface clonedModuleReference;
private static OtpNode node;
private static OtpMbox mbox;
private static Process epmdProcess;
@@ -65,6 +68,7 @@ public class ReferenceServiceTestCase {
ReferenceTestComponentImpl.class, "ReferenceTest");
mboxReference = component.getMboxReference();
moduleReference = component.getModuleReference();
+ clonedModuleReference = component.getClonedModuleReference();
node = new OtpNode("MboxServer");
mbox = node.createMbox("sendArgs");
} catch (IOException e) {
@@ -87,6 +91,11 @@ public class ReferenceServiceTestCase {
}
}
+ /**
+ * Tests passing strings
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testStrings() throws Exception {
String strArg = "Test message";
@@ -100,6 +109,11 @@ public class ReferenceServiceTestCase {
assertEquals(strResult, testResult);
}
+ /**
+ * Tests passing booleans
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testBooleans() throws Exception {
boolean booleanArg = true;
@@ -113,6 +127,11 @@ public class ReferenceServiceTestCase {
assertEquals(booleanResult, testResult);
}
+ /**
+ * Tests passing floats
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testFloats() throws Exception {
float floatArg = 1.0f;
@@ -126,6 +145,11 @@ public class ReferenceServiceTestCase {
assertEquals(floatResult, testResult, 0);
}
+ /**
+ * Tests passing doubles
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testDoubles() throws Exception {
double doubleArg = 1.0f;
@@ -139,6 +163,11 @@ public class ReferenceServiceTestCase {
assertEquals(doubleResult, testResult, 0);
}
+ /**
+ * Tests passing long values
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testLongs() throws Exception {
long longArg = 1;
@@ -152,6 +181,11 @@ public class ReferenceServiceTestCase {
assertEquals(longResult, testResult, 0);
}
+ /**
+ * Tests passing integers
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testInts() throws Exception {
int intArg = 1;
@@ -165,6 +199,11 @@ public class ReferenceServiceTestCase {
assertEquals(intResult, testResult, 0);
}
+ /**
+ * Tests passing chars
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testChars() throws Exception {
char charArg = 1;
@@ -178,6 +217,11 @@ public class ReferenceServiceTestCase {
assertEquals(charResult, testResult, 0);
}
+ /**
+ * Tests passing shorts
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testShorts() throws Exception {
short shortArg = 1;
@@ -191,6 +235,11 @@ public class ReferenceServiceTestCase {
assertEquals(shortResult, testResult, 0);
}
+ /**
+ * Tests passing bytes
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testBytes() throws Exception {
byte byteArg = 1;
@@ -204,6 +253,11 @@ public class ReferenceServiceTestCase {
assertEquals(byteResult, testResult, 0);
}
+ /**
+ * Tests passing multiple arguments
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testMultipleArguments() throws Exception {
MboxListener mboxListener = new MboxListener(mbox, true);
@@ -219,6 +273,11 @@ public class ReferenceServiceTestCase {
.getMsg()).elementAt(1)).stringValue());
}
+ /**
+ * Tests passing tuples
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testTuples() throws Exception {
StructuredTuple tupleResult = new StructuredTuple();
@@ -250,6 +309,11 @@ public class ReferenceServiceTestCase {
.booleanValue());
}
+ /**
+ * Tests passing lists
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testLists() throws Exception {
String[] testArg = new String[] { "One", "Two", "Three" };
@@ -269,6 +333,11 @@ public class ReferenceServiceTestCase {
}
}
+ /**
+ * Tests passing multidimensional lists
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testMultiDimLists() throws Exception {
String[][] testArg = new String[][] { { "One", "Two" },
@@ -294,6 +363,11 @@ public class ReferenceServiceTestCase {
}
}
+ /**
+ * Tests mismatched interface
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void typeMismatch() throws Exception {
try {
@@ -418,6 +492,11 @@ public class ReferenceServiceTestCase {
}
}
+ /**
+ * Basic RPC test, without arguments
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testRPC() throws Exception {
String[] result = moduleReference.sayHellos();
@@ -426,6 +505,11 @@ public class ReferenceServiceTestCase {
assertEquals("2", result[1]);
}
+ /**
+ * Tests RPC with arguments
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testRPCWithArgs() throws Exception {
String arg1 = "One";
@@ -434,6 +518,11 @@ public class ReferenceServiceTestCase {
assertEquals("Hello " + arg1 + " " + arg2, testResult);
}
+ /**
+ * Tests RPC with structured arguments
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testRPCWithComplexArgs() throws Exception {
StructuredTuple arg = new StructuredTuple();
@@ -443,34 +532,39 @@ public class ReferenceServiceTestCase {
new String[] { "some", "array" });
assertEquals(arg, testResult);
}
-
+
+ /**
+ * Tests handling requests pointing to unknown functions
+ *
+ * @throws Exception
+ */
@Test(timeout = 1000)
public void testUnknownFunction() throws Exception {
-
- //following functions differs by parameters
-
+
+ // following functions differs by parameters
+
try {
moduleReference.sayHello();
} catch (Exception e) {
assertEquals(ErlangException.class, e.getClass());
}
-
+
try {
moduleReference.sayHello("1");
} catch (Exception e) {
assertEquals(ErlangException.class, e.getClass());
}
-
+
try {
moduleReference.sayHello(1, 2);
} catch (Exception e) {
assertEquals(ErlangException.class, e.getClass());
}
-
- //for following ones name not exists
-
+
+ // for following ones name not exists
+
moduleReference.notExist();
-
+
try {
moduleReference.notExistWithException();
} catch (Exception e) {
@@ -478,4 +572,35 @@ public class ReferenceServiceTestCase {
}
}
+ /**
+ * 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());
+ }
+ }
+
}
diff --git a/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java b/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java
index f9f9a99054..919ca64568 100644
--- a/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java
+++ b/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java
@@ -6,6 +6,7 @@ public class ReferenceTestComponentImpl implements ReferenceTestComponent {
private MboxInterface mboxReference;
private ServiceInterface moduleReference;
+ private ServiceInterface clonedModuleReference;
@Reference
public void setMboxReference(MboxInterface mboxReference) {
@@ -16,6 +17,11 @@ public class ReferenceTestComponentImpl implements ReferenceTestComponent {
public void setModuleReference(ServiceInterface moduleReference) {
this.moduleReference = moduleReference;
}
+
+ @Reference
+ public void setClonedModuleReference(ServiceInterface clonedModuleReference) {
+ this.clonedModuleReference = clonedModuleReference;
+ }
public MboxInterface getMboxReference() {
return mboxReference;
@@ -24,5 +30,9 @@ public class ReferenceTestComponentImpl implements ReferenceTestComponent {
public ServiceInterface getModuleReference() {
return moduleReference;
}
+
+ public ServiceInterface getClonedModuleReference() {
+ return clonedModuleReference;
+ }
}
diff --git a/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java b/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java
new file mode 100644
index 0000000000..98921bd24d
--- /dev/null
+++ b/sandbox/wjaniszewski/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java
@@ -0,0 +1,19 @@
+package org.apache.tuscany.sca.binding.erlang.testing;
+
+
+public class ServiceTestComponentImplClone implements ServiceTestComponent {
+
+ public String sayHello(String arg1, String arg2) {
+ return "Bye " + arg1 + " " + arg2;
+ }
+
+ public String[] sayHellos() {
+ String[] result = new String[] {"-1", "-2"};
+ return result;
+ }
+
+ public StructuredTuple passComplexArgs(StructuredTuple arg1, String[] arg2) {
+ return arg1;
+ }
+
+}