Commit 4bc9d3a9 by Johannes Edmeier

Fix compilation errors in tests

parent df8b1e43
......@@ -6,7 +6,6 @@ import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.util.Collections;
import org.json.JSONObject;
......@@ -20,7 +19,7 @@ public class ApplicationTest {
private ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
@Test
public void test_1_2_json_format() throws JsonProcessingException, IOException {
public void test_1_2_json_format() throws Exception {
String json = new JSONObject().put("name", "test").put("url", "http://test").toString();
Application value = objectMapper.readValue(json, Application.class);
assertThat(value.getName(), is("test"));
......@@ -30,7 +29,7 @@ public class ApplicationTest {
}
@Test
public void test_1_4_json_format() throws JsonProcessingException, IOException {
public void test_1_4_json_format() throws Exception {
String json = new JSONObject().put("name", "test").put("managementUrl", "http://test")
.put("healthUrl", "http://health").put("serviceUrl", "http://service")
.put("statusInfo", new JSONObject().put("status", "UNKNOWN")).toString();
......@@ -42,7 +41,7 @@ public class ApplicationTest {
}
@Test
public void test_1_5_json_format() throws JsonProcessingException, IOException {
public void test_1_5_json_format() throws Exception {
String json = new JSONObject().put("name", "test").put("managementUrl", "http://test")
.put("healthUrl", "http://health").put("serviceUrl", "http://service")
.put("metadata", new JSONObject().put("labels", "foo,bar")).toString();
......@@ -55,7 +54,7 @@ public class ApplicationTest {
}
@Test
public void test_onlyHealthUrl() throws JsonProcessingException, IOException {
public void test_onlyHealthUrl() throws Exception {
String json = new JSONObject().put("name", "test").put("healthUrl", "http://test")
.toString();
Application value = objectMapper.readValue(json, Application.class);
......@@ -66,14 +65,14 @@ public class ApplicationTest {
}
@Test(expected = IllegalArgumentException.class)
public void test_name_expected() throws JsonProcessingException, IOException {
public void test_name_expected() throws Exception {
String json = new JSONObject().put("name", "").put("managementUrl", "http://test")
.put("healthUrl", "http://health").put("serviceUrl", "http://service").toString();
objectMapper.readValue(json, Application.class);
}
@Test(expected = IllegalArgumentException.class)
public void test_healthUrl_expected() throws JsonProcessingException, IOException {
public void test_healthUrl_expected() throws Exception {
String json = new JSONObject().put("name", "test").put("managementUrl", "http://test")
.put("healthUrl", "").put("serviceUrl", "http://service").toString();
objectMapper.readValue(json, Application.class);
......
......@@ -23,6 +23,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.io.UnsupportedEncodingException;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
......@@ -41,10 +42,20 @@ import de.codecentric.boot.admin.registry.store.SimpleApplicationStore;
public class RegistryControllerTest {
private static final String APPLICATION_TEST_JSON = new JSONObject().put("name", "test")
.put("healthUrl", "http://localhost/mgmt/health").toString();
private static final String APPLICATION_TWICE_JSON = new JSONObject().put("name", "twice")
.put("healthUrl", "http://localhost/mgmt/health").toString();
private static final String APPLICATION_TEST_JSON;
private static final String APPLICATION_TWICE_JSON;
static {
try {
APPLICATION_TEST_JSON = new JSONObject().put("name", "test")
.put("healthUrl", "http://localhost/mgmt/health").toString();
APPLICATION_TWICE_JSON = new JSONObject().put("name", "twice")
.put("healthUrl", "http://localhost/mgmt/health").toString();
} catch (JSONException ex) {
throw new ExceptionInInitializerError(ex);
}
}
private MockMvc mvc;
@Before
......@@ -87,7 +98,6 @@ public class RegistryControllerTest {
mvc.perform(get("/api/applications/{id}", id)).andExpect(status().isNotFound());
}
private String extractId(MvcResult result) throws UnsupportedEncodingException {
return JsonPath.compile("$.id").read(result.getResponse().getContentAsString());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment