Skip to content

Commit 30678bc

Browse files
committed
Upgrade to Spring Boot 2.4.0
1 parent d4b0e05 commit 30678bc

File tree

12 files changed

+98
-271
lines changed

12 files changed

+98
-271
lines changed

pom.xml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.kafkastream</groupId>
77
<artifactId>kafkastream</artifactId>
8-
<version>1.5</version>
8+
<version>1.6</version>
99
<packaging>jar</packaging>
1010

1111
<name>KafkaStream</name>
@@ -14,26 +14,26 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>2.3.1.RELEASE</version>
17+
<version>2.4.0</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

2121
<properties>
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24-
<java.version>1.8</java.version>
25-
<spring-cloud.version>Hoxton.SR5</spring-cloud.version>
26-
<avro.version>1.9.2</avro.version>
24+
<java.version>11</java.version>
25+
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
26+
<avro.version>1.10.0</avro.version>
2727
<kafka.version>2.1.0</kafka.version>
28-
<confluent.version>5.4.0</confluent.version>
28+
<confluent.version>6.0.0</confluent.version>
2929
<javax.ws.rs-api.version>2.1.1</javax.ws.rs-api.version>
3030
</properties>
3131

3232
<dependencies>
3333
<!-- Spring Dependencies-->
3434
<dependency>
3535
<groupId>org.springframework.boot</groupId>
36-
<artifactId>spring-boot-actuator</artifactId>
36+
<artifactId>spring-boot-starter-actuator</artifactId>
3737
</dependency>
3838
<dependency>
3939
<groupId>org.springframework.boot</groupId>
@@ -66,11 +66,7 @@
6666
<artifactId>kafka-streams-avro-serde</artifactId>
6767
<version>${confluent.version}</version>
6868
</dependency>
69-
<dependency>
70-
<groupId>org.apache.kafka</groupId>
71-
<artifactId>kafka_2.12</artifactId>
72-
<version>${kafka.version}</version>
73-
</dependency>
69+
7470
<dependency>
7571
<groupId>org.apache.avro</groupId>
7672
<artifactId>avro</artifactId>
@@ -87,18 +83,15 @@
8783
<dependency>
8884
<groupId>org.eclipse.jetty</groupId>
8985
<artifactId>jetty-server</artifactId>
90-
<version>9.4.35.v20201120</version>
9186
</dependency>
9287
<dependency>
9388
<groupId>org.eclipse.jetty</groupId>
9489
<artifactId>jetty-servlet</artifactId>
95-
<version>9.4.26.v20200117</version>
9690
</dependency>
9791

9892
<dependency>
9993
<groupId>org.glassfish.jersey.inject</groupId>
10094
<artifactId>jersey-hk2</artifactId>
101-
<version>2.29.1</version>
10295
</dependency>
10396
<dependency>
10497
<groupId>org.glassfish.jersey.containers</groupId>
@@ -116,12 +109,16 @@
116109
<optional>true</optional>
117110
</dependency>
118111

119-
120112
<dependency>
121113
<groupId>org.springframework.boot</groupId>
122114
<artifactId>spring-boot-starter-test</artifactId>
123115
<scope>test</scope>
124116
</dependency>
117+
<dependency>
118+
<groupId>org.junit.jupiter</groupId>
119+
<artifactId>junit-jupiter</artifactId>
120+
<version>5.6.3</version>
121+
</dependency>
125122
<dependency>
126123
<groupId>org.springframework.cloud</groupId>
127124
<artifactId>spring-cloud-stream-test-support</artifactId>
@@ -131,7 +128,6 @@
131128
<groupId>com.h2database</groupId>
132129
<artifactId>h2</artifactId>
133130
<scope>test</scope>
134-
<version>1.4.194</version>
135131
</dependency>
136132

137133
</dependencies>

