diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml
index 53d9d4054c..8918fd4450 100644
--- a/apache-cxf/pom.xml
+++ b/apache-cxf/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.baeldung
apache-cxf
@@ -17,6 +17,7 @@
cxf-spring
cxf-jaxrs-implementation
cxf-aegis
+ sse-jaxrs
diff --git a/apache-cxf/sse-jaxrs/pom.xml b/apache-cxf/sse-jaxrs/pom.xml
new file mode 100644
index 0000000000..d4b6c19d03
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+
+ sse-jaxrs
+ pom
+
+
+ com.baeldung
+ apache-cxf
+ 0.0.1-SNAPSHOT
+
+
+
+ sse-jaxrs-server
+ sse-jaxrs-client
+
+
+
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
new file mode 100644
index 0000000000..0f5406fbc7
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-client/pom.xml
@@ -0,0 +1,62 @@
+
+
+ 4.0.0
+
+
+ com.baeldung
+ sse-jaxrs
+ 0.0.1-SNAPSHOT
+
+
+ sse-jaxrs-client
+
+
+ 3.2.0
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.6.0
+
+
+ singleEvent
+
+ java
+
+
+ com.baeldung.sse.jaxrs.client.SseClientApp
+
+
+
+ broadcast
+
+ java
+
+
+ com.baeldung.sse.jaxrs.client.SseClientBroadcastApp
+
+
+
+
+
+
+
+
+
+ org.apache.cxf
+ cxf-rt-rs-client
+ ${cxf-version}
+
+
+ org.apache.cxf
+ cxf-rt-rs-sse
+ ${cxf-version}
+
+
+
+
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientApp.java b/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientApp.java
new file mode 100644
index 0000000000..5d42b3a243
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientApp.java
@@ -0,0 +1,48 @@
+package com.baeldung.sse.jaxrs.client;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.sse.InboundSseEvent;
+import javax.ws.rs.sse.SseEventSource;
+import java.util.function.Consumer;
+
+public class SseClientApp {
+
+ private static final String url = "http://127.0.0.1:9080/sse-jaxrs-server/sse/stock/prices";
+
+ public static void main(String... args) throws Exception {
+
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(url);
+ try (SseEventSource eventSource = SseEventSource.target(target).build()) {
+
+ eventSource.register(onEvent, onError, onComplete);
+ eventSource.open();
+
+ //Consuming events for one hour
+ Thread.sleep(60 * 60 * 1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ client.close();
+ System.out.println("End");
+ }
+
+ // A new event is received
+ private static Consumer onEvent = (inboundSseEvent) -> {
+ String data = inboundSseEvent.readData();
+ System.out.println(data);
+ };
+
+ //Error
+ private static Consumer onError = (throwable) -> {
+ throwable.printStackTrace();
+ };
+
+ //Connection close and there is nothing to receive
+ private static Runnable onComplete = () -> {
+ System.out.println("Done!");
+ };
+
+}
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientBroadcastApp.java b/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientBroadcastApp.java
new file mode 100644
index 0000000000..9afc187a6d
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/java/com/baeldung/sse/jaxrs/client/SseClientBroadcastApp.java
@@ -0,0 +1,52 @@
+package com.baeldung.sse.jaxrs.client;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.sse.InboundSseEvent;
+import javax.ws.rs.sse.SseEventSource;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
+
+public class SseClientBroadcastApp {
+
+ private static final String subscribeUrl = "http://localhost:9080/sse-jaxrs-server/sse/stock/subscribe";
+
+
+ public static void main(String... args) throws Exception {
+
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(subscribeUrl);
+ try (final SseEventSource eventSource = SseEventSource.target(target)
+ .reconnectingEvery(5, TimeUnit.SECONDS)
+ .build()) {
+ eventSource.register(onEvent, onError, onComplete);
+ eventSource.open();
+ System.out.println("Wainting for incoming event ...");
+
+ //Consuming events for one hour
+ Thread.sleep(60 * 60 * 1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ client.close();
+ System.out.println("End");
+ }
+
+ // A new event is received
+ private static Consumer onEvent = (inboundSseEvent) -> {
+ String data = inboundSseEvent.readData();
+ System.out.println(data);
+ };
+
+ //Error
+ private static Consumer onError = (throwable) -> {
+ throwable.printStackTrace();
+ };
+
+ //Connection close and there is nothing to receive
+ private static Runnable onComplete = () -> {
+ System.out.println("Done!");
+ };
+
+}
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/resources/logback.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/resources/logback.xml
new file mode 100644
index 0000000000..7d900d8ea8
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-client/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
new file mode 100644
index 0000000000..46572a2b75
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml
@@ -0,0 +1,85 @@
+
+
+ 4.0.0
+
+
+ com.baeldung
+ sse-jaxrs
+ 0.0.1-SNAPSHOT
+
+
+ sse-jaxrs-server
+ war
+
+
+ 2.4.2
+ false
+ 18.0.0.2
+
+
+
+ ${artifactId}
+
+
+ net.wasdev.wlp.maven.plugins
+ liberty-maven-plugin
+ ${liberty-maven-plugin.version}
+
+
+ io.openliberty
+ openliberty-webProfile8
+ ${openliberty-version}
+ zip
+
+ project
+ true
+ src/main/liberty/config/server.xml
+
+
+
+ install-server
+ prepare-package
+
+ install-server
+ create-server
+ install-feature
+
+
+
+ install-apps
+ package
+
+ install-apps
+
+
+
+
+
+
+
+
+
+
+ javax.ws.rs
+ javax.ws.rs-api
+ 2.1
+ provided
+
+
+ javax.enterprise
+ cdi-api
+ 2.0
+ provided
+
+
+ javax.json.bind
+ javax.json.bind-api
+ 1.0
+ provided
+
+
+
+
+
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/AppConfig.java b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/AppConfig.java
new file mode 100644
index 0000000000..058d19f045
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/AppConfig.java
@@ -0,0 +1,8 @@
+package com.baeldung.sse.jaxrs;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+
+@ApplicationPath("sse")
+public class AppConfig extends Application {
+}
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/SseResource.java b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/SseResource.java
new file mode 100644
index 0000000000..1f60168a1b
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/SseResource.java
@@ -0,0 +1,119 @@
+package com.baeldung.sse.jaxrs;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.sse.OutboundSseEvent;
+import javax.ws.rs.sse.Sse;
+import javax.ws.rs.sse.SseBroadcaster;
+import javax.ws.rs.sse.SseEventSink;
+
+@ApplicationScoped
+@Path("stock")
+public class SseResource {
+
+ @Inject
+ private StockService stockService;
+
+ private Sse sse;
+ private SseBroadcaster sseBroadcaster;
+ private OutboundSseEvent.Builder eventBuilder;
+
+ @Context
+ public void setSse(Sse sse) {
+ this.sse = sse;
+ this.eventBuilder = sse.newEventBuilder();
+ this.sseBroadcaster = sse.newBroadcaster();
+ }
+
+ @GET
+ @Path("prices")
+ @Produces("text/event-stream")
+ public void getStockPrices(@Context SseEventSink sseEventSink,
+ @HeaderParam(HttpHeaders.LAST_EVENT_ID_HEADER) @DefaultValue("-1") int lastReceivedId) {
+
+ int lastEventId = 1;
+ if (lastReceivedId != -1) {
+ lastEventId = ++lastReceivedId;
+ }
+ boolean running = true;
+ while (running) {
+ Stock stock = stockService.getNextTransaction(lastEventId);
+ if (stock != null) {
+ OutboundSseEvent sseEvent = this.eventBuilder
+ .name("stock")
+ .id(String.valueOf(lastEventId))
+ .mediaType(MediaType.APPLICATION_JSON_TYPE)
+ .data(Stock.class, stock)
+ .reconnectDelay(3000)
+ .comment("price change")
+ .build();
+ sseEventSink.send(sseEvent);
+ lastEventId++;
+ }
+ //Simulate connection close
+ if (lastEventId % 5 == 0) {
+ sseEventSink.close();
+ break;
+ }
+
+ try {
+ //Wait 5 seconds
+ Thread.sleep(5 * 1000);
+ } catch (InterruptedException ex) {
+ // ...
+ }
+ //Simulatae a while boucle break
+ running = lastEventId <= 2000;
+ }
+ sseEventSink.close();
+ }
+
+ @GET
+ @Path("subscribe")
+ @Produces(MediaType.SERVER_SENT_EVENTS)
+ public void listen(@Context SseEventSink sseEventSink) {
+ sseEventSink.send(sse.newEvent("Welcome !"));
+ this.sseBroadcaster.register(sseEventSink);
+ sseEventSink.send(sse.newEvent("You are registred !"));
+ }
+
+ @GET
+ @Path("publish")
+ public void broadcast() {
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ int lastEventId = 0;
+ boolean running = true;
+ while (running) {
+ lastEventId++;
+ Stock stock = stockService.getNextTransaction(lastEventId);
+ if (stock != null) {
+ OutboundSseEvent sseEvent = eventBuilder
+ .name("stock")
+ .id(String.valueOf(lastEventId))
+ .mediaType(MediaType.APPLICATION_JSON_TYPE)
+ .data(Stock.class, stock)
+ .reconnectDelay(3000)
+ .comment("price change")
+ .build();
+ sseBroadcaster.broadcast(sseEvent);
+ }
+ try {
+ //Wait 5 seconds
+ Thread.currentThread().sleep(5 * 1000);
+ } catch (InterruptedException ex) {
+ // ...
+ }
+ //Simulatae a while boucle break
+ running = lastEventId <= 2000;
+ }
+ }
+ };
+ new Thread(r).start();
+ }
+}
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/Stock.java b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/Stock.java
new file mode 100644
index 0000000000..a186b32771
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/Stock.java
@@ -0,0 +1,50 @@
+package com.baeldung.sse.jaxrs;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+public class Stock {
+ private Integer id;
+ private String name;
+ private BigDecimal price;
+ LocalDateTime dateTime;
+
+ public Stock(Integer id, String name, BigDecimal price, LocalDateTime dateTime) {
+ this.id = id;
+ this.name = name;
+ this.price = price;
+ this.dateTime = dateTime;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ public LocalDateTime getDateTime() {
+ return dateTime;
+ }
+
+ public void setDateTime(LocalDateTime dateTime) {
+ this.dateTime = dateTime;
+ }
+}
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/StockService.java b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/StockService.java
new file mode 100644
index 0000000000..15818ead5d
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/java/com/baeldung/sse/jaxrs/StockService.java
@@ -0,0 +1,78 @@
+package com.baeldung.sse.jaxrs;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.Initialized;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@ApplicationScoped
+@Named
+public class StockService {
+
+ private static final BigDecimal UP = BigDecimal.valueOf(1.05f);
+ private static final BigDecimal DOWN = BigDecimal.valueOf(0.95f);
+
+ List stockNames = Arrays.asList("GOOG", "IBM", "MS", "GOOG", "YAHO");
+ List stocksDB = new ArrayList<>();
+ private AtomicInteger counter = new AtomicInteger(0);
+
+ public void init(@Observes @Initialized(ApplicationScoped.class) Object init) {
+ //Open price
+ System.out.println("@Start Init ...");
+ stockNames.forEach(stockName -> {
+ stocksDB.add(new Stock(counter.incrementAndGet(), stockName, generateOpenPrice(), LocalDateTime.now()));
+ });
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ //Simulate Change price and put every x seconds
+ while (true) {
+ int indx = new Random().nextInt(stockNames.size());
+ String stockName = stockNames.get(indx);
+ BigDecimal price = getLastPrice(stockName);
+ BigDecimal newprice = changePrice(price);
+ Stock stock = new Stock(counter.incrementAndGet(), stockName, newprice, LocalDateTime.now());
+ stocksDB.add(stock);
+
+ int r = new Random().nextInt(30);
+ try {
+ Thread.currentThread().sleep(r*1000);
+ } catch (InterruptedException ex) {
+ // ...
+ }
+ }
+ }
+ };
+ new Thread(runnable).start();
+ System.out.println("@End Init ...");
+ }
+
+ public Stock getNextTransaction(Integer lastEventId) {
+ return stocksDB.stream().filter(s -> s.getId().equals(lastEventId)).findFirst().orElse(null);
+ }
+
+ BigDecimal generateOpenPrice() {
+ float min = 70;
+ float max = 120;
+ return BigDecimal.valueOf(min + new Random().nextFloat() * (max - min)).setScale(4,RoundingMode.CEILING);
+ }
+
+ BigDecimal changePrice(BigDecimal price) {
+ return Math.random() >= 0.5 ? price.multiply(UP).setScale(4,RoundingMode.CEILING) : price.multiply(DOWN).setScale(4,RoundingMode.CEILING);
+ }
+
+ private BigDecimal getLastPrice(String stockName) {
+ return stocksDB.stream().filter(stock -> stock.getName().equals(stockName)).findFirst().get().getPrice();
+ }
+}
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/liberty/config/server.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/liberty/config/server.xml
new file mode 100644
index 0000000000..9bf66d7795
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/liberty/config/server.xml
@@ -0,0 +1,7 @@
+
+
+ jaxrs-2.1
+ cdi-2.0
+
+
+
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/resources/META-INF/beans.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000000..4f0b3cdeeb
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,6 @@
+
+
\ No newline at end of file
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/resources/logback.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/resources/logback.xml
new file mode 100644
index 0000000000..7d900d8ea8
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/WEB-INF/web.xml b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..b4b8121fdd
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,11 @@
+
+
+ Hello Servlet
+
+
+ index.html
+
+
+
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/index.html b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/index.html
new file mode 100644
index 0000000000..9015a7a32c
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/index.html
@@ -0,0 +1 @@
+index
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse-broadcast.html b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse-broadcast.html
new file mode 100644
index 0000000000..5a46e2a5d3
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse-broadcast.html
@@ -0,0 +1,38 @@
+
+
+
+ Server-Sent Event Broadcasting
+
+
+Stock prices :
+
+
+
+
\ No newline at end of file
diff --git a/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse.html b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse.html
new file mode 100644
index 0000000000..8fddae4717
--- /dev/null
+++ b/apache-cxf/sse-jaxrs/sse-jaxrs-server/src/main/webapp/sse.html
@@ -0,0 +1,38 @@
+
+
+
+ Server-Sent Event
+
+
+Stock prices :
+
+
+
+
\ No newline at end of file
diff --git a/core-java-collections/src/test/java/com/baeldung/collection/CollectionsEmpty.java b/core-java-collections/src/test/java/com/baeldung/collection/CollectionsEmpty.java
new file mode 100644
index 0000000000..86a262107d
--- /dev/null
+++ b/core-java-collections/src/test/java/com/baeldung/collection/CollectionsEmpty.java
@@ -0,0 +1,26 @@
+package com.baeldung.collection;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CollectionsEmpty {
+
+ @Test
+ public void givenArrayList_whenAddingElement_addsNewElement() {
+ ArrayList mutableList = new ArrayList<>();
+ mutableList.add("test");
+
+ Assert.assertEquals(mutableList.size(), 1);
+ Assert.assertEquals(mutableList.get(0), "test");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void givenCollectionsEmptyList_whenAddingElement_throwsUnsupportedOperationException() {
+ List immutableList = Collections.emptyList();
+ immutableList.add("test");
+ }
+
+}
\ No newline at end of file
diff --git a/core-java-sun/pom.xml b/core-java-sun/pom.xml
index f489f3b030..7292335232 100644
--- a/core-java-sun/pom.xml
+++ b/core-java-sun/pom.xml
@@ -303,7 +303,7 @@
1.7.0
- 2.19.1
+ 2.21.0
1.8.0
3.0.2
diff --git a/core-java/pom.xml b/core-java/pom.xml
index b83cb478d4..3f44851f97 100644
--- a/core-java/pom.xml
+++ b/core-java/pom.xml
@@ -530,7 +530,7 @@
3.10.0
- 2.19.1
+ 2.21.0
4.3.4.RELEASE
1.5.8.RELEASE
diff --git a/core-kotlin/src/main/java/com/baeldung/constructor/Car.kt b/core-kotlin/src/main/java/com/baeldung/constructor/Car.kt
new file mode 100644
index 0000000000..72b8d330e8
--- /dev/null
+++ b/core-kotlin/src/main/java/com/baeldung/constructor/Car.kt
@@ -0,0 +1,17 @@
+package com.baeldung.constructor
+
+class Car {
+ val id: String
+ val type: String
+
+ constructor(id: String, type: String) {
+ this.id = id
+ this.type = type
+ }
+
+}
+
+fun main(args: Array) {
+ val car = Car("1", "sport")
+ val s= Car("2", "suv")
+}
\ No newline at end of file
diff --git a/core-kotlin/src/main/java/com/baeldung/constructor/Employee.kt b/core-kotlin/src/main/java/com/baeldung/constructor/Employee.kt
new file mode 100644
index 0000000000..4483bfcf08
--- /dev/null
+++ b/core-kotlin/src/main/java/com/baeldung/constructor/Employee.kt
@@ -0,0 +1,3 @@
+package com.baeldung.constructor
+
+class Employee(name: String, val salary: Int): Person(name)
\ No newline at end of file
diff --git a/core-kotlin/src/main/java/com/baeldung/constructor/Person.java b/core-kotlin/src/main/java/com/baeldung/constructor/Person.java
new file mode 100644
index 0000000000..57911b24ee
--- /dev/null
+++ b/core-kotlin/src/main/java/com/baeldung/constructor/Person.java
@@ -0,0 +1,19 @@
+package com.baeldung.constructor;
+
+class PersonJava {
+ final String name;
+ final String surname;
+ final Integer age;
+
+ public PersonJava(String name, String surname) {
+ this.name = name;
+ this.surname = surname;
+ this.age = null;
+ }
+
+ public PersonJava(String name, String surname, Integer age) {
+ this.name = name;
+ this.surname = surname;
+ this.age = age;
+ }
+}
diff --git a/core-kotlin/src/main/kotlin/com/baeldung/constructor/Person.kt b/core-kotlin/src/main/kotlin/com/baeldung/constructor/Person.kt
new file mode 100644
index 0000000000..3779d74541
--- /dev/null
+++ b/core-kotlin/src/main/kotlin/com/baeldung/constructor/Person.kt
@@ -0,0 +1,26 @@
+package com.baeldung.constructor
+
+open class Person(
+ val name: String,
+ val age: Int? = null
+) {
+ val upperCaseName: String = name.toUpperCase()
+
+ init {
+ println("Hello, I'm $name")
+
+ if (age != null && age < 0) {
+ throw IllegalArgumentException("Age cannot be less than zero!")
+ }
+ }
+
+ init {
+ println("upperCaseName is $upperCaseName")
+ }
+
+}
+
+fun main(args: Array) {
+ val person = Person("John")
+ val personWithAge = Person("John", 22)
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/resources/Kotlin.out b/core-kotlin/src/test/resources/Kotlin.out
new file mode 100644
index 0000000000..63d15d2528
--- /dev/null
+++ b/core-kotlin/src/test/resources/Kotlin.out
@@ -0,0 +1,2 @@
+Kotlin
+Concise, Safe, Interoperable, Tool-friendly
\ No newline at end of file
diff --git a/java-numbers/pom.xml b/java-numbers/pom.xml
index a9fb556517..bf4d3e8792 100644
--- a/java-numbers/pom.xml
+++ b/java-numbers/pom.xml
@@ -156,7 +156,7 @@
1.19
1.19
- 2.19.1
+ 2.21.0
3.0.0-M1
3.0.2
diff --git a/jee-7/pom.xml b/jee-7/pom.xml
index d0246f650a..fbf102185d 100644
--- a/jee-7/pom.xml
+++ b/jee-7/pom.xml
@@ -418,7 +418,7 @@
1.0.0.Final
2.6
4.2.3.RELEASE
- 2.17
+ 2.21.0
1.1.2
2.4
2.2.14
diff --git a/mustache/pom.xml b/mustache/pom.xml
index 6012c9a15a..d385246182 100644
--- a/mustache/pom.xml
+++ b/mustache/pom.xml
@@ -153,7 +153,7 @@
3.7.0
- 2.19.1
+ 2.21.0
0.8
3.3.7
1.8
diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml
index ab6162a5a5..2fc46e4c28 100644
--- a/parent-boot-2/pom.xml
+++ b/parent-boot-2/pom.xml
@@ -8,18 +8,27 @@
Parent for all Spring Boot 2 modules
- org.springframework.boot
- spring-boot-starter-parent
- 2.0.1.RELEASE
-
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ 2.0.1.RELEASE
+ pom
+ import
+
+
+
io.rest-assured
rest-assured
- ${rest-assured.version}
-
+
org.springframework.boot
spring-boot-starter-test
@@ -27,79 +36,16 @@
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
- **/*LiveTest.java
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- ${maven.compiler.target}
-
-
-
-
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.0.1.RELEASE
+
+
+
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*ManualTest.java
- **/*LiveTest.java
- **/AutoconfigurationTest.java
- **/*UnitTest.java
-
-
- **/*IntegrationTest.java
- **/*IntTest.java
- */EthControllerTestOne.java
- **/*EntryPointsTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
thin-jar
@@ -122,13 +68,8 @@
- UTF-8
- UTF-8
- 1.8
3.1.0
- 1.8
- 1.8
1.0.11.RELEASE
diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/DeliveredState.java b/patterns/design-patterns/src/main/java/com/baeldung/state/DeliveredState.java
new file mode 100644
index 0000000000..9f5e4d8fc4
--- /dev/null
+++ b/patterns/design-patterns/src/main/java/com/baeldung/state/DeliveredState.java
@@ -0,0 +1,25 @@
+package com.baeldung.state;
+
+public class DeliveredState implements PackageState {
+
+ @Override
+ public void next(Package pkg) {
+ pkg.setState(new ReceivedState());
+ }
+
+ @Override
+ public void prev(Package pkg) {
+ pkg.setState(new OrderedState());
+ }
+
+ @Override
+ public void printStatus() {
+ System.out.println("Package delivered to post office, not received yet.");
+ }
+
+ @Override
+ public String toString() {
+ return "DeliveredState{}";
+ }
+
+}
\ No newline at end of file
diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/OrderedState.java b/patterns/design-patterns/src/main/java/com/baeldung/state/OrderedState.java
new file mode 100644
index 0000000000..0642c4c73c
--- /dev/null
+++ b/patterns/design-patterns/src/main/java/com/baeldung/state/OrderedState.java
@@ -0,0 +1,24 @@
+package com.baeldung.state;
+
+public class OrderedState implements PackageState {
+
+ @Override
+ public void next(Package pkg) {
+ pkg.setState(new DeliveredState());
+ }
+
+ @Override
+ public void prev(Package pkg) {
+ System.out.println("The package is in it's root state.");
+ }
+
+ @Override
+ public void printStatus() {
+ System.out.println("Package ordered, not delivered to the office yet.");
+ }
+
+ @Override
+ public String toString() {
+ return "OrderedState{}";
+ }
+}
\ No newline at end of file
diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/Package.java b/patterns/design-patterns/src/main/java/com/baeldung/state/Package.java
new file mode 100644
index 0000000000..f3dfbb3fa7
--- /dev/null
+++ b/patterns/design-patterns/src/main/java/com/baeldung/state/Package.java
@@ -0,0 +1,26 @@
+package com.baeldung.state;
+
+public class Package {
+
+ private PackageState state = new OrderedState();
+
+ public PackageState getState() {
+ return state;
+ }
+
+ public void setState(PackageState state) {
+ this.state = state;
+ }
+
+ public void previousState() {
+ state.prev(this);
+ }
+
+ public void nextState() {
+ state.next(this);
+ }
+
+ public void printStatus() {
+ state.printStatus();
+ }
+}
diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/PackageState.java b/patterns/design-patterns/src/main/java/com/baeldung/state/PackageState.java
new file mode 100644
index 0000000000..d6656c78ac
--- /dev/null
+++ b/patterns/design-patterns/src/main/java/com/baeldung/state/PackageState.java
@@ -0,0 +1,10 @@
+package com.baeldung.state;
+
+public interface PackageState {
+
+ void next(Package pkg);
+
+ void prev(Package pkg);
+
+ void printStatus();
+}
\ No newline at end of file
diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/ReceivedState.java b/patterns/design-patterns/src/main/java/com/baeldung/state/ReceivedState.java
new file mode 100644
index 0000000000..84136fa48e
--- /dev/null
+++ b/patterns/design-patterns/src/main/java/com/baeldung/state/ReceivedState.java
@@ -0,0 +1,24 @@
+package com.baeldung.state;
+
+public class ReceivedState implements PackageState {
+
+ @Override
+ public void next(Package pkg) {
+ System.out.println("This package is already received by a client.");
+ }
+
+ @Override
+ public void prev(Package pkg) {
+ pkg.setState(new DeliveredState());
+ }
+
+ @Override
+ public void printStatus() {
+ System.out.println("Package was received by client.");
+ }
+
+ @Override
+ public String toString() {
+ return "ReceivedState{}";
+ }
+}
\ No newline at end of file
diff --git a/patterns/design-patterns/src/main/java/com/baeldung/state/StateDemo.java b/patterns/design-patterns/src/main/java/com/baeldung/state/StateDemo.java
new file mode 100644
index 0000000000..1a63ea3ddf
--- /dev/null
+++ b/patterns/design-patterns/src/main/java/com/baeldung/state/StateDemo.java
@@ -0,0 +1,19 @@
+package com.baeldung.state;
+
+public class StateDemo {
+
+ public static void main(String[] args) {
+
+ Package pkg = new Package();
+ pkg.printStatus();
+
+ pkg.nextState();
+ pkg.printStatus();
+
+ pkg.nextState();
+ pkg.printStatus();
+
+ pkg.nextState();
+ pkg.printStatus();
+ }
+}
diff --git a/patterns/design-patterns/src/test/java/com/baeldung/state/StatePatternUnitTest.java b/patterns/design-patterns/src/test/java/com/baeldung/state/StatePatternUnitTest.java
new file mode 100644
index 0000000000..731974f92b
--- /dev/null
+++ b/patterns/design-patterns/src/test/java/com/baeldung/state/StatePatternUnitTest.java
@@ -0,0 +1,33 @@
+package com.baeldung.state;
+
+import com.baeldung.state.Package;
+
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.instanceOf;
+
+import org.junit.Test;
+
+public class StatePatternUnitTest {
+
+ @Test
+ public void givenNewPackage_whenPackageReceived_thenStateReceived() {
+ Package pkg = new Package();
+
+ assertThat(pkg.getState(), instanceOf(OrderedState.class));
+ pkg.nextState();
+
+ assertThat(pkg.getState(), instanceOf(DeliveredState.class));
+ pkg.nextState();
+
+ assertThat(pkg.getState(), instanceOf(ReceivedState.class));
+ }
+
+ @Test
+ public void givenDeliveredPackage_whenPrevState_thenStateOrdered() {
+ Package pkg = new Package();
+ pkg.setState(new DeliveredState());
+ pkg.previousState();
+
+ assertThat(pkg.getState(), instanceOf(OrderedState.class));
+ }
+}
diff --git a/persistence-modules/spring-data-dynamodb/pom.xml b/persistence-modules/spring-data-dynamodb/pom.xml
index 9f2b63c17c..e5bd78d208 100644
--- a/persistence-modules/spring-data-dynamodb/pom.xml
+++ b/persistence-modules/spring-data-dynamodb/pom.xml
@@ -177,46 +177,12 @@
-
- spring-snapshots
- Spring Snapshots
- https://repo.spring.io/snapshot
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
dynamodb-local
DynamoDB Local Release Repository
${dynamodblocal.repository.url}
-
-
- spring-snapshots
- Spring Snapshots
- https://repo.spring.io/snapshot
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
diff --git a/pom.xml b/pom.xml
index a9aaff3e22..db3bef7fda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,9 +43,15 @@
org.junit.jupiter
junit-jupiter-engine
- ${junit.jupiter.version}
+ ${junit-jupiter.version}
test
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit-jupiter.version}
+ test
+
org.hamcrest
hamcrest-core
@@ -70,6 +76,14 @@
${mockito.version}
test
+
+ org.apache.maven.surefire
+ surefire-logger-api
+ ${maven-surefire-plugin.version}
+
+ test
+ true
+
@@ -98,6 +112,23 @@
**/*LiveTest.java
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit-platform.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit-jupiter.version}
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ ${junit-jupiter.version}
+
+
org.apache.maven.plugins
@@ -187,6 +218,10 @@
+
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
@@ -406,6 +441,7 @@
spring-4
spring-5
spring-5-reactive
+ spring-5-reactive-client
spring-5-mvc
spring-5-security
spring-activiti
@@ -551,7 +587,6 @@
apache-meecrowave
spring-reactive-kotlin
jnosql
- sse-jaxrs
spring-boot-angular-ecommerce
@@ -663,6 +698,7 @@
spring-4
spring-5
spring-5-reactive
+ spring-5-reactive-client
spring-5-mvc
spring-5-security
spring-activiti
@@ -942,6 +978,7 @@
spark-java
spring-4
spring-5-reactive
+ spring-5-reactive-client
spring-5-mvc
spring-5-security
spring-activiti
@@ -1220,7 +1257,7 @@
2.19.1
2.5
1.4
- 2.6
+ 3.0.0
3.1.0
1.2
2.3.1
@@ -1228,7 +1265,8 @@
1.2
2.5.0
1.3
- 5.0.2
+ 1.2.0
+ 5.2.0
0.3.1
2.5.1
0.0.1
diff --git a/spring-5-mvc/pom.xml b/spring-5-mvc/pom.xml
index 0408550c79..f5346a0fa0 100644
--- a/spring-5-mvc/pom.xml
+++ b/spring-5-mvc/pom.xml
@@ -82,11 +82,6 @@
spring-boot-starter-test
test
-
- junit
- junit
- test
-
com.jayway.restassured
rest-assured
@@ -137,46 +132,11 @@
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- false
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LiveTest.java
-
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
+
2.9.0
1.1.2
-
diff --git a/spring-5-reactive-client/pom.xml b/spring-5-reactive-client/pom.xml
index 9388ee83c1..f2f7dd1729 100644
--- a/spring-5-reactive-client/pom.xml
+++ b/spring-5-reactive-client/pom.xml
@@ -11,8 +11,8 @@
spring 5 sample project about new features
- parent-boot-2
com.baeldung
+ parent-boot-2
0.0.1-SNAPSHOT
../parent-boot-2
@@ -43,20 +43,6 @@
javax.json.bind
javax.json.bind-api
-
-
-
-
-
-
-
-
-
-
-
-
-
-
org.apache.geronimo.specs
geronimo-json_1.1_spec
@@ -102,28 +88,6 @@
test
-
- org.junit.jupiter
- junit-jupiter-api
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.platform
- junit-platform-surefire-provider
- ${junit.platform.version}
- test
-
-
- org.junit.platform
- junit-platform-runner
- ${junit.platform.version}
- test
-
-
org.projectlombok
lombok
@@ -145,54 +109,10 @@
JAR
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- 3
- true
- methods
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LiveTest.java
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
- UTF-8
- UTF-8
- 1.8
- 1.0.0
- 5.0.0
- 2.20
- 5.0.2.RELEASE
1.0.1.RELEASE
1.1.3
1.0
diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml
index acc82be0d1..f89fd45581 100644
--- a/spring-5-reactive/pom.xml
+++ b/spring-5-reactive/pom.xml
@@ -43,20 +43,6 @@
org.springframework.boot
spring-boot-starter-actuator
-
-
-
-
-
-
-
-
-
-
-
-
-
-
org.projectlombok
lombok
@@ -100,28 +86,6 @@
${commons-collections4.version}
test
-
-
- org.junit.jupiter
- junit-jupiter-api
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.platform
- junit-platform-surefire-provider
- ${junit.platform.version}
- test
-
-
- org.junit.platform
- junit-platform-runner
- ${junit.platform.version}
- test
-
org.apache.commons
commons-lang3
@@ -159,29 +123,10 @@
JAR
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- 3
- true
- methods
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LiveTest.java
-
-
-
- 1.0.0
- 5.0.2
- 2.20
1.0.1.RELEASE
2.1.12
1.1.3
diff --git a/spring-5-security/pom.xml b/spring-5-security/pom.xml
index 7024e6f873..1435019c24 100644
--- a/spring-5-security/pom.xml
+++ b/spring-5-security/pom.xml
@@ -76,44 +76,7 @@
JAR
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- 3
- true
- methods
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LiveTest.java
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
\ No newline at end of file
diff --git a/spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerTest.java b/spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java
similarity index 97%
rename from spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerTest.java
rename to spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java
index 7a8ea7b248..9d08cb7cfa 100644
--- a/spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerTest.java
+++ b/spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java
@@ -14,7 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = InMemoryAuthApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
-public class InMemoryAuthControllerTest {
+public class InMemoryAuthControllerIntegrationTest {
@Autowired
private TestRestTemplate template;
diff --git a/spring-5/pom.xml b/spring-5/pom.xml
index e37833ff94..9f60b8a364 100644
--- a/spring-5/pom.xml
+++ b/spring-5/pom.xml
@@ -41,18 +41,6 @@
javax.json.bind
javax.json.bind-api
-
-
-
-
-
-
-
-
-
-
-
-
org.apache.geronimo.specs
geronimo-json_1.1_spec
@@ -85,45 +73,21 @@
org.springframework
spring-test
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
org.springframework.security
spring-security-test
test
-
org.apache.commons
commons-collections4
${commons-collections4.version}
test
-
org.junit.jupiter
junit-jupiter-api
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.platform
- junit-platform-surefire-provider
- ${junit.platform.version}
- test
-
-
- org.junit.platform
- junit-platform-runner
- ${junit.platform.version}
- test
-
org.springframework.restdocs
@@ -147,22 +111,6 @@
JAR
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- 3
- true
- methods
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LiveTest.java
-
-
-
org.asciidoctor
asciidoctor-maven-plugin
@@ -190,9 +138,6 @@
- 1.0.0
- 5.0.2.RELEASE
- 1.0.1.RELEASE
1.0
1.5.6
4.1
diff --git a/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationTests.java b/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationTests.java
deleted file mode 100644
index 1add635ed8..0000000000
--- a/spring-boot-mvc/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationTests.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.baeldung.springbootmvc;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class SpringBootMvcApplicationTests {
-
- @Test
- public void contextLoads() {
- }
-
-}
diff --git a/spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationTests.java b/spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationUnitTest.java
similarity index 96%
rename from spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationTests.java
rename to spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationUnitTest.java
index 6364351eb3..567b239ed2 100644
--- a/spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationTests.java
+++ b/spring-boot-vue/src/test/java/com/baeldung/springbootmvc/SpringBootMvcApplicationUnitTest.java
@@ -16,7 +16,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
-public class SpringBootMvcApplicationTests {
+public class SpringBootMvcApplicationUnitTest {
@Autowired
private MockMvc mockMvc;
diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml
index ef30600d45..3a43dbd828 100644
--- a/spring-boot/pom.xml
+++ b/spring-boot/pom.xml
@@ -149,6 +149,12 @@
rome
${rome.version}
+
+
+ de.codecentric
+ chaos-monkey-spring-boot
+ ${chaos.monkey.version}
+
@@ -219,9 +225,11 @@
8.5.11
2.4.1.Final
1.9.0
+ 2.0.0
3.6.0
3.2.0
18.0
+ 1.2.0
\ No newline at end of file
diff --git a/spring-boot/src/main/java/com/baeldung/chaosmonkey/SpringBootChaosMonkeyApp.java b/spring-boot/src/main/java/com/baeldung/chaosmonkey/SpringBootChaosMonkeyApp.java
new file mode 100644
index 0000000000..16a0aea13b
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/chaosmonkey/SpringBootChaosMonkeyApp.java
@@ -0,0 +1,15 @@
+package com.baeldung.chaosmonkey;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Created by adi on 8/2/18.
+ */
+@SpringBootApplication(scanBasePackages = { "com.baeldung.chaosmonkey" })
+public class SpringBootChaosMonkeyApp {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootChaosMonkeyApp.class, args);
+ }
+}
diff --git a/spring-boot/src/main/java/com/baeldung/chaosmonkey/controller/PermissionsController.java b/spring-boot/src/main/java/com/baeldung/chaosmonkey/controller/PermissionsController.java
new file mode 100644
index 0000000000..6ceb117f4e
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/chaosmonkey/controller/PermissionsController.java
@@ -0,0 +1,25 @@
+package com.baeldung.chaosmonkey.controller;
+
+import com.baeldung.chaosmonkey.service.PermissionsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * Created by adi on 8/2/18.
+ */
+@RestController
+@RequestMapping("/permissions")
+public class PermissionsController {
+
+ @Autowired private PermissionsService permissionsService;
+
+ @GetMapping
+ public List getAllPermissions() {
+ return permissionsService.getAllPermissions();
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/chaosmonkey/service/PermissionsService.java b/spring-boot/src/main/java/com/baeldung/chaosmonkey/service/PermissionsService.java
new file mode 100644
index 0000000000..435e262901
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/chaosmonkey/service/PermissionsService.java
@@ -0,0 +1,17 @@
+package com.baeldung.chaosmonkey.service;
+
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by adi on 8/2/18.
+ */
+@Service
+public class PermissionsService {
+
+ public List getAllPermissions() {
+ return Arrays.asList("CREATE", "READ", "UPDATE", "DELETE");
+ }
+}
diff --git a/spring-boot/src/main/resources/application.properties b/spring-boot/src/main/resources/application.properties
index 8c02e528ab..629e880940 100644
--- a/spring-boot/src/main/resources/application.properties
+++ b/spring-boot/src/main/resources/application.properties
@@ -43,3 +43,34 @@ servlet.mapping=/dispatcherExampleURL
#spring.banner.image.invert= //TODO
contactInfoType=email
+
+#chaos monkey for spring boot props
+management.endpoint.chaosmonkey.enabled=true
+management.endpoint.chaosmonkeyjmx.enabled=true
+
+spring.profiles.active=chaos-monkey
+#Determine whether should execute or not
+chaos.monkey.enabled=true
+#How many requests are to be attacked. 1: attack each request; 5: each 5th request is attacked
+chaos.monkey.assaults.level=1
+#Minimum latency in ms added to the request
+chaos.monkey.assaults.latencyRangeStart=3000
+#Maximum latency in ms added to the request
+chaos.monkey.assaults.latencyRangeEnd=15000
+#Latency assault active
+chaos.monkey.assaults.latencyActive=true
+#Exception assault active
+chaos.monkey.assaults.exceptionsActive=false
+#AppKiller assault active
+chaos.monkey.assaults.killApplicationActive=false
+#Controller watcher active
+chaos.monkey.watcher.controller=false
+#RestController watcher active
+chaos.monkey.watcher.restController=false
+#Service watcher active
+chaos.monkey.watcher.service=true
+#Repository watcher active
+chaos.monkey.watcher.repository=false
+#Component watcher active
+chaos.monkey.watcher.component=false
+
diff --git a/spring-cloud/spring-cloud-connectors-heroku/pom.xml b/spring-cloud/spring-cloud-connectors-heroku/pom.xml
index 875aa5ceaa..f25c190d56 100644
--- a/spring-cloud/spring-cloud-connectors-heroku/pom.xml
+++ b/spring-cloud/spring-cloud-connectors-heroku/pom.xml
@@ -79,7 +79,7 @@
Brixton.SR7
- 2.19.1
+ 2.21.0
9.4-1201-jdbc4
diff --git a/spring-cloud/spring-cloud-gateway/pom.xml b/spring-cloud/spring-cloud-gateway/pom.xml
index db57373b6f..8babbff274 100644
--- a/spring-cloud/spring-cloud-gateway/pom.xml
+++ b/spring-cloud/spring-cloud-gateway/pom.xml
@@ -28,7 +28,7 @@
org.springframework.cloud
- spring-cloud-starter-gateway
+ spring-cloud-starter
org.springframework.boot
@@ -54,27 +54,8 @@
-
-
- spring-snapshots
- Spring Snapshots
- https://repo.spring.io/snapshot
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
- 2.0.0.RC2
+ 2.0.1.RELEASE
6.0.2.Final
diff --git a/spring-cloud/spring-cloud-ribbon-client/pom.xml b/spring-cloud/spring-cloud-ribbon-client/pom.xml
index eb8398848c..fd69dbe043 100644
--- a/spring-cloud/spring-cloud-ribbon-client/pom.xml
+++ b/spring-cloud/spring-cloud-ribbon-client/pom.xml
@@ -38,25 +38,6 @@
-
-
- spring-snapshots
- Spring Snapshots
- https://repo.spring.io/snapshot
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
Brixton.SR7
diff --git a/spring-reactive-kotlin/pom.xml b/spring-reactive-kotlin/pom.xml
index 8eafe9f217..f2f0dc58ec 100644
--- a/spring-reactive-kotlin/pom.xml
+++ b/spring-reactive-kotlin/pom.xml
@@ -19,9 +19,6 @@
- UTF-8
- UTF-8
- 1.8
1.2.41
diff --git a/spring-rest-embedded-tomcat/pom.xml b/spring-rest-embedded-tomcat/pom.xml
index edccbb17d5..1a1adce6db 100644
--- a/spring-rest-embedded-tomcat/pom.xml
+++ b/spring-rest-embedded-tomcat/pom.xml
@@ -85,7 +85,6 @@
- 2.19.1
2.9.2
1.8
1.8
diff --git a/spring-security-openid/pom.xml b/spring-security-openid/pom.xml
index 9c498f3700..a2c0b6b119 100644
--- a/spring-security-openid/pom.xml
+++ b/spring-security-openid/pom.xml
@@ -51,27 +51,6 @@
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
2.2.1.RELEASE
1.0.9.RELEASE
diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml
index c60cc00c2c..93365264ac 100644
--- a/testing-modules/junit-5/pom.xml
+++ b/testing-modules/junit-5/pom.xml
@@ -118,14 +118,14 @@
- 5.1.0
- 1.1.0
+ 5.2.0
+ 1.2.0
5.2.0
2.8.2
1.4.196
2.8.9
1.7.4
- 2.19.1
+ 2.21.0
1.6.0
5.0.1.RELEASE
diff --git a/testing-modules/junit5-migration/pom.xml b/testing-modules/junit5-migration/pom.xml
index ae46b479bb..9d9d418774 100644
--- a/testing-modules/junit5-migration/pom.xml
+++ b/testing-modules/junit5-migration/pom.xml
@@ -80,10 +80,10 @@
- 5.1.0
- 1.1.0
+ 5.2.0
+ 1.2.0
5.2.0
- 2.19.1
+ 2.21.0
1.6.0
diff --git a/testing-modules/test-containers/pom.xml b/testing-modules/test-containers/pom.xml
index 2a8f434040..0ace187555 100644
--- a/testing-modules/test-containers/pom.xml
+++ b/testing-modules/test-containers/pom.xml
@@ -109,7 +109,7 @@
1.7.2
42.2.2
3.12.0
- 2.19.1
+ 2.21.0