m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2019-12-25 14:33:59 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2019-12-25 14:34:26 +0100
commitb807c4ea723736f07bd25cec86908854679fda0e (patch)
tree1773236d3ca56a0d55975956d9f07f2fdf06a961 /src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java
parent063314bab3d9c67e3497e475d46c15783e1c0d97 (diff)
Add client GET tests
Diffstat (limited to 'src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java
new file mode 100644
index 0000000..750e2cb
--- /dev/null
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java
@@ -0,0 +1,70 @@
+package pl.edu.mimuw.cloudatlas.client;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.test.context.junit4.SpringRunner;
+import pl.edu.mimuw.cloudatlas.api.Api;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+import static org.junit.Assert.assertThat;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class ClientTest {
+ private static Process registryProcess;
+ private static Process agentProcess;
+ private static Process clientProcess;
+
+ private static Registry registry;
+ private static Api api;
+
+ @BeforeClass
+ public static void bindApi() throws Exception {
+ registryProcess = Runtime.getRuntime().exec("./scripts/registry");
+ Thread.sleep(10000);
+ agentProcess = Runtime.getRuntime().exec("./gradlew runAgent -Dhostname=localhost");
+ Thread.sleep(10000);
+
+ registry = LocateRegistry.getRegistry("localhost");
+ api = (Api) registry.lookup("Api");
+ }
+
+ @AfterClass
+ public static void killProcesses() throws Exception {
+ try {
+ registryProcess.destroy();
+ agentProcess.destroy();
+ } catch (Exception e) {
+ System.out.println("Caught exception: " + e);
+ }
+ }
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Test
+ public void homeMessageCheck() throws Exception {
+ Thread.sleep(100);
+ String response = this.restTemplate.getForObject("http://localhost:" + port + "/", String.class);
+ assertThat(response, CoreMatchers.containsString("Welcome to CloudaAtlas client interface"));
+ }
+
+ @Test
+ public void attributeValuesMessageCheck() throws Exception {
+ Thread.sleep(100);
+ String response = this.restTemplate.getForObject("http://localhost:" + port + "/values", String.class);
+ assertThat(response, CoreMatchers.containsString("Attribute values"));
+ }
+}