Browse Source

Fix RxNetty tests by finding a new port for each test

pull/1111/head
Sebastien Deleuze 11 years ago
parent
commit
77c5b3fd65
  1. 41
      spring-web-reactive/src/test/java/org/springframework/reactive/web/dispatch/method/annotation/RequestMappingIntegrationTests.java
  2. 5
      spring-web-reactive/src/test/java/org/springframework/reactive/web/http/AbstractHttpHandlerIntegrationTests.java
  3. 1
      spring-web-reactive/src/test/java/org/springframework/reactive/web/http/EchoHandlerIntegrationTests.java

41
spring-web-reactive/src/test/java/org/springframework/reactive/web/dispatch/method/annotation/RequestMappingIntegrationTests.java

@ -150,10 +150,25 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati @@ -150,10 +150,25 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati
}
@Test
public void capitalize() throws Exception {
public void publisherCapitalize() throws Exception {
capitalize("http://localhost:" + port + "/publisher-capitalize");
}
@Test
public void observableCapitalize() throws Exception {
capitalize("http://localhost:" + port + "/observable-capitalize");
}
@Test
public void streamCapitalize() throws Exception {
capitalize("http://localhost:" + port + "/stream-capitalize");
}
public void capitalize(String requestUrl) throws Exception {
RestTemplate restTemplate = new RestTemplate();
URI url = new URI("http://localhost:" + port + "/capitalize");
URI url = new URI(requestUrl);
List<Person> persons = Arrays.asList(new Person("Robert"), new Person("Marie"));
RequestEntity<List<Person>> request = RequestEntity
.post(url)
@ -208,9 +223,27 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati @@ -208,9 +223,27 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati
return Streams.just(new Person("Robert"), new Person("Marie"));
}
@RequestMapping("/capitalize")
@RequestMapping("/publisher-capitalize")
@ResponseBody
public Publisher<Person> publisherCapitalize(@RequestBody Publisher<Person> persons) {
return Streams.wrap(persons).map(person -> {
person.setName(person.getName().toUpperCase());
return person;
});
}
@RequestMapping("/observable-capitalize")
@ResponseBody
public Observable<Person> observableCapitalize(@RequestBody Observable<Person> persons) {
return persons.map(person -> {
person.setName(person.getName().toUpperCase());
return person;
});
}
@RequestMapping("/stream-capitalize")
@ResponseBody
public Observable<Person> capitalize(@RequestBody Observable<Person> persons) {
public Stream<Person> streamCapitalize(@RequestBody Stream<Person> persons) {
return persons.map(person -> {
person.setName(person.getName().toUpperCase());
return person;

5
spring-web-reactive/src/test/java/org/springframework/reactive/web/http/AbstractHttpHandlerIntegrationTests.java

@ -27,7 +27,7 @@ import org.springframework.util.SocketUtils; @@ -27,7 +27,7 @@ import org.springframework.util.SocketUtils;
@RunWith(Parameterized.class)
public abstract class AbstractHttpHandlerIntegrationTests {
protected static int port = SocketUtils.findAvailableTcpPort();
protected int port;
@Parameterized.Parameter(0)
public HttpServer server;
@ -45,7 +45,8 @@ public abstract class AbstractHttpHandlerIntegrationTests { @@ -45,7 +45,8 @@ public abstract class AbstractHttpHandlerIntegrationTests {
@Before
public void setup() throws Exception {
this.server.setPort(port);
this.port = SocketUtils.findAvailableTcpPort();
this.server.setPort(this.port);
this.server.setHandler(createHttpHandler());
this.server.afterPropertiesSet();
this.server.start();

1
spring-web-reactive/src/test/java/org/springframework/reactive/web/http/EchoHandlerIntegrationTests.java

@ -44,7 +44,6 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT @@ -44,7 +44,6 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT
@Test
@Ignore
public void echoBytes() throws Exception {
RestTemplate restTemplate = new RestTemplate();

Loading…
Cancel
Save