Repository: jhipster/generator-jhipster
Pull request #9852 (2019-06-04 06:08:00)

Daily builds: add missing badges [skip ci]
-   Please make sure the below checklist is followed for Pull Requests.

-   [ ] [Travis tests](https://travis-ci.org/jhipster/generator-jhipster/pull_requests) are green
-   [ ] Tests are added where necessary
-   [ ] Documentation is added/updated where necessary
-   [ ] Coding Rules & Commit Guidelines as per our [CONTRIBUTING.md document](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) are followed

<!--
Please also reference the issue number in a commit message to [automatically close the related Github issue](https://help.github.com/articles/closing-issues-via-commit-messages/)

Note: It is also possible to add `[skip ci]` to your commit message to skip Travis tests
-->



Patch:
diff --git a/README.md b/README.md
index 8ff416e8b3..f0aaddccd1 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,7 @@ Additional builds at [hipster-labs/jhipster-daily-builds](https://github.com/hip
 | Type                 | Status                                                 |
 | :------------------- | :----------------------------------------------------- |
 | Docker               | [![Build Status][img-docker]][azure-url]               |
+| Official             | [![Build Status][img-official]][azure-url]             |
 | Angular.Maven        | [![Build Status][img-angular-maven]][azure-url]        |
 | Angular.Maven.NoSQL  | [![Build Status][img-angular-maven-nosql]][azure-url]  |
 | Angular.Gradle       | [![Build Status][img-angular-gradle]][azure-url]       |
@@ -55,6 +56,10 @@ Additional builds at [hipster-labs/jhipster-daily-builds](https://github.com/hip
 | Microservices.JWT    | [![Build Status][img-ms-jwt]][azure-url]               |
 | Microservices.OAuth2 | [![Build Status][img-ms-oauth2]][azure-url]            |
 | Microservices.UAA    | [![Build Status][img-ms-uaa]][azure-url]               |
+| Monolith.OAuth2      | [![Build Status][img-monolith-oauth2]][azure-url]      |
+| Official OpenJDK 8   | [![Build Status][img-official-openjdk8]][azure-url]    |
+| Yarn                 | [![Build Status][img-yarn]][azure-url]                 |
+| No Database          | [![Build Status][img-nodatabase]][azure-url]           |
 
 ## Analysis of the sample JHipster project
 
@@ -62,6 +67,7 @@ Additional builds at [hipster-labs/jhipster-daily-builds](https://github.com/hip
 
 [azure-url]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_build
 [img-docker]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Docker.Image
+[img-official]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Official
 [img-angular-maven]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Angular.Maven
 [img-angular-maven-nosql]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Angular.Maven.NoSQL
 [img-angular-gradle]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Angular.Gradle
@@ -74,6 +80,10 @@ Additional builds at [hipster-labs/jhipster-daily-builds](https://github.com/hip
 [img-ms-jwt]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Microservices.JWT
 [img-ms-oauth2]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Microservices.OAuth2
 [img-ms-uaa]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Microservices.UAA
+[img-monolith-oauth2]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Monolith.OAuth2
+[img-official-openjdk8]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Official.OpenJDK8
+[img-yarn]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/Yarn
+[img-nodatabase]: https://dev.azure.com/hipster-labs/jhipster-daily-builds/_apis/build/status/NoDatabase
 [sonar-url]: https://sonarcloud.io/dashboard?id=io.github.jhipster.sample%3Ajhipster-sample-application
 [sonar-quality-gate]: https://sonarcloud.io/api/project_badges/measure?project=io.github.jhipster.sample%3Ajhipster-sample-application&metric=alert_status
 [sonar-coverage]: https://sonarcloud.io/api/project_badges/measure?project=io.github.jhipster.sample%3Ajhipster-sample-application&metric=coverage
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 8f57814300..be75b43c03 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -38,6 +38,7 @@ jobs:
           JHI_DISABLE_WEBPACK_LOGS: true
           JHI_E2E_HEADLESS: true
           JHI_SCRIPTS: $(Build.Repository.LocalPath)/test-integration/scripts
+          NG_CLI_ANALYTICS: false
 
       strategy:
           matrix:
diff --git a/generators/client/templates/angular/package.json.ejs b/generators/client/templates/angular/package.json.ejs
index 34ac95cf8d..d7ca08b37f 100644
--- a/generators/client/templates/angular/package.json.ejs
+++ b/generators/client/templates/angular/package.json.ejs
@@ -46,7 +46,7 @@
     <%_ } _%>
     "core-js": "3.1.3",
     "moment": "2.24.0",
-    "ng-jhipster": "0.9.3",
+    "ng-jhipster": "0.10.1",
     "ngx-cookie": "4.0.2",
     "ngx-infinite-scroll": "7.1.0",
     "ngx-webstorage": "4.0.0",
diff --git a/generators/docker-compose/templates/kafka.yml.ejs b/generators/docker-compose/templates/kafka.yml.ejs
index 1cd6caf608..b90ad2ef0e 100644
--- a/generators/docker-compose/templates/kafka.yml.ejs
+++ b/generators/docker-compose/templates/kafka.yml.ejs
@@ -20,12 +20,16 @@ version: '<%= DOCKER_COMPOSE_FORMAT_VERSION %>'
 services:
     zookeeper:
         image: <%= DOCKER_ZOOKEEPER %>
+        environment:
+            ZOOKEEPER_CLIENT_PORT: 2181
+            ZOOKEEPER_TICK_TIME: 2000
+            ZOOKEEPER_SYNC_LIMIT: 2
     kafka:
         image: <%= DOCKER_KAFKA %>
         environment:
-            KAFKA_ADVERTISED_HOST_NAME: kafka
-            KAFKA_ADVERTISED_PORT: 9092
+            KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
             KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
-            KAFKA_CREATE_TOPICS: "topic-jhipster:1:1"
+            KAFKA_BROKER_ID: 2
+            KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
         #ports:
         #    - 9092:9092  # Uncomment to make Kafka available externally
diff --git a/generators/generator-constants.js b/generators/generator-constants.js
index 57babae94f..d32cd9077d 100644
--- a/generators/generator-constants.js
+++ b/generators/generator-constants.js
@@ -31,8 +31,8 @@ const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.12';
 const DOCKER_MEMCACHED = 'memcached:1.5.15-alpine';
 const DOCKER_KEYCLOAK = 'jboss/keycloak:6.0.1';
 const DOCKER_ELASTICSEARCH = 'docker.elastic.co/elasticsearch/elasticsearch:6.4.3'; // The version should be coerent with the one from spring-data-elasticsearch project
-const DOCKER_KAFKA = 'wurstmeister/kafka:2.11-2.0.1';
-const DOCKER_ZOOKEEPER = 'wurstmeister/zookeeper:3.4.6';
+const DOCKER_KAFKA = 'confluentinc/cp-kafka:5.2.1';
+const DOCKER_ZOOKEEPER = 'confluentinc/cp-zookeeper:5.2.1';
 const DOCKER_SONAR = 'sonarqube:7.7-community';
 const DOCKER_JHIPSTER_CONSOLE = 'jhipster/jhipster-console:v4.0.0';
 const DOCKER_JHIPSTER_CURATOR = 'jhipster/jhipster-curator:v4.0.0';
diff --git a/generators/kubernetes/templates/deployment.yml.ejs b/generators/kubernetes/templates/deployment.yml.ejs
index 773f8c8052..fc81122d00 100644
--- a/generators/kubernetes/templates/deployment.yml.ejs
+++ b/generators/kubernetes/templates/deployment.yml.ejs
@@ -151,10 +151,10 @@ spec:
           value: http://<%= app.baseName.toLowerCase() %>-elasticsearch.<%= kubernetesNamespace %>.svc.cluster.local:9200
         <%_ } _%>
         <%_ if (app.messageBroker === 'kafka') { _%>
-        - name: SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS
-          value: jhipster-kafka.<%= kubernetesNamespace %>.svc.cluster.local
-        - name: SPRING_CLOUD_STREAM_KAFKA_BINDER_ZK_NODES
-          value: jhipster-zookeeper.<%= kubernetesNamespace %>.svc.cluster.local
+        - name: SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS
+          value: 'jhipster-kafka.<%= kubernetesNamespace %>.svc.cluster.local:9092'
+        - name: SPRING_KAFKA_PRODUCER_BOOTSTRAP_SERVERS
+          value: 'jhipster-kafka.<%= kubernetesNamespace %>.svc.cluster.local:9092'
         <%_ } _%>
         <%_ if (monitoring === 'elk') { _%>
         - name: JHIPSTER_METRICS_LOGS_ENABLED
diff --git a/generators/kubernetes/templates/messagebroker/kafka.yml.ejs b/generators/kubernetes/templates/messagebroker/kafka.yml.ejs
index 58c4ea1864..d1eb7208e1 100644
--- a/generators/kubernetes/templates/messagebroker/kafka.yml.ejs
+++ b/generators/kubernetes/templates/messagebroker/kafka.yml.ejs
@@ -39,14 +39,14 @@ spec:
       - name: kafka
         image: <%= DOCKER_KAFKA %>
         env:
-        - name: KAFKA_ADVERTISED_HOST_NAME
-          value: jhipster-kafka.<%= kubernetesNamespace %>.svc.cluster.local
-        - name: KAFKA_ADVERTISED_PORT
-          value: '9092'
+        - name: KAFKA_ADVERTISED_LISTENERS
+          value: 'PLAINTEXT://jhipster-kafka.<%= kubernetesNamespace %>.svc.cluster.local:9092'
         - name: KAFKA_ZOOKEEPER_CONNECT
-          value: jhipster-zookeeper.<%= kubernetesNamespace %>.svc.cluster.local:2181
-        - name: KAFKA_CREATE_TOPICS
-          value: 'topic-jhipster:1:1'
+          value: 'jhipster-zookeeper.<%= kubernetesNamespace %>.svc.cluster.local:2181'
+        - name: KAFKA_BROKER_ID
+          value: '2'
+        - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
+          value: '1'
         ports:
         - containerPort: 9092
 ---
@@ -83,6 +83,13 @@ spec:
       containers:
       - name: zookeeper
         image: <%= DOCKER_ZOOKEEPER %>
+        env:
+        - name: ZOOKEEPER_CLIENT_PORT
+          value: '2181'
+        - name: ZOOKEEPER_TICK_TIME
+          value: '2000'
+        - name: ZOOKEEPER_SYNC_LIMIT
+          value: '2'
         ports:
         - containerPort: 2181
 ---
diff --git a/generators/openshift/templates/deployment.yml.ejs b/generators/openshift/templates/deployment.yml.ejs
index daaf60b3cf..1d50a22663 100644
--- a/generators/openshift/templates/deployment.yml.ejs
+++ b/generators/openshift/templates/deployment.yml.ejs
@@ -233,10 +233,10 @@ objects:
               value: http://${APPLICATION_NAME}-elasticsearch:9200
             <%_ } _%>
             <%_ if (app.messageBroker === 'kafka') { _%>
-            - name: SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS
-              value: jhipster-kafka
-            - name: SPRING_CLOUD_STREAM_KAFKA_BINDER_ZK_NODES
-              value: jhipster-zookeeper
+            - name: SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS
+              value: jhipster-kafka:9092
+            - name: SPRING_KAFKA_PRODUCER_BOOTSTRAP_SERVERS
+              value: jhipster-kafka:9092
             <%_ } _%>
             <%_ if (monitoring === 'elk') { _%>
             - name: JHIPSTER_METRICS_LOGS_ENABLED
diff --git a/generators/openshift/templates/messagebroker/kafka.yml.ejs b/generators/openshift/templates/messagebroker/kafka.yml.ejs
index 53b1ce5fc6..18e131b435 100644
--- a/generators/openshift/templates/messagebroker/kafka.yml.ejs
+++ b/generators/openshift/templates/messagebroker/kafka.yml.ejs
@@ -134,6 +134,13 @@ objects:
           containers:
           - name: ${ZK_APPLICATION_NAME}
             image: <%= DOCKER_ZOOKEEPER %>
+            env:
+            - name: ZOOKEEPER_CLIENT_PORT
+              value: 2181
+            - name: ZOOKEEPER_TICK_TIME
+              value: 2000
+            - name: ZOOKEEPER_SYNC_LIMIT
+              value: 2
             ports:
             - containerPort: 2181
             volumeMounts:
@@ -203,14 +210,14 @@ objects:
           - name: ${APPLICATION_NAME}
             image: <%= DOCKER_KAFKA %>
             env:
-            - name: KAFKA_ADVERTISED_HOST_NAME
-              value: ${APPLICATION_NAME}
-            - name: KAFKA_ADVERTISED_PORT
-              value: '9092'
+            - name: KAFKA_ADVERTISED_LISTENERS
+              value: PLAINTEXT://${APPLICATION_NAME}:9092
             - name: KAFKA_ZOOKEEPER_CONNECT
-              value: ${ZK_APPLICATION_NAME}
-            - name: KAFKA_CREATE_TOPICS
-              value: 'topic-jhipster:1:1'
+              value: ${ZK_APPLICATION_NAME}:2181
+            - name: KAFKA_BROKER_ID
+              value: 2
+            - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
+              value: 1
             ports:
             - containerPort: 9092
             volumeMounts:
diff --git a/generators/server/files.js b/generators/server/files.js
index 3417089669..357b491022 100644
--- a/generators/server/files.js
+++ b/generators/server/files.js
@@ -957,16 +957,6 @@ const serverFiles = {
                     renameTo: generator => `${generator.javaDir}config/ElasticsearchConfiguration.java`
                 }
             ]
-        },
-        {
-            condition: generator => generator.messageBroker === 'kafka',
-            path: SERVER_MAIN_SRC_DIR,
-            templates: [
-                {
-                    file: 'package/config/MessagingConfiguration.java',
-                    renameTo: generator => `${generator.javaDir}config/MessagingConfiguration.java`
-                }
-            ]
         }
     ],
     serverJavaDomain: [
@@ -1020,6 +1010,22 @@ const serverFiles = {
             templates: [
                 { file: 'package/service/util/RandomUtil.java', renameTo: generator => `${generator.javaDir}service/util/RandomUtil.java` }
             ]
+        },
+        {
+            condition: generator => generator.messageBroker === 'kafka',
+            path: SERVER_MAIN_SRC_DIR,
+            templates: [
+                {
+                    file: 'package/service/KafkaConsumer.java',
+                    renameTo: generator =>
+                        `${generator.javaDir}service/${generator.upperFirstCamelCase(generator.baseName)}KafkaConsumer.java`
+                },
+                {
+                    file: 'package/service/KafkaProducer.java',
+                    renameTo: generator =>
+                        `${generator.javaDir}service/${generator.upperFirstCamelCase(generator.baseName)}KafkaProducer.java`
+                }
+            ]
         }
     ],
     serverJavaWebError: [
@@ -1094,6 +1100,17 @@ const serverFiles = {
                     renameTo: generator => `${generator.javaDir}web/rest/ClientForwardController.java`
                 }
             ]
+        },
+        {
+            condition: generator => generator.messageBroker === 'kafka',
+            path: SERVER_MAIN_SRC_DIR,
+            templates: [
+                {
+                    file: 'package/web/rest/KafkaResource.java',
+                    renameTo: generator =>
+                        `${generator.javaDir}web/rest/${generator.upperFirstCamelCase(generator.baseName)}KafkaResource.java`
+                }
+            ]
         }
     ],
     serverJavaWebsocket: [
@@ -1315,6 +1332,17 @@ const serverFiles = {
                     renameTo: generator => `${generator.testDir}security/DomainUserDetailsServiceIT.java`
                 }
             ]
