Skip to content

Commit fb2c026

Browse files
anuragagarwal561994iluwatar
authored andcommitted
Java 11 migrate remaining e (iluwatar#1112)
* Moves eip-aggregator to Java 11 * Moves eip-message-channel to Java 11 * Moves eip-publish-subscribe to Java 11 * Moves eip-splitter to Java 11 * Moves eip-wire-tap to Java 11 * Moves event-aggregator to Java 11 * Moves event-asynchronous to Java 11 * Moves event-driven-architecture to Java 11 * Moves event-queue to Java 11 * Moves event-sourcing to Java 11 * Moves execute-around to Java 11 * Moves extension-objects to Java 11
1 parent b09b100 commit fb2c026

File tree

64 files changed

+306
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+306
-390
lines changed

eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/App.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.camel.builder.RouteBuilder;
2828
import org.springframework.boot.SpringApplication;
2929
import org.springframework.boot.autoconfigure.SpringBootApplication;
30-
import org.springframework.context.ConfigurableApplicationContext;
3130

3231
/**
3332
* Sometimes in enterprise systems there is a need to group incoming data in order to process it as
@@ -49,19 +48,17 @@ public class App {
4948
*/
5049
public static void main(String[] args) throws Exception {
5150
// Run Spring Boot application and obtain ApplicationContext
52-
ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
51+
var context = SpringApplication.run(App.class, args);
5352

5453
// Get CamelContext from ApplicationContext
55-
CamelContext camelContext = (CamelContext) context.getBean("camelContext");
54+
var camelContext = (CamelContext) context.getBean("camelContext");
5655

5756
// Add a new routes that will handle endpoints form SplitterRoute class.
5857
camelContext.addRoutes(new RouteBuilder() {
59-
6058
@Override
61-
public void configure() throws Exception {
59+
public void configure() {
6260
from("{{endpoint}}").log("ENDPOINT: ${body}");
6361
}
64-
6562
});
6663

6764
// Add producer that will send test message to an entry point in WireTapRoute

eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/AggregatorRoute.java

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ public class AggregatorRoute extends RouteBuilder {
4848

4949
/**
5050
* Configures the route.
51-
*
52-
* @throws Exception in case of exception during configuration
5351
*/
5452
@Override
5553
public void configure() {

eip-aggregator/src/main/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategy.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
4040
return newExchange;
4141
}
4242

43-
String in1 = (String) oldExchange.getIn().getBody();
44-
String in2 = (String) newExchange.getIn().getBody();
43+
var in1 = (String) oldExchange.getIn().getBody();
44+
var in2 = (String) newExchange.getIn().getBody();
4545

4646
oldExchange.getIn().setBody(in1 + ";" + in2);
4747

eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/AppTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class AppTest {
3232

3333
@Test
3434
public void testMain() throws Exception {
35-
String[] args = {};
36-
App.main(args);
35+
App.main(new String[]{});
3736
}
3837
}

eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/AggregatorRouteTest.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
package com.iluwatar.eip.aggregator.routes;
2525

26+
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
2628
import org.apache.camel.EndpointInject;
2729
import org.apache.camel.ProducerTemplate;
2830
import org.apache.camel.component.mock.MockEndpoint;
@@ -35,13 +37,11 @@
3537
import org.springframework.test.context.ActiveProfiles;
3638
import org.springframework.test.context.junit.jupiter.SpringExtension;
3739

38-
import static org.junit.jupiter.api.Assertions.assertEquals;
39-
4040
/**
4141
* Test class for <i>AggregatorRoute</i>.
4242
* <p>
43-
* In order for it to work we have to mock endpoints we want to read/write to. To mock those we need to substitute
44-
* original endpoint names to mocks.
43+
* In order for it to work we have to mock endpoints we want to read/write to. To mock those we need
44+
* to substitute original endpoint names to mocks.
4545
* </p>
4646
*/
4747
@ExtendWith(SpringExtension.class)
@@ -59,6 +59,7 @@ public class AggregatorRouteTest {
5959

6060
/**
6161
* Test if endpoint receives three separate messages.
62+
*
6263
* @throws Exception in case of en exception during the test
6364
*/
6465
@Test
@@ -76,10 +77,10 @@ public void testSplitter() throws Exception {
7677
endpoint.expectedMessageCount(2);
7778
endpoint.assertIsSatisfied();
7879

79-
String body = (String) endpoint.getReceivedExchanges().get(0).getIn().getBody();
80+
var body = (String) endpoint.getReceivedExchanges().get(0).getIn().getBody();
8081
assertEquals(3, body.split(";").length);
8182

82-
String body2 = (String) endpoint.getReceivedExchanges().get(1).getIn().getBody();
83+
var body2 = (String) endpoint.getReceivedExchanges().get(1).getIn().getBody();
8384
assertEquals(2, body2.split(";").length);
8485
}
8586
}

eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java

+11-12
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,40 @@
2323

2424
package com.iluwatar.eip.aggregator.routes;
2525

26+
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
2628
import org.apache.camel.CamelContext;
27-
import org.apache.camel.Exchange;
2829
import org.apache.camel.impl.DefaultExchange;
2930
import org.junit.jupiter.api.Test;
3031

31-
import static org.junit.jupiter.api.Assertions.assertEquals;
32-
3332
/**
3433
* Tests MessageAggregationStrategy
3534
*/
3635
public class MessageAggregationStrategyTest {
3736

3837
@Test
3938
public void testAggregate() {
40-
MessageAggregationStrategy mas = new MessageAggregationStrategy();
41-
Exchange oldExchange = new DefaultExchange((CamelContext) null);
39+
var mas = new MessageAggregationStrategy();
40+
var oldExchange = new DefaultExchange((CamelContext) null);
4241
oldExchange.getIn().setBody("TEST1");
4342

44-
Exchange newExchange = new DefaultExchange((CamelContext) null);
43+
var newExchange = new DefaultExchange((CamelContext) null);
4544
newExchange.getIn().setBody("TEST2");
4645

47-
Exchange output = mas.aggregate(oldExchange, newExchange);
48-
String outputBody = (String) output.getIn().getBody();
46+
var output = mas.aggregate(oldExchange, newExchange);
47+
var outputBody = (String) output.getIn().getBody();
4948
assertEquals("TEST1;TEST2", outputBody);
5049
}
5150

5251
@Test
5352
public void testAggregateOldNull() {
54-
MessageAggregationStrategy mas = new MessageAggregationStrategy();
53+
var mas = new MessageAggregationStrategy();
5554

56-
Exchange newExchange = new DefaultExchange((CamelContext) null);
55+
var newExchange = new DefaultExchange((CamelContext) null);
5756
newExchange.getIn().setBody("TEST2");
5857

59-
Exchange output = mas.aggregate(null, newExchange);
60-
String outputBody = (String) output.getIn().getBody();
58+
var output = mas.aggregate(null, newExchange);
59+
var outputBody = (String) output.getIn().getBody();
6160

6261
assertEquals(newExchange, output);
6362
assertEquals("TEST2", outputBody);

eip-message-channel/src/main/java/com/iluwatar/eip/message/channel/App.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
package com.iluwatar.eip.message.channel;
2525

26-
import org.apache.camel.CamelContext;
2726
import org.apache.camel.builder.RouteBuilder;
2827
import org.apache.camel.impl.DefaultCamelContext;
2928
import org.slf4j.Logger;
@@ -57,7 +56,7 @@ public class App {
5756
* Program entry point.
5857
*/
5958
public static void main(String[] args) throws Exception {
60-
CamelContext context = new DefaultCamelContext();
59+
var context = new DefaultCamelContext();
6160

6261
context.addRoutes(new RouteBuilder() {
6362

eip-message-channel/src/test/java/com/iluwatar/eip/message/channel/AppTest.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
import org.junit.jupiter.api.Test;
2727

2828
/**
29-
*
3029
* Application test
31-
*
3230
*/
3331
public class AppTest {
3432

3533
@Test
3634
public void test() throws Exception {
37-
String[] args = {};
38-
App.main(args);
35+
App.main(new String[]{});
3936
}
4037
}

eip-publish-subscribe/src/main/java/com/iluwatar/eip/publish/subscribe/App.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
package com.iluwatar.eip.publish.subscribe;
2525

26-
import org.apache.camel.CamelContext;
27-
import org.apache.camel.ProducerTemplate;
2826
import org.apache.camel.builder.RouteBuilder;
2927
import org.apache.camel.impl.DefaultCamelContext;
3028
import org.slf4j.Logger;
@@ -55,14 +53,14 @@ public class App {
5553
* Program entry point.
5654
*/
5755
public static void main(String[] args) throws Exception {
58-
CamelContext context = new DefaultCamelContext();
56+
var context = new DefaultCamelContext();
5957
context.addRoutes(new RouteBuilder() {
6058
@Override
6159
public void configure() throws Exception {
6260
from("direct:origin").multicast().to("mock:foo", "mock:bar", "stream:out");
6361
}
6462
});
65-
ProducerTemplate template = context.createProducerTemplate();
63+
var template = context.createProducerTemplate();
6664
context.start();
6765
context.getRoutes().forEach(r -> LOGGER.info(r.toString()));
6866
template.sendBody("direct:origin", "Hello from origin");

eip-publish-subscribe/src/test/java/com/iluwatar/eip/publish/subscribe/AppTest.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
import org.junit.jupiter.api.Test;
2727

2828
/**
29-
*
3029
* Application test
31-
*
3230
*/
3331
public class AppTest {
3432

3533
@Test
3634
public void test() throws Exception {
37-
String[] args = {};
38-
App.main(args);
35+
App.main(new String[]{});
3936
}
4037
}

eip-splitter/src/main/java/com/iluwatar/eip/splitter/App.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.camel.builder.RouteBuilder;
2828
import org.springframework.boot.SpringApplication;
2929
import org.springframework.boot.autoconfigure.SpringBootApplication;
30-
import org.springframework.context.ConfigurableApplicationContext;
3130

3231
/**
3332
* It is very common in integration systems that incoming messages consists of many items bundled
@@ -53,10 +52,10 @@ public class App {
5352
*/
5453
public static void main(String[] args) throws Exception {
5554
// Run Spring Boot application and obtain ApplicationContext
56-
ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
55+
var context = SpringApplication.run(App.class, args);
5756

5857
// Get CamelContext from ApplicationContext
59-
CamelContext camelContext = (CamelContext) context.getBean("camelContext");
58+
var camelContext = (CamelContext) context.getBean("camelContext");
6059

6160
// Add a new routes that will handle endpoints form SplitterRoute class.
6261
camelContext.addRoutes(new RouteBuilder() {

eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class AppTest {
3232

3333
@Test
3434
public void testMain() throws Exception {
35-
String[] args = {};
36-
App.main(args);
35+
App.main(new String[]{});
3736
}
3837
}

eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
/**
3939
* Test class for <i>SplitterRoute</i>.
4040
* <p>
41-
* In order for it to work we have to mock endpoints we want to read/write to. To mock those we need to substitute
42-
* original endpoint names to mocks.
41+
* In order for it to work we have to mock endpoints we want to read/write to. To mock those we need
42+
* to substitute original endpoint names to mocks.
4343
* </p>
4444
*/
4545
@ExtendWith(SpringExtension.class)
@@ -57,14 +57,15 @@ public class SplitterRouteTest {
5757

5858
/**
5959
* Test if endpoint receives three separate messages.
60+
*
6061
* @throws Exception in case of en exception during the test
6162
*/
6263
@Test
6364
@DirtiesContext
6465
public void testSplitter() throws Exception {
6566

6667
// Three items in one entry message
67-
entry.sendBody(new String[] {"TEST1", "TEST2", "TEST3"});
68+
entry.sendBody(new String[]{"TEST1", "TEST2", "TEST3"});
6869

6970
// Endpoint should have three different messages in the end order of the messages is not important
7071
endpoint.expectedMessageCount(3);

eip-wire-tap/src/main/java/com/iluwatar/eip/wiretap/App.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.camel.builder.RouteBuilder;
2828
import org.springframework.boot.SpringApplication;
2929
import org.springframework.boot.autoconfigure.SpringBootApplication;
30-
import org.springframework.context.ConfigurableApplicationContext;
3130

3231
/**
3332
* In most integration cases there is a need to monitor the messages flowing through the system. It
@@ -52,10 +51,10 @@ public class App {
5251
*/
5352
public static void main(String[] args) throws Exception {
5453
// Run Spring Boot application and obtain ApplicationContext
55-
ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
54+
var context = SpringApplication.run(App.class, args);
5655

5756
// Get CamelContext from ApplicationContext
58-
CamelContext camelContext = (CamelContext) context.getBean("camelContext");
57+
var camelContext = (CamelContext) context.getBean("camelContext");
5958

6059
// Add a new routes that will handle endpoints form WireTapRoute class.
6160
camelContext.addRoutes(new RouteBuilder() {

eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class AppTest {
3232

3333
@Test
3434
public void testMain() throws Exception {
35-
String[] args = {};
36-
App.main(args);
35+
App.main(new String[]{});
3736
}
3837
}

eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323

2424
package com.iluwatar.eip.wiretap.routes;
2525

26+
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
2628
import org.apache.camel.EndpointInject;
27-
import org.apache.camel.Message;
2829
import org.apache.camel.ProducerTemplate;
2930
import org.apache.camel.component.mock.MockEndpoint;
3031
import org.junit.jupiter.api.Test;
@@ -36,13 +37,11 @@
3637
import org.springframework.test.context.ActiveProfiles;
3738
import org.springframework.test.context.junit.jupiter.SpringExtension;
3839

39-
import static org.junit.jupiter.api.Assertions.assertEquals;
40-
4140
/**
4241
* Test class for <i>WireTapRoute</i>.
4342
* <p>
44-
* In order for it to work we have to mock endpoints we want to read/write to. To mock those we need to substitute
45-
* original endpoint names to mocks.
43+
* In order for it to work we have to mock endpoints we want to read/write to. To mock those we need
44+
* to substitute original endpoint names to mocks.
4645
* </p>
4746
*/
4847
@ExtendWith(SpringExtension.class)
@@ -63,6 +62,7 @@ public class WireTapRouteTest {
6362

6463
/**
6564
* Test if both endpoints receive exactly one message containing the same, unchanged body.
65+
*
6666
* @throws Exception in case of en exception during the test
6767
*/
6868
@Test
@@ -76,8 +76,8 @@ public void testWireTap() throws Exception {
7676
endpoint.assertIsSatisfied();
7777
wireTapEndpoint.assertIsSatisfied();
7878

79-
Message endpointIn = endpoint.getExchanges().get(0).getIn();
80-
Message wireTapEndpointIn = wireTapEndpoint.getExchanges().get(0).getIn();
79+
var endpointIn = endpoint.getExchanges().get(0).getIn();
80+
var wireTapEndpointIn = wireTapEndpoint.getExchanges().get(0).getIn();
8181

8282
assertEquals("TEST", endpointIn.getBody());
8383
assertEquals("TEST", wireTapEndpointIn.getBody());

0 commit comments

Comments
 (0)