src/main/java/com/kafkastream/events/EventsSender.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.kafkastream.model.Customer;
55
import com.kafkastream.model.Greetings;
66
import com.kafkastream.model.Order;
7-
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig;
7+
import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig;
88
import io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde;
99
import io.confluent.kafka.streams.serdes.avro.SpecificAvroSerializer;
1010
import org.apache.avro.specific.SpecificRecord;
@@ -27,7 +27,7 @@
2727
@Service
2828
public class EventsSender
2929
{
30-
private Properties properties;
30+
private final Properties properties;
3131
private static final Logger logger= LoggerFactory.getLogger(EventsSender.class);
3232

3333
public EventsSender()
@@ -75,7 +75,7 @@ public void sendGreetingsEvent(Greetings greetings) throws ExecutionException, I
7575
private static <VT extends SpecificRecord> SpecificAvroSerde<VT> createSerde()
7676
{
7777
final SpecificAvroSerde<VT> serde = new SpecificAvroSerde<>();
78-
final Map<String, String> serdeConfig = Collections.singletonMap(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, KafkaConstants.SCHEMA_REGISTRY_URL);
78+
final Map<String, String> serdeConfig = Collections.singletonMap(AbstractKafkaSchemaSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, KafkaConstants.SCHEMA_REGISTRY_URL);
7979
serde.configure(serdeConfig, false);
8080
return serde;
8181
}

src/main/java/com/kafkastream/service/CustomRestTemplateService.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,37 @@ public CustomRestTemplateService(RestTemplate restTemplate)
3131
public List<Customer> getAllCustomers()
3232
{
3333
ResponseEntity<List<Customer>> response=restTemplate.exchange(REST_PROXY_HOST+":"+REST_PROXY_PORT+"/store/customers",
34-
HttpMethod.GET,null, new ParameterizedTypeReference<List<Customer>>(){});
34+
HttpMethod.GET,null, new ParameterizedTypeReference<>()
35+
{
36+
});
3537
return response.getBody();
3638
}
3739

3840
public List<Order> getAllOrders()
3941
{
4042
ResponseEntity<List<Order>> response=restTemplate.exchange(REST_PROXY_HOST+":"+REST_PROXY_PORT+"/store/orders",
41-
HttpMethod.GET,null, new ParameterizedTypeReference<List<Order>>(){});
43+
HttpMethod.GET,null, new ParameterizedTypeReference<>()
44+
{
45+
});
4246
return response.getBody();
4347
}
4448

4549
public List<Greetings> getAllGreetings()
4650
{
4751
ResponseEntity<List<Greetings>> response=restTemplate.exchange(REST_PROXY_HOST+":"+REST_PROXY_PORT+"/store/greetings",
48-
HttpMethod.GET,null, new ParameterizedTypeReference<List<Greetings>>(){});
52+
HttpMethod.GET,null, new ParameterizedTypeReference<>()
53+
{
54+
});
4955
return response.getBody();
5056
}
5157

5258
public List<CustomerOrder> getAllCustomersOrders()
5359
{
5460
ResponseEntity<List<CustomerOrder>> response=restTemplate.exchange(REST_PROXY_HOST+":"+REST_PROXY_PORT+"/store/customer" +
5561
"-order/all",
56-
HttpMethod.GET,null, new ParameterizedTypeReference<List<CustomerOrder>>(){});
62+
HttpMethod.GET,null, new ParameterizedTypeReference<>()
63+
{
64+
});
5765
return response.getBody();
5866
}
5967
}

src/test/java/com/kafkastream/KafkaStreamApplicationTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.kafkastream;
22

3-
import org.junit.Test;
4-
import org.junit.runner.RunWith;
3+
4+
import org.junit.jupiter.api.Test;
5+
import org.junit.jupiter.api.extension.ExtendWith;
56
import org.springframework.boot.test.context.SpringBootTest;
6-
import org.springframework.test.context.junit4.SpringRunner;
7+
import org.springframework.test.context.junit.jupiter.SpringExtension;
78

8-
@RunWith(SpringRunner.class)
9+
@ExtendWith(SpringExtension.class)
910
@SpringBootTest
1011
public class KafkaStreamApplicationTests {
1112

src/test/java/com/kafkastream/TestConsumer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
import org.apache.kafka.streams.state.ReadOnlyKeyValueStore;
2828
import org.apache.kafka.streams.state.StoreBuilder;
2929
import org.apache.kafka.streams.state.Stores;
30-
import org.junit.Before;
31-
import org.junit.Ignore;
32-
import org.junit.Test;
30+
import org.junit.jupiter.api.BeforeEach;
31+
import org.junit.jupiter.api.Disabled;
32+
import org.junit.jupiter.api.Test;
33+
3334

3435
import java.util.Collections;
3536
import java.util.HashMap;
@@ -43,7 +44,7 @@ public class TestConsumer
4344

4445
private StreamsBuilder streamsBuilder;
4546

46-
@Before
47+
@BeforeEach
4748
public void setUp()
4849
{
4950
this.properties = new Properties();
@@ -371,7 +372,7 @@ public void cleanStateStore()
371372

372373
//Not using this test case
373374
@Test
374-
@Ignore
375+
@Disabled
375376
public void queryCustomerStore()
376377
{
377378
SpecificAvroSerde<Customer> customerSerde = createSerde("http://localhost:8081");

src/test/java/com/kafkastream/TestProducer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import org.apache.kafka.clients.producer.RecordMetadata;
1515
import org.apache.kafka.common.serialization.Serdes;
1616
import org.apache.kafka.streams.StreamsBuilder;
17-
import org.junit.Before;
18-
import org.junit.Test;
17+
import org.junit.jupiter.api.BeforeEach;
18+
import org.junit.jupiter.api.Test;
1919
import org.springframework.beans.factory.annotation.Autowired;
2020

2121
import java.util.Calendar;
@@ -27,7 +27,7 @@
2727
import java.util.concurrent.ExecutionException;
2828
import java.util.concurrent.Future;
2929

30-
public class TestProducer
30+
class TestProducer
3131
{
3232
@Autowired
3333
private EventsSender eventsSender;
@@ -36,8 +36,8 @@ public class TestProducer
3636

3737
private StreamsBuilder streamsBuilder;
3838

39-
@Before
40-
public void setUp()
39+
@BeforeEach
40+
void setUp()
4141
{
4242
//When configuring the default serdes of StreamConfig
4343
properties = new Properties();
@@ -52,7 +52,7 @@ public void setUp()
5252
}
5353

5454
@Test
55-
public void sendCustomer() throws ExecutionException, InterruptedException
55+
void sendCustomer() throws ExecutionException, InterruptedException
5656
{
5757
// When you want to override serdes explicitly/selectively
5858
SpecificAvroSerde<Customer> customerSerde = createSerde("http://localhost:8081");
@@ -73,7 +73,7 @@ public void sendCustomer() throws ExecutionException, InterruptedException
7373
}
7474

7575
@Test
76-
public void sendOrder() throws ExecutionException, InterruptedException
76+
void sendOrder() throws ExecutionException, InterruptedException
7777
{
7878
Random random = new Random(1);
7979

@@ -96,7 +96,7 @@ public void sendOrder() throws ExecutionException, InterruptedException
9696
}
9797

9898
@Test
99-
public void sendCustomerAndOrder() throws ExecutionException, InterruptedException
99+
void sendCustomerAndOrder() throws ExecutionException, InterruptedException
100100
{
101101
// When you want to override serdes explicitly/selectively
102102
SpecificAvroSerde<Customer> customerSerde = createSerde("http://localhost:8081");
Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,52 @@
11
package com.kafkastream.jersey;
22

3+
import lombok.Data;
4+
35
import javax.ws.rs.GET;
46
import javax.ws.rs.Path;
57
import javax.ws.rs.Produces;
68
import javax.ws.rs.QueryParam;
79
import javax.ws.rs.core.MediaType;
810

911
@Path("calculator")
10-
public class Calculator {
11-
@GET
12-
@Path("squareRoot")
13-
@Produces(MediaType.APPLICATION_JSON)
14-
public Result squareRoot(@QueryParam("input") double input){
15-
Result result = new Result("Square Root");
16-
result.setInput(input);
17-
result.setOutput(Math.sqrt(result.getInput()));
18-
return result;
19-
}
20-
21-
@GET
22-
@Path("square")
23-
@Produces(MediaType.APPLICATION_JSON)
24-
public Result square(@QueryParam("input") double input){
25-
Result result = new Result("Square");
26-
result.setInput(input);
27-
result.setOutput(result.getInput()*result.getInput());
28-
return result;
29-
}
30-
31-
static class Result{
32-
double input;
33-
double output;
34-
String action;
35-
36-
public Result(){}
37-
38-
public Result(String action) {
39-
this.action = action;
40-
}
41-
42-
public String getAction() {
43-
return action;
44-
}
45-
46-
public void setAction(String action) {
47-
this.action = action;
48-
}
49-
50-
public double getInput() {
51-
return input;
52-
}
53-
54-
public void setInput(double input) {
55-
this.input = input;
56-
}
57-
58-
public double getOutput() {
59-
return output;
60-
}
61-
62-
public void setOutput(double output) {
63-
this.output = output;
64-
}
65-
}
12+
public class Calculator
13+
{
14+
@GET
15+
@Path("squareRoot")
16+
@Produces(MediaType.APPLICATION_JSON)
17+
public Result squareRoot(@QueryParam("input") double input)
18+
{
19+
Result result = new Result("Square Root");
20+
result.setInput(input);
21+
result.setOutput(Math.sqrt(result.getInput()));
22+
return result;
23+
}
24+
25+
@GET
26+
@Path("square")
27+
@Produces(MediaType.APPLICATION_JSON)
28+
public Result square(@QueryParam("input") double input)
29+
{
30+
Result result = new Result("Square");
31+
result.setInput(input);
32+
result.setOutput(result.getInput() * result.getInput());
33+
return result;
34+
}
35+
36+
@Data
37+
static class Result
38+
{
39+
double input;
40+
double output;
41+
String action;
42+
43+
public Result()
44+
{
45+
}
46+
47+
public Result(String action)
48+
{
49+
this.action = action;
50+
}
51+
}
6652
}

0 commit comments

Comments
 (0)