+        },
+        {
+            condition: generator => generator.messageBroker === 'kafka',
+            path: SERVER_TEST_SRC_DIR,
+            templates: [
+                {
+                    file: 'package/web/rest/KafkaResourceIT.java',
+                    renameTo: generator =>
+                        `${generator.testDir}web/rest/${generator.upperFirstCamelCase(generator.baseName)}KafkaResourceIT.java`
+                }
+            ]
         }
     ],
     serverJavaUserManagement: [
diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs
index 6cf3950e96..240d777a74 100644
--- a/generators/server/templates/build.gradle.ejs
+++ b/generators/server/templates/build.gradle.ejs
@@ -362,8 +362,6 @@ dependencies {
     implementation "org.springframework.boot:spring-boot-starter-data-<%=databaseType%><% if (reactive) { %>-reactive<% } %>"
     <%_ } _%>
     <%_ if (messageBroker === 'kafka') { _%>
-    implementation "org.springframework.cloud:spring-cloud-stream"
-    implementation "org.springframework.cloud:spring-cloud-stream-binder-kafka"
     implementation "org.springframework.kafka:spring-kafka"
     <%_ } _%>
     implementation "org.springframework.boot:spring-boot-starter-security"
@@ -501,7 +499,7 @@ dependencies {
     testImplementation "de.flapdoodle.embed:de.flapdoodle.embed.mongo"
     <%_ } _%>
     <%_ if (databaseType === 'couchbase') { _%>
-    testImplementation "com.github.differentway:couchbase-testcontainer"
+    testImplementation "org.testcontainers:couchbase"
     <%_ } _%>
     testImplementation "org.hamcrest:hamcrest-library"
     <%_ if (databaseType === 'sql') { _%>
@@ -515,7 +513,7 @@ dependencies {
     liquibaseRuntime "com.oracle.jdbc:ojdbc8"
     <%_ } _%>
     <%_ if (messageBroker === 'kafka') { _%>
-    testImplementation "org.springframework.cloud:spring-cloud-stream-test-support"
+    testImplementation "org.springframework.kafka:spring-kafka-test"
     <%_ } _%>
     //jhipster-needle-gradle-dependency - JHipster will add additional dependencies here
 }
diff --git a/generators/server/templates/gradle/profile_dev.gradle.ejs b/generators/server/templates/gradle/profile_dev.gradle.ejs
index 25a52c95ee..4dbe8e1389 100644
--- a/generators/server/templates/gradle/profile_dev.gradle.ejs
+++ b/generators/server/templates/gradle/profile_dev.gradle.ejs
@@ -16,8 +16,15 @@
  See the License for the specific language governing permissions and
  limitations under the License.
 -%>
+configurations {
+    developmentOnly
+    runtimeClasspath {
+        extendsFrom developmentOnly
+    }
+}
+
 dependencies {
-    runtimeOnly "org.springframework.boot:spring-boot-devtools"
+    developmentOnly "org.springframework.boot:spring-boot-devtools"
     <%_ if (devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { _%>
     implementation "com.h2database:h2"
     <%_ } _%>
diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs
index 4b9d19cba7..aab5373f67 100644
--- a/generators/server/templates/pom.xml.ejs
+++ b/generators/server/templates/pom.xml.ejs
@@ -318,8 +318,8 @@
 <%_ } _%>
 <%_ if (databaseType === 'couchbase') { _%>
         <dependency>
-            <groupId>com.github.differentway</groupId>
-            <artifactId>couchbase-testcontainer</artifactId>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>couchbase</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -577,16 +577,12 @@
 <%_ if (messageBroker === 'kafka') { _%>
         <!-- Kafka support -->
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-stream</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-stream-binder-kafka</artifactId>
-        </dependency>
+            <groupId>org.springframework.kafka</groupId>
+            <artifactId>spring-kafka</artifactId>
+		</dependency>
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-stream-test-support</artifactId>
+            <groupId>org.springframework.kafka</groupId>
+            <artifactId>spring-kafka-test</artifactId>
             <scope>test</scope>
         </dependency>
 <%_ } _%>
diff --git a/generators/server/templates/src/main/docker/app.yml.ejs b/generators/server/templates/src/main/docker/app.yml.ejs
index ce00d32999..1c6a63c413 100644
--- a/generators/server/templates/src/main/docker/app.yml.ejs
+++ b/generators/server/templates/src/main/docker/app.yml.ejs
@@ -73,23 +73,16 @@ services:
             - SPRING_DATA_CASSANDRA_CONTACTPOINTS=<%= baseName.toLowerCase() %>-cassandra
                 <%_ if (authenticationType === 'uaa') { _%>
             - JHIPSTER_SLEEP=80 # gives time for uaa and the Cassandra cluster to start and execute the migration scripts
-                <%_ } else { _%>
-            - JHIPSTER_SLEEP=30 # gives time for the Cassandra cluster to start and execute the migration scripts
-                <%_ } _%>
-            <%_ } else { _%>
-                <%_ if (serviceDiscoveryType === 'eureka') { _%>
-            - JHIPSTER_SLEEP=30 # gives time for the JHipster Registry to boot before the application
-                <%_ } else { _%>
-            - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application
                 <%_ } _%>
             <%_ } _%>
+            - JHIPSTER_SLEEP=30 # gives time for other services to boot before the application
             <%_ if (searchEngine === 'elasticsearch') { _%>
             - SPRING_DATA_JEST_URI=http://<%= baseName.toLowerCase() %>-elasticsearch:9200
             - SPRING_ELASTICSEARCH_REST_URIS=http://<%= baseName.toLowerCase() %>-elasticsearch:9200
             <%_ } _%>
             <%_ if (messageBroker === 'kafka') { _%>
-            - SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS=kafka
-            - SPRING_CLOUD_STREAM_KAFKA_BINDER_ZK_NODES=zookeeper
+            - SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS=kafka:9092
+            - SPRING_KAFKA_PRODUCER_BOOTSTRAP_SERVERS=kafka:9092
             <%_ } _%>
             <%_ if (cacheProvider === 'infinispan') { _%>
             - JAVA_OPTS=-Djgroups.tcp.address=NON_LOOPBACK -Djava.net.preferIPv4Stack=true
diff --git a/generators/server/templates/src/main/docker/kafka.yml.ejs b/generators/server/templates/src/main/docker/kafka.yml.ejs
index 3f83ebb700..b984cfcf55 100644
--- a/generators/server/templates/src/main/docker/kafka.yml.ejs
+++ b/generators/server/templates/src/main/docker/kafka.yml.ejs
@@ -20,14 +20,18 @@ version: '2'
 services:
     zookeeper:
         image: <%= DOCKER_ZOOKEEPER %>
+        environment:
+            ZOOKEEPER_CLIENT_PORT: 2181
+            ZOOKEEPER_TICK_TIME: 2000
+            ZOOKEEPER_SYNC_LIMIT: 2
         ports:
             - 2181:2181
     kafka:
         image: <%= DOCKER_KAFKA %>
         environment:
-            KAFKA_ADVERTISED_HOST_NAME: localhost
-            KAFKA_ADVERTISED_PORT: 9092
+            KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
             KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
-            KAFKA_CREATE_TOPICS: "topic-jhipster:1:1"
+            KAFKA_BROKER_ID: 2
+            KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
         ports:
             - 9092:9092
diff --git a/generators/server/templates/src/main/java/package/service/KafkaConsumer.java.ejs b/generators/server/templates/src/main/java/package/service/KafkaConsumer.java.ejs
new file mode 100644
index 0000000000..e05ecbb055
--- /dev/null
+++ b/generators/server/templates/src/main/java/package/service/KafkaConsumer.java.ejs
@@ -0,0 +1,38 @@
+<%#
+ Copyright 2013-2019 the original author or authors from the JHipster project.
+
+ This file is part of the JHipster project, see https://www.jhipster.tech/
+ for more information.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-%>
+package <%=packageName%>.service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+
+@Service
+public class <%= upperFirstCamelCase(baseName) %>KafkaConsumer {
+
+    private final Logger log = LoggerFactory.getLogger(<%= upperFirstCamelCase(baseName) %>KafkaConsumer.class);
+    private static final String TOPIC = "topic_<%= baseName.toLowerCase() %>";
+
+    @KafkaListener(topics = "topic_<%= baseName.toLowerCase() %>", groupId = "group_id")
+    public void consume(String message) throws IOException {
+        log.info("Consumed message in {} : {}", TOPIC, message);
+    }
+}
diff --git a/generators/server/templates/src/main/java/package/service/KafkaProducer.java.ejs b/generators/server/templates/src/main/java/package/service/KafkaProducer.java.ejs
new file mode 100644
index 0000000000..4d4f3c1177
--- /dev/null
+++ b/generators/server/templates/src/main/java/package/service/KafkaProducer.java.ejs
@@ -0,0 +1,42 @@
+<%#
+ Copyright 2013-2019 the original author or authors from the JHipster project.
+
+ This file is part of the JHipster project, see https://www.jhipster.tech/
+ for more information.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-%>
+package <%=packageName%>.service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.stereotype.Service;
+
+@Service
+public class <%= upperFirstCamelCase(baseName) %>KafkaProducer {
+
+    private static final Logger log = LoggerFactory.getLogger(<%= upperFirstCamelCase(baseName) %>KafkaProducer.class);
+    private static final String TOPIC = "topic_<%= baseName.toLowerCase() %>";
+
+    private KafkaTemplate<String, String> kafkaTemplate;
+
+    public <%= upperFirstCamelCase(baseName) %>KafkaProducer(KafkaTemplate<String, String> kafkaTemplate) {
+        this.kafkaTemplate = kafkaTemplate;
+    }
+
+    public void sendMessage(String message) {
+        log.info("Producing message to {} : {}", TOPIC, message);
+        this.kafkaTemplate.send(TOPIC, message);
+    }
+}
diff --git a/generators/server/templates/src/main/java/package/web/rest/KafkaResource.java.ejs b/generators/server/templates/src/main/java/package/web/rest/KafkaResource.java.ejs
new file mode 100644
index 0000000000..5378972b02
--- /dev/null
+++ b/generators/server/templates/src/main/java/package/web/rest/KafkaResource.java.ejs
@@ -0,0 +1,43 @@
+<%#
+ Copyright 2013-2019 the original author or authors from the JHipster project.
+
+ This file is part of the JHipster project, see https://www.jhipster.tech/
+ for more information.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-%>
+package <%=packageName%>.web.rest;
+
+import <%=packageName%>.service.<%= upperFirstCamelCase(baseName) %>KafkaProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping(value = "/api/<%= dasherizedBaseName %>-kafka")
+public class <%= upperFirstCamelCase(baseName) %>KafkaResource {
+
+    private final Logger log = LoggerFactory.getLogger(<%= upperFirstCamelCase(baseName) %>KafkaResource.class);
+
+    private <%= upperFirstCamelCase(baseName) %>KafkaProducer kafkaProducer;
+
+    public <%= upperFirstCamelCase(baseName) %>KafkaResource(<%= upperFirstCamelCase(baseName) %>KafkaProducer kafkaProducer) {
+        this.kafkaProducer = kafkaProducer;
+    }
+
+    @PostMapping(value = "/publish")
+    public void sendMessageToKafkaTopic(@RequestParam("message") String message) {
+        log.debug("REST request to send to Kafka topic the message : {}", message);
+        this.kafkaProducer.sendMessage(message);
+    }
+}
diff --git a/generators/server/templates/src/main/resources/config/application-dev.yml.ejs b/generators/server/templates/src/main/resources/config/application-dev.yml.ejs
index 528c9482cf..3cefe041fd 100644
--- a/generators/server/templates/src/main/resources/config/application-dev.yml.ejs
+++ b/generators/server/templates/src/main/resources/config/application-dev.yml.ejs
@@ -74,25 +74,26 @@ spring:
     jackson:
         serialization:
             indent-output: true
-    <%_ if (messageBroker === 'kafka' || serviceDiscoveryType === 'consul') { _%>
+    <%_ if (messageBroker === 'kafka') { _%>
+    kafka:
+        consumer:
+            bootstrap-servers: localhost:9092
+            group-id: group_id
+            auto-offset-reset: earliest
+            key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+            value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+        producer:
+            bootstrap-servers: localhost:9092
+            key-serializer: org.apache.kafka.common.serialization.StringSerializer
+            value-serializer: org.apache.kafka.common.serialization.StringSerializer
+    <%_ } _%>
+    <%_ if (serviceDiscoveryType === 'consul') { _%>
     cloud:
-        <%_ if (serviceDiscoveryType === 'consul') { _%>
         consul:
             discovery:
                prefer-ip-address: true
             host: localhost
             port: 8500
-        <%_ } _%>
-        <%_ if (messageBroker === 'kafka') { _%>
-        stream:
-            kafka:
-                binder:
-                    brokers: localhost
-                    zk-nodes: localhost
-            bindings:
-                output:
-                    destination: topic-jhipster
-        <%_ } _%>
     <%_ } _%>
     <%_ if (databaseType === 'sql') { _%>
     datasource:
diff --git a/generators/server/templates/src/main/resources/config/application-prod.yml.ejs b/generators/server/templates/src/main/resources/config/application-prod.yml.ejs
index 517abce581..08995cb1b8 100644
--- a/generators/server/templates/src/main/resources/config/application-prod.yml.ejs
+++ b/generators/server/templates/src/main/resources/config/application-prod.yml.ejs
@@ -58,25 +58,26 @@ spring:
             enabled: false
         livereload:
             enabled: false
-    <%_ if (messageBroker === 'kafka' || serviceDiscoveryType === 'consul') { _%>
+    <%_ if (messageBroker === 'kafka') { _%>
+    kafka:
+        consumer:
+            bootstrap-servers: localhost:9092
+            group-id: group_id
+            auto-offset-reset: earliest
+            key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+            value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+        producer:
+            bootstrap-servers: localhost:9092
+            key-serializer: org.apache.kafka.common.serialization.StringSerializer
+            value-serializer: org.apache.kafka.common.serialization.StringSerializer
+    <%_ } _%>
+    <%_ if (serviceDiscoveryType === 'consul') { _%>
     cloud:
-        <%_ if (serviceDiscoveryType === 'consul') { _%>
         consul:
             discovery:
                prefer-ip-address: true
             host: localhost
             port: 8500
-        <%_ } _%>
-        <%_ if (messageBroker === 'kafka') { _%>
-        stream:
-            kafka:
-                binder:
-                    brokers: localhost
-                    zk-nodes: localhost
-            bindings:
-                output:
-                    destination: topic-jhipster
-        <%_ } _%>
     <%_ } _%>
     <%_ if (databaseType === 'sql') { _%>
     datasource:
diff --git a/generators/spring-controller/index.js b/generators/spring-controller/index.js
index 9d1f8d6704..844cda8838 100644
--- a/generators/spring-controller/index.js
+++ b/generators/spring-controller/index.js
@@ -75,6 +75,10 @@ module.exports = class extends BaseBlueprintGenerator {
                 this.packageName = configuration.get('packageName');
                 this.packageFolder = configuration.get('packageFolder');
                 this.databaseType = configuration.get('databaseType');
+                this.messageBroker = configuration.get('messageBroker') === 'no' ? false : configuration.get('messageBroker');
+                if (this.messageBroker === undefined) {
+                    this.messageBroker = false;
+                }
                 this.reactiveController = false;
                 this.applicationType = configuration.get('applicationType');
                 this.reactive = configuration.get('reactive');


Test patch:
diff --git a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
index d8c25d228c..b03e1a95e7 100644
--- a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
+++ b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
@@ -95,6 +95,9 @@ import org.springframework.data.domain.PageRequest;
 import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
 import org.springframework.http.MediaType;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 <%_ if (reactiveRepositories) { _%>
 import org.springframework.test.web.reactive.server.WebTestClient;
 <%_ } _%>
@@ -153,6 +156,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@Link <%= entityClass %>Resource} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 <%_ } else if (authenticationType === 'uaa' && applicationType !== 'uaa') { _%>
diff --git a/generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs b/generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs
index 82a536bb0a..295eba02de 100644
--- a/generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs
@@ -23,9 +23,15 @@ import com.datastax.driver.core.Session;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 public class CassandraKeyspaceIT extends AbstractCassandraTest {
 
diff --git a/generators/server/templates/src/test/java/package/config/DatabaseConfigurationIT.java.ejs b/generators/server/templates/src/test/java/package/config/DatabaseConfigurationIT.java.ejs
index 30e14c38df..64251e8ac1 100644
--- a/generators/server/templates/src/test/java/package/config/DatabaseConfigurationIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/config/DatabaseConfigurationIT.java.ejs
@@ -38,7 +38,7 @@ public class DatabaseConfigurationIT extends AbstractCouchbaseConfiguration {
 
     private CouchbaseProperties couchbaseProperties;
 
-    private static CouchbaseContainer<? extends CouchbaseContainer<?>> couchbaseContainer;
+    private static CouchbaseContainer couchbaseContainer;
 
     public DatabaseConfigurationIT(CouchbaseProperties couchbaseProperties) {
         this.couchbaseProperties = couchbaseProperties;
@@ -75,11 +75,11 @@ public class DatabaseConfigurationIT extends AbstractCouchbaseConfiguration {
         return this;
     }
 
-    private CouchbaseContainer<? extends CouchbaseContainer<?>> getCouchbaseContainer() {
+    private CouchbaseContainer getCouchbaseContainer() {
         if (couchbaseContainer != null) {
             return couchbaseContainer;
         }
-        couchbaseContainer = new CouchbaseContainer<>("<%= DOCKER_COUCHBASE %>");
+        couchbaseContainer = new CouchbaseContainer("<%= DOCKER_COUCHBASE %>");
         couchbaseContainer
             .withNewBucket(DefaultBucketSettings.builder()
                 .name(getBucketName())
diff --git a/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneIT.java.ejs b/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneIT.java.ejs
index b9f9f9ae51..5447afa33a 100644
--- a/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneIT.java.ejs
@@ -33,6 +33,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.support.rowset.SqlRowSet;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.*;
@@ -44,6 +47,9 @@ import static org.assertj.core.api.Assertions.assertThat;
 /**
  * Integration tests for the UTC Hibernate configuration.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'uaa' && applicationType !== 'uaa') { _%>
 @SpringBootTest(classes = {SecurityBeanOverrideConfiguration.class, <%= mainClass %>.class})
 <%_ } else if (authenticationType === 'oauth2') { _%>
diff --git a/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIT.java.ejs b/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIT.java.ejs
index 84badc3a50..5a225ba174 100644
--- a/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIT.java.ejs
@@ -30,6 +30,9 @@ import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.actuate.audit.AuditEvent;
 import org.springframework.boot.test.context.SpringBootTest;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 <%_ if (!reactive) { _%>
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpSession;
@@ -57,6 +60,9 @@ import static <%=packageName%>.repository.CustomAuditEventRepository.EVENT_DATA_
 /**
  * Integration tests for {@link CustomAuditEventRepository}.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 <%_ } else { _%>
diff --git a/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs b/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs
index c96b9ddf0b..f84e77a4d0 100644
--- a/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs
@@ -30,6 +30,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 <%_ if (reactive) { _%>
 import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
 <%_ } _%>
@@ -58,6 +61,9 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 /**
  * Integrations tests for {@link DomainUserDetailsService}.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 <%_ if (databaseType === 'sql') { _%>
 @Transactional
diff --git a/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs b/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs
index af46ac4e80..7e74ae56ee 100644
--- a/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs
@@ -33,6 +33,9 @@ import org.mockito.Spy;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.MessageSource;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.mail.MailSendException;
 import org.springframework.mail.javamail.JavaMailSenderImpl;
 import org.thymeleaf.spring5.SpringTemplateEngine;
@@ -61,6 +64,9 @@ import static org.mockito.Mockito.*;
 /**
  * Integration tests for {@link MailService}.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 public class MailServiceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{
 
diff --git a/generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs b/generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs
index c4ee214dc9..5084d8d090 100644
--- a/generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs
@@ -69,6 +69,9 @@ import org.springframework.data.domain.Page;
     <%_ } _%>
 import org.springframework.data.domain.PageRequest;
 <%_ } _%>
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.GrantedAuthority;
@@ -126,6 +129,9 @@ import static org.mockito.Mockito.when;
 /**
  * Integration tests for {@link UserService}.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 <%_ } else { _%>
diff --git a/generators/server/templates/src/test/java/package/service/mapper/UserMapperIT.java.ejs b/generators/server/templates/src/test/java/package/service/mapper/UserMapperIT.java.ejs
index 19f8587fab..acdaf582c0 100644
--- a/generators/server/templates/src/test/java/package/service/mapper/UserMapperIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/service/mapper/UserMapperIT.java.ejs
@@ -33,6 +33,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -44,6 +47,9 @@ import static org.assertj.core.api.Assertions.assertThat;
 /**
  * Integration tests for {@link UserMapper}.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 <%_ } else { _%>
diff --git a/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs
index 4155f2b342..88989ffc9f 100644
--- a/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs
@@ -34,6 +34,9 @@ import org.mockito.MockitoAnnotations;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.http.MediaType;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
@@ -59,6 +62,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@link AccountResource} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 public class AccountResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{
 
@@ -149,6 +155,9 @@ import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.http.MediaType;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -159,6 +168,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@link AccountResource} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 public class AccountResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{
 
@@ -237,6 +249,9 @@ import org.springframework.http.MediaType;
 <%_ if (!reactive) { _%>
 import org.springframework.http.converter.HttpMessageConverter;
 <%_ } _%>
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.security.test.context.support.WithMockUser;
 <%_ if (reactive) { _%>
@@ -275,6 +290,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@link AccountResource} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 public class AccountResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{
 
diff --git a/generators/server/templates/src/test/java/package/web/rest/AuditResourceIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/AuditResourceIT.java.ejs
index 4b9c626ccf..e5d9001c0e 100644
--- a/generators/server/templates/src/test/java/package/web/rest/AuditResourceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/AuditResourceIT.java.ejs
@@ -37,6 +37,9 @@ import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
 import org.springframework.format.support.FormattingConversionService;
 import org.springframework.http.MediaType;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;<% if (databaseType === 'sql') { %>
 import org.springframework.transaction.annotation.Transactional;<% } %>
@@ -54,6 +57,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@link AuditResource} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 <%_ } else { _%>
diff --git a/generators/server/templates/src/test/java/package/web/rest/ClientForwardControllerIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/ClientForwardControllerIT.java.ejs
index b003041635..7ebcb8b5e3 100644
--- a/generators/server/templates/src/test/java/package/web/rest/ClientForwardControllerIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/ClientForwardControllerIT.java.ejs
@@ -29,6 +29,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.http.MediaType;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.ResultActions;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -43,6 +46,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@link ClientForwardController} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 <%_ } else { _%>
diff --git a/generators/server/templates/src/test/java/package/web/rest/KafkaResourceIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/KafkaResourceIT.java.ejs
new file mode 100644
index 0000000000..fa90fc1db5
--- /dev/null
+++ b/generators/server/templates/src/test/java/package/web/rest/KafkaResourceIT.java.ejs
@@ -0,0 +1,57 @@
+<%#
+ Copyright 2013-2019 the original author or authors from the JHipster project.
+
+ This file is part of the JHipster project, see https://www.jhipster.tech/
+ for more information.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-%>
+package <%= packageName %>.web.rest;
+
+import <%= packageName %>.<%= mainClass %>;
+import <%= packageName %>.service.<%= upperFirstCamelCase(baseName) %>KafkaProducer;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.kafka.test.context.EmbeddedKafka;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@EmbeddedKafka
+@SpringBootTest(classes = <%= mainClass %>.class)
+public class <%= upperFirstCamelCase(baseName) %>KafkaResourceIT {
+
+    @Autowired
+    private <%= upperFirstCamelCase(baseName) %>KafkaProducer kafkaProducer;
+
+    private MockMvc restMockMvc;
+
+    @BeforeEach
+    public void setup() {
+        <%= upperFirstCamelCase(baseName) %>KafkaResource kafkaResource = new <%= upperFirstCamelCase(baseName) %>KafkaResource(kafkaProducer);
+
+        this.restMockMvc = MockMvcBuilders.standaloneSetup(kafkaResource)
+            .build();
+    }
+
+    @Test
+    public void sendMessageToKafkaTopic() throws Exception {
+        restMockMvc.perform(post("/api/<%= dasherizedBaseName %>-kafka/publish?message=yolo"))
+            .andExpect(status().isOk());
+    }
+}
diff --git a/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIT.java.ejs
index 533c1675eb..40694d9e41 100644
--- a/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIT.java.ejs
@@ -26,6 +26,9 @@ import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.http.MediaType;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.security.core.context.SecurityContextHolder;
@@ -51,6 +54,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@link LogoutResource} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 public class LogoutResourceIT {
 
diff --git a/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs
index c496d71788..f8c6f85c90 100644
--- a/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs
@@ -33,6 +33,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 <%_ if (reactive) { _%>
 import org.springframework.security.authentication.ReactiveAuthenticationManager;
 <%_ } _%>
@@ -70,6 +73,9 @@ import static org.hamcrest.Matchers.not;
 /**
  * Integration tests for the {@link UserJWTController} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 public class UserJWTControllerIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{
 
diff --git a/generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs
index 1fbbee75b8..c37b44d9bc 100644
--- a/generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs
@@ -61,6 +61,9 @@ import org.springframework.http.MediaType;
 <%_ if (!reactive) { _%>
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 <%_ } _%>
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 <%_ if (reactive) { _%>
 import org.springframework.test.web.reactive.server.WebTestClient;
 <%_ } _%>
@@ -103,6 +106,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests for the {@link UserResource} REST controller.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'oauth2') { _%>
 @SpringBootTest(classes = {<%= mainClass %>.class, TestSecurityConfiguration.class})
 <%_ } else { _%>
diff --git a/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs b/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs
index 360708edf4..3457ac8fae 100644
--- a/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs
@@ -32,6 +32,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 <%_ if (!reactive) { _%>
 import org.springframework.http.MediaType;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@@ -47,6 +50,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 /**
  * Integration tests {@link ExceptionTranslator} controller advice.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 <%_ if (authenticationType === 'uaa' && applicationType !== 'uaa') { _%>
 @SpringBootTest(classes = {SecurityBeanOverrideConfiguration.class, <%= mainClass %>.class})
 <%_ } else if (authenticationType === 'oauth2') { _%>
@@ -164,6 +170,9 @@ public class ExceptionTranslatorIT <% if (databaseType === 'cassandra') { %>exte
 import org.springframework.boot.web.codec.CodecCustomizer;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.test.web.reactive.server.MockServerConfigurer;
 import org.springframework.test.web.reactive.server.WebTestClient;
 import org.springframework.web.server.WebExceptionHandler;
@@ -174,6 +183,9 @@ import java.util.List;
 /**
  * Integration tests {@link ExceptionTranslator} controller advice.
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 public class ExceptionTranslatorIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{
 
diff --git a/generators/server/templates/src/test/resources/config/application.yml.ejs b/generators/server/templates/src/test/resources/config/application.yml.ejs
index 97e6a8f28a..da0d9b291b 100644
--- a/generators/server/templates/src/test/resources/config/application.yml.ejs
+++ b/generators/server/templates/src/test/resources/config/application.yml.ejs
@@ -43,21 +43,10 @@ eureka:
 spring:
     application:
         name: <%= baseName %>
-    <%_ if (messageBroker === 'kafka') { _%>
-    cloud:
-        stream:
-            kafka:
-                binder:
-                    brokers: localhost
-                    zk-nodes: localhost
-            bindings:
-                output:
-                    destination: topic-jhipster
-    <%_ } _%>
     <%_ if (databaseType === 'sql') { _%>
     datasource:
         type: com.zaxxer.hikari.HikariDataSource
-        url: jdbc:h2:mem:<%= baseName %>;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
+        url: jdbc:h2:mem:<%= baseName %>;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MULTI_THREADED=FALSE
         name:
         username:
         password:
@@ -111,6 +100,10 @@ spring:
             name: jhipster
             password: password
     <%_ } _%>
+    <%_ if (messageBroker === 'kafka') { _%>
+    kafka:
+        bootstrap-servers: ${spring.embedded.kafka.brokers}
+    <%_ } _%>
     <%_ if (databaseType === 'sql') { _%>
     liquibase:
         contexts: test
diff --git a/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs b/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs
index d1d649862a..2c0d58987e 100644
--- a/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs
+++ b/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs
@@ -23,6 +23,9 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.MockitoAnnotations;
 import org.springframework.boot.test.context.SpringBootTest;
+<%_ if (messageBroker === 'kafka') { _%>
+import org.springframework.kafka.test.context.EmbeddedKafka;
+<%_ } _%>
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 
@@ -35,6 +38,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
  *
  * @see <%= controllerClass %>
  */
+<%_ if (messageBroker === 'kafka') { _%>
+@EmbeddedKafka
+<%_ } _%>
 @SpringBootTest(classes = <%= mainClass %>.class)
 public class <%= controllerClass %>IT {
 
diff --git a/test/templates/compose/09-kafka/src/main/docker/app.yml b/test/templates/compose/09-kafka/src/main/docker/app.yml
index 38b3ba7b76..689c9567ad 100644
--- a/test/templates/compose/09-kafka/src/main/docker/app.yml
+++ b/test/templates/compose/09-kafka/src/main/docker/app.yml
@@ -6,8 +6,8 @@ services:
             - SPRING_PROFILES_ACTIVE=prod,swagger
             - SPRING_DATASOURCE_URL=jdbc:mysql://samplekafka-mysql:3306/samplekafka?useUnicode=true&characterEncoding=utf8&useSSL=false
             - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application
-            - SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS=kafka
-            - SPRING_CLOUD_STREAM_KAFKA_BINDER_ZK_NODES=zookeeper
+            - SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS=kafka:9092
+            - SPRING_KAFKA_PRODUCER_BOOTSTRAP_SERVERS=kafka:9092
         ports:
             - 8080:8080
     samplekafka-mysql:
diff --git a/test/templates/compose/09-kafka/src/main/docker/kafka.yml b/test/templates/compose/09-kafka/src/main/docker/kafka.yml
index b1542f320e..a66bfe8c25 100644
--- a/test/templates/compose/09-kafka/src/main/docker/kafka.yml
+++ b/test/templates/compose/09-kafka/src/main/docker/kafka.yml
@@ -1,15 +1,17 @@
 version: '2'
 services:
     zookeeper:
-        image: wurstmeister/zookeeper:3.4.6
-        ports:
-          - 2181:2181
+    image: confluentinc/cp-zookeeper:5.2.1
+    environment:
+        ZOOKEEPER_CLIENT_PORT: 2181
+        ZOOKEEPER_TICK_TIME: 2000
+        ZOOKEEPER_SYNC_LIMIT: 2
     kafka:
-        image: wurstmeister/kafka:1.0.0
+        image: confluentinc/cp-kafka:5.2.1
         environment:
-            KAFKA_ADVERTISED_HOST_NAME: localhost
-            KAFKA_ADVERTISED_PORT: 9092
+            KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
             KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
-            KAFKA_CREATE_TOPICS: "topic-jhipster:1:1"
+            KAFKA_BROKER_ID: 2
+            KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
         ports:
             - 9092:9092
diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js
index 3112ef91c0..20f8ee1021 100644
--- a/test/utils/expected-files.js
+++ b/test/utils/expected-files.js
@@ -574,7 +574,13 @@ const expectedFiles = {
         `${DOCKER_DIR}keycloak.yml`
     ],
 
-    messageBroker: [`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/MessagingConfiguration.java`, `${DOCKER_DIR}kafka.yml`],
+    messageBroker: [
+        `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/JhipsterKafkaResource.java`,
+        `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/JhipsterKafkaConsumer.java`,
+        `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/JhipsterKafkaProducer.java`,
+        `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/JhipsterKafkaResourceIT.java`,
+        `${DOCKER_DIR}kafka.yml`
+    ],
 
     swaggerCodegen: [`${SERVER_MAIN_RES_DIR}swagger/api.yml`],