java-pkmst.integration.integrationtest.mustache Maven / Gradle / Ivy
package {{basePackage}}.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import {{basePackage}}.{{serviceName}}Application;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {{serviceName}}Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class {{serviceName}}IT {
@LocalServerPort
private int port;
TestRestTemplate restTemplate = new TestRestTemplate();
HttpHeaders headers = new HttpHeaders();
@Test
public void testYourMethod() {
//add your logic
}
private String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}
}