Polish Jersey integration tests
This commit is contained in:
parent
c752fac5c0
commit
54bea72554
|
@ -30,22 +30,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterContextPathTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterContextPathTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -58,20 +56,17 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest({ "server.port=0", "spring.jersey.type=filter",
|
@WebIntegrationTest(randomPort = true, value = {"spring.jersey.type=filter",
|
||||||
"server.contextPath=/app" })
|
"server.contextPath=/app" })
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationCustomFilterContextPathTests {
|
public class JerseyAutoConfigurationCustomFilterContextPathTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
||||||
"http://localhost:" + this.port + "/app/rest/hello", String.class);
|
"/app/rest/hello", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,22 +30,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterPathTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomFilterPathTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -58,19 +56,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest({ "server.port=0", "spring.jersey.type=filter" })
|
@WebIntegrationTest(randomPort = true, value = "spring.jersey.type=filter")
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationCustomFilterPathTests {
|
public class JerseyAutoConfigurationCustomFilterPathTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
||||||
"http://localhost:" + this.port + "/rest/hello", String.class);
|
"/rest/hello", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,22 +30,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -58,19 +56,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest({ "server.port=0", "spring.jackson.serialization-inclusion=non_null" })
|
@WebIntegrationTest(randomPort = true, value = "spring.jackson.serialization-inclusion=non_null")
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationCustomObjectMapperProviderTests {
|
public class JerseyAutoConfigurationCustomObjectMapperProviderTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> response = this.restTemplate.getForEntity(
|
ResponseEntity<String> response = this.restTemplate.getForEntity(
|
||||||
"http://localhost:" + this.port + "/rest/message", String.class);
|
"/rest/message", String.class);
|
||||||
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
|
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
|
||||||
assertThat("{\"subject\":\"Jersey\"}").isEqualTo(response.getBody());
|
assertThat("{\"subject\":\"Jersey\"}").isEqualTo(response.getBody());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,22 +30,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletContextPathTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletContextPathTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -58,19 +56,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest({ "server.port=0", "server.contextPath=/app" })
|
@WebIntegrationTest(randomPort = true, value = "server.contextPath=/app")
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationCustomServletContextPathTests {
|
public class JerseyAutoConfigurationCustomServletContextPathTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
||||||
"http://localhost:" + this.port + "/app/rest/hello", String.class);
|
"/app/rest/hello", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,22 +30,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -58,19 +56,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest("server.port=0")
|
@WebIntegrationTest(randomPort = true)
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationCustomServletPathTests {
|
public class JerseyAutoConfigurationCustomServletPathTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
||||||
"http://localhost:" + this.port + "/rest/hello", String.class);
|
"/rest/hello", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,22 +29,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultFilterPathTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultFilterPathTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -57,19 +55,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest({ "server.port=0", "spring.jersey.type=filter" })
|
@WebIntegrationTest(randomPort = true, value = "spring.jersey.type=filter")
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationDefaultFilterPathTests {
|
public class JerseyAutoConfigurationDefaultFilterPathTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> entity = this.restTemplate
|
ResponseEntity<String> entity = this.restTemplate
|
||||||
.getForEntity("http://localhost:" + this.port + "/hello", String.class);
|
.getForEntity("/hello", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,22 +29,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultServletPathTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationDefaultServletPathTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -57,19 +55,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest("server.port=0")
|
@WebIntegrationTest(randomPort = true)
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationDefaultServletPathTests {
|
public class JerseyAutoConfigurationDefaultServletPathTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> entity = this.restTemplate
|
ResponseEntity<String> entity = this.restTemplate
|
||||||
.getForEntity("http://localhost:" + this.port + "/hello", String.class);
|
.getForEntity("/hello", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,22 +30,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationObjectMapperProviderTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -58,19 +56,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest("server.port=0")
|
@WebIntegrationTest(randomPort = true)
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationObjectMapperProviderTests {
|
public class JerseyAutoConfigurationObjectMapperProviderTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> response = this.restTemplate.getForEntity(
|
ResponseEntity<String> response = this.restTemplate.getForEntity(
|
||||||
"http://localhost:" + this.port + "/rest/message", String.class);
|
"/rest/message", String.class);
|
||||||
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
|
assertThat(HttpStatus.OK).isEqualTo(response.getStatusCode());
|
||||||
assertThat("{\"subject\":\"Jersey\",\"body\":null}")
|
assertThat("{\"subject\":\"Jersey\",\"body\":null}")
|
||||||
.isEqualTo(response.getBody());
|
.isEqualTo(response.getBody());
|
||||||
|
|
|
@ -34,16 +34,14 @@ import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServ
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.boot.test.rule.OutputCapture;
|
import org.springframework.boot.test.rule.OutputCapture;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@ -56,16 +54,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest("server.port=0")
|
@WebIntegrationTest(randomPort = true)
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationServletContainerTests {
|
public class JerseyAutoConfigurationServletContainerTests {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static OutputCapture output = new OutputCapture();
|
public static OutputCapture output = new OutputCapture();
|
||||||
|
|
||||||
@LocalServerPort
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void existingJerseyServletIsAmended() {
|
public void existingJerseyServletIsAmended() {
|
||||||
assertThat(output.toString())
|
assertThat(output.toString())
|
||||||
|
|
|
@ -29,22 +29,20 @@ import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationCustomServletPathTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
|
||||||
import org.springframework.boot.context.web.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.IntegrationTest;
|
|
||||||
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
import org.springframework.boot.test.context.SpringApplicationConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.context.web.WebIntegrationTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -57,19 +55,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DirtiesContext
|
@DirtiesContext
|
||||||
@SpringApplicationConfiguration(Application.class)
|
@SpringApplicationConfiguration(Application.class)
|
||||||
@IntegrationTest({ "server.port=0", "spring.jersey.application-path=/api" })
|
@WebIntegrationTest(randomPort = true, value = "spring.jersey.application-path=/api")
|
||||||
@WebAppConfiguration
|
|
||||||
public class JerseyAutoConfigurationWithoutApplicationPathTests {
|
public class JerseyAutoConfigurationWithoutApplicationPathTests {
|
||||||
|
|
||||||
@LocalServerPort
|
@Autowired
|
||||||
private int port;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
private RestTemplate restTemplate = new TestRestTemplate();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
ResponseEntity<String> entity = this.restTemplate.getForEntity(
|
||||||
"http://localhost:" + this.port + "/api/hello", String.class);
|
"/api/hello", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue