definierten Werte lesen
Code: Select all
.bashrc
Code: Select all
# Obviously I setted the values, are empty just to show you
export DB_URL_TEST=""
export DB_USERNAME_TEST=""
export DB_PASSWORD_TEST=""
< /code>
/test/resources/application-test.yml
Code: Select all
spring:
datasource:
url: "${DB_URL_TEST}"
username: "${DB_USERNAME_TEST}"
password: "${DB_PASSWORD_TEST}"
driver-class-name: org.mariadb.jdbc.Driver
< /code>
The test in question:
// It's in development, it's I have
package com.latteIceCream.latte;
import org.junit.jupiter.api.Test;
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.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("test")
public class FlavorCRUDTest {
@Autowired
MockMvc mockMvc;
@Test
public void flavorRequest() throws Exception
{
mockMvc.perform
(
MockMvcRequestBuilders.post("/flavor/{name}")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isCreated())
.andExpect
(MockMvcResultMatchers.content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)
);
}
}