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 16:04:58 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2019-12-25 16:04:58 +0100
commitf51288ab6ac7b968be99a19784cd9c8de068f18c (patch)
tree1db8718f5e53d981249e34a9c97a4cdef26350c1 /src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java
parentcafcc4242fe6b6bc72a65b1012527fb1c0ebb3e5 (diff)
Extend client 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.java66
1 files changed, 62 insertions, 4 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
index 13b9fd7..431122b 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/client/ClientTest.java
@@ -6,18 +6,24 @@ 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.autoconfigure.web.servlet.AutoConfigureMockMvc;
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.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
import pl.edu.mimuw.cloudatlas.api.Api;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import static org.junit.Assert.assertThat;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
@RunWith(SpringRunner.class)
+@AutoConfigureMockMvc
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ClientTest {
private static Process registryProcess;
@@ -52,6 +58,9 @@ public class ClientTest {
private int port;
@Autowired
+ private MockMvc mvc;
+
+ @Autowired
private TestRestTemplate restTemplate;
@Test
@@ -68,21 +77,70 @@ public class ClientTest {
@Test
public void queryInstallationCheck() throws Exception {
- // TODO
+ this.mvc.perform(post("/installQuery")
+ .param("name", "&sampleQuery")
+ .param("value", "SELECT 1 AS one"))
+ .andExpect(status().isOk()).andExpect(content()
+ .contentType("text/html;charset=UTF-8"))
+ .andExpect(content().string(CoreMatchers.containsString("Query installed successfully")));
}
@Test
public void queryUninstallationCheck() throws Exception {
- // TODO
+ this.mvc.perform(post("/installQuery")
+ .param("name", "&sampleQuery")
+ .param("value", "SELECT 1 AS one"))
+ .andExpect(status().isOk()).andExpect(content()
+ .contentType("text/html;charset=UTF-8"))
+ .andExpect(content().string(CoreMatchers.containsString("Query installed successfully")));
+
+ this.mvc.perform(post("/uninstallQuery")
+ .param("name", "&sampleQuery"))
+ .andExpect(status().isOk()).andExpect(content()
+ .contentType("text/html;charset=UTF-8"))
+ .andExpect(content().string(CoreMatchers.containsString("Query uninstalled successfully")));
+ }
+
+ @Test
+ public void attributeInstallationCheck() throws Exception {
+ this.mvc.perform(post("/attribs")
+ .param("zoneName", "/")
+ .param("attributeName", "a")
+ .param("attributeType", "Int")
+ .param("valueString", "1"))
+ .andExpect(status().isOk()).andExpect(content()
+ .contentType("text/html;charset=UTF-8"))
+ .andExpect(content().string(CoreMatchers.containsString("Attribute submitted successfully")));
+ }
+
+ @Test
+ public void complexAttributeInstallationCheck() throws Exception {
+ this.mvc.perform(post("/attribs")
+ .param("zoneName", "/")
+ .param("attributeName", "a")
+ .param("attributeType", "List")
+ .param("attributeComplexType", "List, Set, Int")
+ .param("valueString", "[[1]]"))
+ .andExpect(status().isOk())
+ .andExpect(content().contentType("text/html;charset=UTF-8"))
+ .andExpect(content().string(CoreMatchers.containsString("Attribute submitted successfully")));
}
@Test
public void numericalRESTApiCheck() throws Exception {
- // TODO
+ Thread.sleep(10000);
+ this.mvc.perform(get("/attribNumValues")
+ .accept(MediaType.TEXT_PLAIN))
+ .andExpect(status().isOk())
+ .andExpect(content().string(CoreMatchers.containsString("num_processes")));
}
@Test
public void allValuesRESTApiCheck() throws Exception {
- // TODO
+ Thread.sleep(10000);
+ mvc.perform(get("/attribAllValues")
+ .accept(MediaType.TEXT_PLAIN))
+ .andExpect(status().isOk())
+ .andExpect(content().string(CoreMatchers.containsString("contacts")));
}
}