m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java
blob: 6ab10d6b688b03faf5c3e3c888000770eb16f183 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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.util.Set;

import java.rmi.registry.LocateRegistry;
import java.rmi.RemoteException;
import java.rmi.registry.Registry;
import java.math.BigDecimal;

import pl.edu.mimuw.cloudatlas.api.Api;

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(2000);
        agentProcess = Runtime.getRuntime().exec("./gradlew runAgent");
        Thread.sleep(5000);
    }

    @AfterClass
    public static void killProcesses() throws Exception {
        try {
            registryProcess.destroy();
            agentProcess.destroy();
        } catch (Exception e) {
            System.out.println("Caught exception: " + e);
        }
    }

    @Test
    public void testGetZoneSet() {
		try {
			Registry registry = LocateRegistry.getRegistry("localhost");
			Api api = (Api) registry.lookup("Api");
			Set<String> set = api.getZoneSet();
            assertEquals(null, set);
		} catch (Exception e) {
			e.printStackTrace();
            assertTrue(false);
		}
    }
}