m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-14 19:13:32 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-14 19:13:32 +0100
commit4708ba199166d777d0b60879398a8e000f7aaf56 (patch)
tree130fdf9aa0a83869138866cd64658f6cf1ebb6dd /src/test/java/pl/edu/mimuw
parenta014f22d8c8c5c15aa08500a02da0d0717d62b64 (diff)
Setup simple api
Diffstat (limited to 'src/test/java/pl/edu/mimuw')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java
new file mode 100644
index 0000000..a185649
--- /dev/null
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java
@@ -0,0 +1,50 @@
+package pl.edu.mimuw.cloudatlas.agent;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.lang.Runtime;
+import java.lang.Process;
+import java.lang.Thread;
+
+import java.io.InputStream;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+import java.math.BigDecimal;
+
+public class AgentTest {
+ private static Process registryProcess;
+ private static Process agentProcess;
+
+ @BeforeClass
+ public static void bindApi() throws Exception {
+ registryProcess = Runtime.getRuntime().exec("./scripts/registry");
+ Thread.sleep(1000);
+ agentProcess = Runtime.getRuntime().exec("./gradlew runAgent");
+ Thread.sleep(1000);
+ }
+
+ @AfterClass
+ public static void killProcesses() throws Exception {
+ registryProcess.destroy();
+ agentProcess.destroy();
+ }
+
+ @Test
+ public void testPing() {
+ try {
+ Registry registry = LocateRegistry.getRegistry("localhost");
+ Api api = (Api) registry.lookup("Api");
+ int res = api.ping(10);
+ assertEquals(11, res);
+ } catch (Exception e) {
+ System.err.println("FibonacciClient exception:");
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+}