Skip to content
Snippets Groups Projects
Commit c9363cb2 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4814 rewritten Http ENdpoint test

parent 13506301
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.admin.environment;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import de.ozgcloud.common.test.ITCase;
@ITCase
class MongoConfigServerITCase {
private final String APPNAME = "testapp";
private final String PROFILE = "testprofile";
private final String LABEL = "testlabel";
private MockMvc mockMvc;
@BeforeEach
void setup(WebApplicationContext context) {
mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
}
@Test
void shouldHaveHttpEndpoint() throws Exception {
mockMvc.perform(get("/" + APPNAME + "/" + PROFILE + "/" + LABEL))
.andExpect(status().isOk());
}
}
package de.ozgcloud.admin.environment;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import de.ozgcloud.admin.AdministrationApplication;
@SpringBootTest(classes = AdministrationApplication.class, webEnvironment = WebEnvironment.DEFINED_PORT)
class MongoConfigServerTest {
private final String APPNAME = "testapp";
private final String PROFILE = "testprofile";
private final String LABEL = "testlabel";
@LocalServerPort
private int port;
@Test
void shouldHaveHttpEndpoint() {
ResponseEntity<Environment> response = new TestRestTemplate().getForEntity("http://localhost:"
+ port + "/" + APPNAME + "/" + PROFILE + "/" + LABEL, Environment.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment