Skip to content
This repository was archived by the owner on Mar 13, 2021. It is now read-only.

Commit 45fc0c4

Browse files
Dave Syertrisberg
authored andcommitted
Upgrade next and simple it sample (upgrade to SCF 2.0)
1 parent c5c4654 commit 45fc0c4

5 files changed

Lines changed: 41 additions & 21 deletions

File tree

src/it/next/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<properties>
2121
<java.version>1.8</java.version>
22-
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
22+
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
2323
</properties>
2424

2525
<dependencies>

src/it/next/src/test/java/com/example/SampleApplicationTests.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
*/
1616
package com.example;
1717

18+
import org.junit.Before;
1819
import org.junit.Test;
1920
import org.junit.runner.RunWith;
2021

21-
import org.springframework.boot.web.server.LocalServerPort;
2222
import org.springframework.boot.test.context.SpringBootTest;
2323
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2424
import org.springframework.boot.test.web.client.TestRestTemplate;
25+
import org.springframework.boot.web.server.LocalServerPort;
26+
import org.springframework.http.HttpEntity;
27+
import org.springframework.http.HttpHeaders;
28+
import org.springframework.http.MediaType;
2529
import org.springframework.test.context.junit4.SpringRunner;
2630

2731
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,29 +38,36 @@
3438
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
3539
public class SampleApplicationTests {
3640

41+
private HttpHeaders headers;
42+
3743
@LocalServerPort
3844
private int port;
45+
private TestRestTemplate rest = new TestRestTemplate();
46+
47+
@Before
48+
public void before() {
49+
headers = new HttpHeaders();
50+
headers.setContentType(MediaType.APPLICATION_JSON);
51+
}
3952

4053
@Test
4154
public void words() {
42-
assertThat(new TestRestTemplate()
43-
.getForObject("http://localhost:" + port + "/words", String.class))
44-
.isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
55+
assertThat(rest.getForObject("http://localhost:" + port + "/words", String.class))
56+
.isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
4557
}
4658

4759
@Test
4860
public void uppercase() {
49-
// TODO: make this work with a JSON stream as well (like in WebFlux)
50-
assertThat(new TestRestTemplate().postForObject(
51-
"http://localhost:" + port + "/uppercase", "[{\"value\":\"foo\"}]",
52-
String.class)).isEqualTo("[{\"value\":\"FOO\"}]");
61+
assertThat(rest.postForObject("http://localhost:" + port + "/uppercase",
62+
new HttpEntity<>("[{\"value\":\"foo\"}]", headers), String.class))
63+
.isEqualTo("[{\"value\":\"FOO\"}]");
5364
}
5465

5566
@Test
5667
public void lowercase() {
57-
assertThat(new TestRestTemplate().postForObject(
58-
"http://localhost:" + port + "/lowercase", "[{\"value\":\"Foo\"}]",
59-
String.class)).isEqualTo("[{\"value\":\"foo\"}]");
68+
assertThat(rest.postForObject("http://localhost:" + port + "/lowercase",
69+
new HttpEntity<>("[{\"value\":\"Foo\"}]", headers), String.class))
70+
.isEqualTo("[{\"value\":\"foo\"}]");
6071
}
6172

6273
}

src/it/simple/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<properties>
2121
<java.version>11</java.version>
22-
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
22+
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
2323
</properties>
2424

2525
<dependencies>

src/it/simple/src/main/java/com/example/SampleApplication.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616
package com.example;
1717

1818
import java.util.function.Function;
19-
import java.util.function.Supplier;
2019

2120
import org.springframework.boot.SpringApplication;
2221
import org.springframework.boot.autoconfigure.SpringBootApplication;
2322
import org.springframework.context.annotation.Bean;
2423

25-
import reactor.core.publisher.Flux;
26-
2724
@SpringBootApplication
2825
public class SampleApplication {
2926

src/it/simple/src/test/java/com/example/SampleApplicationTests.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
*/
1616
package com.example;
1717

18+
import org.junit.Before;
1819
import org.junit.Test;
1920
import org.junit.runner.RunWith;
2021

21-
import org.springframework.boot.web.server.LocalServerPort;
2222
import org.springframework.boot.test.context.SpringBootTest;
2323
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2424
import org.springframework.boot.test.web.client.TestRestTemplate;
25+
import org.springframework.boot.web.server.LocalServerPort;
26+
import org.springframework.http.HttpEntity;
27+
import org.springframework.http.HttpHeaders;
28+
import org.springframework.http.MediaType;
2529
import org.springframework.test.context.junit4.SpringRunner;
2630

2731
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,15 +38,23 @@
3438
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
3539
public class SampleApplicationTests {
3640

41+
private HttpHeaders headers;
42+
3743
@LocalServerPort
3844
private int port;
45+
private TestRestTemplate rest = new TestRestTemplate();
46+
47+
@Before
48+
public void before() {
49+
headers = new HttpHeaders();
50+
headers.setContentType(MediaType.APPLICATION_JSON);
51+
}
3952

4053
@Test
4154
public void uppercase() {
42-
// TODO: make this work with a JSON stream as well (like in WebFlux)
43-
assertThat(new TestRestTemplate().postForObject(
44-
"http://localhost:" + port + "/", "[{\"value\":\"foo\"}]",
45-
String.class)).isEqualTo("[{\"value\":\"FOO\"}]");
55+
assertThat(rest.postForObject("http://localhost:" + port + "/uppercase",
56+
new HttpEntity<>("[{\"value\":\"foo\"}]", headers), String.class))
57+
.isEqualTo("[{\"value\":\"FOO\"}]");
4658
}
4759

4860
}

0 commit comments

Comments
 (0)