From 268cb98333617101019c7565e77c63487b35d378 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 30 Oct 2018 23:15:53 +0000 Subject: [PATCH 001/444] Target travis to jhipster-generator 'spring-boot_2.1.0' branch --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a67958ccf4f..83dcd3c72782 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,10 +24,10 @@ env: - JHI_PROTRACTOR=0 # if JHIPSTER_LIB_BRANCH value is release, use the release from Maven - JHI_LIB_REPO=https://github.com/jhipster/jhipster.git - - JHI_LIB_BRANCH=release + - JHI_LIB_BRANCH=spring-boot_2.1.0 # if JHIPSTER_BRANCH value is release, use the release from NPM - JHI_GEN_REPO=https://github.com/jhipster/generator-jhipster.git - - JHI_GEN_BRANCH=release + - JHI_GEN_BRANCH=spring-boot_2.1.0 - SPRING_OUTPUT_ANSI_ENABLED=ALWAYS - SPRING_JPA_SHOW_SQL=false - JHI_DISABLE_WEBPACK_LOGS=true From a3e5eb3b1d8b7e578c6be927b469f23e9aab8f47 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 30 Oct 2018 23:27:04 +0000 Subject: [PATCH 002/444] Update jhipster-dependencies version to 2.1.0-SNAPSHOT --- generators/server/templates/gradle.properties.ejs | 2 +- generators/server/templates/pom.xml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 703f076ff39e..617f03860e7a 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -25,7 +25,7 @@ npm_version=<%= NPM_VERSION %> yarn_version=<%= YARN_VERSION %> # Dependency versions -jhipster_dependencies_version=2.0.27 +jhipster_dependencies_version=2.1.0-SNAPSHOT # The spring-boot version should match the one managed by # https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster_dependencies_version} spring_boot_version=2.0.6.RELEASE diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 3e916cf82971..b9f6a88a57d7 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -72,7 +72,7 @@ - 2.0.27 + 2.1.0-SNAPSHOT 2.0.6.RELEASE From 9b18dd71db258ae9b0bbdfa804cadae1e4d27057 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 18:09:53 +0000 Subject: [PATCH 003/444] Update spring-boot version to 2.1.0.RELEASE --- generators/server/templates/gradle.properties.ejs | 2 +- generators/server/templates/pom.xml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 617f03860e7a..65ebb7a9dd3b 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -28,7 +28,7 @@ yarn_version=<%= YARN_VERSION %> jhipster_dependencies_version=2.1.0-SNAPSHOT # The spring-boot version should match the one managed by # https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster_dependencies_version} -spring_boot_version=2.0.6.RELEASE +spring_boot_version=2.1.0.RELEASE # The hibernate version should match the one managed by # https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} --> hibernate_version=5.2.17.Final diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index b9f6a88a57d7..63f2e26b7a4e 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -75,7 +75,7 @@ 2.1.0-SNAPSHOT - 2.0.6.RELEASE + 2.1.0.RELEASE <%_ if (databaseType === 'sql') { _%> From e0dca5920cf6d8fe821d27c2a31b8698bb6ff3a0 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 18:11:21 +0000 Subject: [PATCH 004/444] Update hibernate version to 5.3.7.Final --- generators/server/templates/gradle.properties.ejs | 2 +- generators/server/templates/pom.xml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 65ebb7a9dd3b..9dbfe9e46a81 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -31,7 +31,7 @@ jhipster_dependencies_version=2.1.0-SNAPSHOT spring_boot_version=2.1.0.RELEASE # The hibernate version should match the one managed by # https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} --> -hibernate_version=5.2.17.Final +hibernate_version=5.3.7.Final mapstruct_version=1.2.0.Final liquibase_hibernate5_version=3.6 diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 63f2e26b7a4e..99202c86120f 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -79,7 +79,7 @@ <%_ if (databaseType === 'sql') { _%> - 5.2.17.Final + 5.3.7.Final 3.22.0-GA From 276ca712bd64e82afc9e9c00521f367c7eb78125 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 18:26:26 +0000 Subject: [PATCH 005/444] Update javassist version to 3.23.1-GA --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 99202c86120f..2244ded86770 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -82,7 +82,7 @@ 5.3.7.Final - 3.22.0-GA + 3.23.1-GA 3.5.5 From 7d2e05c75c69c163857b92843c6a03d9da9c8b1c Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 18:27:38 +0000 Subject: [PATCH 006/444] Update liquibase version to 3.6.2 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 2244ded86770..4ced002f7afc 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -85,7 +85,7 @@ 3.23.1-GA - 3.5.5 + 3.6.2 3.6 2.0.1.Final <%_ } _%> From b9e4c3bfbc369970cb0db23f0a996f9d53c44907 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 18:32:12 +0000 Subject: [PATCH 007/444] Update liquibase dbchangelog xsd version to 3.6 --- .../resources/config/liquibase/changelog/added_entity.xml.ejs | 2 +- .../config/liquibase/changelog/added_entity_constraints.xml.ejs | 2 +- .../resources/config/liquibase/changelog/initial_schema.xml.ejs | 2 +- .../src/main/resources/config/liquibase/master.xml.ejs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs index f34f0bb8b6ac..902ae10e6366 100644 --- a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs @@ -21,7 +21,7 @@ xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity_constraints.xml.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity_constraints.xml.ejs index 69933b4f5e64..a9600453c50c 100644 --- a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity_constraints.xml.ejs +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity_constraints.xml.ejs @@ -20,7 +20,7 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> diff --git a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs index 7d07af8a26d6..8b8e076e823b 100644 --- a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs +++ b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs @@ -21,7 +21,7 @@ xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> <%_ if (prodDatabaseType === 'mysql' || prodDatabaseType === 'mariadb') { _%> diff --git a/generators/server/templates/src/main/resources/config/liquibase/master.xml.ejs b/generators/server/templates/src/main/resources/config/liquibase/master.xml.ejs index f2b0b1f7e69e..b4f8f5a6f0c0 100644 --- a/generators/server/templates/src/main/resources/config/liquibase/master.xml.ejs +++ b/generators/server/templates/src/main/resources/config/liquibase/master.xml.ejs @@ -2,7 +2,7 @@ + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> From ee5ced3e535c879f3329976165f94b83949bd501 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Thu, 1 Nov 2018 19:00:41 +0100 Subject: [PATCH 008/444] CI: use correct script to change version of jhipster lib --- test-integration/scripts/10-install-jhipster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-integration/scripts/10-install-jhipster.sh b/test-integration/scripts/10-install-jhipster.sh index 967786b9a749..b59526146654 100755 --- a/test-integration/scripts/10-install-jhipster.sh +++ b/test-integration/scripts/10-install-jhipster.sh @@ -29,7 +29,7 @@ else fi git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit - "$JHI_SCRIPTS"/13-replace-version-generated-project.sh + travis/scripts/00-replace-version-jhipster.sh ./mvnw clean install -Dgpg.skip=true ls -al ~/.m2/repository/io/github/jhipster/jhipster-framework/ From b7d4737a2160bf2e12049caf36715b852a1c1613 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Thu, 1 Nov 2018 19:31:55 +0100 Subject: [PATCH 009/444] Azure: switch to spring-boot_2.1.0 branch --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cdabb66981a6..0ebf78897155 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -26,9 +26,9 @@ jobs: JHI_RUN_APP: 1 JHI_PROTRACTOR: 0 JHI_LIB_REPO: https://github.com/jhipster/jhipster.git - JHI_LIB_BRANCH: release + JHI_LIB_BRANCH: spring-boot_2.1.0 JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git - JHI_GEN_BRANCH: release + JHI_GEN_BRANCH: spring-boot_2.1.0 SPRING_OUTPUT_ANSI_ENABLED: NEVER SPRING_JPA_SHOW_SQL: false JHI_DISABLE_WEBPACK_LOGS: true From 54b8bbf5dadbb323386532daabe35bb57a870398 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 23:17:39 +0000 Subject: [PATCH 010/444] Removed liquibase-slf4j since liquibase 3.6 it is used slf4j --- generators/server/templates/build.gradle.ejs | 4 ---- generators/server/templates/pom.xml.ejs | 6 ------ test/templates/ci-cd/maven-ngx-yarn/pom.xml | 4 ---- 3 files changed, 14 deletions(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 7254bc0f03df..da3dea8358a2 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -316,7 +316,6 @@ dependencies { compile "org.hibernate:hibernate-envers" compile "org.hibernate.validator:hibernate-validator" compile "org.liquibase:liquibase-core" - compile "com.mattbertolini:liquibase-slf4j" liquibaseRuntime "org.liquibase:liquibase-core" liquibaseRuntime "org.liquibase.ext:liquibase-hibernate5:${liquibase_hibernate5_version}" liquibaseRuntime sourceSets.main.compileClasspath @@ -468,9 +467,6 @@ dependencies { testCompile "org.assertj:assertj-core" testCompile "junit:junit" testCompile "org.mockito:mockito-core" - <%_ if (databaseType === 'sql') { _%> - testCompile "com.mattbertolini:liquibase-slf4j" - <%_ } _%> <%_ if (databaseType === 'mongodb') { _%> testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo" <%_ } _%> diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 4ced002f7afc..b9a3a6a11e98 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -324,12 +324,6 @@ springfox-bean-validators <%_ } _%> - <%_ if (databaseType === 'sql') { _%> - - com.mattbertolini - liquibase-slf4j - - <%_ } _%> com.ryantenney.metrics metrics-spring diff --git a/test/templates/ci-cd/maven-ngx-yarn/pom.xml b/test/templates/ci-cd/maven-ngx-yarn/pom.xml index 5034e0b8bff4..3d1ef678fd1a 100644 --- a/test/templates/ci-cd/maven-ngx-yarn/pom.xml +++ b/test/templates/ci-cd/maven-ngx-yarn/pom.xml @@ -204,10 +204,6 @@ io.springfox springfox-bean-validators - - com.mattbertolini - liquibase-slf4j - com.ryantenney.metrics metrics-spring From b20a776c68922661c18ffb30512a0b98b92f0095 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 23:34:32 +0000 Subject: [PATCH 011/444] Use infinispan-hibernate-cache instead of hibernate-infinispan --- generators/server/templates/build.gradle.ejs | 2 +- generators/server/templates/pom.xml.ejs | 4 ++-- .../java/package/config/CacheFactoryConfiguration.java.ejs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index da3dea8358a2..6a2d176a0614 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -274,7 +274,7 @@ dependencies { compile "com.hazelcast:hazelcast-spring" <%_ } _%> <%_ if (cacheProvider === 'infinispan') { _%> - compile "org.hibernate:hibernate-infinispan" + compile "org.infinispan:infinispan-hibernate-cache" <%_ } _%> <%_ if (cacheProvider === 'infinispan') {_%> compile "org.infinispan:infinispan-spring-boot-starter" diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index b9a3a6a11e98..fffc5ce92568 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -270,8 +270,8 @@ <%_ } _%> <%_ if (cacheProvider === 'infinispan') { _%> - org.hibernate - hibernate-infinispan + org.infinispan + infinispan-hibernate-cache <%_ } _%> <%_ if (cacheProvider === 'infinispan') { _%> diff --git a/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs index 2b053c371ef7..ee8cb2824f77 100644 --- a/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs @@ -18,8 +18,8 @@ -%> package <%=packageName%>.config; -import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.service.ServiceRegistry; +import org.infinispan.hibernate.cache.InfinispanRegionFactory; import org.infinispan.manager.EmbeddedCacheManager; import java.util.Properties; @@ -39,7 +39,7 @@ public class CacheFactoryConfiguration extends InfinispanRegionFactory { private static final long serialVersionUID = 1L; /** - * Defines an Hibernate L2 cache: hibernate-infinispan + * Defines an Hibernate L2 cache: infinispan-hibernate-cache */ @Override protected EmbeddedCacheManager createCacheManager(Properties properties, ServiceRegistry serviceRegistry) { From 37f224a4b6cfeda98beb7cd4aceb450d135f8ab9 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 1 Nov 2018 23:59:14 +0000 Subject: [PATCH 012/444] Switch from infinispan-spring-boot-starter to infinispan-spring-boot-starter-embedded --- generators/server/templates/build.gradle.ejs | 2 +- generators/server/templates/pom.xml.ejs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 6a2d176a0614..d4d8b33d55a5 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -277,7 +277,7 @@ dependencies { compile "org.infinispan:infinispan-hibernate-cache" <%_ } _%> <%_ if (cacheProvider === 'infinispan') {_%> - compile "org.infinispan:infinispan-spring-boot-starter" + compile "org.infinispan:infinispan-spring-boot-starter-embedded" compile "org.infinispan:infinispan-core" compile "org.infinispan:infinispan-jcache" compile ("org.infinispan:infinispan-cloud") { diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index fffc5ce92568..6cd88fd86265 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -277,7 +277,7 @@ <%_ if (cacheProvider === 'infinispan') { _%> org.infinispan - infinispan-spring-boot-starter + infinispan-spring-boot-starter-embedded org.infinispan @@ -287,12 +287,10 @@ org.infinispan infinispan-jcache - <%_ } _%> <%_ if (cacheProvider === 'memcached') { _%> From 2ef89966e62b96632a3df888088a11a8d34b4291 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 2 Nov 2018 00:00:22 +0000 Subject: [PATCH 013/444] Update infinispan cache configuration --- .../config/CacheConfiguration.java.ejs | 33 ++++++++++++------- .../resources/config/application-dev.yml.ejs | 2 +- .../resources/config/application-prod.yml.ejs | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index f4e3135753a8..703ec60a09f9 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -85,16 +85,16 @@ import javax.annotation.PreDestroy; import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.global.GlobalConfigurationBuilder; -import infinispan.autoconfigure.embedded.InfinispanCacheConfigurer; -import infinispan.autoconfigure.embedded.InfinispanGlobalConfigurer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.github.jhipster.config.JHipsterProperties; import java.util.concurrent.TimeUnit; import org.infinispan.eviction.EvictionType; import org.infinispan.manager.EmbeddedCacheManager; +import org.infinispan.spring.starter.embedded.InfinispanCacheConfigurer; +import org.infinispan.spring.starter.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; +import org.infinispan.spring.starter.embedded.InfinispanGlobalConfigurer; import org.infinispan.transaction.TransactionMode; -import infinispan.autoconfigure.embedded.InfinispanEmbeddedCacheManagerAutoConfiguration; import org.infinispan.jcache.embedded.ConfigurationAdapter; import org.infinispan.jcache.embedded.JCache; import org.infinispan.jcache.embedded.JCacheManager; @@ -371,7 +371,7 @@ public class CacheConfiguration { * If the service discovery is not enabled, host discovery will be based on * the default transport settings defined in the 'config-file' packaged within * the Jar. The 'config-file' can be overridden using the application property - * jhipster.cache.inifnispan.config-file + * jhipster.cache.infinispan.config-file * *

* If no service discovery is defined, you have the choice of 'config-file' @@ -379,6 +379,8 @@ public class CacheConfiguration { * supports discovery natively for most of the platforms like Kubernets/OpenShift, * AWS, Azure and Google. * + * @param jHipsterProperties the jhipster properties to configure from + * @return the infinispan global configurer */ @Bean public InfinispanGlobalConfigurer globalConfiguration(JHipsterProperties jHipsterProperties) { @@ -441,6 +443,8 @@ public class CacheConfiguration { * * * + * @param jHipsterProperties the jhipster properties to configure from + * @return the infinispan cache configurer */ @Bean public InfinispanCacheConfigurer cacheConfigurer(JHipsterProperties jHipsterProperties) { @@ -449,19 +453,21 @@ public class CacheConfiguration { return manager -> { // initialize application cache - manager.defineConfiguration("local-app-data", new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL) + manager.defineConfiguration("local-app-data", new ConfigurationBuilder() + .clustering().cacheMode(CacheMode.LOCAL) .jmxStatistics().enabled(cacheInfo.isStatsEnabled()) - .eviction().type(EvictionType.COUNT).size(cacheInfo.getLocal().getMaxEntries()).expiration() + .memory().evictionType(EvictionType.COUNT).size(cacheInfo.getLocal().getMaxEntries()).expiration() .lifespan(cacheInfo.getLocal().getTimeToLiveSeconds(), TimeUnit.MINUTES).build()); manager.defineConfiguration("dist-app-data", new ConfigurationBuilder() .clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(cacheInfo.getDistributed().getInstanceCount()) - .jmxStatistics().enabled(cacheInfo.isStatsEnabled()).eviction() - .type(EvictionType.COUNT).size(cacheInfo.getDistributed().getMaxEntries()).expiration().lifespan(cacheInfo.getDistributed() - .getTimeToLiveSeconds(), TimeUnit.MINUTES).build()); - manager.defineConfiguration("repl-app-data", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC) .jmxStatistics().enabled(cacheInfo.isStatsEnabled()) - .eviction().type(EvictionType.COUNT).size(cacheInfo.getReplicated() - .getMaxEntries()).expiration().lifespan(cacheInfo.getReplicated().getTimeToLiveSeconds(), TimeUnit.MINUTES).build()); + .memory().evictionType(EvictionType.COUNT).size(cacheInfo.getDistributed().getMaxEntries()).expiration() + .lifespan(cacheInfo.getDistributed().getTimeToLiveSeconds(), TimeUnit.MINUTES).build()); + manager.defineConfiguration("repl-app-data", new ConfigurationBuilder() + .clustering().cacheMode(CacheMode.REPL_SYNC) + .jmxStatistics().enabled(cacheInfo.isStatsEnabled()) + .memory().evictionType(EvictionType.COUNT).size(cacheInfo.getReplicated().getMaxEntries()).expiration() + .lifespan(cacheInfo.getReplicated().getTimeToLiveSeconds(), TimeUnit.MINUTES).build()); // initialize Hibernate L2 cache manager.defineConfiguration("entity", new ConfigurationBuilder().clustering().cacheMode(CacheMode.INVALIDATION_SYNC) @@ -495,6 +501,9 @@ public class CacheConfiguration { *

* jCache stats are at instance level. If you need stats at clustering level, then it needs to be retrieved from MBX:org.infinispan * + * @param cacheManager the embedded cache manager + * @param jHipsterProperties the jhipster properties to configure from + * @return the jcache manager */ @Bean public JCacheManager getJCacheManager(EmbeddedCacheManager cacheManager, JHipsterProperties jHipsterProperties){ 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 c80fdcaaca3b..750aea35d451 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 @@ -170,7 +170,7 @@ spring: hibernate.cache.inifinispan.statistics: true hibernate.cache.use_minimal_puts: true hibernate.cache.infinispan.entity.expiration.lifespan: 3600000 - hibernate.cache.infinispan.entity.eviction.max_entries: 1000 + hibernate.cache.infinispan.entity.memory.size: 1000 hibernate.cache.infinispan.jgroups_cfg: default-configs/default-jgroups-tcp.xml <%_ } _%> <%_ if (cacheProvider === 'hazelcast') { _%> 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 4bdab0aa4c77..f517a91c8ec5 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 @@ -146,7 +146,7 @@ spring: hibernate.cache.inifinispan.statistics: false hibernate.cache.use_minimal_puts: true hibernate.cache.infinispan.entity.expiration.lifespan: 3600000 - hibernate.cache.infinispan.entity.eviction.max_entries: 1000 + hibernate.cache.infinispan.entity.memory.size: 1000 hibernate.cache.infinispan.jgroups_cfg: default-configs/default-jgroups-tcp.xml <%_ } _%> <%_ if (cacheProvider === 'hazelcast') { _%> From a941d9c94e461fd935c12ea1242cbd5104cc41c6 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 2 Nov 2018 00:26:08 +0000 Subject: [PATCH 014/444] Upgrade dropwizard metrics version to 4.0.3 --- .../main/java/package/config/MetricsConfiguration.java.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs index 846552ea34e3..7263e3d1cdc5 100644 --- a/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs @@ -20,8 +20,8 @@ package <%=packageName%>.config; import io.github.jhipster.config.JHipsterProperties; -import com.codahale.metrics.JmxReporter; -import com.codahale.metrics.JvmAttributeGaugeSet; +import com.codahale.metrics.jmx.JmxReporter; +import com.codahale.metrics.jvm.JvmAttributeGaugeSet; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Slf4jReporter; import com.codahale.metrics.health.HealthCheckRegistry; From 8c0fcb20f716a89fd2b31cd3456488987387f46f Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 2 Nov 2018 00:59:21 +0000 Subject: [PATCH 015/444] Use infinispan-hibernate-cache-v53 instead of infinispan-hibernate-cache --- generators/server/templates/build.gradle.ejs | 4 +--- generators/server/templates/pom.xml.ejs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index d4d8b33d55a5..791ca444524c 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -274,9 +274,7 @@ dependencies { compile "com.hazelcast:hazelcast-spring" <%_ } _%> <%_ if (cacheProvider === 'infinispan') { _%> - compile "org.infinispan:infinispan-hibernate-cache" - <%_ } _%> - <%_ if (cacheProvider === 'infinispan') {_%> + compile "org.infinispan:infinispan-hibernate-cache-v53" compile "org.infinispan:infinispan-spring-boot-starter-embedded" compile "org.infinispan:infinispan-core" compile "org.infinispan:infinispan-jcache" diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 6cd88fd86265..9ce739128195 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -271,10 +271,8 @@ <%_ if (cacheProvider === 'infinispan') { _%> org.infinispan - infinispan-hibernate-cache + infinispan-hibernate-cache-v53 - <%_ } _%> - <%_ if (cacheProvider === 'infinispan') { _%> org.infinispan infinispan-spring-boot-starter-embedded From e58e4426ebec8c85dcf5b14ca414201d14ae4a70 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 2 Nov 2018 01:06:00 +0000 Subject: [PATCH 016/444] Added metrics-jmx --- generators/server/templates/build.gradle.ejs | 1 + generators/server/templates/pom.xml.ejs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 791ca444524c..95b21fd3c118 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -243,6 +243,7 @@ dependencies { compile "io.dropwizard.metrics:metrics-jcache" <%_ } _%> compile "io.dropwizard.metrics:metrics-json" + compile "io.dropwizard.metrics:metrics-jmx" compile "io.dropwizard.metrics:metrics-jvm" compile "io.dropwizard.metrics:metrics-servlet" compile "io.dropwizard.metrics:metrics-servlets" diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 9ce739128195..90134d5cd897 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -209,6 +209,10 @@ metrics-jcache <%_ } _%> + + io.dropwizard.metrics + metrics-jmx + io.dropwizard.metrics metrics-jvm From 7efc06191765b276d21694299b5727b2ca9a9dd7 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 2 Nov 2018 01:45:40 +0000 Subject: [PATCH 017/444] Review metrics imports --- .../src/main/java/package/config/MetricsConfiguration.java.ejs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs index 7263e3d1cdc5..110b5cb908e9 100644 --- a/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs @@ -20,14 +20,13 @@ package <%=packageName%>.config; import io.github.jhipster.config.JHipsterProperties; -import com.codahale.metrics.jmx.JmxReporter; -import com.codahale.metrics.jvm.JvmAttributeGaugeSet; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Slf4jReporter; import com.codahale.metrics.health.HealthCheckRegistry; <%_ if (['ehcache', 'infinispan'].includes(cacheProvider)) { _%> import com.codahale.metrics.jcache.JCacheGaugeSet; <%_ } _%> +import com.codahale.metrics.jmx.*; import com.codahale.metrics.jvm.*; import com.ryantenney.metrics.spring.config.annotation.EnableMetrics; import com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerAdapter; From 4e17ce2b9bb2bc85fec818e5848f98707eba5242 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Mon, 5 Nov 2018 16:04:12 +0000 Subject: [PATCH 018/444] Switch again travis and azure pipelines to spring-boot_2.1.0 branch --- .travis.yml | 4 ++-- azure-pipelines.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d84e8932a97..6152f7a4a3c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,10 +43,10 @@ env: - JHI_PROTRACTOR=0 # if JHI_LIB_BRANCH value is release, use the release from Maven - JHI_LIB_REPO=https://github.com/jhipster/jhipster.git - - JHI_LIB_BRANCH=release + - JHI_LIB_BRANCH=spring-boot_2.1.0 # if JHI_GEN_BRANCH value is release, use the release from NPM - JHI_GEN_REPO=https://github.com/jhipster/generator-jhipster.git - - JHI_GEN_BRANCH=release + - JHI_GEN_BRANCH=spring-boot_2.1.0 # specific config - SPRING_OUTPUT_ANSI_ENABLED=ALWAYS - SPRING_JPA_SHOW_SQL=false diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0d67322ce7bd..64d327c059ce 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,10 +27,10 @@ jobs: JHI_PROTRACTOR: 0 # if JHI_LIB_BRANCH value is release, use the release from Maven JHI_LIB_REPO: https://github.com/jhipster/jhipster.git - JHI_LIB_BRANCH: release + JHI_LIB_BRANCH: spring-boot_2.1.0 # if JHI_GEN_BRANCH value is release, use the release from NPM JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git - JHI_GEN_BRANCH: release + JHI_GEN_BRANCH: spring-boot_2.1.0 # specific config SPRING_OUTPUT_ANSI_ENABLED: NEVER SPRING_JPA_SHOW_SQL: false From 19af06faad26c6f14cca4072df2e3062cd603ec5 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Mon, 5 Nov 2018 16:34:16 +0000 Subject: [PATCH 019/444] [JDK9+ compatibility] Substitute @PreDestroy by DisposableBean implementation --- .../main/java/package/config/CacheConfiguration.java.ejs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index afbf0799c04c..3597a05d3b59 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -77,9 +77,8 @@ import org.springframework.cache.support.NoOpCacheManager; <%_ } _%> import org.springframework.context.annotation.*; <%_ if (cacheProvider === 'hazelcast') { _%> +import org.springframework.beans.factory.DisposableBean; import org.springframework.core.env.Environment; - -import javax.annotation.PreDestroy; <%_ } _%> <%_ if (cacheProvider === 'infinispan') { _%> import org.infinispan.configuration.cache.CacheMode; @@ -135,7 +134,7 @@ import io.github.jhipster.config.JHipsterProperties; <%_ if (cacheProvider === 'infinispan') { _%> @Import(InfinispanEmbeddedCacheManagerAutoConfiguration.class) <%_ } _%> -public class CacheConfiguration { +public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implements DisposableBean<% } %> { <%_ if (cacheProvider === 'ehcache') { _%> private final javax.cache.configuration.Configuration jcacheConfiguration; @@ -206,8 +205,8 @@ public class CacheConfiguration { } <%_ } _%> - @PreDestroy - public void destroy() { + @Override + public void destroy() throws Exception { log.info("Closing Cache Manager"); Hazelcast.shutdownAll(); } From ba8d2b0a8ef00c7d8ebe814eca6602bf02dcccf5 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Mon, 5 Nov 2018 17:00:29 +0000 Subject: [PATCH 020/444] [JDK9+ compatibility] Substitute @PostConstruct by InitializingBean implementation --- .../src/main/java/package/Application.java.ejs | 8 ++++---- .../java/package/config/MetricsConfiguration.java.ejs | 8 ++++---- .../package/config/SecurityConfiguration.java.ejs | 11 ++++------- .../config/UaaWebSecurityConfiguration.java.ejs | 9 ++++----- .../config/cassandra/CassandraConfiguration.java.ejs | 8 ++++---- .../java/package/security/jwt/TokenProvider.java.ejs | 8 ++++---- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/generators/server/templates/src/main/java/package/Application.java.ejs b/generators/server/templates/src/main/java/package/Application.java.ejs index 9f8ef069c6e8..d8e20fc2d002 100644 --- a/generators/server/templates/src/main/java/package/Application.java.ejs +++ b/generators/server/templates/src/main/java/package/Application.java.ejs @@ -29,6 +29,7 @@ import io.github.jhipster.config.JHipsterConstants; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; <%_ if (databaseType === 'sql') { _%> @@ -47,7 +48,6 @@ import org.springframework.context.annotation.FilterType; <%_ } _%> import org.springframework.core.env.Environment; -import javax.annotation.PostConstruct; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; @@ -66,7 +66,7 @@ import java.util.Collection; <%_ if (applicationType === 'gateway' && serviceDiscoveryType) { _%> @EnableZuulProxy <%_ } _%> -public class <%= mainClass %> { +public class <%= mainClass %> implements InitializingBean { private static final Logger log = LoggerFactory.getLogger(<%= mainClass %>.class); @@ -83,8 +83,8 @@ public class <%= mainClass %> { *

* You can find more information on how profiles work with JHipster on https://www.jhipster.tech/profiles/. */ - @PostConstruct - public void initApplication() { + @Override + public void afterPropertiesSet() throws Exception { Collection activeProfiles = Arrays.asList(env.getActiveProfiles()); if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) { log.error("You have misconfigured your application! It should not run " + diff --git a/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs index 110b5cb908e9..3b2da2c1320e 100644 --- a/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/MetricsConfiguration.java.ejs @@ -43,20 +43,20 @@ import org.slf4j.MarkerFactory; <%_ if (databaseType === 'sql') { _%> import org.springframework.beans.factory.annotation.Autowired; <%_ } _%> +import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.web.servlet.ServletContextInitializer; <%_ if (['ehcache', 'infinispan'].includes(cacheProvider)) { _%> import org.springframework.cache.CacheManager; <%_ } _%> import org.springframework.context.annotation.*; -import javax.annotation.PostConstruct; import javax.servlet.ServletContext; import java.lang.management.ManagementFactory; import java.util.concurrent.TimeUnit; @Configuration @EnableMetrics(proxyTargetClass = true) -public class MetricsConfiguration extends MetricsConfigurerAdapter implements ServletContextInitializer { +public class MetricsConfiguration extends MetricsConfigurerAdapter implements InitializingBean, ServletContextInitializer { private static final String PROP_METRIC_REG_JVM_MEMORY = "jvm.memory"; private static final String PROP_METRIC_REG_JVM_GARBAGE = "jvm.garbage"; @@ -107,8 +107,8 @@ public class MetricsConfiguration extends MetricsConfigurerAdapter implements Se return healthCheckRegistry; } - @PostConstruct - public void init() { + @Override + public void afterPropertiesSet() throws Exception { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); diff --git a/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs index ec1599f3c3b7..e44f6c8b8f4e 100644 --- a/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs @@ -35,6 +35,7 @@ import io.github.jhipster.security.*; <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%> import org.springframework.beans.factory.BeanInitializationException; +import org.springframework.beans.factory.InitializingBean; <%_ } _%> import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -89,10 +90,6 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic import org.springframework.web.filter.CorsFilter; <%_ } _%> import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport; -<%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%> - -import javax.annotation.PostConstruct; -<%_ } _%> @Configuration <%_ if (authenticationType === 'oauth2') { _%> @@ -106,7 +103,7 @@ import javax.annotation.PostConstruct; <%_ } _%> @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @Import(SecurityProblemSupport.class) -public class SecurityConfiguration extends <% if (authenticationType === 'oauth2' && applicationType === 'microservice') { %>ResourceServer<% } else { %>WebSecurity<% } %>ConfigurerAdapter { +public class SecurityConfiguration<% if (authenticationType !== 'oauth2' && !skipUserManagement) { %> implements InitializingBean<% } %> extends <% if (authenticationType === 'oauth2' && applicationType === 'microservice') { %>ResourceServer<% } else { %>WebSecurity<% } %>ConfigurerAdapter { <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%> private final AuthenticationManagerBuilder authenticationManagerBuilder; @@ -150,8 +147,8 @@ public class SecurityConfiguration extends <% if (authenticationType === 'oauth2 } <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%> - @PostConstruct - public void init() { + @Override + public void afterPropertiesSet() throws Exception { try { authenticationManagerBuilder .userDetailsService(userDetailsService) diff --git a/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs index c5d9f109b163..c196b1a6bee2 100644 --- a/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs @@ -19,6 +19,7 @@ package <%=packageName%>.config; import org.springframework.beans.factory.BeanInitializationException; +import org.springframework.beans.factory.InitializingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; @@ -32,11 +33,9 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.data.repository.query.SecurityEvaluationContextExtension; -import javax.annotation.PostConstruct; - @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) -public class UaaWebSecurityConfiguration extends WebSecurityConfigurerAdapter { +public class UaaWebSecurityConfiguration implements InitializingBean extends WebSecurityConfigurerAdapter { private final UserDetailsService userDetailsService; @@ -47,8 +46,8 @@ public class UaaWebSecurityConfiguration extends WebSecurityConfigurerAdapter { this.authenticationManagerBuilder = authenticationManagerBuilder; } - @PostConstruct - public void init() throws Exception { + @Override + public void afterPropertiesSet() throws Exception { try { authenticationManagerBuilder .userDetailsService(userDetailsService) diff --git a/generators/server/templates/src/main/java/package/config/cassandra/CassandraConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/cassandra/CassandraConfiguration.java.ejs index 40f014c72e38..167b7949713a 100644 --- a/generators/server/templates/src/main/java/package/config/cassandra/CassandraConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/cassandra/CassandraConfiguration.java.ejs @@ -28,6 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.autoconfigure.cassandra.CassandraProperties; import org.springframework.boot.autoconfigure.cassandra.ClusterBuilderCustomizer; <%_ if (applicationType === 'gateway' && databaseType !== 'cassandra') { _%> @@ -43,7 +44,6 @@ import org.springframework.data.convert.WritingConverter; import org.springframework.util.StringUtils; import javax.annotation.Nonnull; -import javax.annotation.PostConstruct; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; @@ -54,7 +54,7 @@ import java.util.List; @Configuration<% if (applicationType === 'gateway' && databaseType !== 'cassandra') { %> @ConditionalOnProperty("jhipster.gateway.rate-limiting.enabled")<% } %> @Profile({JHipsterConstants.SPRING_PROFILE_DEVELOPMENT, JHipsterConstants.SPRING_PROFILE_PRODUCTION}) -public class CassandraConfiguration { +public class CassandraConfiguration implements InitializingBean { @Value("${spring.data.cassandra.protocolVersion:V4}") private ProtocolVersion protocolVersion; @@ -67,8 +67,8 @@ public class CassandraConfiguration { @Autowired private Cluster cluster; - @PostConstruct - public void postConstruct() { + @Override + public void afterPropertiesSet() throws Exception { TupleType tupleType = cluster.getMetadata() .newTupleType(DataType.timestamp(), DataType.varchar()); diff --git a/generators/server/templates/src/main/java/package/security/jwt/TokenProvider.java.ejs b/generators/server/templates/src/main/java/package/security/jwt/TokenProvider.java.ejs index 33010b44963f..cc97a6be77ad 100644 --- a/generators/server/templates/src/main/java/package/security/jwt/TokenProvider.java.ejs +++ b/generators/server/templates/src/main/java/package/security/jwt/TokenProvider.java.ejs @@ -22,10 +22,10 @@ import java.nio.charset.StandardCharsets; import java.security.Key; import java.util.*; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; @@ -40,7 +40,7 @@ import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; @Component -public class TokenProvider { +public class TokenProvider implements InitializingBean { private final Logger log = LoggerFactory.getLogger(TokenProvider.class); @@ -58,8 +58,8 @@ public class TokenProvider { this.jHipsterProperties = jHipsterProperties; } - @PostConstruct - public void init() { + @Override + public void afterPropertiesSet() throws Exception { byte[] keyBytes; String secret = jHipsterProperties.getSecurity().getAuthentication().getJwt().getSecret(); if (!StringUtils.isEmpty(secret)) { From 1a4017bc3f0c5690dd22b4565d94fa6e1e223563 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 6 Nov 2018 00:15:30 +0000 Subject: [PATCH 021/444] Update jhipster-dependencies version to 2.1.0-SNAPSHOT --- generators/server/templates/gradle.properties.ejs | 2 +- generators/server/templates/pom.xml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index c3505d5bdbbe..9dbfe9e46a81 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -25,7 +25,7 @@ npm_version=<%= NPM_VERSION %> yarn_version=<%= YARN_VERSION %> # Dependency versions -jhipster_dependencies_version=2.0.28 +jhipster_dependencies_version=2.1.0-SNAPSHOT # The spring-boot version should match the one managed by # https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster_dependencies_version} spring_boot_version=2.1.0.RELEASE diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 332fe3155bf7..e230532c64b5 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -72,7 +72,7 @@ - 2.0.28 + 2.1.0-SNAPSHOT 2.1.0.RELEASE From ad5fa90cb93a745906a0910d720455dd8797aff7 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 6 Nov 2018 00:35:30 +0000 Subject: [PATCH 022/444] Set spring.main.allow-bean-definition-overriding to true to allow bean overriding --- .../templates/src/main/resources/config/application.yml.ejs | 2 ++ .../templates/src/test/resources/config/application.yml.ejs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/generators/server/templates/src/main/resources/config/application.yml.ejs b/generators/server/templates/src/main/resources/config/application.yml.ejs index 6ab44689d873..31e6559aded4 100644 --- a/generators/server/templates/src/main/resources/config/application.yml.ejs +++ b/generators/server/templates/src/main/resources/config/application.yml.ejs @@ -164,6 +164,8 @@ spring: <%_ } _%> messages: basename: i18n/messages + main: + allow-bean-definition-overriding: true mvc: favicon: enabled: false 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 bfc4d9d99993..7bcdf101bcea 100644 --- a/generators/server/templates/src/test/resources/config/application.yml.ejs +++ b/generators/server/templates/src/test/resources/config/application.yml.ejs @@ -121,6 +121,8 @@ spring: <%_ } _%> mail: host: localhost + main: + allow-bean-definition-overriding: true messages: basename: i18n/messages mvc: From 1795a1e88df2ea9c0917b84d2bfcbc4a9ead0c72 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 6 Nov 2018 01:46:11 +0000 Subject: [PATCH 023/444] [JDK9+ compatibility] Substitute @PostConstruct by InitializingBean implementation --- .../src/main/java/package/config/SecurityConfiguration.java.ejs | 2 +- .../java/package/config/UaaWebSecurityConfiguration.java.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs index e44f6c8b8f4e..f1863b377a76 100644 --- a/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs @@ -103,7 +103,7 @@ import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport; <%_ } _%> @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @Import(SecurityProblemSupport.class) -public class SecurityConfiguration<% if (authenticationType !== 'oauth2' && !skipUserManagement) { %> implements InitializingBean<% } %> extends <% if (authenticationType === 'oauth2' && applicationType === 'microservice') { %>ResourceServer<% } else { %>WebSecurity<% } %>ConfigurerAdapter { +public class SecurityConfiguration extends <% if (authenticationType === 'oauth2' && applicationType === 'microservice') { %>ResourceServer<% } else { %>WebSecurity<% } %>ConfigurerAdapter<% if (authenticationType !== 'oauth2' && !skipUserManagement) { %> implements InitializingBean<% } %> { <%_ if (authenticationType !== 'oauth2' && !skipUserManagement) { _%> private final AuthenticationManagerBuilder authenticationManagerBuilder; diff --git a/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs index c196b1a6bee2..39b7e6ea89f3 100644 --- a/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/UaaWebSecurityConfiguration.java.ejs @@ -35,7 +35,7 @@ import org.springframework.security.data.repository.query.SecurityEvaluationCont @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) -public class UaaWebSecurityConfiguration implements InitializingBean extends WebSecurityConfigurerAdapter { +public class UaaWebSecurityConfiguration extends WebSecurityConfigurerAdapter implements InitializingBean { private final UserDetailsService userDetailsService; From 45bd98327382abe7bba0eaf22f981f9e21ba0243 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Wed, 7 Nov 2018 14:51:30 +0000 Subject: [PATCH 024/444] Substitute deprecated function acceptsProfiles(string...) by acceptsProfiles(Profiles.of(string)...) --- .../src/main/java/package/aop/logging/LoggingAspect.java.ejs | 3 ++- .../src/main/java/package/config/CacheConfiguration.java.ejs | 5 +++-- .../main/java/package/config/LiquibaseConfiguration.java.ejs | 3 ++- .../src/main/java/package/config/WebConfigurer.java.ejs | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/generators/server/templates/src/main/java/package/aop/logging/LoggingAspect.java.ejs b/generators/server/templates/src/main/java/package/aop/logging/LoggingAspect.java.ejs index ede1eb18b3c9..0f4025c20704 100644 --- a/generators/server/templates/src/main/java/package/aop/logging/LoggingAspect.java.ejs +++ b/generators/server/templates/src/main/java/package/aop/logging/LoggingAspect.java.ejs @@ -29,6 +29,7 @@ import org.aspectj.lang.annotation.Pointcut; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; +import org.springframework.core.env.Profiles; import java.util.Arrays; @@ -76,7 +77,7 @@ public class LoggingAspect { */ @AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e") public void logAfterThrowing(JoinPoint joinPoint, Throwable e) { - if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { + if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) { log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e); diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index 3597a05d3b59..c6c8bcca31a7 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -79,6 +79,7 @@ import org.springframework.context.annotation.*; <%_ if (cacheProvider === 'hazelcast') { _%> import org.springframework.beans.factory.DisposableBean; import org.springframework.core.env.Environment; +import org.springframework.core.env.Profiles; <%_ } _%> <%_ if (cacheProvider === 'infinispan') { _%> import org.infinispan.configuration.cache.CacheMode; @@ -238,7 +239,7 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem String serviceId = registration.getServiceId(); log.debug("Configuring Hazelcast clustering for instanceId: {}", serviceId); // In development, everything goes through 127.0.0.1, with a different port - if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { + if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) { log.debug("Application is running with the \"dev\" profile, Hazelcast " + "cluster will only work with localhost instances"); @@ -265,7 +266,7 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem config.getNetworkConfig().setPortAutoIncrement(true); // In development, remove multicast auto-configuration - if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { + if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) { System.setProperty("hazelcast.local.localAddress", "127.0.0.1"); config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false); diff --git a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs index 1314ba38f70f..fc86af361baf 100644 --- a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs @@ -30,6 +30,7 @@ import org.springframework.cache.CacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; +import org.springframework.core.env.Profiles; import org.springframework.core.task.TaskExecutor; import io.github.jhipster.config.JHipsterConstants; @@ -66,7 +67,7 @@ public class LiquibaseConfiguration { liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema()); liquibase.setDropFirst(liquibaseProperties.isDropFirst()); liquibase.setChangeLogParameters(liquibaseProperties.getParameters()); - if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE)) { + if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE))) { liquibase.setShouldRun(false); } else { liquibase.setShouldRun(liquibaseProperties.isEnabled()); diff --git a/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs b/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs index b121409e26e3..5de5c78b5ca6 100644 --- a/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs +++ b/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs @@ -48,6 +48,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; <%_ } _%> import org.springframework.core.env.Environment; +import org.springframework.core.env.Profiles; import org.springframework.http.MediaType; import org.springframework.web.cors.CorsConfiguration; <%_ if (!reactive) { _%> @@ -117,12 +118,12 @@ public class WebConfigurer implements ServletContextInitializer, WebServerFactor EnumSet disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); initMetrics(servletContext, disps); <%_ if (!skipClient) { _%> - if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) { + if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_PRODUCTION))) { initCachingHttpHeadersFilter(servletContext, disps); } <%_ } _%> <%_ if (devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { _%> - if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { + if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) { initH2Console(servletContext); } <%_ } _%> From 82e76c30e3a5cb5e117ab30c01616917d3ea0980 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Sun, 11 Nov 2018 17:05:21 +0100 Subject: [PATCH 025/444] CI: migrate jhipster/jhipster to test-integration folder [ci skip] --- test-integration/scripts/10-install-jhipster.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-integration/scripts/10-install-jhipster.sh b/test-integration/scripts/10-install-jhipster.sh index 8713d0c55f93..31dafe3ec455 100755 --- a/test-integration/scripts/10-install-jhipster.sh +++ b/test-integration/scripts/10-install-jhipster.sh @@ -30,7 +30,7 @@ else fi git --no-pager log -n 10 --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit - travis/scripts/00-replace-version-jhipster.sh + test-integration/scripts/10-replace-version-jhipster.sh ./mvnw clean install -Dgpg.skip=true ls -al ~/.m2/repository/io/github/jhipster/jhipster-framework/ From 8704f8520636a748ef8499f86b8bd7627c90b96f Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 20 Nov 2018 18:23:31 +0100 Subject: [PATCH 026/444] Use the new micrometer configuration from Spring Boot 2.1 --- .../templates/src/main/resources/config/application.yml.ejs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/resources/config/application.yml.ejs b/generators/server/templates/src/main/resources/config/application.yml.ejs index 31e6559aded4..f92ad8fc0cb8 100644 --- a/generators/server/templates/src/main/resources/config/application.yml.ejs +++ b/generators/server/templates/src/main/resources/config/application.yml.ejs @@ -122,7 +122,8 @@ management: mail: enabled: false # When using the MailService, configure an SMTP server and set this to true metrics: - enabled: false # http://micrometer.io/ is disabled by default, as we use http://metrics.dropwizard.io/ instead + enable: + all: false # http://micrometer.io/ is disabled by default, as we use http://metrics.dropwizard.io/ instead spring: <%_ if (searchEngine === 'elasticsearch') { _%> From 5725cb5b75e76f945751fff700dd963bd991813e Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 20 Nov 2018 18:23:42 +0100 Subject: [PATCH 027/444] Remove the "async" configuration as this is now handled by Spring Boot 2.1 See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes --- .../config/AsyncConfiguration.java.ejs | 54 ++----------------- .../config/LiquibaseConfiguration.java.ejs | 2 +- .../main/resources/config/application.yml.ejs | 15 ++++-- .../test/resources/config/application.yml.ejs | 15 ++++-- 4 files changed, 26 insertions(+), 60 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs index 143f3858c8cc..6b4ac25d8d00 100644 --- a/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs @@ -18,60 +18,12 @@ -%> package <%=packageName%>.config; -import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor; -import io.github.jhipster.config.JHipsterProperties; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; -import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.*; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.scheduling.annotation.SchedulingConfigurer; -import org.springframework.scheduling.config.ScheduledTaskRegistrar; - -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; @Configuration @EnableAsync @EnableScheduling -public class AsyncConfiguration implements AsyncConfigurer, SchedulingConfigurer { - - private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class); - - private final JHipsterProperties jHipsterProperties; - - public AsyncConfiguration(JHipsterProperties jHipsterProperties) { - this.jHipsterProperties = jHipsterProperties; - } - - @Override - @Bean(name = "taskExecutor") - public Executor getAsyncExecutor() { - log.debug("Creating Async Task Executor"); - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize()); - executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize()); - executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity()); - executor.setThreadNamePrefix("<%= dasherizedBaseName %>-Executor-"); - return new ExceptionHandlingAsyncTaskExecutor(executor); - } - - @Override - public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { - return new SimpleAsyncUncaughtExceptionHandler(); - } - - @Override - public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { - taskRegistrar.setScheduler(scheduledTaskExecutor()); - } - - @Bean - public Executor scheduledTaskExecutor() { - return Executors.newScheduledThreadPool(jHipsterProperties.getAsync().getCorePoolSize()); - } +public class AsyncConfiguration { } diff --git a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs index fc86af361baf..fd8b36f86064 100644 --- a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs @@ -56,7 +56,7 @@ public class LiquibaseConfiguration { } @Bean - public SpringLiquibase liquibase(@Qualifier("taskExecutor") TaskExecutor taskExecutor, + public SpringLiquibase liquibase(@Qualifier("taskScheduler") TaskExecutor taskExecutor, DataSource dataSource, LiquibaseProperties liquibaseProperties) { // Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously diff --git a/generators/server/templates/src/main/resources/config/application.yml.ejs b/generators/server/templates/src/main/resources/config/application.yml.ejs index f92ad8fc0cb8..1a7181a20294 100644 --- a/generators/server/templates/src/main/resources/config/application.yml.ejs +++ b/generators/server/templates/src/main/resources/config/application.yml.ejs @@ -170,6 +170,17 @@ spring: mvc: favicon: enabled: false + task: + execution: + thread-name-prefix: <%= dasherizedBaseName %>-task- + pool: + core-size: 2 + max-size: 50 + queue-capacity: 10000 + scheduling: + thread-name-prefix: <%= dasherizedBaseName %>-scheduling- + pool: + size: 2 thymeleaf: mode: HTML <%_ if (authenticationType === 'oauth2') { _%> @@ -241,10 +252,6 @@ info: # =================================================================== jhipster: - async: - core-pool-size: 2 - max-pool-size: 50 - queue-capacity: 10000 # By default CORS is disabled. Uncomment to enable. #cors: #allowed-origins: "*" 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 7bcdf101bcea..f4035f527fa7 100644 --- a/generators/server/templates/src/test/resources/config/application.yml.ejs +++ b/generators/server/templates/src/test/resources/config/application.yml.ejs @@ -128,6 +128,17 @@ spring: mvc: favicon: enabled: false + task: + execution: + thread-name-prefix: <%= dasherizedBaseName %>-task- + pool: + core-size: 1 + max-size: 50 + queue-capacity: 10000 + scheduling: + thread-name-prefix: <%= dasherizedBaseName %>-scheduling- + pool: + size: 1 thymeleaf: mode: HTML @@ -156,10 +167,6 @@ server: # =================================================================== jhipster: - async: - core-pool-size: 1 - max-pool-size: 50 - queue-capacity: 10000 # To test logstash appender logging: logstash: From cc0f9b5e26d290650e596c82890aca36e14677df Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 22 Nov 2018 16:24:22 +0100 Subject: [PATCH 028/444] JDK 11 support --- generators/server/templates/build.gradle.ejs | 3 ++- generators/server/templates/pom.xml.ejs | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 95b21fd3c118..fc996f0f930d 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -54,7 +54,6 @@ plugins { apply plugin: 'java' sourceCompatibility=<%= JAVA_VERSION %> targetCompatibility=<%= JAVA_VERSION %> -// Until JHipster supports JDK 9 assert System.properties['java.specification.version'] == '1.8' apply plugin: 'maven' @@ -444,6 +443,8 @@ dependencies { annotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct_version}" <%_ if (databaseType === 'sql') { _%> annotationProcessor "org.hibernate:hibernate-jpamodelgen" + annotationProcessor "javax.xml.bind:jaxb-api:2.3.1" + annotationProcessor "com.sun.xml.bind:jaxb-impl:2.3.1" <%_ } _%> annotationProcessor ("org.springframework.boot:spring-boot-configuration-processor") { exclude group: 'com.vaadin.external.google', module: 'android-json' diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index e230532c64b5..51ee04c9a813 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -771,6 +771,8 @@ org.apache.maven.plugins maven-compiler-plugin + ${java.version} + ${java.version} org.mapstruct @@ -784,7 +786,17 @@ hibernate-jpamodelgen ${hibernate.version} -<% } %> + + javax.xml.bind + jaxb-api + 2.3.1 + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + +<%_ } _%> @@ -1095,9 +1107,8 @@ [${maven.version},) - - You are running an incompatible version of Java. JHipster requires JDK ${java.version} - [1.8,1.9) + You are running an incompatible version of Java. JHipster supports JDK 8 to 11. + [1.8,12) From 04751d430d84a9e6a0f38471940fa9f4f0f85618 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 22 Nov 2018 17:30:25 +0100 Subject: [PATCH 029/444] Correct JDK warning, now that we support JDK 11 --- generators/generator-base-private.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generators/generator-base-private.js b/generators/generator-base-private.js index 1735c4235b37..adf1f1917d33 100644 --- a/generators/generator-base-private.js +++ b/generators/generator-base-private.js @@ -787,12 +787,12 @@ module.exports = class extends Generator { const done = this.async(); exec('java -version', (err, stdout, stderr) => { if (err) { - this.warning('Java 8 is not found on your computer.'); + this.warning('Java is not found on your computer.'); } else { const javaVersion = stderr.match(/(?:java|openjdk) version "(.*)"/)[1]; - if (!javaVersion.match(new RegExp(constants.JAVA_VERSION.replace('.', '\\.')))) { + if (!javaVersion.match(new RegExp('11'.replace('.', '\\.'))) && !javaVersion.match(new RegExp(constants.JAVA_VERSION.replace('.', '\\.')))) { this.warning( - `Java ${constants.JAVA_VERSION} is not found on your computer. Your Java version is: ${chalk.yellow(javaVersion)}` + `Java 8 or Java 11 are not found on your computer. Your Java version is: ${chalk.yellow(javaVersion)}` ); } } From a13a3c84dd22af1b7c45fc331abee30d2ab70f62 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 22 Nov 2018 17:53:22 +0100 Subject: [PATCH 030/444] Allow to use JDK 11 with Gradle --- generators/server/templates/build.gradle.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index fc996f0f930d..88b2d1f1bfce 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -54,7 +54,7 @@ plugins { apply plugin: 'java' sourceCompatibility=<%= JAVA_VERSION %> targetCompatibility=<%= JAVA_VERSION %> -assert System.properties['java.specification.version'] == '1.8' +assert System.properties['java.specification.version'] == '1.8' || '11' apply plugin: 'maven' apply plugin: 'org.springframework.boot' From 42806a2b7f1ad708a2a26b2d8bc96d101713aecf Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Thu, 22 Nov 2018 13:57:31 -0500 Subject: [PATCH 031/444] Need to specify the Ehcache default URI to correctly get the caching provider using the Spring cache loader --- .../templates/src/main/resources/config/application.yml.ejs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generators/server/templates/src/main/resources/config/application.yml.ejs b/generators/server/templates/src/main/resources/config/application.yml.ejs index 1a7181a20294..b9b277cd2907 100644 --- a/generators/server/templates/src/main/resources/config/application.yml.ejs +++ b/generators/server/templates/src/main/resources/config/application.yml.ejs @@ -157,6 +157,9 @@ spring: open-in-view: false properties: hibernate.jdbc.time_zone: UTC + <%_ if (enableHibernateCache && cacheProvider === 'ehcache') { _%> + hibernate.javax.cache.uri: urn:X-ehcache:jsr107-default-config + <%_ } _%> hibernate: ddl-auto: none naming: From eb0a6ecdb263d1af4907158ff0dd876020e8e481 Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Thu, 22 Nov 2018 14:54:09 -0500 Subject: [PATCH 032/444] Get rid of the BeanClassLoaderAwareJCacheRegionFactory --- .../package/config/CacheConfiguration.java.ejs | 18 +++++++++++++++++- .../resources/config/application-dev.yml.ejs | 4 +--- .../resources/config/application-prod.yml.ejs | 4 +--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index c6c8bcca31a7..044086b09b1b 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -25,7 +25,10 @@ import org.ehcache.config.builders.*; import org.ehcache.jsr107.Eh107Configuration; <%_ if (enableHibernateCache) { _%> -import io.github.jhipster.config.jcache.BeanClassLoaderAwareJCacheRegionFactory; +import org.hibernate.cache.jcache.ConfigSettings; + +import javax.cache.Caching; +import javax.cache.spi.CachingProvider <%_ } _%> import io.github.jhipster.config.JHipsterProperties; @@ -46,6 +49,9 @@ import org.springframework.beans.factory.annotation.Autowired; <%_ } _%> <%_ if (cacheProvider === 'ehcache') { _%> import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer; + <%_ if (enableHibernateCache) { _%> +import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; + <%_ } _%> <%_ } _%> <%_ if (cacheProvider === 'hazelcast') { _%> <%_ if (serviceDiscoveryType === 'eureka' || serviceDiscoveryType === 'consul') { _%> @@ -154,6 +160,16 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem .build()); } + <%_ if (enableHibernateCache) { _%> + @Bean + public HibernatePropertiesCustomizer hibernatePropertiesCustomizer() { + return hibernateProperties -> { + CachingProvider cachingProvider = Caching.getCachingProvider(); + hibernateProperties.put(ConfigSettings.CACHE_MANAGER, cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), getClass().getClassLoader())); + }; + } + <%_ } _%> + @Bean public JCacheManagerCustomizer cacheManagerCustomizer() { return cm -> { 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 750aea35d451..6bb8fa8c00d8 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 @@ -160,9 +160,7 @@ spring: hibernate.cache.use_query_cache: false hibernate.generate_statistics: true <%_ if (enableHibernateCache) { _%> - <%_ if (cacheProvider === 'ehcache') { _%> - hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.BeanClassLoaderAwareJCacheRegionFactory - <%_ } else if (cacheProvider === 'hazelcast') { _%> + <%_ if (cacheProvider === 'hazelcast') { _%> hibernate.cache.region.factory_class: com.hazelcast.hibernate.HazelcastCacheRegionFactory hibernate.cache.hazelcast.instance_name: <%= baseName %> <%_ } else if (cacheProvider === 'infinispan') { _%> 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 4b25c6f656ab..dfefc7adf169 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 @@ -136,9 +136,7 @@ spring: hibernate.cache.use_query_cache: false hibernate.generate_statistics: false <%_ if (enableHibernateCache) { _%> - <%_ if (cacheProvider === 'ehcache') { _%> - hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.BeanClassLoaderAwareJCacheRegionFactory - <%_ } else if (cacheProvider === 'hazelcast') { _%> + <%_ if (cacheProvider === 'hazelcast') { _%> hibernate.cache.region.factory_class: com.hazelcast.hibernate.HazelcastCacheRegionFactory hibernate.cache.hazelcast.instance_name: <%= baseName %> <%_ } else if (cacheProvider === 'infinispan') { _%> From f122519d8b440aef6dd3dcce46dcc70bf1dda42e Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 22 Nov 2018 23:21:19 +0100 Subject: [PATCH 033/444] Add missing ; --- .../src/main/java/package/config/CacheConfiguration.java.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index 044086b09b1b..762f147bc7fd 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -28,7 +28,7 @@ import org.ehcache.jsr107.Eh107Configuration; import org.hibernate.cache.jcache.ConfigSettings; import javax.cache.Caching; -import javax.cache.spi.CachingProvider +import javax.cache.spi.CachingProvider; <%_ } _%> import io.github.jhipster.config.JHipsterProperties; From 8ff473521137c80b57c4dda7b545a0a24d56d8cb Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 22 Nov 2018 23:30:39 +0100 Subject: [PATCH 034/444] Remove call to BeanClassLoaderAwareJCacheRegionFactory --- .../src/main/java/package/config/CacheConfiguration.java.ejs | 3 --- 1 file changed, 3 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index 762f147bc7fd..e897447990c5 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -147,9 +147,6 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem private final javax.cache.configuration.Configuration jcacheConfiguration; public CacheConfiguration(JHipsterProperties jHipsterProperties) { - <%_ if (enableHibernateCache) { _%> - BeanClassLoaderAwareJCacheRegionFactory.setBeanClassLoader(this.getClass().getClassLoader()); - <%_ } _%> JHipsterProperties.Cache.Ehcache ehcache = jHipsterProperties.getCache().getEhcache(); From 1c0de1a637ae8b3004d5a4c049da08c835b3b740 Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Thu, 22 Nov 2018 22:03:00 -0500 Subject: [PATCH 035/444] Inject directly the CacheManager used by Spring. Not need to get it from the CachingProvider --- .../java/package/config/CacheConfiguration.java.ejs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index e897447990c5..42ebb5c4d641 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -26,9 +26,6 @@ import org.ehcache.jsr107.Eh107Configuration; <%_ if (enableHibernateCache) { _%> import org.hibernate.cache.jcache.ConfigSettings; - -import javax.cache.Caching; -import javax.cache.spi.CachingProvider; <%_ } _%> import io.github.jhipster.config.JHipsterProperties; @@ -159,11 +156,8 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem <%_ if (enableHibernateCache) { _%> @Bean - public HibernatePropertiesCustomizer hibernatePropertiesCustomizer() { - return hibernateProperties -> { - CachingProvider cachingProvider = Caching.getCachingProvider(); - hibernateProperties.put(ConfigSettings.CACHE_MANAGER, cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), getClass().getClassLoader())); - }; + public HibernatePropertiesCustomizer hibernatePropertiesCustomizer(javax.cache.CacheManager cacheManager) { + return hibernateProperties -> hibernateProperties.put(ConfigSettings.CACHE_MANAGER, cacheManager); } <%_ } _%> From 632b8d2152752f6931e1d39a4ff24e041b353aba Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Thu, 22 Nov 2018 22:06:38 -0500 Subject: [PATCH 036/444] No need to set the URI for the cache manager anymore --- .../templates/src/main/resources/config/application.yml.ejs | 3 --- 1 file changed, 3 deletions(-) diff --git a/generators/server/templates/src/main/resources/config/application.yml.ejs b/generators/server/templates/src/main/resources/config/application.yml.ejs index b9b277cd2907..1a7181a20294 100644 --- a/generators/server/templates/src/main/resources/config/application.yml.ejs +++ b/generators/server/templates/src/main/resources/config/application.yml.ejs @@ -157,9 +157,6 @@ spring: open-in-view: false properties: hibernate.jdbc.time_zone: UTC - <%_ if (enableHibernateCache && cacheProvider === 'ehcache') { _%> - hibernate.javax.cache.uri: urn:X-ehcache:jsr107-default-config - <%_ } _%> hibernate: ddl-auto: none naming: From 57a0aa5a5733a29a2fd40f1227c0ed5256a59422 Mon Sep 17 00:00:00 2001 From: Henri Tremblay Date: Fri, 23 Nov 2018 11:12:05 -0500 Subject: [PATCH 037/444] Do not add a Hibernate customizer if no JSR107 CacheManager is available --- .../src/main/java/package/config/CacheConfiguration.java.ejs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index 42ebb5c4d641..a2d618514bb9 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -47,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired; <%_ if (cacheProvider === 'ehcache') { _%> import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer; <%_ if (enableHibernateCache) { _%> +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; <%_ } _%> <%_ } _%> @@ -155,6 +156,7 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem } <%_ if (enableHibernateCache) { _%> + @ConditionalOnBean(type = { "javax.cache.CacheManager" }) @Bean public HibernatePropertiesCustomizer hibernatePropertiesCustomizer(javax.cache.CacheManager cacheManager) { return hibernateProperties -> hibernateProperties.put(ConfigSettings.CACHE_MANAGER, cacheManager); From 4868e9f7e1cfa1271257d28116141bdea7d20c54 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Fri, 23 Nov 2018 17:57:46 +0100 Subject: [PATCH 038/444] Add the Spring milestone repositories for Spring Cloud 2.1 --- generators/server/templates/build.gradle.ejs | 2 ++ generators/server/templates/pom.xml.ejs | 21 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 88b2d1f1bfce..3a32aa53eaf5 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -225,6 +225,8 @@ repositories { // more information at https://blogs.oracle.com/dev2dev/entry/how_to_get_oracle_jdbc maven { url "https://maven.oracle.com" } <%_ } _%> + // TODO To remove after final Spring-cloud 2.1 release + maven { url "http://repo.spring.io/milestone" } //jhipster-needle-gradle-repositories - JHipster will add additional repositories } diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 51ee04c9a813..a6b9f75fefcd 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -40,9 +40,30 @@ <%_ } _%> + + + spring-milestones + Spring Milestones + http://repo.spring.io/milestone + + false + + + + + + spring-milestones + Spring Milestones + http://repo.spring.io/milestone + + false + + + + From 27490a31c239681b46e60b074474a4e6a0527132 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Sat, 24 Nov 2018 13:58:52 +0100 Subject: [PATCH 039/444] Upgrade to the new Infinispan release --- .../main/java/package/config/CacheFactoryConfiguration.java.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs index ee8cb2824f77..6be370e268b1 100644 --- a/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheFactoryConfiguration.java.ejs @@ -19,7 +19,7 @@ package <%=packageName%>.config; import org.hibernate.service.ServiceRegistry; -import org.infinispan.hibernate.cache.InfinispanRegionFactory; +import org.infinispan.hibernate.cache.v53.InfinispanRegionFactory; import org.infinispan.manager.EmbeddedCacheManager; import java.util.Properties; From e9f299d6c1dadfb449effa8c2c9b9211c687ac46 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Sat, 24 Nov 2018 13:59:16 +0100 Subject: [PATCH 040/444] Upgrade to the new sequence generator name for Hibernate --- .../resources/config/liquibase/changelog/initial_schema.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs index 8b8e076e823b..2d582f7ddd8a 100644 --- a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs +++ b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs @@ -29,7 +29,7 @@ <%_ } _%> <%_ if (prodDatabaseType === 'postgresql' || prodDatabaseType === 'oracle' || prodDatabaseType === 'mssql') { _%> - + <%_ } _%> From 27522172adb519e63dac52fa0a400f2a7680a0ba Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Sat, 24 Nov 2018 13:59:45 +0100 Subject: [PATCH 041/444] Remove the "simple cache" trick for tests, as it was causing issues with Ehcache and Infinispan --- .../src/main/java/package/config/CacheConfiguration.java.ejs | 2 -- .../templates/src/test/resources/config/application.yml.ejs | 4 ---- 2 files changed, 6 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index a2d618514bb9..42ebb5c4d641 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -47,7 +47,6 @@ import org.springframework.beans.factory.annotation.Autowired; <%_ if (cacheProvider === 'ehcache') { _%> import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer; <%_ if (enableHibernateCache) { _%> -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; <%_ } _%> <%_ } _%> @@ -156,7 +155,6 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem } <%_ if (enableHibernateCache) { _%> - @ConditionalOnBean(type = { "javax.cache.CacheManager" }) @Bean public HibernatePropertiesCustomizer hibernatePropertiesCustomizer(javax.cache.CacheManager cacheManager) { return hibernateProperties -> hibernateProperties.put(ConfigSettings.CACHE_MANAGER, cacheManager); 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 f4035f527fa7..27742e44f7df 100644 --- a/generators/server/templates/src/test/resources/config/application.yml.ejs +++ b/generators/server/templates/src/test/resources/config/application.yml.ejs @@ -43,10 +43,6 @@ eureka: spring: application: name: <%= baseName %> - <%_ if (cacheManagerIsAvailable === true) { _%> - cache: - type: simple - <%_ } _%> <%_ if (messageBroker === 'kafka') { _%> cloud: stream: From eb2b5dabadb2be0d94dbede10c1f5917e4f96da6 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Sat, 24 Nov 2018 20:28:20 +0100 Subject: [PATCH 042/444] Add a root dependency on hibernate-core to solve transitive dependency issue with Javassist --- generators/server/templates/pom.xml.ejs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index a6b9f75fefcd..0f9b567cb9f2 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -463,6 +463,10 @@ hibernate-jpamodelgen provided + + org.hibernate + hibernate-core + org.hibernate hibernate-envers From 3c108b7da5766c691ebadb838db24758a6c81cce Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 26 Nov 2018 14:13:08 +0100 Subject: [PATCH 043/444] Formatting --- .../main/java/package/config/LiquibaseConfiguration.java.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs index fd8b36f86064..ea2101cdb880 100644 --- a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs @@ -43,8 +43,8 @@ public class LiquibaseConfiguration { private final Logger log = LoggerFactory.getLogger(LiquibaseConfiguration.class); private final Environment env; - <%_ if (enableHibernateCache) { _%> + private final CacheManager cacheManager; <%_ } _%> From a2a4e93c52d379ba6120f76eab1551cba2007c9d Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 26 Nov 2018 15:05:10 +0100 Subject: [PATCH 044/444] Custom Task Scheduling as the default Spring Boot configuration does not work with Spring Websocket --- .../config/AsyncConfiguration.java.ejs | 38 ++++++++++++++++++- .../config/LiquibaseConfiguration.java.ejs | 15 ++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs index 6b4ac25d8d00..448a0fe61eb8 100644 --- a/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs @@ -18,12 +18,48 @@ -%> package <%=packageName%>.config; +import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; +import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; +import org.springframework.boot.autoconfigure.task.TaskExecutionProperties; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; @Configuration @EnableAsync @EnableScheduling -public class AsyncConfiguration { +public class AsyncConfiguration implements AsyncConfigurer { + + private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class); + + private final TaskExecutionProperties taskExecutionProperties; + + public AsyncConfiguration(TaskExecutionProperties taskExecutionProperties) { + this.taskExecutionProperties = taskExecutionProperties; + } + + @Override + @Bean(name = "taskExecutor") + public Executor getAsyncExecutor() { + log.debug("Creating Async Task Executor"); + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(taskExecutionProperties.getPool().getCoreSize()); + executor.setMaxPoolSize(taskExecutionProperties.getPool().getMaxSize()); + executor.setQueueCapacity(taskExecutionProperties.getPool().getQueueCapacity()); + executor.setThreadNamePrefix(taskExecutionProperties.getThreadNamePrefix()); + return new ExceptionHandlingAsyncTaskExecutor(executor); + } + + @Override + public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { + return new SimpleAsyncUncaughtExceptionHandler(); + } } diff --git a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs index ea2101cdb880..0159f96845f6 100644 --- a/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/LiquibaseConfiguration.java.ejs @@ -18,8 +18,9 @@ -%> package <%=packageName%>.config; -import javax.sql.DataSource; - +import io.github.jhipster.config.JHipsterConstants; +import io.github.jhipster.config.liquibase.AsyncSpringLiquibase; +import liquibase.integration.spring.SpringLiquibase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; @@ -31,11 +32,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; -import org.springframework.core.task.TaskExecutor; -import io.github.jhipster.config.JHipsterConstants; -import io.github.jhipster.config.liquibase.AsyncSpringLiquibase; -import liquibase.integration.spring.SpringLiquibase; +import javax.sql.DataSource; +import java.util.concurrent.Executor; @Configuration public class LiquibaseConfiguration { @@ -56,11 +55,11 @@ public class LiquibaseConfiguration { } @Bean - public SpringLiquibase liquibase(@Qualifier("taskScheduler") TaskExecutor taskExecutor, + public SpringLiquibase liquibase(@Qualifier("taskExecutor") Executor executor, DataSource dataSource, LiquibaseProperties liquibaseProperties) { // Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously - SpringLiquibase liquibase = new AsyncSpringLiquibase(taskExecutor, env); + SpringLiquibase liquibase = new AsyncSpringLiquibase(executor, env); liquibase.setDataSource(dataSource); liquibase.setChangeLog("classpath:config/liquibase/master.xml"); liquibase.setContexts(liquibaseProperties.getContexts()); From e595b948526a74719d5ee250423c15cf574662ea Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 27 Nov 2018 00:32:31 +0000 Subject: [PATCH 045/444] Upgrade elastic version to 6.4.2 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index a9161143ccda..b89617f9a456 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -31,7 +31,7 @@ const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.9.3'; const DOCKER_MEMCACHED = 'memcached:1.5.8-alpine'; const DOCKER_KEYCLOAK = 'jboss/keycloak:4.5.0.Final'; -const DOCKER_ELASTICSEARCH = 'elasticsearch:5.6.5'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.1 +const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.2'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 const DOCKER_KAFKA = 'wurstmeister/kafka:1.0.0'; const DOCKER_ZOOKEEPER = 'wurstmeister/zookeeper:3.4.6'; const DOCKER_SONAR = 'sonarqube:7.1'; From a94e5a12e28ea5b2e4a7f9786291becf1e446ade Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 27 Nov 2018 00:53:10 +0000 Subject: [PATCH 046/444] Upgrade hazelcast/management-center version to 3.11 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index b89617f9a456..526e3ec91703 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -28,7 +28,7 @@ const DOCKER_COUCHBASE = 'couchbase/server:5.5.1'; const DOCKER_CASSANDRA = 'cassandra:3.9'; const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest'; const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; -const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.9.3'; +const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; const DOCKER_MEMCACHED = 'memcached:1.5.8-alpine'; const DOCKER_KEYCLOAK = 'jboss/keycloak:4.5.0.Final'; const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.2'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 From 96ee313fb8262be0d85c9feab3c30cf91188a033 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 27 Nov 2018 01:23:05 +0000 Subject: [PATCH 047/444] Upgrade wurstmeister/kafka version to 2.11-2.0.0 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 526e3ec91703..90e4a9a2b193 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -32,7 +32,7 @@ const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; const DOCKER_MEMCACHED = 'memcached:1.5.8-alpine'; const DOCKER_KEYCLOAK = 'jboss/keycloak:4.5.0.Final'; const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.2'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 -const DOCKER_KAFKA = 'wurstmeister/kafka:1.0.0'; +const DOCKER_KAFKA = 'wurstmeister/kafka:2.11-2.0.0'; const DOCKER_ZOOKEEPER = 'wurstmeister/zookeeper:3.4.6'; const DOCKER_SONAR = 'sonarqube:7.1'; const DOCKER_JHIPSTER_CONSOLE = 'jhipster/jhipster-console:v4.0.0'; From 943f65a9d839acb8a5fa3b5426843b8164c3d6f7 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 27 Nov 2018 01:36:18 +0000 Subject: [PATCH 048/444] Upgrade mysql version to 8.0.13 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 90e4a9a2b193..4b443821eab6 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -20,7 +20,7 @@ // version of docker images const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v4.0.6'; const DOCKER_JAVA_JRE = 'openjdk:8-jre-alpine'; -const DOCKER_MYSQL = 'mysql:5.7.20'; +const DOCKER_MYSQL = 'mysql:8.0.13'; const DOCKER_MARIADB = 'mariadb:10.3.7'; const DOCKER_POSTGRESQL = 'postgres:10.4'; const DOCKER_MONGODB = 'mongo:4.0.2'; From 2ea89eb29c7421d91873824bc76b8f962fedb286 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 27 Nov 2018 11:36:33 +0100 Subject: [PATCH 049/444] Add the Sonaytype SNAPSHOT repository, in order to get the JHipster snapshot builds --- generators/server/templates/build.gradle.ejs | 2 ++ generators/server/templates/pom.xml.ejs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 3a32aa53eaf5..f71552a735f2 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -225,6 +225,8 @@ repositories { // more information at https://blogs.oracle.com/dev2dev/entry/how_to_get_oracle_jdbc maven { url "https://maven.oracle.com" } <%_ } _%> + // TODO To remove after final JHipster release + maven { url "http://oss.sonatype.org/content/repositories/snapshots" } // TODO To remove after final Spring-cloud 2.1 release maven { url "http://repo.spring.io/milestone" } //jhipster-needle-gradle-repositories - JHipster will add additional repositories diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 0f9b567cb9f2..34ffc5b30774 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -40,6 +40,17 @@ <%_ } _%> + + + oss.sonatype.org-snapshot + http://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + spring-milestones From 8e423545236abd279262ae67aae1b81405bcd8a1 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Tue, 27 Nov 2018 13:10:49 +0100 Subject: [PATCH 050/444] CI: replace version for UAA --- .../scripts/13-replace-version-generated-project.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test-integration/scripts/13-replace-version-generated-project.sh b/test-integration/scripts/13-replace-version-generated-project.sh index 3d670c4cb45b..89bcafa27ee4 100755 --- a/test-integration/scripts/13-replace-version-generated-project.sh +++ b/test-integration/scripts/13-replace-version-generated-project.sh @@ -13,6 +13,14 @@ if [[ $JHI_VERSION == '' ]]; then JHI_VERSION=0.0.0-CICD fi +# replace version in uaa +if [[ "$JHI_APP" == *"uaa"* ]]; then + cd "$JHI_FOLDER_UAA" + sed -e 's/.*<\/jhipster-dependencies.version>/'$JHI_VERSION'<\/jhipster-dependencies.version>/1;' pom.xml > pom.xml.sed + mv -f pom.xml.sed pom.xml + cat pom.xml | grep \ +fi + # jhipster-dependencies.version in generated pom.xml or gradle.properties cd "$JHI_FOLDER_APP" if [[ -a mvnw ]]; then From d28ef3d8ac74bfdcc38ad88b5c0f327949c2e936 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 10:40:47 +0000 Subject: [PATCH 051/444] Upgrade spring-boot version to 2.1.1.RELEASE --- generators/server/templates/gradle.properties.ejs | 2 +- generators/server/templates/pom.xml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 9dbfe9e46a81..16f6be6a9460 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -28,7 +28,7 @@ yarn_version=<%= YARN_VERSION %> jhipster_dependencies_version=2.1.0-SNAPSHOT # The spring-boot version should match the one managed by # https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster_dependencies_version} -spring_boot_version=2.1.0.RELEASE +spring_boot_version=2.1.1.RELEASE # The hibernate version should match the one managed by # https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} --> hibernate_version=5.3.7.Final diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 0f9b567cb9f2..12649cef3ed9 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -96,7 +96,7 @@ 2.1.0-SNAPSHOT - 2.1.0.RELEASE + 2.1.1.RELEASE <%_ if (databaseType === 'sql') { _%> From 89bc7fe7777a9cd943c13dbfc6be743febf32d3f Mon Sep 17 00:00:00 2001 From: Anthony Viard Date: Fri, 30 Nov 2018 12:23:31 +0100 Subject: [PATCH 052/444] Force id to be considered as numeric value In case of postgresql the id is considered as varying value instead of numeric. The loadData failed. --- .../config/liquibase/changelog/initial_schema.xml.ejs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs index 2d582f7ddd8a..a3799dd44af8 100644 --- a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs +++ b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs @@ -147,6 +147,9 @@ identityInsertEnabled="true" <%_ } _%> tableName="<%= jhiTablePrefix %>_user"> + <%_ if (prodDatabaseType === 'postgresql') { _%> + + <%_ } _%> ext:<% } %>loadData> From f94ea56972bccc4c61bcae4bbdaa009034dccba1 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 13:52:05 +0000 Subject: [PATCH 053/444] Upgrade postgre version to 11.1 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 4b443821eab6..55a1c61570a6 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -22,7 +22,7 @@ const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v4.0.6'; const DOCKER_JAVA_JRE = 'openjdk:8-jre-alpine'; const DOCKER_MYSQL = 'mysql:8.0.13'; const DOCKER_MARIADB = 'mariadb:10.3.7'; -const DOCKER_POSTGRESQL = 'postgres:10.4'; +const DOCKER_POSTGRESQL = 'postgres:11.1'; const DOCKER_MONGODB = 'mongo:4.0.2'; const DOCKER_COUCHBASE = 'couchbase/server:5.5.1'; const DOCKER_CASSANDRA = 'cassandra:3.9'; From c176a0082fa1ed957c8b1b5aff426e1aa53c5d70 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 13:53:49 +0000 Subject: [PATCH 054/444] Upgrade mongo version to 4.0.4 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 55a1c61570a6..13ef08cddea7 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -23,7 +23,7 @@ const DOCKER_JAVA_JRE = 'openjdk:8-jre-alpine'; const DOCKER_MYSQL = 'mysql:8.0.13'; const DOCKER_MARIADB = 'mariadb:10.3.7'; const DOCKER_POSTGRESQL = 'postgres:11.1'; -const DOCKER_MONGODB = 'mongo:4.0.2'; +const DOCKER_MONGODB = 'mongo:4.0.4'; const DOCKER_COUCHBASE = 'couchbase/server:5.5.1'; const DOCKER_CASSANDRA = 'cassandra:3.9'; const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest'; From fedf12dbecaa2f75c5f7468435209b4fd0442c1e Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:00:18 +0000 Subject: [PATCH 055/444] Upgrade couchbase server version to 6.0.0 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 13ef08cddea7..02a0529a39b1 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -24,7 +24,7 @@ const DOCKER_MYSQL = 'mysql:8.0.13'; const DOCKER_MARIADB = 'mariadb:10.3.7'; const DOCKER_POSTGRESQL = 'postgres:11.1'; const DOCKER_MONGODB = 'mongo:4.0.4'; -const DOCKER_COUCHBASE = 'couchbase/server:5.5.1'; +const DOCKER_COUCHBASE = 'couchbase/server:6.0.0'; const DOCKER_CASSANDRA = 'cassandra:3.9'; const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest'; const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; From 1c64496ba00c87e472852de09fdb41ce055bc9a5 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:15:07 +0000 Subject: [PATCH 056/444] Upgrade cassandra server version to 3.11.3 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 02a0529a39b1..332c106aefbc 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -25,7 +25,7 @@ const DOCKER_MARIADB = 'mariadb:10.3.7'; const DOCKER_POSTGRESQL = 'postgres:11.1'; const DOCKER_MONGODB = 'mongo:4.0.4'; const DOCKER_COUCHBASE = 'couchbase/server:6.0.0'; -const DOCKER_CASSANDRA = 'cassandra:3.9'; +const DOCKER_CASSANDRA = 'cassandra:3.11.3'; const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest'; const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; From e6cc66a38a037d4770c5c95c4f9f3f0186e1557a Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:26:44 +0000 Subject: [PATCH 057/444] Upgrade memcached version to 1.5.12-alpine --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 332c106aefbc..ca51d788e3a7 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -29,7 +29,7 @@ const DOCKER_CASSANDRA = 'cassandra:3.11.3'; const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest'; const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; -const DOCKER_MEMCACHED = 'memcached:1.5.8-alpine'; +const DOCKER_MEMCACHED = 'memcached:1.5.12-alpine'; const DOCKER_KEYCLOAK = 'jboss/keycloak:4.5.0.Final'; const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.2'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 const DOCKER_KAFKA = 'wurstmeister/kafka:2.11-2.0.0'; From d5a26c835d800da4310dbf156034d59428a934f7 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:28:26 +0000 Subject: [PATCH 058/444] Upgrade keycloak version to 4.6.0.Final --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index ca51d788e3a7..c99564b80679 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -30,7 +30,7 @@ const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest'; const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; const DOCKER_MEMCACHED = 'memcached:1.5.12-alpine'; -const DOCKER_KEYCLOAK = 'jboss/keycloak:4.5.0.Final'; +const DOCKER_KEYCLOAK = 'jboss/keycloak:4.6.0.Final'; const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.2'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 const DOCKER_KAFKA = 'wurstmeister/kafka:2.11-2.0.0'; const DOCKER_ZOOKEEPER = 'wurstmeister/zookeeper:3.4.6'; From 19279dad714059133c425315c21c08d2502f2ecf Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:29:03 +0000 Subject: [PATCH 059/444] Upgrade elasticsearch version to 6.4.3 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index c99564b80679..6ea95bf277bc 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -31,7 +31,7 @@ const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; const DOCKER_MEMCACHED = 'memcached:1.5.12-alpine'; const DOCKER_KEYCLOAK = 'jboss/keycloak:4.6.0.Final'; -const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.2'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 +const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.3'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 const DOCKER_KAFKA = 'wurstmeister/kafka:2.11-2.0.0'; const DOCKER_ZOOKEEPER = 'wurstmeister/zookeeper:3.4.6'; const DOCKER_SONAR = 'sonarqube:7.1'; From a62af7bb870cb8dfb6d915daad6ef12bb0c6f312 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:30:43 +0000 Subject: [PATCH 060/444] Upgrade kafka version to 2.11-2.0.1 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 6ea95bf277bc..e4d310370373 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -32,7 +32,7 @@ const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; const DOCKER_MEMCACHED = 'memcached:1.5.12-alpine'; const DOCKER_KEYCLOAK = 'jboss/keycloak:4.6.0.Final'; const DOCKER_ELASTICSEARCH = 'elasticsearch:6.4.3'; // docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.1 -const DOCKER_KAFKA = 'wurstmeister/kafka:2.11-2.0.0'; +const DOCKER_KAFKA = 'wurstmeister/kafka:2.11-2.0.1'; const DOCKER_ZOOKEEPER = 'wurstmeister/zookeeper:3.4.6'; const DOCKER_SONAR = 'sonarqube:7.1'; const DOCKER_JHIPSTER_CONSOLE = 'jhipster/jhipster-console:v4.0.0'; From d590f5711f7221660aced66d05be6ff163a2277a Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:32:56 +0000 Subject: [PATCH 061/444] Upgrade consul version to 1.4.0 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index e4d310370373..18890cc6fbb7 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -42,7 +42,7 @@ const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0'; const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0'; const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; const DOCKER_TRAEFIK = 'traefik:1.7.4'; -const DOCKER_CONSUL = 'consul:1.3.0'; +const DOCKER_CONSUL = 'consul:1.4.0'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.4.3'; const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.15.2'; From f4503dd12dbbe4f9761b0715f10d0959ebc5780c Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:33:55 +0000 Subject: [PATCH 062/444] Upgrade prometheus version to v2.5.0 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 18890cc6fbb7..0a0838d74128 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -44,7 +44,7 @@ const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; const DOCKER_TRAEFIK = 'traefik:1.7.4'; const DOCKER_CONSUL = 'consul:1.4.0'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; -const DOCKER_PROMETHEUS = 'prom/prometheus:v2.4.3'; +const DOCKER_PROMETHEUS = 'prom/prometheus:v2.5.0'; const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.15.2'; const DOCKER_GRAFANA = 'grafana/grafana:5.3.0'; const DOCKER_JENKINS = 'jenkins:latest'; From d354f9b5f016d1e145de743dae554b79cdabda86 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:34:36 +0000 Subject: [PATCH 063/444] Upgrade prom/alertmanager version to v0.15.3 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 0a0838d74128..c46a2a687651 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -45,7 +45,7 @@ const DOCKER_TRAEFIK = 'traefik:1.7.4'; const DOCKER_CONSUL = 'consul:1.4.0'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.5.0'; -const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.15.2'; +const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.15.3'; const DOCKER_GRAFANA = 'grafana/grafana:5.3.0'; const DOCKER_JENKINS = 'jenkins:latest'; const DOCKER_SWAGGER_EDITOR = 'swaggerapi/swagger-editor:latest'; From 34b2b73c41c937c64d1bf6db4ccc4e94daa5c37a Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 14:35:38 +0000 Subject: [PATCH 064/444] Upgrade grafana version to 5.3.4 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index c46a2a687651..07570e98f96f 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -46,7 +46,7 @@ const DOCKER_CONSUL = 'consul:1.4.0'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.5.0'; const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.15.3'; -const DOCKER_GRAFANA = 'grafana/grafana:5.3.0'; +const DOCKER_GRAFANA = 'grafana/grafana:5.3.4'; const DOCKER_JENKINS = 'jenkins:latest'; const DOCKER_SWAGGER_EDITOR = 'swaggerapi/swagger-editor:latest'; const DOCKER_COMPOSE_FORMAT_VERSION = '2'; From 113a3052448310caa227dd024211a11cdcb37068 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 16:18:17 +0000 Subject: [PATCH 065/444] Upgrade elasticsearch docker image version --- .../server/templates/src/main/docker/elasticsearch.yml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/docker/elasticsearch.yml.ejs b/generators/server/templates/src/main/docker/elasticsearch.yml.ejs index b844776b7b88..707ec5eaab82 100644 --- a/generators/server/templates/src/main/docker/elasticsearch.yml.ejs +++ b/generators/server/templates/src/main/docker/elasticsearch.yml.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -version: '2' +version: '2.2' services: <%= baseName.toLowerCase() %>-elasticsearch: image: <%= DOCKER_ELASTICSEARCH %> From ddd34f6320a74c8ce1538d55b44e55e4cc4d7359 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 17:53:49 +0000 Subject: [PATCH 066/444] Upgrade maven-surefire-plugin version to 3.0.0-M1 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 12649cef3ed9..fd2d3811ccfd 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -118,7 +118,7 @@ 2.10 3.0.0-M2 3.1.0 - 2.22.1 + 3.0.0-M1 3.2.2 0.9.11 <%_ if (!skipClient) { _%> From f91ef654a217fb4b64302118a1508d76eecc4f41 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 17:55:49 +0000 Subject: [PATCH 067/444] Upgrade scala-maven-plugin version to 3.4.4 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index fd2d3811ccfd..610b22e1cf37 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -126,7 +126,7 @@ <%_ } _%> 0.8.2 1.0.0 - 3.4.2 + 3.4.4 3.5.0.1254 <%_ if (enableSwaggerCodegen) { _%> 3.3.0 From 03a098a75ed001e8735b6414de00f5f3afabf67d Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 30 Nov 2018 17:56:37 +0000 Subject: [PATCH 068/444] Upgrade openapi-generator-maven-plugin version to 3.3.3 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 610b22e1cf37..c58747f9674c 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -129,7 +129,7 @@ 3.4.4 3.5.0.1254 <%_ if (enableSwaggerCodegen) { _%> - 3.3.0 + 3.3.3 <%_ } _%> 2.2.5 From dde4f1c1e8ee45a048425f4b5c7783e99f58a8b8 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Mon, 3 Dec 2018 13:25:43 +0000 Subject: [PATCH 069/444] Upgrade traefik version to 1.7.5 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 07570e98f96f..e8a6dc997d18 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -41,7 +41,7 @@ const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.0.0'; const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0'; const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0'; const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; -const DOCKER_TRAEFIK = 'traefik:1.7.4'; +const DOCKER_TRAEFIK = 'traefik:1.7.5'; const DOCKER_CONSUL = 'consul:1.4.0'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.5.0'; From 56622fd3e324f663e4440821d44291e0ad2e1e6e Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 4 Dec 2018 14:14:51 +0100 Subject: [PATCH 070/444] migrate to hazelcast-hibernate53 --- generators/server/templates/build.gradle.ejs | 2 +- generators/server/templates/pom.xml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index f71552a735f2..fee63e727159 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -269,7 +269,7 @@ dependencies { <%_ if (cacheProvider === 'hazelcast') { _%> compile "com.hazelcast:hazelcast" <%_ if (enableHibernateCache) { _%> - compile "com.hazelcast:hazelcast-hibernate52" + compile "com.hazelcast:hazelcast-hibernate53" <%_ } _%> compile "com.hazelcast:hazelcast-spring" <%_ } _%> diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 30d0c3ef271a..083eee06defb 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -296,7 +296,7 @@ <%_ if (cacheProvider === 'hazelcast' && enableHibernateCache) { _%> com.hazelcast - hazelcast-hibernate52 + hazelcast-hibernate53 <%_ } _%> <%_ if (cacheProvider === 'hazelcast') { _%> From c7dd5f3b4c01b74bddee51b1b473a6d131a845ee Mon Sep 17 00:00:00 2001 From: Anthony Viard Date: Tue, 4 Dec 2018 16:49:30 +0100 Subject: [PATCH 071/444] Fix Docker settings Revert to version 2 otherwise it does not start Remove command network.host deprecated Move command discovery.type to environment #8683 --- .../server/templates/src/main/docker/elasticsearch.yml.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/src/main/docker/elasticsearch.yml.ejs b/generators/server/templates/src/main/docker/elasticsearch.yml.ejs index 707ec5eaab82..4babc6601e8f 100644 --- a/generators/server/templates/src/main/docker/elasticsearch.yml.ejs +++ b/generators/server/templates/src/main/docker/elasticsearch.yml.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -version: '2.2' +version: '2' services: <%= baseName.toLowerCase() %>-elasticsearch: image: <%= DOCKER_ELASTICSEARCH %> @@ -25,6 +25,6 @@ services: ports: - 9200:9200 - 9300:9300 - command: -Enetwork.host=0.0.0.0 -Ediscovery.type=single-node environment: - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" + - discovery.type=single-node From cca0e06edc60a6bed47633a66c62527288646a62 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 4 Dec 2018 23:01:52 +0000 Subject: [PATCH 072/444] Fix webflux testMethodNotSupported test: change 405 response detail --- .../package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs index e15c669e4509..7abebbecac84 100644 --- a/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs @@ -332,7 +332,7 @@ public class ExceptionTranslatorIntTest { .expectHeader().contentType(MediaType.APPLICATION_PROBLEM_JSON) .expectBody() .jsonPath("$.message").isEqualTo("error.http.405") - .jsonPath("$.detail").isEqualTo("Response status 405 with reason \"Request method 'POST' not supported\""); + .jsonPath("$.detail").isEqualTo("405 METHOD_NOT_ALLOWED \"Request method 'POST' not supported\""); } @Test From 437461a6992bf70e4025b8cd0618bbfcf1c77aa8 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 14 Dec 2018 09:27:15 +0000 Subject: [PATCH 073/444] Upgrade traefik version to 1.7.6 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index e8a6dc997d18..a99507c08a46 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -41,7 +41,7 @@ const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.0.0'; const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0'; const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0'; const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; -const DOCKER_TRAEFIK = 'traefik:1.7.5'; +const DOCKER_TRAEFIK = 'traefik:1.7.6'; const DOCKER_CONSUL = 'consul:1.4.0'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.5.0'; From 696e92268a97c144361090e78db0f5ed6d5b1024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Sun, 16 Dec 2018 23:57:29 +0100 Subject: [PATCH 074/444] Fix NoClassDefFoundError: com/codahale/metrics/JmxReporter --- .../src/test/java/package/AbstractCassandraTest.java.ejs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs b/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs index b67544b74fa1..43e5e5ed95bc 100644 --- a/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs +++ b/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs @@ -41,8 +41,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static org.cassandraunit.utils.EmbeddedCassandraServerHelper.getNativeTransportPort; - /** * Base class for starting/stopping Cassandra during tests. */ @@ -58,7 +56,7 @@ public class AbstractCassandraTest { public static void startServer() throws TTransportException, ConfigurationException, IOException, URISyntaxException { if (! started) { EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_UNIT_RANDOM_PORT_YAML, CASSANDRA_TIMEOUT); - Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(getNativeTransportPort()).build(); + Cluster cluster = EmbeddedCassandraServerHelper.getCluster(); Session session = cluster.connect(); String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}"; session.execute(createQuery); From 4fb418537fc6e73db85ca16b07513d6b1adfb8e9 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 21 Dec 2018 10:03:55 +0000 Subject: [PATCH 075/444] Upgrade maven-surefire-plugin version to 3.0.0-M2 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 083eee06defb..9a3510cdcf00 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -129,7 +129,7 @@ 2.10 3.0.0-M2 3.1.0 - 3.0.0-M1 + 3.0.0-M2 3.2.2 0.9.11 <%_ if (!skipClient) { _%> From e7c9a1692ea07b81809ea8d0035d600f1c1c7e31 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 21 Dec 2018 10:05:35 +0000 Subject: [PATCH 076/444] Upgrade openapi-generator-maven-plugin version to 3.3.4 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 9a3510cdcf00..52b0ebbe6531 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -140,7 +140,7 @@ 3.4.4 3.5.0.1254 <%_ if (enableSwaggerCodegen) { _%> - 3.3.3 + 3.3.4 <%_ } _%> 2.2.5 From 3988ff40258851e39016deb482612e08a32b2ecd Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 21 Dec 2018 10:08:23 +0000 Subject: [PATCH 077/444] Upgrade openapi-generator-gradle-plugin version to 3.3.4 --- generators/server/templates/build.gradle.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index fee63e727159..01978b8141a3 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -29,7 +29,7 @@ buildscript { classpath "org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}" classpath "io.spring.gradle:propdeps-plugin:0.0.10.RELEASE" <%_ if (enableSwaggerCodegen) { _%> - classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.0" + classpath "org.openapitools:openapi-generator-gradle-plugin:3.3.4" <%_ } _%> classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.5.2" //jhipster-needle-gradle-buildscript-dependency - JHipster will add additional gradle build script plugins here From fd73b582dba8cdb712787a02992b344e46bba7b7 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 21 Dec 2018 10:13:39 +0000 Subject: [PATCH 078/444] Remove explicit problem-spring-web version --- generators/server/templates/build.gradle.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 01978b8141a3..661bca789720 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -358,7 +358,7 @@ dependencies { compile "org.springframework.boot:spring-boot-starter-websocket" <%_ } _%> compile "org.springframework.boot:spring-boot-starter-thymeleaf" - compile "org.zalando:problem-spring-web<% if (reactive) { %>flux<% } %>:0.24.0-RC.0" + compile "org.zalando:problem-spring-web<% if (reactive) { %>flux<% } %>" <%_ if (databaseType === 'cassandra') { _%> compile "com.datastax.cassandra:cassandra-driver-extras" compile "com.datastax.cassandra:cassandra-driver-mapping" From 0872de6ad90c760c62604905b77a843f9097f122 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 21 Dec 2018 10:17:00 +0000 Subject: [PATCH 079/444] Added jaxb-api version gradle property --- generators/server/templates/build.gradle.ejs | 2 +- generators/server/templates/gradle.properties.ejs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 661bca789720..0aa42bc56763 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -447,7 +447,7 @@ dependencies { annotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct_version}" <%_ if (databaseType === 'sql') { _%> annotationProcessor "org.hibernate:hibernate-jpamodelgen" - annotationProcessor "javax.xml.bind:jaxb-api:2.3.1" + annotationProcessor "javax.xml.bind:jaxb-api:${jaxb-api_version}" annotationProcessor "com.sun.xml.bind:jaxb-impl:2.3.1" <%_ } _%> annotationProcessor ("org.springframework.boot:spring-boot-configuration-processor") { diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 16f6be6a9460..47278e1c0a04 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -37,6 +37,7 @@ mapstruct_version=1.2.0.Final liquibase_hibernate5_version=3.6 liquibaseTaskPrefix=liquibase +jaxb-api_version=2.3.1 ## below are some of the gradle performance improvement settings that can be used as required, these are not enabled by default ## The Gradle daemon aims to improve the startup and execution time of Gradle. From c0ca72ef1bad821ff867e710ba23aa20c0c010af Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 21 Dec 2018 10:18:09 +0000 Subject: [PATCH 080/444] Added jaxb-impl version gradle property --- generators/server/templates/build.gradle.ejs | 2 +- generators/server/templates/gradle.properties.ejs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 0aa42bc56763..73911b36845c 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -448,7 +448,7 @@ dependencies { <%_ if (databaseType === 'sql') { _%> annotationProcessor "org.hibernate:hibernate-jpamodelgen" annotationProcessor "javax.xml.bind:jaxb-api:${jaxb-api_version}" - annotationProcessor "com.sun.xml.bind:jaxb-impl:2.3.1" + annotationProcessor "com.sun.xml.bind:jaxb-impl:${jaxb-impl_version}" <%_ } _%> annotationProcessor ("org.springframework.boot:spring-boot-configuration-processor") { exclude group: 'com.vaadin.external.google', module: 'android-json' diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 47278e1c0a04..6621bd29be41 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -38,6 +38,8 @@ liquibase_hibernate5_version=3.6 liquibaseTaskPrefix=liquibase jaxb-api_version=2.3.1 +jaxb-impl_version=2.3.1 + ## below are some of the gradle performance improvement settings that can be used as required, these are not enabled by default ## The Gradle daemon aims to improve the startup and execution time of Gradle. From d30485add920701357c7c547d20051696359e8e5 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Fri, 21 Dec 2018 10:49:59 +0000 Subject: [PATCH 081/444] Fix jaxb-api and jaxb-impl gradle property --- generators/server/templates/build.gradle.ejs | 4 ++-- generators/server/templates/gradle.properties.ejs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 73911b36845c..975e3694fb57 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -447,8 +447,8 @@ dependencies { annotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct_version}" <%_ if (databaseType === 'sql') { _%> annotationProcessor "org.hibernate:hibernate-jpamodelgen" - annotationProcessor "javax.xml.bind:jaxb-api:${jaxb-api_version}" - annotationProcessor "com.sun.xml.bind:jaxb-impl:${jaxb-impl_version}" + annotationProcessor "javax.xml.bind:jaxb-api:${jaxb_api_version}" + annotationProcessor "com.sun.xml.bind:jaxb-impl:${jaxb_impl_version}" <%_ } _%> annotationProcessor ("org.springframework.boot:spring-boot-configuration-processor") { exclude group: 'com.vaadin.external.google', module: 'android-json' diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 6621bd29be41..0021a655479a 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -37,8 +37,8 @@ mapstruct_version=1.2.0.Final liquibase_hibernate5_version=3.6 liquibaseTaskPrefix=liquibase -jaxb-api_version=2.3.1 -jaxb-impl_version=2.3.1 +jaxb_api_version=2.3.1 +jaxb_impl_version=2.3.1 ## below are some of the gradle performance improvement settings that can be used as required, these are not enabled by default From b418628ad51acf4278de474eeaeea3847a8f5174 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Fri, 21 Dec 2018 17:54:56 +0100 Subject: [PATCH 082/444] Remove JMX to improve start-up performance See #8954 --- .../templates/src/main/java/package/Application.java.ejs | 3 ++- .../src/main/resources/config/application-dev.yml.ejs | 2 +- .../src/main/resources/config/application-prod.yml.ejs | 2 +- .../templates/src/main/resources/config/application.yml.ejs | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/generators/server/templates/src/main/java/package/Application.java.ejs b/generators/server/templates/src/main/java/package/Application.java.ejs index d8e20fc2d002..ae0653769c0a 100644 --- a/generators/server/templates/src/main/java/package/Application.java.ejs +++ b/generators/server/templates/src/main/java/package/Application.java.ejs @@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; <%_ if (databaseType === 'sql') { _%> import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties; <%_ } _%> @@ -58,7 +59,7 @@ import java.util.Collection; excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = OAuth2InterceptedFeignConfiguration.class) ) <%_ } _%> -@SpringBootApplication +@SpringBootApplication(exclude = JmxAutoConfiguration.class) @EnableConfigurationProperties({<% if (databaseType === 'sql') { %>LiquibaseProperties.class, <% } %>ApplicationProperties.class}) <%_ if (serviceDiscoveryType) { _%> @EnableDiscoveryClient 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 6bb8fa8c00d8..e10172f27831 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 @@ -347,7 +347,7 @@ jhipster: base-url: http://127.0.0.1:<%= applicationType !== 'uaa' ? serverPort : 8080 %> metrics: # DropWizard Metrics configuration, used by MetricsConfiguration jmx: - enabled: true + enabled: false prometheus: enabled: false #expose metrics via prometheus logs: # Reports Dropwizard metrics in the logs 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 dfefc7adf169..58407993db4b 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 @@ -331,7 +331,7 @@ jhipster: base-url: http://my-server-url-to-change # Modify according to your server's URL metrics: # DropWizard Metrics configuration, used by MetricsConfiguration jmx: - enabled: true + enabled: false prometheus: enabled: false #expose metrics via prometheus logs: # Reports Dropwizard metrics in the logs diff --git a/generators/server/templates/src/main/resources/config/application.yml.ejs b/generators/server/templates/src/main/resources/config/application.yml.ejs index 1a7181a20294..b0654d5b8bbe 100644 --- a/generators/server/templates/src/main/resources/config/application.yml.ejs +++ b/generators/server/templates/src/main/resources/config/application.yml.ejs @@ -152,6 +152,8 @@ spring: # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS` active: #spring.profiles.active# <%_ } _%> + jmx: + enabled: false <%_ if (databaseType === 'sql') { _%> jpa: open-in-view: false From 7ba27d3dcc392c833bc79fa275809099d53fe45f Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Fri, 21 Dec 2018 17:59:33 +0100 Subject: [PATCH 083/444] Use deferred mode for JPA repositories, to speed up start up See #8954 --- .../templates/src/main/resources/config/application.yml.ejs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generators/server/templates/src/main/resources/config/application.yml.ejs b/generators/server/templates/src/main/resources/config/application.yml.ejs index 1a7181a20294..844301286a6c 100644 --- a/generators/server/templates/src/main/resources/config/application.yml.ejs +++ b/generators/server/templates/src/main/resources/config/application.yml.ejs @@ -153,6 +153,10 @@ spring: active: #spring.profiles.active# <%_ } _%> <%_ if (databaseType === 'sql') { _%> + data: + jpa: + repositories: + bootstrap-mode: deferred jpa: open-in-view: false properties: From 521cb862d0c8351f17884dbfb43e664140af85a7 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Fri, 21 Dec 2018 18:11:06 +0100 Subject: [PATCH 084/444] Lazy init Spring Beans at start-up. This is gives a huge performance boost, but is considered experimental, so this is only configured in dev mode for the moment. See #8954 --- generators/server/files.js | 4 + .../LazyInitBeanFactoryPostProcessor.java.ejs | 73 +++++++++++++++++++ .../src/main/resources/logback-spring.xml.ejs | 1 + test/utils/expected-files.js | 1 + 4 files changed, 79 insertions(+) create mode 100644 generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs diff --git a/generators/server/files.js b/generators/server/files.js index 547bdeb764d0..77c3cc74ee6e 100644 --- a/generators/server/files.js +++ b/generators/server/files.js @@ -795,6 +795,10 @@ const serverFiles = { file: 'package/aop/logging/LoggingAspect.java', renameTo: generator => `${generator.javaDir}aop/logging/LoggingAspect.java` }, + { + file: 'package/config/lazy/LazyInitBeanFactoryPostProcessor.java', + renameTo: generator => `${generator.javaDir}config/lazy/LazyInitBeanFactoryPostProcessor.java` + }, { file: 'package/config/DefaultProfileUtil.java', renameTo: generator => `${generator.javaDir}config/DefaultProfileUtil.java` diff --git a/generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs b/generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs new file mode 100644 index 000000000000..7857de20fef0 --- /dev/null +++ b/generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs @@ -0,0 +1,73 @@ +<%# + Copyright 2013-2018 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%>.config.lazy; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +/** + * Lazy initialize all Spring Beans, which boosts up start-up performance. + * + * This class originally comes from https://github.com/dsyer/spring-boot-allocations where it is written + * it can be copied on a project. + * + * As this is an experimental feature, we only recommend to use it in "dev" mode for the moment. + */ +@Component +@Profile("dev") +public class LazyInitBeanFactoryPostProcessor implements BeanFactoryPostProcessor { + + private Class[] exclusionList; + + public LazyInitBeanFactoryPostProcessor() { + } + + public LazyInitBeanFactoryPostProcessor(Class[] exclusionList) { + this.exclusionList = exclusionList; + } + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) + throws BeansException { + + // Iterate over all beans, mark them as lazy if they are not in the exclusion list. + for (String beanName : beanFactory.getBeanDefinitionNames()) { + if (isLazy(beanName, beanFactory)) { + BeanDefinition definition = beanFactory.getBeanDefinition(beanName); + definition.setLazyInit(true); + } + } + } + + private boolean isLazy(String beanName, ConfigurableListableBeanFactory beanFactory) { + if (exclusionList == null || exclusionList.length == 0) { + return true; + } + for (Class clazz : exclusionList) { + if (beanFactory.isTypeMatch(beanName, clazz)) { + return false; + } + } + return true; + } +} diff --git a/generators/server/templates/src/main/resources/logback-spring.xml.ejs b/generators/server/templates/src/main/resources/logback-spring.xml.ejs index 917c6782f6f3..5961548bb19c 100644 --- a/generators/server/templates/src/main/resources/logback-spring.xml.ejs +++ b/generators/server/templates/src/main/resources/logback-spring.xml.ejs @@ -122,6 +122,7 @@ <% if (databaseType === 'sql') { %> <% } %> + <%_ if (applicationType === 'microservice' || applicationType === 'gateway' || cacheProvider === 'hazelcast') { _%> <%_ } _%> diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js index 91640882f937..2c6729beb613 100644 --- a/test/utils/expected-files.js +++ b/test/utils/expected-files.js @@ -148,6 +148,7 @@ const expectedFiles = { `${SERVER_MAIN_RES_DIR}i18n/messages.properties`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/JhipsterApp.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/aop/logging/LoggingAspect.java`, + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/lazy/LazyInitBeanFactoryPostProcessor.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/package-info.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/ApplicationProperties.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/AsyncConfiguration.java`, From c03c16064c9fb95263cfff05221c1391db6e3e5e Mon Sep 17 00:00:00 2001 From: Srinivasa Vasu Date: Tue, 25 Dec 2018 23:39:23 +0530 Subject: [PATCH 085/444] update sb-2.1.1 --- .../config/CacheConfiguration.java.ejs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs index 42ebb5c4d641..b4489c7b4ffd 100644 --- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs @@ -396,20 +396,21 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem if (this.registration == null) { // if registry is not defined, use native discovery log.warn("No discovery service is set up, Infinispan will use default discovery for cluster formation"); return () -> GlobalConfigurationBuilder - .defaultClusteredBuilder().transport().defaultTransport() + .defaultClusteredBuilder().defaultCacheName("infinispan-<%=baseName%>-cluster-cache").transport().defaultTransport() .addProperty("configurationFile", jHipsterProperties.getCache().getInfinispan().getConfigFile()) .clusterName("infinispan-<%=baseName%>-cluster").globalJmxStatistics() .enabled(jHipsterProperties.getCache().getInfinispan().isStatsEnabled()) .allowDuplicateDomains(true).build(); } return () -> GlobalConfigurationBuilder - .defaultClusteredBuilder().transport().transport(new JGroupsTransport(getTransportChannel())) + .defaultClusteredBuilder().defaultCacheName("infinispan-<%=baseName%>-cluster-cache").transport() + .transport(new JGroupsTransport(getTransportChannel())) .clusterName("infinispan-<%=baseName%>-cluster").globalJmxStatistics() .enabled(jHipsterProperties.getCache().getInfinispan().isStatsEnabled()) .allowDuplicateDomains(true).build(); <%_ } else { _%> return () -> GlobalConfigurationBuilder - .defaultClusteredBuilder().transport().defaultTransport() + .defaultClusteredBuilder().defaultCacheName("infinispan-<%=baseName%>-cluster-cache").transport().defaultTransport() .addProperty("configurationFile", jHipsterProperties.getCache().getInfinispan().getConfigFile()) .clusterName("infinispan-<%=baseName%>-cluster").globalJmxStatistics() .enabled(jHipsterProperties.getCache().getInfinispan().isStatsEnabled()) @@ -529,7 +530,7 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem cacheManager.getCache("oAuth2Authentication").getAdvancedCache(), this, ConfigurationAdapter.create())); <%_ } _%> - <%_ if (!skipUserManagement || (authenticationType === 'oauth2' && applicationType !== 'microservice')) { _%> + <%_ if (!skipUserManagement || (authenticationType === 'oauth2')) { _%> registerPredefinedCache(<%=packageName%>.repository.UserRepository.USERS_BY_LOGIN_CACHE, new JCache( cacheManager.getCache(<%=packageName%>.repository.UserRepository.USERS_BY_LOGIN_CACHE).getAdvancedCache(), this, ConfigurationAdapter.create())); @@ -573,8 +574,8 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem * MPING multicast is replaced with TCPPING with the host details discovered * from registry and sends only unicast messages to the host list. */ - private Channel getTransportChannel() { - JChannel channel = new JChannel(false); + private JChannel getTransportChannel() { + JChannel channel = null; List initialHosts = new ArrayList<>(); try { for (ServiceInstance instance : discoveryClient.getInstances(registration.getServiceId())) { @@ -587,12 +588,7 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem tcp.setBindPort(7800); tcp.setThreadPoolMinThreads(2); tcp.setThreadPoolMaxThreads(30); - tcp.setThreadPoolQueueEnabled(false); tcp.setThreadPoolKeepAliveTime(60000); - tcp.setOOBThreadPoolMinThreads(2); - tcp.setOOBThreadPoolMaxThreads(200); - tcp.setOOBThreadPoolKeepAliveTime(60000); - tcp.setOOBThreadPoolQueueEnabled(false); TCPPING tcpping = new TCPPING(); initialHosts.add(new IpAddress(InetAddress.getLocalHost(), 7800)); @@ -629,7 +625,7 @@ public class CacheConfiguration<% if (cacheProvider === 'hazelcast') { %> implem .addProtocol(new GMS()) .addProtocol(new MFC()) .addProtocol(new FRAG2()); - channel.setProtocolStack(stack); + channel = new JChannel(stack); stack.init(); } catch (Exception e) { throw new BeanInitializationException("Cache (Infinispan protocol stack) configuration failed", e); From 325168a1bd17d369483921046bc1761f1dd3593a Mon Sep 17 00:00:00 2001 From: ctayeb Date: Thu, 27 Dec 2018 19:26:13 +0100 Subject: [PATCH 086/444] Fix reactive build when no cache manager selected --- .../src/main/java/package/service/UserService.java.ejs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/src/main/java/package/service/UserService.java.ejs b/generators/server/templates/src/main/java/package/service/UserService.java.ejs index b505b44f56c4..c95e4ca614db 100644 --- a/generators/server/templates/src/main/java/package/service/UserService.java.ejs +++ b/generators/server/templates/src/main/java/package/service/UserService.java.ejs @@ -279,7 +279,9 @@ public class UserService { return userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()) .flatMap(existingUser -> { if (!existingUser.getActivated()) { - this.clearUserCaches(existingUser); + <%_ if (cacheManagerIsAvailable === true) { _%> + this.clearUserCaches(newUser); + <%_ } _%> return userRepository.delete(existingUser); } else { throw new LoginAlreadyUsedException(); @@ -288,7 +290,9 @@ public class UserService { .then(userRepository.findOneByEmailIgnoreCase(userDTO.getEmail())) .flatMap(existingUser -> { if (!existingUser.getActivated()) { - this.clearUserCaches(existingUser); + <%_ if (cacheManagerIsAvailable === true) { _%> + this.clearUserCaches(newUser); + <%_ } _%> return userRepository.delete(existingUser); } else { throw new EmailAlreadyUsedException(); @@ -315,7 +319,9 @@ public class UserService { .thenReturn(newUser) .doOnNext(user -> user.setAuthorities(authorities)) .flatMap(this::createUser) + <%_ if (cacheManagerIsAvailable === true) { _%> .doOnNext(this::clearUserCaches) + <%_ } _%> .doOnNext(user -> log.debug("Created Information for User: {}", user)); }); <%_ } _%> From 05eef31984bc86a60b9e207b944960e98ab3fb0e Mon Sep 17 00:00:00 2001 From: ctayeb Date: Sun, 30 Dec 2018 17:16:42 +0100 Subject: [PATCH 087/444] Add reactive couchbase option --- generators/server/files.js | 14 +++ generators/server/prompts.js | 8 +- .../config/DatabaseConfiguration.java.ejs | 5 +- .../repository/UserRepository.java.ejs | 4 +- ...omReactiveN1qlCouchbaseRepository.java.ejs | 93 +++++++++++++++++++ .../ReactiveN1qlCouchbaseRepository.java.ejs | 47 ++++++++++ .../java/package/service/UserService.java.ejs | 15 ++- travis/samples/reactive-couchbase/.yo-rc.json | 28 ++++++ 8 files changed, 207 insertions(+), 7 deletions(-) create mode 100644 generators/server/templates/src/main/java/package/repository/reactive/CustomReactiveN1qlCouchbaseRepository.java.ejs create mode 100644 generators/server/templates/src/main/java/package/repository/reactive/ReactiveN1qlCouchbaseRepository.java.ejs create mode 100644 travis/samples/reactive-couchbase/.yo-rc.json diff --git a/generators/server/files.js b/generators/server/files.js index 547bdeb764d0..2ba7068ec820 100644 --- a/generators/server/files.js +++ b/generators/server/files.js @@ -920,6 +920,20 @@ const serverFiles = { } ] }, + { + condition: generator => generator.reactive && generator.databaseType === 'couchbase', + path: SERVER_MAIN_SRC_DIR, + templates: [ + { + file: 'package/repository/reactive/ReactiveN1qlCouchbaseRepository.java', + renameTo: generator => `${generator.javaDir}repository/${generator.reactiveRepository}ReactiveN1qlCouchbaseRepository.java` + }, + { + file: 'package/repository/reactive/CustomReactiveN1qlCouchbaseRepository.java', + renameTo: generator => `${generator.javaDir}repository/${generator.reactiveRepository}CustomReactiveN1qlCouchbaseRepository.java` + } + ] + }, { condition: generator => generator.websocket === 'spring-websocket', path: SERVER_MAIN_SRC_DIR, diff --git a/generators/server/prompts.js b/generators/server/prompts.js index ddcfbdef9d7d..587eea01754d 100644 --- a/generators/server/prompts.js +++ b/generators/server/prompts.js @@ -171,11 +171,11 @@ function askForServerSideOpts(meta) { value: 'mongodb', name: 'MongoDB' }); + opts.push({ + value: 'couchbase', + name: 'Couchbase' + }); if (!reactive) { - opts.push({ - value: 'couchbase', - name: 'Couchbase' - }); if ( (response.authenticationType !== 'oauth2' && applicationType === 'microservice') || (response.authenticationType === 'uaa' && applicationType === 'gateway') diff --git a/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs index f39c4e5a09bc..4280b23ecc6d 100644 --- a/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs @@ -31,6 +31,9 @@ import com.mongodb.MongoClient; import com.couchbase.client.java.Bucket; import com.github.couchmove.Couchmove; import <%=packageName%>.repository.CustomN1qlCouchbaseRepository; +<%_ if (reactive) { _%> +import <%=packageName%>.repository.reactive.CustomReactiveN1qlCouchbaseRepository; +<%_ } _%> import org.apache.commons.codec.binary.Base64; <%_ } _%> <%_ if (databaseType === 'mongodb') { _%> @@ -149,7 +152,7 @@ import java.util.List; <%_ if (databaseType === 'couchbase') { _%> @EnableCouchbaseRepositories(repositoryBaseClass = CustomN1qlCouchbaseRepository.class, basePackages = "<%=packageName%>.repository") <%_ if (reactive) { _%> -@EnableReactiveCouchbaseRepositories("<%=packageName%>.repository.reactive") +@EnableReactiveCouchbaseRepositories(repositoryBaseClass = CustomReactiveN1qlCouchbaseRepository.class, basePackages = "<%=packageName%>.repository.reactive") <%_ } _%> @Import(value = CouchbaseAutoConfiguration.class) @EnableCouchbaseAuditing(auditorAwareRef = "springSecurityAuditorAware") diff --git a/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs b/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs index 84065d665378..6038d2513f19 100644 --- a/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs +++ b/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs @@ -30,7 +30,9 @@ import <%=packageName%>.domain.User; import org.springframework.cache.annotation.Cacheable; <%_ } _%> <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%> +<%_ if (!reactive) { _%> import org.springframework.data.domain.Page; +<%_ } %> import org.springframework.data.domain.Pageable; <%_ } _%> <%_ if (databaseType === 'sql') { _%> @@ -116,7 +118,7 @@ public interface UserRepository extends <% if (databaseType === 'sql') { %>JpaRe <%_ if (cacheManagerIsAvailable === true) { _%> @Cacheable(cacheNames = USERS_BY_LOGIN_CACHE) <%_ } _%> - default Optional findOneByLogin(String login) { + default <% if (reactive) { %>Mono<% } else { %>Optional<% } %> findOneByLogin(String login) { return findById(User.PREFIX + ID_DELIMITER + login); } <%_ } else if (databaseType === 'mongodb') { _%> diff --git a/generators/server/templates/src/main/java/package/repository/reactive/CustomReactiveN1qlCouchbaseRepository.java.ejs b/generators/server/templates/src/main/java/package/repository/reactive/CustomReactiveN1qlCouchbaseRepository.java.ejs new file mode 100644 index 000000000000..32c5b90fe497 --- /dev/null +++ b/generators/server/templates/src/main/java/package/repository/reactive/CustomReactiveN1qlCouchbaseRepository.java.ejs @@ -0,0 +1,93 @@ +<%# + Copyright 2013-2018 the original author or authors from the JHipster project. + + This file is part of the JHipster project, see https://jhipster.github.io/ + 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%>.repository.reactive; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.couchbase.core.CouchbaseTemplate; +import org.springframework.data.couchbase.core.RxJavaCouchbaseOperations; +import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity; +import org.springframework.data.couchbase.repository.query.CouchbaseEntityInformation; +import org.springframework.data.couchbase.repository.support.ReactiveN1qlCouchbaseRepository; +import org.springframework.data.repository.util.QueryExecutionConverters; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.io.Serializable; +import java.lang.reflect.Field; +import java.util.Set; + +/** + * A custom implementation of CouchbaseRepository . + */ +public class CustomReactiveN1qlCouchbaseRepository extends ReactiveN1qlCouchbaseRepository { + + private final CouchbasePersistentEntity persistentEntity; + + @Autowired + private CouchbaseTemplate template; + + /** + * Create a new Repository. + * + * @param metadata the Metadata for the entity. + * @param couchbaseOperations the reference to the template used. + */ + public CustomReactiveN1qlCouchbaseRepository(CouchbaseEntityInformation metadata, RxJavaCouchbaseOperations couchbaseOperations) { + super(metadata, couchbaseOperations); + persistentEntity = getCouchbaseOperations().getConverter().getMappingContext().getPersistentEntity(getEntityInformation().getJavaType()); + template = new CouchbaseTemplate(getCouchbaseOperations().getCouchbaseClusterInfo(), getCouchbaseOperations().getCouchbaseBucket()); + allowPageable(); + } + + // Temporary Hack to fix pageable + @SuppressWarnings("unchecked") + private void allowPageable() { + try { + Field allowed_pageable_types = QueryExecutionConverters.class.getDeclaredField("ALLOWED_PAGEABLE_TYPES"); + allowed_pageable_types.setAccessible(true); + Set> ALLOWED_PAGEABLE_TYPES = (Set>) allowed_pageable_types.get(QueryExecutionConverters.class); + ALLOWED_PAGEABLE_TYPES.add(Flux.class); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + + @Override + public Mono save(S entity) { + return super.save(populateIdIfNecessary(entity)); + } + + /** + * Add generated ID to entity if not already set + * + * @param entity + * @return entity with ID set + */ + private S populateIdIfNecessary(S entity) { + if (getEntityInformation().getId(entity) != null) { + return entity; + } + setId(entity, template.getGeneratedId(entity)); + return entity; + } + + private void setId(S entity, String generatedId) { + persistentEntity.getPropertyAccessor(entity).setProperty(persistentEntity.getIdProperty(), generatedId); + } +} diff --git a/generators/server/templates/src/main/java/package/repository/reactive/ReactiveN1qlCouchbaseRepository.java.ejs b/generators/server/templates/src/main/java/package/repository/reactive/ReactiveN1qlCouchbaseRepository.java.ejs new file mode 100644 index 000000000000..5df8dd24920d --- /dev/null +++ b/generators/server/templates/src/main/java/package/repository/reactive/ReactiveN1qlCouchbaseRepository.java.ejs @@ -0,0 +1,47 @@ +<%# + Copyright 2013-2018 the original author or authors from the JHipster project. + + This file is part of the JHipster project, see https://jhipster.github.io/ + 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%>.repository.reactive; + +import org.springframework.data.couchbase.core.query.Query; +import org.springframework.data.couchbase.repository.ReactiveCouchbaseSortingRepository; +import org.springframework.data.repository.NoRepositoryBean; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.io.Serializable; + +/** + * Couchbase specific {@link org.springframework.data.repository.Repository} interface uses N1QL for all requests + */ +@NoRepositoryBean +public interface ReactiveN1qlCouchbaseRepository extends ReactiveCouchbaseSortingRepository { + + @Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter}") + Flux findAll(); + + @Query("SELECT count(*) FROM #{#n1ql.bucket} WHERE #{#n1ql.filter}") + Mono count(); + + @Query("DELETE FROM #{#n1ql.bucket} WHERE #{#n1ql.filter} returning #{#n1ql.fields}") + Flux removeAll(); + + default Mono deleteAll() { + return removeAll().then(); + } +} diff --git a/generators/server/templates/src/main/java/package/service/UserService.java.ejs b/generators/server/templates/src/main/java/package/service/UserService.java.ejs index c95e4ca614db..cca52de7ddb6 100644 --- a/generators/server/templates/src/main/java/package/service/UserService.java.ejs +++ b/generators/server/templates/src/main/java/package/service/UserService.java.ejs @@ -313,12 +313,18 @@ public class UserService { newUser.setActivated(false); // new user gets registration key newUser.setActivationKey(RandomUtil.generateActivationKey()); - Set authorities = new HashSet<>(); + Set<<% if (databaseType === 'couchbase') { %>String<% } else { %>Authority<% } %>> authorities = new HashSet<>(); + <%_ if (databaseType === 'couchbase') { _%> + authorities.add(AuthoritiesConstants.USER); + newUser.setAuthorities(authorities); + return createUser(newUser) + <%_ } else { _%> return authorityRepository.findById(AuthoritiesConstants.USER) .map(authorities::add) .thenReturn(newUser) .doOnNext(user -> user.setAuthorities(authorities)) .flatMap(this::createUser) + <%_ } _%> <%_ if (cacheManagerIsAvailable === true) { _%> .doOnNext(this::clearUserCaches) <%_ } _%> @@ -384,6 +390,9 @@ public class UserService { <%_ } else { _%> return Flux.fromIterable(Optional.ofNullable(userDTO.getAuthorities()).orElse(new HashSet<>())) .flatMap(authorityRepository::findById) + <%_ if (databaseType === 'couchbase') { _%> + .map(Authority::getName) + <%_ } _%> .doOnNext(authority -> user.getAuthorities().add(authority)) .then(createUser(user)) <%_ if (cacheManagerIsAvailable === true) { _%> @@ -500,10 +509,14 @@ public class UserService { return user; }) <%_ } else { _%> + <%_ if (databaseType === 'couchbase') { _%> + return Mono.just(user); + <%_ } else { _%> return Flux.fromIterable(userDTO.getAuthorities()) .flatMap(authorityRepository::findById) .map(managedAuthorities::add) .then(Mono.just(user)); + <%_ } _%> }) .flatMap(this::updateUser) <%_ if (cacheManagerIsAvailable === true) { _%> diff --git a/travis/samples/reactive-couchbase/.yo-rc.json b/travis/samples/reactive-couchbase/.yo-rc.json new file mode 100644 index 000000000000..37289afc1ce0 --- /dev/null +++ b/travis/samples/reactive-couchbase/.yo-rc.json @@ -0,0 +1,28 @@ +{ + "generator-jhipster": { + "reactive": true, + "applicationType": "monolith", + "baseName": "travisCBReactive", + "packageName": "com.mycompany.myapp", + "packageFolder": "com/mycompany/myapp", + "serverPort": "8080", + "authenticationType": "jwt", + "cacheProvider": "no", + "enableHibernateCache": false, + "websocket": false, + "databaseType": "couchbase", + "devDatabaseType": "couchbase", + "prodDatabaseType": "couchbase", + "searchEngine": false, + "messageBroker": false, + "serviceDiscoveryType": false, + "buildTool": "maven", + "enableSwaggerCodegen": false, + "jwtSecretKey": "MTI3OWJlNDY4MmU3M2FjMGZmMDYzYjE2ZDM3YjY3YTU4OWFjYzcxZWI0NTU4MDhlMzEzNDg5MWVhYWFiMjg3ZWJkODcwYTkwZDhiNTlhZDQ3MmVhYWJkYzA4NjIxYzcxZWMzNTkzNzhjNmRhOWY1M2ExYzVlYzJhNGQwYmQzOTc=", + "enableTranslation": false, + "testFrameworks": [], + "jhiPrefix": "jhi", + "clientPackageManager": "yarn", + "skipClient": true + } +} From 4a83525f68efa61dd038c3f3cd61c0b7bb190d69 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 31 Dec 2018 13:38:11 +0100 Subject: [PATCH 088/444] Keep the JMX autoconfiguration working --- .../templates/src/main/java/package/Application.java.ejs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generators/server/templates/src/main/java/package/Application.java.ejs b/generators/server/templates/src/main/java/package/Application.java.ejs index ae0653769c0a..d8e20fc2d002 100644 --- a/generators/server/templates/src/main/java/package/Application.java.ejs +++ b/generators/server/templates/src/main/java/package/Application.java.ejs @@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; <%_ if (databaseType === 'sql') { _%> import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties; <%_ } _%> @@ -59,7 +58,7 @@ import java.util.Collection; excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = OAuth2InterceptedFeignConfiguration.class) ) <%_ } _%> -@SpringBootApplication(exclude = JmxAutoConfiguration.class) +@SpringBootApplication @EnableConfigurationProperties({<% if (databaseType === 'sql') { %>LiquibaseProperties.class, <% } %>ApplicationProperties.class}) <%_ if (serviceDiscoveryType) { _%> @EnableDiscoveryClient From 4d65a6000a2a1847989bdd316bd7795af9f20f6d Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 31 Dec 2018 14:21:28 +0100 Subject: [PATCH 089/444] Fix eslint tests --- generators/generator-base-private.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/generators/generator-base-private.js b/generators/generator-base-private.js index debc864eb635..c69fa855d98d 100644 --- a/generators/generator-base-private.js +++ b/generators/generator-base-private.js @@ -812,10 +812,11 @@ module.exports = class extends Generator { this.warning('Java is not found on your computer.'); } else { const javaVersion = stderr.match(/(?:java|openjdk) version "(.*)"/)[1]; - if (!javaVersion.match(new RegExp('11'.replace('.', '\\.'))) && !javaVersion.match(new RegExp(constants.JAVA_VERSION.replace('.', '\\.')))) { - this.warning( - `Java 8 or Java 11 are not found on your computer. Your Java version is: ${chalk.yellow(javaVersion)}` - ); + if ( + !javaVersion.match(new RegExp('11'.replace('.', '\\.'))) && + !javaVersion.match(new RegExp(constants.JAVA_VERSION.replace('.', '\\.'))) + ) { + this.warning(`Java 8 or Java 11 are not found on your computer. Your Java version is: ${chalk.yellow(javaVersion)}`); } } done(); From 9c13694e2e756791e1d20e2626e0b1fe295d74e3 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 31 Dec 2018 15:06:19 +0100 Subject: [PATCH 090/444] Add JVM options to improve startup time See #8954 --- generators/server/templates/src/main/docker/entrypoint.sh.ejs | 2 +- generators/server/templates/src/main/jib/entrypoint.sh.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/src/main/docker/entrypoint.sh.ejs b/generators/server/templates/src/main/docker/entrypoint.sh.ejs index ccffafb5a499..b49252e7a3a4 100644 --- a/generators/server/templates/src/main/docker/entrypoint.sh.ejs +++ b/generators/server/templates/src/main/docker/entrypoint.sh.ejs @@ -1,4 +1,4 @@ #!/bin/sh echo "The application will start in ${JHIPSTER_SLEEP}s..." && sleep ${JHIPSTER_SLEEP} -exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar "${HOME}/app.war" "$@" +exec java ${JAVA_OPTS} -noverify -XX:+AlwaysPreTouch -Djava.security.egd=file:/dev/./urandom -jar "${HOME}/app.war" "$@" diff --git a/generators/server/templates/src/main/jib/entrypoint.sh.ejs b/generators/server/templates/src/main/jib/entrypoint.sh.ejs index 6543a19760cc..1126c13f874e 100644 --- a/generators/server/templates/src/main/jib/entrypoint.sh.ejs +++ b/generators/server/templates/src/main/jib/entrypoint.sh.ejs @@ -1,4 +1,4 @@ #!/bin/sh echo "The application will start in ${JHIPSTER_SLEEP}s..." && sleep ${JHIPSTER_SLEEP} -exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp /app/resources/:/app/classes/:/app/libs/* "<%= packageName %>.<%= mainClass %>" "$@" +exec java ${JAVA_OPTS} -noverify -XX:+AlwaysPreTouch -Djava.security.egd=file:/dev/./urandom -cp /app/resources/:/app/classes/:/app/libs/* "<%= packageName %>.<%= mainClass %>" "$@" From 99513878893c9729e575ba8ff00f8020a6ce46aa Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 2 Jan 2019 16:05:56 +0100 Subject: [PATCH 091/444] Migrate Cassandra tests to TestContainers, to support JDK 11 --- generators/cleanup.js | 5 + generators/server/files.js | 5 - generators/server/templates/build.gradle.ejs | 1 + generators/server/templates/pom.xml.ejs | 5 + .../package/AbstractCassandraTest.java.ejs | 47 +- .../CassandraKeyspaceUnitTest.java.ejs | 9 +- .../CassandraTestConfiguration.java.ejs | 25 +- .../resources/cassandra-random-port.yml.ejs | 620 ------------------ 8 files changed, 53 insertions(+), 664 deletions(-) delete mode 100644 generators/server/templates/src/test/resources/cassandra-random-port.yml.ejs diff --git a/generators/cleanup.js b/generators/cleanup.js index 55dfb93e6448..8d08f3b4653b 100644 --- a/generators/cleanup.js +++ b/generators/cleanup.js @@ -164,4 +164,9 @@ function cleanupOldServerFiles(generator, javaDir, testDir, mainResourceDir, tes generator.removeFile(`${constants.DOCKER_DIR}keycloak.yml`); } } + if (generator.isJhipsterVersionLessThan('5.8.0')) { + if (generator.databaseType === 'cassandra') { + generator.removeFile(`${testResourceDir}cassandra-random-port.yml`); + } + } } diff --git a/generators/server/files.js b/generators/server/files.js index 4e3c940b13e7..7e88dd12cde6 100644 --- a/generators/server/files.js +++ b/generators/server/files.js @@ -1168,11 +1168,6 @@ const serverFiles = { } ] }, - { - condition: generator => generator.databaseType === 'cassandra', - path: SERVER_TEST_RES_DIR, - templates: ['cassandra-random-port.yml'] - }, { condition: generator => generator.databaseType === 'couchbase', path: SERVER_TEST_SRC_DIR, diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 096d7da5bf92..4ab6c67f2f52 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -462,6 +462,7 @@ dependencies { testCompile ("org.cassandraunit:cassandra-unit-spring") { exclude(group: 'org.slf4j') } + testCompile "org.testcontainers:database-commons" <%_ } _%> <%_ if (cucumberTests) { _%> testCompile "io.cucumber:cucumber-junit" diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 9275da35cb0b..aa8eb4543360 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -459,6 +459,11 @@ cassandra-unit-spring test + + org.testcontainers + database-commons + test + <%_ } _%> <%_ if (cacheProvider === 'ehcache') { _%> diff --git a/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs b/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs index 43e5e5ed95bc..07b9cd68b644 100644 --- a/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs +++ b/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs @@ -18,17 +18,18 @@ -%> package <%=packageName%>; -import io.github.jhipster.config.JHipsterConstants; - import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; +import io.github.jhipster.config.JHipsterConstants; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.thrift.transport.TTransportException; import org.cassandraunit.CQLDataLoader; import org.cassandraunit.dataset.cql.ClassPathCQLDataSet; -import org.cassandraunit.utils.EmbeddedCassandraServerHelper; import org.junit.BeforeClass; import org.springframework.test.context.ActiveProfiles; +import org.testcontainers.containers.BindMode; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; import java.io.IOException; import java.net.URISyntaxException; @@ -37,6 +38,7 @@ import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -48,26 +50,45 @@ import java.util.List; public class AbstractCassandraTest { public static final String CASSANDRA_UNIT_KEYSPACE = "cassandra_unit_keyspace"; - private static final String CASSANDRA_UNIT_RANDOM_PORT_YAML = "cassandra-random-port.yml"; - private static final long CASSANDRA_TIMEOUT = 30000L; + public static GenericContainer CASSANDRA_CONTAINER = null; + public static final int CASSANDRA_TEST_PORT = 9042; private static boolean started = false; @BeforeClass - public static void startServer() throws TTransportException, ConfigurationException, IOException, URISyntaxException { - if (! started) { - EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_UNIT_RANDOM_PORT_YAML, CASSANDRA_TIMEOUT); - Cluster cluster = EmbeddedCassandraServerHelper.getCluster(); + public static void startServer() throws TTransportException, ConfigurationException, IOException, URISyntaxException { + if (!started) { + startTestcontainer(); + Cluster cluster = new Cluster.Builder() + .addContactPoint("127.0.0.1") + .withPort(CASSANDRA_CONTAINER.getMappedPort(CASSANDRA_TEST_PORT)) + .withoutMetrics() + .withoutJMXReporting() + .build(); + Session session = cluster.connect(); - String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}"; - session.execute(createQuery); - String useKeyspaceQuery = "USE " + CASSANDRA_UNIT_KEYSPACE; - session.execute(useKeyspaceQuery); + createTestKeyspace(session); CQLDataLoader dataLoader = new CQLDataLoader(session); applyScripts(dataLoader, "config/cql/changelog/", "*.cql"); started = true; } } + private static void startTestcontainer() throws TTransportException, IOException { + CASSANDRA_CONTAINER = + new GenericContainer("<%= DOCKER_CASSANDRA %>") + .waitingFor(Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(30))) + .withExposedPorts(CASSANDRA_TEST_PORT); + + CASSANDRA_CONTAINER.start(); + } + + private static void createTestKeyspace(Session session) { + String createQuery = "CREATE KEYSPACE " + CASSANDRA_UNIT_KEYSPACE + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}"; + session.execute(createQuery); + String useKeyspaceQuery = "USE " + CASSANDRA_UNIT_KEYSPACE; + session.execute(useKeyspaceQuery); + } + private static void applyScripts(CQLDataLoader dataLoader, String cqlDir, String pattern) throws IOException, URISyntaxException { URL dirUrl = ClassLoader.getSystemResource(cqlDir); if (dirUrl == null) { // protect for empty directory diff --git a/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs b/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs index fb2613af47b8..27e9190c5130 100644 --- a/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs +++ b/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs @@ -18,12 +18,11 @@ -%> package <%=packageName%>; -import com.datastax.driver.core.*; - +import com.datastax.driver.core.Metadata; +import com.datastax.driver.core.Session; +import com.mycompany.myapp.config.AbstractCassandraTest; import org.junit.Test; import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -34,8 +33,6 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(classes = <%= mainClass %>.class) public class CassandraKeyspaceUnitTest extends AbstractCassandraTest { - protected final Logger log = LoggerFactory.getLogger(this.getClass().getCanonicalName()); - @Autowired private Session session; diff --git a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs b/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs index 5fb0b56b1c5b..a439a33d1f9a 100644 --- a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs +++ b/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs @@ -22,9 +22,7 @@ import <%=packageName%>.config.cassandra.CassandraConfiguration; import io.github.jhipster.config.JHipsterConstants; -import org.apache.cassandra.config.DatabaseDescriptor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.mycompany.myapp.config.cassandra.CassandraConfiguration; import org.springframework.boot.autoconfigure.cassandra.CassandraProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @@ -33,26 +31,13 @@ import org.springframework.context.annotation.Profile; @Profile(JHipsterConstants.SPRING_PROFILE_TEST) public class CassandraTestConfiguration extends CassandraConfiguration { - private final Logger log = LoggerFactory.getLogger(CassandraTestConfiguration.class); - /** - * Override how to get the port to connect to the Cassandra cluster - * When deployed, the port is read by properties - * For the tests we need to read the port dynamically to discover on which random port Cassandra-unit has started the - * embedded cluster - * @param properties - * @return + * Override how to get the port to connect to the Cassandra cluster. + *

+ * This uses the TestContainers API to get the mapped port in Docker. */ @Override protected int getPort(CassandraProperties properties) { - int port = properties.getPort(); - if (port == 0) { - // random port for the tests - int randomPort = DatabaseDescriptor.getNativeTransportPort(); - log.info("Starting the cassandra cluster connection to a random port for the tests: {}", randomPort); - return randomPort; - } else { - return port; - } + return AbstractCassandraTest.CASSANDRA_CONTAINER.getMappedPort(AbstractCassandraTest.CASSANDRA_TEST_PORT); } } diff --git a/generators/server/templates/src/test/resources/cassandra-random-port.yml.ejs b/generators/server/templates/src/test/resources/cassandra-random-port.yml.ejs deleted file mode 100644 index b09354864f65..000000000000 --- a/generators/server/templates/src/test/resources/cassandra-random-port.yml.ejs +++ /dev/null @@ -1,620 +0,0 @@ -<%# - Copyright 2013-2018 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. --%> -# Cassandra storage config YAML - -# NOTE: -# See http://wiki.apache.org/cassandra/StorageConfiguration for -# full explanations of configuration directives -# /NOTE - -# The name of the cluster. This is mainly used to prevent machines in -# one logical cluster from joining another. -cluster_name: 'Test Cluster' - -# You should always specify InitialToken when setting up a production -# cluster for the first time, and often when adding capacity later. -# The principle is that each node should be given an equal slice of -# the token ring; see http://wiki.apache.org/cassandra/Operations -# for more details. -# -# If blank, Cassandra will request a token bisecting the range of -# the heaviest-loaded existing node. If there is no load information -# available, such as is the case with a new cluster, it will pick -# a random token, which will lead to hot spots. -#initial_token: - -# See http://wiki.apache.org/cassandra/HintedHandoff -hinted_handoff_enabled: true -# this defines the maximum amount of time a dead host will have hints -# generated. After it has been dead this long, new hints for it will not be -# created until it has been seen alive and gone down again. -max_hint_window_in_ms: 10800000 # 3 hours -# Maximum throttle in KBs per second, per delivery thread. This will be -# reduced proportionally to the number of nodes in the cluster. (If there -# are two nodes in the cluster, each delivery thread will use the maximum -# rate; if there are three, each will throttle to half of the maximum, -# since we expect two nodes to be delivering hints simultaneously.) -hinted_handoff_throttle_in_kb: 1024 -# Number of threads with which to deliver hints; -# Consider increasing this number when you have multi-dc deployments, since -# cross-dc handoff tends to be slower -max_hints_delivery_threads: 2 - -hints_directory: <%= BUILD_DIR %>embeddedCassandra/hints - -# The following setting populates the page cache on memtable flush and compaction -# WARNING: Enable this setting only when the whole node's data fits in memory. -# Defaults to: false -# populate_io_cache_on_flush: false - -# Authentication backend, implementing IAuthenticator; used to identify users -# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator, -# PasswordAuthenticator}. -# -# - AllowAllAuthenticator performs no checks - set it to disable authentication. -# - PasswordAuthenticator relies on username/password pairs to authenticate -# users. It keeps usernames and hashed passwords in system_auth.credentials table. -# Please increase system_auth keyspace replication factor if you use this authenticator. -authenticator: AllowAllAuthenticator - -# Authorization backend, implementing IAuthorizer; used to limit access/provide permissions -# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer, -# CassandraAuthorizer}. -# -# - AllowAllAuthorizer allows any action to any user - set it to disable authorization. -# - CassandraAuthorizer stores permissions in system_auth.permissions table. Please -# increase system_auth keyspace replication factor if you use this authorizer. -authorizer: AllowAllAuthorizer - -# Validity period for permissions cache (fetching permissions can be an -# expensive operation depending on the authorizer, CassandraAuthorizer is -# one example). Defaults to 2000, set to 0 to disable. -# Will be disabled automatically for AllowAllAuthorizer. -permissions_validity_in_ms: 2000 - - -# The partitioner is responsible for distributing rows (by key) across -# nodes in the cluster. Any IPartitioner may be used, including your -# own as long as it is on the classpath. Out of the box, Cassandra -# provides org.apache.cassandra.dht.{Murmur3Partitioner, RandomPartitioner -# ByteOrderedPartitioner, OrderPreservingPartitioner (deprecated)}. -# -# - RandomPartitioner distributes rows across the cluster evenly by md5. -# This is the default prior to 1.2 and is retained for compatibility. -# - Murmur3Partitioner is similar to RandomPartioner but uses Murmur3_128 -# Hash Function instead of md5. When in doubt, this is the best option. -# - ByteOrderedPartitioner orders rows lexically by key bytes. BOP allows -# scanning rows in key order, but the ordering can generate hot spots -# for sequential insertion workloads. -# - OrderPreservingPartitioner is an obsolete form of BOP, that stores -# - keys in a less-efficient format and only works with keys that are -# UTF8-encoded Strings. -# - CollatingOPP collates according to EN,US rules rather than lexical byte -# ordering. Use this as an example if you need custom collation. -# -# See http://wiki.apache.org/cassandra/Operations for more on -# partitioners and token selection. -partitioner: org.apache.cassandra.dht.Murmur3Partitioner - -# directories where Cassandra should store data on disk. -data_file_directories: - - <%= BUILD_DIR %>embeddedCassandra/data - -# commit log -commitlog_directory: <%= BUILD_DIR %>embeddedCassandra/commitlog - -cdc_raw_directory: <%= BUILD_DIR %>embeddedCassandra/cdc - -# policy for data disk failures: -# stop: shut down gossip and Thrift, leaving the node effectively dead, but -# can still be inspected via JMX. -# best_effort: stop using the failed disk and respond to requests based on -# remaining available sstables. This means you WILL see obsolete -# data at CL.ONE! -# ignore: ignore fatal errors and let requests fail, as in pre-1.2 Cassandra -disk_failure_policy: stop - - -# Maximum size of the key cache in memory. -# -# Each key cache hit saves 1 seek and each row cache hit saves 2 seeks at the -# minimum, sometimes more. The key cache is fairly tiny for the amount of -# time it saves, so it's worthwhile to use it at large numbers. -# The row cache saves even more time, but must store the whole values of -# its rows, so it is extremely space-intensive. It's best to only use the -# row cache if you have hot rows or static rows. -# -# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. -# -# Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache. -key_cache_size_in_mb: - -# Duration in seconds after which Cassandra should -# safe the keys cache. Caches are saved to saved_caches_directory as -# specified in this configuration file. -# -# Saved caches greatly improve cold-start speeds, and is relatively cheap in -# terms of I/O for the key cache. Row cache saving is much more expensive and -# has limited use. -# -# Default is 14400 or 4 hours. -key_cache_save_period: 14400 - -# Number of keys from the key cache to save -# Disabled by default, meaning all keys are going to be saved -# key_cache_keys_to_save: 100 - -# Maximum size of the row cache in memory. -# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup. -# -# Default value is 0, to disable row caching. -row_cache_size_in_mb: 0 - -# Duration in seconds after which Cassandra should -# safe the row cache. Caches are saved to saved_caches_directory as specified -# in this configuration file. -# -# Saved caches greatly improve cold-start speeds, and is relatively cheap in -# terms of I/O for the key cache. Row cache saving is much more expensive and -# has limited use. -# -# Default is 0 to disable saving the row cache. -row_cache_save_period: 0 - -# Number of keys from the row cache to save -# Disabled by default, meaning all keys are going to be saved -# row_cache_keys_to_save: 100 - -# saved caches -saved_caches_directory: <%= BUILD_DIR %>embeddedCassandra/saved_caches - -# commitlog_sync may be either "periodic" or "batch." -# When in batch mode, Cassandra won't ack writes until the commit log -# has been fsynced to disk. It will wait up to -# commitlog_sync_batch_window_in_ms milliseconds for other writes, before -# performing the sync. -# -# commitlog_sync: batch -# commitlog_sync_batch_window_in_ms: 50 -# -# the other option is "periodic" where writes may be acked immediately -# and the CommitLog is simply synced every commitlog_sync_period_in_ms -# milliseconds. -commitlog_sync: periodic -commitlog_sync_period_in_ms: 10000 - -# The size of the individual commitlog file segments. A commitlog -# segment may be archived, deleted, or recycled once all the data -# in it (potentially from each columnfamily in the system) has been -# flushed to sstables. -# -# The default size is 32, which is almost always fine, but if you are -# archiving commitlog segments (see commitlog_archiving.properties), -# then you probably want a finer granularity of archiving; 8 or 16 MB -# is reasonable. -commitlog_segment_size_in_mb: 32 - -# any class that implements the SeedProvider interface and has a -# constructor that takes a Map of parameters will do. -seed_provider: - # Addresses of hosts that are deemed contact points. - # Cassandra nodes use this list of hosts to find each other and learn - # the topology of the ring. You must change this if you are running - # multiple nodes! - - class_name: org.apache.cassandra.locator.SimpleSeedProvider - parameters: - # seeds is actually a comma-delimited list of addresses. - # Ex: ",," - - seeds: "127.0.0.1" - - -# For workloads with more data than can fit in memory, Cassandra's -# bottleneck will be reads that need to fetch data from -# disk. "concurrent_reads" should be set to (16 * number_of_drives) in -# order to allow the operations to enqueue low enough in the stack -# that the OS and drives can reorder them. -# -# On the other hand, since writes are almost never IO bound, the ideal -# number of "concurrent_writes" is dependent on the number of cores in -# your system; (8 * number_of_cores) is a good rule of thumb. -concurrent_reads: 32 -concurrent_writes: 32 - -# Total memory to use for memtables. Cassandra will flush the largest -# memtable when this much memory is used. -# If omitted, Cassandra will set it to 1/3 of the heap. -# memtable_total_space_in_mb: 2048 - -# Total space to use for commitlogs. -# If space gets above this value (it will round up to the next nearest -# segment multiple), Cassandra will flush every dirty CF in the oldest -# segment and remove it. -# commitlog_total_space_in_mb: 4096 - -# This sets the amount of memtable flush writer threads. These will -# be blocked by disk io, and each one will hold a memtable in memory -# while blocked. If you have a large heap and many data directories, -# you can increase this value for better flush performance. -# By default this will be set to the amount of data directories defined. -#memtable_flush_writers: 1 - -# the number of full memtables to allow pending flush, that is, -# waiting for a writer thread. At a minimum, this should be set to -# the maximum number of secondary indexes created on a single CF. -#memtable_flush_queue_size: 4 - -# Whether to, when doing sequential writing, fsync() at intervals in -# order to force the operating system to flush the dirty -# buffers. Enable this to avoid sudden dirty buffer flushing from -# impacting read latencies. Almost always a good idea on SSD:s; not -# necessarily on platters. -trickle_fsync: false -trickle_fsync_interval_in_kb: 10240 - -# TCP port, for commands and data -storage_port: 0 - -# SSL port, for encrypted communication. Unused unless enabled in -# server_encryption_options -ssl_storage_port: 7011 - -# Address to bind to and tell other Cassandra nodes to connect to. You -# _must_ change this if you want multiple nodes to be able to -# communicate! -# -# Leaving it blank leaves it up to InetAddress.getLocalHost(). This -# will always do the Right Thing *if* the node is properly configured -# (hostname, name resolution, etc), and the Right Thing is to use the -# address associated with the hostname (it might not be). -# -# Setting this to 0.0.0.0 is always wrong. -listen_address: 127.0.0.1 - -start_native_transport: true -# port for the CQL native transport to listen for clients on -native_transport_port: 0 - -# Whether to start the thrift rpc server. -start_rpc: false - -# Address to broadcast to other Cassandra nodes -# Leaving this blank will set it to the same value as listen_address -# broadcast_address: 1.2.3.4 - -# The address to bind the Thrift RPC service to -- clients connect -# here. Unlike ListenAddress above, you *can* specify 0.0.0.0 here if -# you want Thrift to listen on all interfaces. -# -# Leaving this blank has the same effect it does for ListenAddress, -# (i.e. it will be based on the configured hostname of the node). -rpc_address: localhost -# port for Thrift to listen for clients on -rpc_port: 0 - -# enable or disable keepalive on rpc connections -rpc_keepalive: true - -# Cassandra provides three options for the RPC Server: -# -# sync -> One connection per thread in the rpc pool (see below). -# For a very large number of clients, memory will be your limiting -# factor; on a 64 bit JVM, 128KB is the minimum stack size per thread. -# Connection pooling is very, very strongly recommended. -# -# async -> Nonblocking server implementation with one thread to serve -# rpc connections. This is not recommended for high throughput use -# cases. Async has been tested to be about 50% slower than sync -# or hsha and is deprecated: it will be removed in the next major release. -# -# hsha -> Stands for "half synchronous, half asynchronous." The rpc thread pool -# (see below) is used to manage requests, but the threads are multiplexed -# across the different clients. -# -# The default is sync because on Windows hsha is about 30% slower. On Linux, -# sync/hsha performance is about the same, with hsha of course using less memory. -rpc_server_type: sync - -# Uncomment rpc_min|max|thread to set request pool size. -# You would primarily set max for the sync server to safeguard against -# misbehaved clients; if you do hit the max, Cassandra will block until one -# disconnects before accepting more. The defaults for sync are min of 16 and max -# unlimited. -# -# For the Hsha server, the min and max both default to quadruple the number of -# CPU cores. -# -# This configuration is ignored by the async server. -# -# rpc_min_threads: 16 -# rpc_max_threads: 2048 - -# uncomment to set socket buffer sizes on rpc connections -# rpc_send_buff_size_in_bytes: -# rpc_recv_buff_size_in_bytes: - -# Frame size for thrift (maximum field length). -# 0 disables TFramedTransport in favor of TSocket. This option -# is deprecated; we strongly recommend using Framed mode. -thrift_framed_transport_size_in_mb: 15 - -# The max length of a thrift message, including all fields and -# internal thrift overhead. -thrift_max_message_length_in_mb: 16 - -# Set to true to have Cassandra create a hard link to each sstable -# flushed or streamed locally in a backups/ subdirectory of the -# Keyspace data. Removing these links is the operator's -# responsibility. -incremental_backups: false - -# Whether or not to take a snapshot before each compaction. Be -# careful using this option, since Cassandra won't clean up the -# snapshots for you. Mostly useful if you're paranoid when there -# is a data format change. -snapshot_before_compaction: false - -# Whether or not a snapshot is taken of the data before keyspace truncation -# or dropping of column families. The STRONGLY advised default of true -# should be used to provide data safety. If you set this flag to false, you will -# lose data on truncation or drop. -auto_snapshot: false - -# Add column indexes to a row after its contents reach this size. -# Increase if your column values are large, or if you have a very large -# number of columns. The competing causes are, Cassandra has to -# deserialize this much of the row to read a single column, so you want -# it to be small - at least if you do many partial-row reads - but all -# the index data is read for each access, so you don't want to generate -# that wastefully either. -column_index_size_in_kb: 64 - -# Size limit for rows being compacted in memory. Larger rows will spill -# over to disk and use a slower two-pass compaction process. A message -# will be logged specifying the row key. -#in_memory_compaction_limit_in_mb: 64 - -# Number of simultaneous compactions to allow, NOT including -# validation "compactions" for anti-entropy repair. Simultaneous -# compactions can help preserve read performance in a mixed read/write -# workload, by mitigating the tendency of small sstables to accumulate -# during a single long running compactions. The default is usually -# fine and if you experience problems with compaction running too -# slowly or too fast, you should look at -# compaction_throughput_mb_per_sec first. -# -# This setting has no effect on LeveledCompactionStrategy. -# -# concurrent_compactors defaults to the number of cores. -# Uncomment to make compaction mono-threaded, the pre-0.8 default. -#concurrent_compactors: 1 - -# Multi-threaded compaction. When enabled, each compaction will use -# up to one thread per core, plus one thread per sstable being merged. -# This is usually only useful for SSD-based hardware: otherwise, -# your concern is usually to get compaction to do LESS i/o (see: -# compaction_throughput_mb_per_sec), not more. -#multithreaded_compaction: false - -# Throttles compaction to the given total throughput across the entire -# system. The faster you insert data, the faster you need to compact in -# order to keep the sstable count down, but in general, setting this to -# 16 to 32 times the rate you are inserting data is more than sufficient. -# Setting this to 0 disables throttling. Note that this account for all types -# of compaction, including validation compaction. -compaction_throughput_mb_per_sec: 16 - -# Track cached row keys during compaction, and re-cache their new -# positions in the compacted sstable. Disable if you use really large -# key caches. -#compaction_preheat_key_cache: true - -# Throttles all outbound streaming file transfers on this node to the -# given total throughput in Mbps. This is necessary because Cassandra does -# mostly sequential IO when streaming data during bootstrap or repair, which -# can lead to saturating the network connection and degrading rpc performance. -# When unset, the default is 200 Mbps or 25 MB/s. -# stream_throughput_outbound_megabits_per_sec: 200 - -# How long the coordinator should wait for read operations to complete -read_request_timeout_in_ms: 5000 -# How long the coordinator should wait for seq or index scans to complete -range_request_timeout_in_ms: 10000 -# How long the coordinator should wait for writes to complete -write_request_timeout_in_ms: 2000 -# How long a coordinator should continue to retry a CAS operation -# that contends with other proposals for the same row -cas_contention_timeout_in_ms: 1000 -# How long the coordinator should wait for truncates to complete -# (This can be much longer, because unless auto_snapshot is disabled -# we need to flush first so we can snapshot before removing the data.) -truncate_request_timeout_in_ms: 60000 -# The default timeout for other, miscellaneous operations -request_timeout_in_ms: 10000 - -# Enable operation timeout information exchange between nodes to accurately -# measure request timeouts. If disabled, replicas will assume that requests -# were forwarded to them instantly by the coordinator, which means that -# under overload conditions we will waste that much extra time processing -# already-timed-out requests. -# -# Warning: before enabling this property make sure to ntp is installed -# and the times are synchronized between the nodes. -cross_node_timeout: false - -# Enable socket timeout for streaming operation. -# When a timeout occurs during streaming, streaming is retried from the start -# of the current file. This _can_ involve re-streaming an important amount of -# data, so you should avoid setting the value too low. -# Default value is 0, which never timeout streams. -# streaming_socket_timeout_in_ms: 0 - -# phi value that must be reached for a host to be marked down. -# most users should never need to adjust this. -# phi_convict_threshold: 8 - -# endpoint_snitch -- Set this to a class that implements -# IEndpointSnitch. The snitch has two functions: -# - it teaches Cassandra enough about your network topology to route -# requests efficiently -# - it allows Cassandra to spread replicas around your cluster to avoid -# correlated failures. It does this by grouping machines into -# "datacenters" and "racks." Cassandra will do its best not to have -# more than one replica on the same "rack" (which may not actually -# be a physical location) -# -# IF YOU CHANGE THE SNITCH AFTER DATA IS INSERTED INTO THE CLUSTER, -# YOU MUST RUN A FULL REPAIR, SINCE THE SNITCH AFFECTS WHERE REPLICAS -# ARE PLACED. -# -# Out of the box, Cassandra provides -# - SimpleSnitch: -# Treats Strategy order as proximity. This improves cache locality -# when disabling read repair, which can further improve throughput. -# Only appropriate for single-datacenter deployments. -# - PropertyFileSnitch: -# Proximity is determined by rack and data center, which are -# explicitly configured in cassandra-topology.properties. -# - RackInferringSnitch: -# Proximity is determined by rack and data center, which are -# assumed to correspond to the 3rd and 2nd octet of each node's -# IP address, respectively. Unless this happens to match your -# deployment conventions (as it did Facebook's), this is best used -# as an example of writing a custom Snitch class. -# - Ec2Snitch: -# Appropriate for EC2 deployments in a single Region. Loads Region -# and Availability Zone information from the EC2 API. The Region is -# treated as the Datacenter, and the Availability Zone as the rack. -# Only private IPs are used, so this will not work across multiple -# Regions. -# - Ec2MultiRegionSnitch: -# Uses public IPs as broadcast_address to allow cross-region -# connectivity. (Thus, you should set seed addresses to the public -# IP as well.) You will need to open the storage_port or -# ssl_storage_port on the public IP firewall. (For intra-Region -# traffic, Cassandra will switch to the private IP after -# establishing a connection.) -# -# You can use a custom Snitch by setting this to the full class name -# of the snitch, which will be assumed to be on your classpath. -endpoint_snitch: SimpleSnitch - -# controls how often to perform the more expensive part of host score -# calculation -dynamic_snitch_update_interval_in_ms: 100 -# controls how often to reset all host scores, allowing a bad host to -# possibly recover -dynamic_snitch_reset_interval_in_ms: 600000 -# if set greater than zero and read_repair_chance is < 1.0, this will allow -# 'pinning' of replicas to hosts in order to increase cache capacity. -# The badness threshold will control how much worse the pinned host has to be -# before the dynamic snitch will prefer other replicas over it. This is -# expressed as a double which represents a percentage. Thus, a value of -# 0.2 means Cassandra would continue to prefer the static snitch values -# until the pinned host was 20% worse than the fastest. -dynamic_snitch_badness_threshold: 0.1 - -# request_scheduler -- Set this to a class that implements -# RequestScheduler, which will schedule incoming client requests -# according to the specific policy. This is useful for multi-tenancy -# with a single Cassandra cluster. -# NOTE: This is specifically for requests from the client and does -# not affect inter node communication. -# org.apache.cassandra.scheduler.NoScheduler - No scheduling takes place -# org.apache.cassandra.scheduler.RoundRobinScheduler - Round robin of -# client requests to a node with a separate queue for each -# request_scheduler_id. The scheduler is further customized by -# request_scheduler_options as described below. -request_scheduler: org.apache.cassandra.scheduler.NoScheduler - -# Scheduler Options vary based on the type of scheduler -# NoScheduler - Has no options -# RoundRobin -# - throttle_limit -- The throttle_limit is the number of in-flight -# requests per client. Requests beyond -# that limit are queued up until -# running requests can complete. -# The value of 80 here is twice the number of -# concurrent_reads + concurrent_writes. -# - default_weight -- default_weight is optional and allows for -# overriding the default which is 1. -# - weights -- Weights are optional and will default to 1 or the -# overridden default_weight. The weight translates into how -# many requests are handled during each turn of the -# RoundRobin, based on the scheduler id. -# -# request_scheduler_options: -# throttle_limit: 80 -# default_weight: 5 -# weights: -# Keyspace1: 1 -# Keyspace2: 5 - -# request_scheduler_id -- An identifer based on which to perform -# the request scheduling. Currently the only valid option is keyspace. -# request_scheduler_id: keyspace - -# Enable or disable inter-node encryption -# JVM defaults for supported SSL socket protocols and cipher suites can -# be replaced using custom encryption options. This is not recommended -# unless you have policies in place that dictate certain settings, or -# need to disable vulnerable ciphers or protocols in case the JVM cannot -# be updated. -# FIPS compliant settings can be configured at JVM level and should not -# involve changing encryption settings here: -# https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/FIPS.html -# *NOTE* No custom encryption options are enabled at the moment -# The available internode options are : all, none, dc, rack -# -# If set to dc cassandra will encrypt the traffic between the DCs -# If set to rack cassandra will encrypt the traffic between the racks -# -# The passwords used in these options must match the passwords used when generating -# the keystore and truststore. For instructions on generating these files, see: -# http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#CreateKeystore -# -server_encryption_options: - internode_encryption: none - keystore: conf/.keystore - keystore_password: cassandra - truststore: conf/.truststore - truststore_password: cassandra - # More advanced defaults below: - # protocol: TLS - # algorithm: SunX509 - # store_type: JKS - # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] - # require_client_auth: false - # require_endpoint_verification: false - -# enable or disable client/server encryption. -client_encryption_options: - enabled: false - # If enabled and optional is set to true encrypted and unencrypted connections are handled. - optional: false - keystore: conf/.keystore - keystore_password: cassandra - # require_client_auth: false - # Set trustore and truststore_password if require_client_auth is true - # truststore: conf/.truststore - # truststore_password: cassandra - # More advanced defaults below: - # protocol: TLS - # algorithm: SunX509 - # store_type: JKS - # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA] From 40201cf238aa79d8e2a17731fec6afe00643d919 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 2 Jan 2019 17:27:58 +0100 Subject: [PATCH 092/444] Fix compilation issue with Cassandra --- .../test/java/package/config/CassandraTestConfiguration.java.ejs | 1 - 1 file changed, 1 deletion(-) diff --git a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs b/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs index a439a33d1f9a..d826dc418d87 100644 --- a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs +++ b/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs @@ -22,7 +22,6 @@ import <%=packageName%>.config.cassandra.CassandraConfiguration; import io.github.jhipster.config.JHipsterConstants; -import com.mycompany.myapp.config.cassandra.CassandraConfiguration; import org.springframework.boot.autoconfigure.cassandra.CassandraProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; From 527f91803b3e22be3ba89130301d343561b8748c Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 2 Jan 2019 18:19:30 +0100 Subject: [PATCH 093/444] Upgrade to the latest MariaDB version --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 1d5a3d669b53..2d60b16e16e5 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -21,7 +21,7 @@ const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v4.0.6'; const DOCKER_JAVA_JRE = 'openjdk:8-jre-alpine'; const DOCKER_MYSQL = 'mysql:8.0.13'; -const DOCKER_MARIADB = 'mariadb:10.3.7'; +const DOCKER_MARIADB = 'mariadb:10.4.1'; const DOCKER_POSTGRESQL = 'postgres:11.1'; const DOCKER_MONGODB = 'mongo:4.0.4'; const DOCKER_COUCHBASE = 'couchbase/server:6.0.0'; From d4f44049201d8b54e412c86d3a382dc88838cbdb Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 2 Jan 2019 18:21:23 +0100 Subject: [PATCH 094/444] Upgrade the OpenJDK Docker base image to JDK 11 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 2d60b16e16e5..f79a174ef0a9 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -19,7 +19,7 @@ // version of docker images const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v4.0.6'; -const DOCKER_JAVA_JRE = 'openjdk:8-jre-alpine'; +const DOCKER_JAVA_JRE = 'openjdk:11.0.1-slim-stretch'; const DOCKER_MYSQL = 'mysql:8.0.13'; const DOCKER_MARIADB = 'mariadb:10.4.1'; const DOCKER_POSTGRESQL = 'postgres:11.1'; From d2201df655643610f71bcc418c6c65259d8472ac Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 2 Jan 2019 18:35:18 +0100 Subject: [PATCH 095/444] Fix compilation issue with Cassandra --- .../src/test/java/package/AbstractCassandraTest.java.ejs | 3 ++- .../src/test/java/package/CassandraKeyspaceUnitTest.java.ejs | 1 - .../java/package/config/CassandraTestConfiguration.java.ejs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs b/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs index 07b9cd68b644..cea83c345285 100644 --- a/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs +++ b/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs @@ -18,9 +18,10 @@ -%> package <%=packageName%>; +import io.github.jhipster.config.JHipsterConstants; + import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; -import io.github.jhipster.config.JHipsterConstants; import org.apache.cassandra.exceptions.ConfigurationException; import org.apache.thrift.transport.TTransportException; import org.cassandraunit.CQLDataLoader; diff --git a/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs b/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs index 27e9190c5130..262c5b90f28b 100644 --- a/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs +++ b/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs @@ -20,7 +20,6 @@ package <%=packageName%>; import com.datastax.driver.core.Metadata; import com.datastax.driver.core.Session; -import com.mycompany.myapp.config.AbstractCassandraTest; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs b/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs index d826dc418d87..b452f5779b6c 100644 --- a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs +++ b/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs @@ -18,6 +18,7 @@ -%> package <%=packageName%>.config; +import <%=packageName%>.AbstractCassandraTest; import <%=packageName%>.config.cassandra.CassandraConfiguration; import io.github.jhipster.config.JHipsterConstants; From 24446511ca953a7eaced864e0f40658dd4b9bd28 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Wed, 2 Jan 2019 21:47:45 +0100 Subject: [PATCH 096/444] Update license for 2019 --- .../config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs b/generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs index 7857de20fef0..bde22130278e 100644 --- a/generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs +++ b/generators/server/templates/src/main/java/package/config/lazy/LazyInitBeanFactoryPostProcessor.java.ejs @@ -1,5 +1,5 @@ <%# - Copyright 2013-2018 the original author or authors from the JHipster project. + 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. From 599aeecafc579dcef848000934e31a8bafbcc74d Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 3 Jan 2019 18:20:48 +0100 Subject: [PATCH 097/444] Revert "Upgrade cassandra server version to 3.11.3" This reverts commit 1c64496ba00c87e472852de09fdb41ce055bc9a5. --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 822b74bd4388..428a5c313fbf 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -25,7 +25,7 @@ const DOCKER_MARIADB = 'mariadb:10.4.1'; const DOCKER_POSTGRESQL = 'postgres:11.1'; const DOCKER_MONGODB = 'mongo:4.0.4'; const DOCKER_COUCHBASE = 'couchbase/server:6.0.0'; -const DOCKER_CASSANDRA = 'cassandra:3.11.3'; +const DOCKER_CASSANDRA = 'cassandra:3.9'; const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest'; const DOCKER_ORACLE = 'sath89/oracle-12c:latest'; const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.11'; From 26f08f63676d235db8a891c9628d7783047eec8e Mon Sep 17 00:00:00 2001 From: clunven Date: Fri, 4 Jan 2019 13:14:37 +0100 Subject: [PATCH 098/444] Fixing bug #8944 - Allowing extra migrations steps on extra folder --- .../src/main/docker/cassandra/scripts/autoMigrate.sh.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/docker/cassandra/scripts/autoMigrate.sh.ejs b/generators/server/templates/src/main/docker/cassandra/scripts/autoMigrate.sh.ejs index fed914bbec34..a2b23b55770b 100644 --- a/generators/server/templates/src/main/docker/cassandra/scripts/autoMigrate.sh.ejs +++ b/generators/server/templates/src/main/docker/cassandra/scripts/autoMigrate.sh.ejs @@ -69,7 +69,7 @@ if [ "$#" -gt 0 ]; then fi CREATE_KEYSPACE_SCRIPT_FOLDER="$(dirname $CQL_FILES_PATH)" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - EXECUTE_CQL_SCRIPT=$SCRIPT_DIR'/execute-cql.sh' + EXECUTE_CQL_SCRIPT=$SCRIPT_DIR'/execute-cql' else CQL_FILES_PATH="/cql/changelog/" EXECUTE_CQL_SCRIPT="./usr/local/bin/execute-cql" From 608a362d1fbcb61bf3a4c537a67bcc00c9fb68d0 Mon Sep 17 00:00:00 2001 From: Jonathan Ruddell Date: Fri, 4 Jan 2019 10:44:28 -0800 Subject: [PATCH 099/444] add elasticsearch field annotation on ID Fix #8739 --- .../src/main/java/package/domain/Entity.java.ejs | 11 ++++++----- .../src/main/java/package/domain/User.java.ejs | 9 +++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs index 5e5f6d313c25..a0983910c53c 100644 --- a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs @@ -58,8 +58,8 @@ import javax.persistence.*; import javax.validation.constraints.*; <%_ } _%> -<%_ if (searchEngine === 'elasticsearch' && databaseType !== 'mongodb') { _%> -import org.springframework.data.elasticsearch.annotations.Document; +<%_ if (searchEngine === 'elasticsearch') { _%> +import org.springframework.data.elasticsearch.annotations.FieldType; <%_ } _%> import java.io.Serializable; <%_ if (fieldsContainBigDecimal === true) { _%> @@ -114,10 +114,8 @@ import static org.springframework.data.couchbase.core.mapping.id.GenerationStrat @Document <%_ } if (databaseType === 'cassandra') { _%> @Table("<%= entityInstance %>") -<%_ } if (searchEngine === 'elasticsearch' && databaseType === 'mongodb') { _%> +<%_ } if (searchEngine === 'elasticsearch') { _%> @org.springframework.data.elasticsearch.annotations.Document(indexName = "<%= entityInstance.toLowerCase() %>") -<%_ } if (searchEngine === 'elasticsearch' && databaseType !== 'mongodb') { _%> -@Document(indexName = "<%= entityInstance.toLowerCase() %>") <%_ } _%> public class <%= entityClass %> implements Serializable { @@ -142,6 +140,9 @@ public class <%= entityClass %> implements Serializable { <%_ if (databaseType === 'couchbase') { _%> @GeneratedValue(strategy = UNIQUE, delimiter = ID_DELIMITER) <%_ } _%> + <%_ if (searchEngine === 'elasticsearch') { _%> + @org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword) + <%_ } _%> private <%= pkType %> id; <%_ for (idx in fields) { diff --git a/generators/server/templates/src/main/java/package/domain/User.java.ejs b/generators/server/templates/src/main/java/package/domain/User.java.ejs index 6cea285c39a9..048a95b84999 100644 --- a/generators/server/templates/src/main/java/package/domain/User.java.ejs +++ b/generators/server/templates/src/main/java/package/domain/User.java.ejs @@ -40,6 +40,9 @@ import org.springframework.data.couchbase.core.mapping.id.GeneratedValue; import org.springframework.data.couchbase.core.mapping.id.IdAttribute; import org.springframework.data.couchbase.core.mapping.id.IdPrefix; <%_ } _%> +<%_ if (searchEngine === 'elasticsearch') { _%> +import org.springframework.data.elasticsearch.annotations.FieldType; +<%_ } _%> <%_ if (databaseType === 'sql') { _%> import javax.persistence.*; @@ -84,6 +87,9 @@ public class User<% if (databaseType === 'sql' || databaseType === 'mongodb' || @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") @SequenceGenerator(name = "sequenceGenerator") <%_ } _%> + <%_ if (searchEngine === 'elasticsearch') { _%> + @org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword) + <%_ } _%> private <% if (authenticationType === 'oauth2') { %>String<% } else { %>Long<% } %> id;<% } else { %><% if (databaseType === 'couchbase') { %> public static final String PREFIX = "user"; @@ -94,6 +100,9 @@ public class User<% if (databaseType === 'sql' || databaseType === 'mongodb' || @Id<% } %><% if (databaseType === 'couchbase') { %> @GeneratedValue(strategy = USE_ATTRIBUTES, delimiter = ID_DELIMITER)<% } %><% if (databaseType === 'cassandra') { %> @PartitionKey<% } %> + <%_ if (searchEngine === 'elasticsearch') { _%> + @org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword) + <%_ } _%> private String id;<% } %> @NotNull From ae11cb0b87afabcd4233ae54acd73e0471f93c4a Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 7 Jan 2019 11:30:43 +0100 Subject: [PATCH 100/444] Disable Hibernate statistics by default as we don't use them at the moment --- .../templates/src/main/resources/config/application-dev.yml.ejs | 2 +- .../src/main/resources/config/application-prod.yml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 729e37858952..7e467fde80d0 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 @@ -163,7 +163,7 @@ spring: hibernate.connection.provider_disables_autocommit: true hibernate.cache.use_second_level_cache: <% if (enableHibernateCache) { %>true<% } else { %>false<% } %> hibernate.cache.use_query_cache: false - hibernate.generate_statistics: true + hibernate.generate_statistics: false <%_ if (enableHibernateCache) { _%> <%_ if (cacheProvider === 'hazelcast') { _%> hibernate.cache.region.factory_class: com.hazelcast.hibernate.HazelcastCacheRegionFactory 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 36d36da95671..d98a3aac7a3b 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 @@ -135,7 +135,7 @@ spring: hibernate.connection.provider_disables_autocommit: true hibernate.cache.use_second_level_cache: <% if (enableHibernateCache) { %>true<% } else { %>false<% } %> hibernate.cache.use_query_cache: false - hibernate.generate_statistics: true + hibernate.generate_statistics: false <%_ if (enableHibernateCache) { _%> <%_ if (cacheProvider === 'hazelcast') { _%> hibernate.cache.region.factory_class: com.hazelcast.hibernate.HazelcastCacheRegionFactory From eed7b61e48abce08d2f80242e8e1dd1e07eb9fd4 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Mon, 7 Jan 2019 11:31:11 +0100 Subject: [PATCH 101/444] Test using JDK 11 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9374b1510f03..0b21d4a08846 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ language: node_js node_js: - "10.14.1" jdk: - - oraclejdk8 + - openjdk11 addons: apt: sources: From 0ae7715a72b2b6329b32d6d0f97b430b56c96ab6 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Tue, 8 Jan 2019 08:08:15 +0100 Subject: [PATCH 102/444] Sonar: no use of jq --- test-integration/scripts/25-sonar-analyze.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-integration/scripts/25-sonar-analyze.sh b/test-integration/scripts/25-sonar-analyze.sh index d764911e6c29..888457fd1a91 100755 --- a/test-integration/scripts/25-sonar-analyze.sh +++ b/test-integration/scripts/25-sonar-analyze.sh @@ -22,7 +22,7 @@ elif [[ $JHI_SONAR = 1 ]]; then sleep 30 docker-compose -f src/main/docker/sonar.yml logs echo "*** Sonar results:" - curl 'http://localhost:9001/api/measures/component?componentKey=JHipsterSonar&metricKeys=bugs%2Ccoverage%2Cvulnerabilities%2Cduplicated_lines_density%2Ccode_smells' | jq + curl 'http://localhost:9001/api/measures/component?componentKey=JHipsterSonar&metricKeys=bugs%2Ccoverage%2Cvulnerabilities%2Cduplicated_lines_density%2Ccode_smells' else echo "*** No sonar analyze" From 6fa36ac5f9cd1c66aa62dc00d6c1d455d77535e7 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 8 Jan 2019 11:56:12 +0100 Subject: [PATCH 103/444] formatting --- .../src/main/java/package/config/JacksonConfiguration.java.ejs | 2 -- 1 file changed, 2 deletions(-) diff --git a/generators/server/templates/src/main/java/package/config/JacksonConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/JacksonConfiguration.java.ejs index a84fcf03a4db..94aa2bd004d1 100644 --- a/generators/server/templates/src/main/java/package/config/JacksonConfiguration.java.ejs +++ b/generators/server/templates/src/main/java/package/config/JacksonConfiguration.java.ejs @@ -46,7 +46,6 @@ public class JacksonConfiguration { public Jdk8Module jdk8TimeModule() { return new Jdk8Module(); } - <%_ if (databaseType === 'sql') { _%> /* @@ -81,5 +80,4 @@ public class JacksonConfiguration { ConstraintViolationProblemModule constraintViolationProblemModule() { return new ConstraintViolationProblemModule(); } - } From 8f21fb6513a1f25298648647827bb9486e86cfad Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 8 Jan 2019 11:57:36 +0100 Subject: [PATCH 104/444] formatting --- .../src/main/java/package/config/WebConfigurer.java.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs b/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs index 0e00cc676486..92773f7d9559 100644 --- a/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs +++ b/generators/server/templates/src/main/java/package/config/WebConfigurer.java.ejs @@ -72,8 +72,8 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Paths; <%_ } _%> import java.util.*; - <%_ if (!skipClient) { _%> + import static java.net.URLDecoder.decode; <%_ } _%> From 1973fc6410508634c0f164588204fda113385577 Mon Sep 17 00:00:00 2001 From: Patrice Blanchardie Date: Tue, 8 Jan 2019 12:43:17 +0100 Subject: [PATCH 105/444] rewrite Entity equals and hashCode accept subclasses as parameter to equals to avoid problems with proxies, and provide consistent hashCode with database generated identifiers fix #8656 --- .../src/main/java/package/domain/Entity.java.ejs | 10 +++------- .../main/java/package/domain/Authority.java.ejs | 10 ++++------ .../package/domain/PersistentAuditEvent.java.ejs | 8 +++----- .../java/package/domain/PersistentToken.java.ejs | 14 ++++---------- .../src/main/java/package/domain/User.java.ejs | 8 +++----- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs index 324853772406..707c8c0712ca 100644 --- a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs @@ -440,19 +440,15 @@ public class <%= asEntity(entityClass) %> implements Serializable { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof <%= asEntity(entityClass) %>)) { return false; } - <%= asEntity(entityClass) %> <%= entityInstance %> = (<%= asEntity(entityClass) %>) o; - if (<%= entityInstance %>.getId() == null || getId() == null) { - return false; - } - return Objects.equals(getId(), <%= entityInstance %>.getId()); + return id != null && id.equals(((<%= asEntity(entityClass) %>) o).id); } @Override public int hashCode() { - return Objects.hashCode(getId()); + return 31; } @Override diff --git a/generators/server/templates/src/main/java/package/domain/Authority.java.ejs b/generators/server/templates/src/main/java/package/domain/Authority.java.ejs index 16eb24e5caf3..fa96aee3c248 100644 --- a/generators/server/templates/src/main/java/package/domain/Authority.java.ejs +++ b/generators/server/templates/src/main/java/package/domain/Authority.java.ejs @@ -35,6 +35,7 @@ import javax.persistence.Column; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.io.Serializable; +import java.util.Objects; /** * An authority (a security role) used by Spring Security. @@ -79,18 +80,15 @@ public class Authority implements Serializable { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof Authority)) { return false; } - - Authority authority = (Authority) o; - - return !(name != null ? !name.equals(authority.name) : authority.name != null); + return Objects.equals(name, ((Authority) o).name); } @Override public int hashCode() { - return name != null ? name.hashCode() : 0; + return Objects.hashCode(name); } @Override diff --git a/generators/server/templates/src/main/java/package/domain/PersistentAuditEvent.java.ejs b/generators/server/templates/src/main/java/package/domain/PersistentAuditEvent.java.ejs index 180a021b2b77..fea85b8106f4 100644 --- a/generators/server/templates/src/main/java/package/domain/PersistentAuditEvent.java.ejs +++ b/generators/server/templates/src/main/java/package/domain/PersistentAuditEvent.java.ejs @@ -149,17 +149,15 @@ public class PersistentAuditEvent implements Serializable { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof PersistentAuditEvent)) { return false; } - - PersistentAuditEvent persistentAuditEvent = (PersistentAuditEvent) o; - return !(persistentAuditEvent.getId() == null || getId() == null) && Objects.equals(getId(), persistentAuditEvent.getId()); + return id != null && id.equals(((PersistentAuditEvent) o).id); } @Override public int hashCode() { - return Objects.hashCode(getId()); + return 31; } @Override diff --git a/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs b/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs index 325581955430..4f02bf9512d2 100644 --- a/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs +++ b/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs @@ -46,6 +46,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.io.Serializable; +import java.util.Objects; <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%> import java.time.LocalDate; <%_ } _%> @@ -223,22 +224,15 @@ public class PersistentToken implements Serializable { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof PersistentToken)) { return false; } - - PersistentToken that = (PersistentToken) o; - - if (!series.equals(that.series)) { - return false; - } - - return true; + return Objects.equals(series, ((PersistentToken) o).series); } @Override public int hashCode() { - return series.hashCode(); + return Objects.hashCode(series); } @Override diff --git a/generators/server/templates/src/main/java/package/domain/User.java.ejs b/generators/server/templates/src/main/java/package/domain/User.java.ejs index 7bb41d23959d..525d035ac325 100644 --- a/generators/server/templates/src/main/java/package/domain/User.java.ejs +++ b/generators/server/templates/src/main/java/package/domain/User.java.ejs @@ -316,17 +316,15 @@ public class <%= asEntity('User') %><% if (databaseType === 'sql' || databaseTyp if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof <%= asEntity('User') %>)) { return false; } - - <%= asEntity('User') %> user = (<%= asEntity('User') %>) o; - return !(user.getId() == null || getId() == null) && Objects.equals(getId(), user.getId()); + return id != null && id.equals(((<%= asEntity('User') %>) o).id); } @Override public int hashCode() { - return Objects.hashCode(getId()); + return 31; } @Override From ca932affadb4046b6552ad81c7bea0e07526617d Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 8 Jan 2019 12:10:00 +0000 Subject: [PATCH 106/444] Upgrade traefik version to 1.7.7 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 428a5c313fbf..c4d5acdf57f4 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -41,7 +41,7 @@ const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.0.0'; const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0'; const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0'; const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; -const DOCKER_TRAEFIK = 'traefik:1.7.6'; +const DOCKER_TRAEFIK = 'traefik:1.7.7'; const DOCKER_CONSUL = 'consul:1.4.0'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.5.0'; From 692df7cbc9bcd18797d685f3caee0ab85262db1b Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sat, 12 Jan 2019 02:18:17 +0000 Subject: [PATCH 107/444] Upgrade spring-boot version to 2.1.2.RELEASE --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 20e0a164663c..260f8a474b58 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -109,7 +109,7 @@ 2.2.0-SNAPSHOT - 2.1.1.RELEASE + 2.1.2.RELEASE <%_ if (databaseType === 'sql') { _%> From b2d87923edc197e2bb50af19988d628714ff445f Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sat, 12 Jan 2019 02:18:53 +0000 Subject: [PATCH 108/444] Upgrade spring-boot version to 2.1.2.RELEASE --- generators/server/templates/gradle.properties.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/gradle.properties.ejs b/generators/server/templates/gradle.properties.ejs index 33dc12b84558..ae1a43051843 100644 --- a/generators/server/templates/gradle.properties.ejs +++ b/generators/server/templates/gradle.properties.ejs @@ -28,7 +28,7 @@ yarn_version=<%= YARN_VERSION %> jhipster_dependencies_version=2.2.0-SNAPSHOT # The spring-boot version should match the one managed by # https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster_dependencies_version} -spring_boot_version=2.1.1.RELEASE +spring_boot_version=2.1.2.RELEASE # The hibernate version should match the one managed by # https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} --> hibernate_version=5.3.7.Final From d479ee87427b40174051fbf61abbb2fdd2aa6b32 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sun, 13 Jan 2019 17:39:40 +0000 Subject: [PATCH 109/444] Upgrade plugin org.sonarqube version to 2.7 --- generators/server/templates/build.gradle.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index c6ec43968155..99ec3f32d9a3 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -37,7 +37,7 @@ buildscript { } plugins { - id "org.sonarqube" version "2.6.2" + id "org.sonarqube" version "2.7" id "net.ltgt.apt-eclipse" version "0.19" id "net.ltgt.apt-idea" version "0.19" id "net.ltgt.apt" version "0.19" From 7f342b189a4b35a40d7617ad1f455eca9c2ad6cb Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sun, 13 Jan 2019 17:40:34 +0000 Subject: [PATCH 110/444] Upgrade plugin net.ltgt.apt-eclipse version to 0.20 --- generators/server/templates/build.gradle.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 99ec3f32d9a3..96e7f43515ed 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -38,7 +38,7 @@ buildscript { plugins { id "org.sonarqube" version "2.7" - id "net.ltgt.apt-eclipse" version "0.19" + id "net.ltgt.apt-eclipse" version "0.20" id "net.ltgt.apt-idea" version "0.19" id "net.ltgt.apt" version "0.19" id "io.spring.dependency-management" version "1.0.6.RELEASE" From d2dff71ecfd7aec2f1cbbbc93c343b6ecd4e6b6b Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sun, 13 Jan 2019 17:41:09 +0000 Subject: [PATCH 111/444] Upgrade plugin net.ltgt.apt-idea version to 0.20 --- generators/server/templates/build.gradle.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index 96e7f43515ed..fa90bddf3dbf 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -39,7 +39,7 @@ buildscript { plugins { id "org.sonarqube" version "2.7" id "net.ltgt.apt-eclipse" version "0.20" - id "net.ltgt.apt-idea" version "0.19" + id "net.ltgt.apt-idea" version "0.20" id "net.ltgt.apt" version "0.19" id "io.spring.dependency-management" version "1.0.6.RELEASE" <%_ if (!skipClient) { _%> From 66c6622e69188dd98236e7faad32b6f6ab8c27a4 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sun, 13 Jan 2019 17:41:25 +0000 Subject: [PATCH 112/444] Upgrade plugin net.ltgt.apt version to 0.20 --- generators/server/templates/build.gradle.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index fa90bddf3dbf..5aede5eed123 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -40,7 +40,7 @@ plugins { id "org.sonarqube" version "2.7" id "net.ltgt.apt-eclipse" version "0.20" id "net.ltgt.apt-idea" version "0.20" - id "net.ltgt.apt" version "0.19" + id "net.ltgt.apt" version "0.20" id "io.spring.dependency-management" version "1.0.6.RELEASE" <%_ if (!skipClient) { _%> id "com.moowork.node" version "1.2.0" From 80502d1901ce60ee1acb6d1dda0ea849a06c4eb5 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sun, 13 Jan 2019 17:49:58 +0000 Subject: [PATCH 113/444] Upgrade maven-surefire-plugin version to 3.0.0.M3 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 260f8a474b58..620b147bab1e 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -133,7 +133,7 @@ 2.10 3.0.0-M2 3.1.0 - 3.0.0-M2 + 3.0.0-M3 3.2.2 0.9.11 <%_ if (!skipClient) { _%> From f55f169591d2428ae2650b0131d94431885e3495 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Sun, 13 Jan 2019 17:53:13 +0000 Subject: [PATCH 114/444] Upgrade git-commit-id-plugin version to 2.2.6 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 620b147bab1e..b2b4cd544952 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -146,7 +146,7 @@ <%_ if (enableSwaggerCodegen) { _%> 3.3.4 <%_ } _%> - 2.2.5 + 2.2.6 http://localhost:9001 From f040010eec0d835d5f35c1a019f668196cf585a0 Mon Sep 17 00:00:00 2001 From: Panayiotis Vlissidis Date: Tue, 15 Jan 2019 08:47:24 +0200 Subject: [PATCH 115/444] Liquibase - fix floatType for mariadb Fixes #9061 --- .../config/liquibase/changelog/added_entity.xml.ejs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs index f03f3f1c8751..6897f474ec51 100644 --- a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs @@ -41,7 +41,7 @@ <%_ } _%> - + + + + + <%_ for (idx in fields) { + let loadColumnType = 'string'; + let columnType = fields[idx].columnType; + if (columnType === 'integer' || columnType === 'bigint' || columnType === 'double' || columnType === 'decimal(10,2)' || columnType === '${floatType}') { + loadColumnType = 'numeric'; + } + if (columnType === 'date' || columnType === 'datetime') { + loadColumnType = 'date'; + } + if (columnType === 'boolean') { + loadColumnType = 'boolean'; + } + if (fields[idx].fieldIsEnum) { + loadColumnType = 'skip'; + } + _%> + + <%_ } _%> + <%_ for (const idx in fields) { if (fields[idx].fieldType === 'ZonedDateTime' || fields[idx].fieldType === 'Instant') { _%> <%_ } } _%> - <% for (idx in relationships) { + <%_ for (idx in relationships) { const relationshipType = relationships[idx].relationshipType, relationshipName = relationships[idx].relationshipName, ownerSide = relationships[idx].ownerSide, diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs new file mode 100644 index 000000000000..b03c87e08798 --- /dev/null +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs @@ -0,0 +1,100 @@ +<%# + 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. +-%> +id;<% for (idx in fields) { %><%=fields[idx].fieldNameAsDatabaseColumn%><% if (idx < fields.length - 1) { %>;<% } } %> +<%_ +let table = []; +for (lineNb = 1; lineNb <= 20; lineNb++) { + let line = [ lineNb ]; + for (idx in fields) { + let data = ''; + let columnType = fields[idx].columnType; + if (columnType === 'integer' || columnType === 'bigint') { + data = this.faker.random.number(); + } + if (columnType === 'date' || columnType === 'datetime') { + // Write the date without milliseconds so Java can parse it + // See https://stackoverflow.com/a/34053802/150868 + data = this.faker.date.recent().toISOString().split('.')[0]; + } + if (columnType.startsWith('varchar')) { + let columnName = fields[idx].fieldNameAsDatabaseColumn; + if (columnName === 'first_name') { + data = this.faker.name.firstName(); + } else if (columnName === 'last_name') { + data = this.faker.name.lastName(); + } else if (columnName === 'job_title') { + data = this.faker.name.jobTitle(); + } else if (columnName === 'telephone' || columnName === 'phone') { + data = this.faker.phone.phoneNumber(); + } else if (columnName === 'zip_code' || columnName === 'post_code') { + data = this.faker.address.zipCode(); + } else if (columnName === 'city') { + data = this.faker.address.city(); + } else if (columnName === 'street_name' || columnName === 'street') { + data = this.faker.address.streetName(); + } else if (columnName === 'country') { + data = this.faker.address.country(); + } else if (columnName === 'country_code') { + data = this.faker.address.countryCode(); + } else if (columnName === 'color') { + data = this.faker.commerce.color(); + } else if (columnName === 'account') { + data = this.faker.commerce.account(); + } else if (columnName === 'account_name') { + data = this.faker.finance.accountName(); + } else if (columnName === 'currency_code') { + data = this.faker.finance.currencyCode(); + } else if (columnName === 'currency_name') { + data = this.faker.finance.currencyName(); + } else if (columnName === 'currency_symbol') { + data = this.faker.finance.currencySymbol(); + } else if (columnName === 'iban') { + data = this.faker.finance.iban(); + } else if (columnName === 'bic') { + data = this.faker.finance.bic(); + } else if (columnName === 'email') { + data = this.faker.internet.email(); + } else if (columnName === 'url') { + data = this.faker.internet.url(); + } else { + data = this.faker.random.words(); + } + // manage String max length + if (fields[idx].fieldValidate === true && fields[idx].fieldValidateRules.includes('maxlength')) { + let maxlength = fields[idx].fieldValidateRulesMaxlength; + data = data.substring(0, maxlength); + } + } + if (fields[idx].fieldIsEnum) { + data = '0'; + } + line.push(data); + } + table.push(line); +} +let result = table + .map(line => + line.map(data => { + return data; + }) + .join(';') + ) + .join('\n'); + _%> +<%-result%> diff --git a/generators/server/files.js b/generators/server/files.js index 4fae57a10bf2..f6d0a2784ea2 100644 --- a/generators/server/files.js +++ b/generators/server/files.js @@ -1349,7 +1349,7 @@ const serverFiles = { generator.applicationType !== 'microservice') || (!generator.skipUserManagement && generator.databaseType === 'sql'), path: SERVER_MAIN_RES_DIR, - templates: ['config/liquibase/users.csv'] + templates: ['config/liquibase/data/user.csv'] }, { condition: generator => @@ -1359,7 +1359,7 @@ const serverFiles = { generator.databaseType === 'sql') || (!generator.skipUserManagement && generator.databaseType === 'sql'), path: SERVER_MAIN_RES_DIR, - templates: ['config/liquibase/authorities.csv', 'config/liquibase/users_authorities.csv'] + templates: ['config/liquibase/data/authority.csv', 'config/liquibase/data/user_authority.csv'] }, { condition: generator => generator.skipUserManagement && generator.authenticationType === 'oauth2', diff --git a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs index 80153076e074..2b555acf88b7 100644 --- a/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs +++ b/generators/server/templates/src/main/resources/config/liquibase/changelog/initial_schema.xml.ejs @@ -29,7 +29,7 @@ <%_ } _%> <%_ if (prodDatabaseType === 'postgresql' || prodDatabaseType === 'oracle' || prodDatabaseType === 'mssql') { _%> - + <%_ } _%> @@ -140,8 +140,8 @@ referencedTableName="<%= jhiTablePrefix %>_user"/> <%_ } _%> <%_ if (authenticationType !== 'oauth2' || (authenticationType === 'oauth2' && applicationType !== 'microservice')) { _%> - <<% if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { %>ext:<% } %>loadData encoding="UTF-8" - file="config/liquibase/users.csv" + <<% if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { %>ext:<% } %>loadData + file="config/liquibase/data/user.csv" separator=";" <%_ if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { _%> identityInsertEnabled="true" @@ -154,16 +154,16 @@ ext:<% } %>loadData> - <<% if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { %>ext:<% } %>loadData encoding="UTF-8" - file="config/liquibase/authorities.csv" + <<% if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { %>ext:<% } %>loadData + file="config/liquibase/data/authority.csv" separator=";" <%_ if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { _%> identityInsertEnabled="true" <%_ } _%> tableName="<%= jhiTablePrefix %>_authority"/> - <<% if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { %>ext:<% } %>loadData encoding="UTF-8" - file="config/liquibase/users_authorities.csv" + <<% if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { %>ext:<% } %>loadData + file="config/liquibase/data/user_authority.csv" separator=";" <%_ if (devDatabaseType === 'mssql' || prodDatabaseType === 'mssql') { _%> identityInsertEnabled="true" diff --git a/generators/server/templates/src/main/resources/config/liquibase/data/authority.csv.ejs b/generators/server/templates/src/main/resources/config/liquibase/data/authority.csv.ejs new file mode 100644 index 000000000000..af5c6dfa186d --- /dev/null +++ b/generators/server/templates/src/main/resources/config/liquibase/data/authority.csv.ejs @@ -0,0 +1,3 @@ +name +ROLE_ADMIN +ROLE_USER diff --git a/generators/server/templates/src/main/resources/config/liquibase/data/oauth_client_details.csv.ejs b/generators/server/templates/src/main/resources/config/liquibase/data/oauth_client_details.csv.ejs new file mode 100644 index 000000000000..ad3d52d67be9 --- /dev/null +++ b/generators/server/templates/src/main/resources/config/liquibase/data/oauth_client_details.csv.ejs @@ -0,0 +1,2 @@ +client_id;resource_ids;client_secret;scope;authorized_grant_types;web_server_redirect_uri;authorities;access_token_validity;refresh_token_validity;additional_information;autoapprove +<%= baseName %>app;res_<%= baseName %>;bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl;read,write;password,refresh_token,authorization_code,implicit;;ROLE_ADMIN,ROLE_USER;1800;2000;{};true diff --git a/generators/server/templates/src/main/resources/config/liquibase/data/user.csv.ejs b/generators/server/templates/src/main/resources/config/liquibase/data/user.csv.ejs new file mode 100644 index 000000000000..590a55c9cf7d --- /dev/null +++ b/generators/server/templates/src/main/resources/config/liquibase/data/user.csv.ejs @@ -0,0 +1,7 @@ +id;login;<% if (authenticationType !== 'oauth2') { %>password_hash;<% } %>first_name;last_name;email;image_url;activated;lang_key;created_by;last_modified_by +1;system;<% if (authenticationType !== 'oauth2') { %>$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG;<% } %>System;System;system@localhost;;true;<%= nativeLanguage %>;system;system +2;anonymoususer;<% if (authenticationType !== 'oauth2') { %>$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO;<% } %>Anonymous;User;anonymous@localhost;;true;<%= nativeLanguage %>;system;system +<%_ if (authenticationType !== 'oauth2') { _%> +3;admin;$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC;Administrator;Administrator;admin@localhost;;true;<%= nativeLanguage %>;system;system +4;user;$2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K;User;User;user@localhost;;true;<%= nativeLanguage %>;system;system +<%_ } _%> diff --git a/generators/server/templates/src/main/resources/config/liquibase/data/user_authority.csv.ejs b/generators/server/templates/src/main/resources/config/liquibase/data/user_authority.csv.ejs new file mode 100644 index 000000000000..7d17146cc5d0 --- /dev/null +++ b/generators/server/templates/src/main/resources/config/liquibase/data/user_authority.csv.ejs @@ -0,0 +1,8 @@ +user_id;authority_name +1;ROLE_ADMIN +1;ROLE_USER +<%_ if (authenticationType !== 'oauth2') { _%> +3;ROLE_ADMIN +3;ROLE_USER +4;ROLE_USER +<%_ } _%> diff --git a/package-lock.json b/package-lock.json index 486c12e37c07..6d9fa17d1c61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -382,6 +382,11 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", @@ -718,13 +723,34 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "concat-stream": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", - "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", "requires": { + "buffer-from": "^1.0.0", "inherits": "^2.0.3", - "readable-stream": "^2.2.2", + "readable-stream": "^3.0.2", "typedarray": "^0.0.6" + }, + "dependencies": { + "readable-stream": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.1.1.tgz", + "integrity": "sha512-DkN66hPyqDhnIQ6Jcsvx9bFjhw214O4poMBcIMgPVpQvNy9a0e0Uhg5SqySyDKAmUlwt8LonTBz1ezOnM8pUdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", + "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "conf": { @@ -767,6 +793,14 @@ "which": "^1.2.9" } }, + "csv-stringify": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-5.1.2.tgz", + "integrity": "sha512-rvNEMy8IwVe/gnCjnF4a/3cxKPm8oaAZEBB8RIzlx9HcNrLrn3NlgacUIFZBRH86tKF76WVA13nkFF0mX7G2EQ==", + "requires": { + "lodash.get": "~4.4.2" + } + }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", @@ -1209,7 +1243,7 @@ }, "ansi-escapes": { "version": "3.1.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", "dev": true }, @@ -1466,7 +1500,7 @@ }, "load-json-file": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -1620,6 +1654,11 @@ "shebang-command": "^1.2.0", "which": "^1.2.9" } + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" } } }, @@ -1752,9 +1791,14 @@ "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" }, + "faker": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/faker/-/faker-4.1.0.tgz", + "integrity": "sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8=" + }, "fast-deep-equal": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" }, "fast-diff": { @@ -1977,11 +2021,6 @@ "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", "dev": true }, - "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" - }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -2095,6 +2134,13 @@ "timed-out": "^4.0.0", "url-parse-lax": "^1.0.0", "url-to-options": "^1.0.1" + }, + "dependencies": { + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + } } }, "graceful-fs": { @@ -2927,8 +2973,7 @@ "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", - "dev": true + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" }, "lodash.pad": { "version": "4.5.1", @@ -4519,6 +4564,19 @@ "requires": { "concat-stream": "^1.4.7", "os-shim": "^0.1.2" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + } } }, "spdx-correct": { @@ -5281,7 +5339,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -5295,7 +5353,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" @@ -5319,7 +5377,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -5333,7 +5391,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" diff --git a/package.json b/package.json index 7712d4149406..053cc4b6e8cf 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "conf": "2.0.0", "didyoumean": "1.2.1", "ejs": "2.6.1", + "faker": "4.1.0", "glob": "7.1.2", "gulp-filter": "5.1.0", "insight": "0.10.1", diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js index 7f0c960a9b53..6461bdb26d57 100644 --- a/test/utils/expected-files.js +++ b/test/utils/expected-files.js @@ -209,9 +209,9 @@ const expectedFiles = { ], userManagementServer: [ - `${SERVER_MAIN_RES_DIR}config/liquibase/authorities.csv`, - `${SERVER_MAIN_RES_DIR}config/liquibase/users.csv`, - `${SERVER_MAIN_RES_DIR}config/liquibase/users_authorities.csv`, + `${SERVER_MAIN_RES_DIR}config/liquibase/authority.csv`, + `${SERVER_MAIN_RES_DIR}config/liquibase/user.csv`, + `${SERVER_MAIN_RES_DIR}config/liquibase/user_authority.csv`, `${SERVER_MAIN_RES_DIR}templates/mail/activationEmail.html`, `${SERVER_MAIN_RES_DIR}templates/mail/passwordResetEmail.html`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/Authority.java`, From faf26404645b2188643eff6b0de038f2573d92ae Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 22 Jan 2019 10:36:02 +0100 Subject: [PATCH 129/444] fix path for expected liquibase files --- test/utils/expected-files.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js index 6461bdb26d57..977a46aa3040 100644 --- a/test/utils/expected-files.js +++ b/test/utils/expected-files.js @@ -209,9 +209,9 @@ const expectedFiles = { ], userManagementServer: [ - `${SERVER_MAIN_RES_DIR}config/liquibase/authority.csv`, - `${SERVER_MAIN_RES_DIR}config/liquibase/user.csv`, - `${SERVER_MAIN_RES_DIR}config/liquibase/user_authority.csv`, + `${SERVER_MAIN_RES_DIR}config/liquibase/data/authority.csv`, + `${SERVER_MAIN_RES_DIR}config/liquibase/data/user.csv`, + `${SERVER_MAIN_RES_DIR}config/liquibase/data/user_authority.csv`, `${SERVER_MAIN_RES_DIR}templates/mail/activationEmail.html`, `${SERVER_MAIN_RES_DIR}templates/mail/passwordResetEmail.html`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/Authority.java`, From 9ccece8bc12c01b8edc74a036d6d10cbb6c8ee52 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 22 Jan 2019 16:38:33 +0100 Subject: [PATCH 130/444] handle blobs and clobs with Faker.js --- .../liquibase/changelog/added_entity.xml.ejs | 14 +++--- .../config/liquibase/data/table.csv.ejs | 20 +++++--- package-lock.json | 50 +++---------------- 3 files changed, 26 insertions(+), 58 deletions(-) diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs index 4fefa3e2322d..e74fa22776eb 100644 --- a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs @@ -156,18 +156,20 @@ let columnType = fields[idx].columnType; if (columnType === 'integer' || columnType === 'bigint' || columnType === 'double' || columnType === 'decimal(10,2)' || columnType === '${floatType}') { loadColumnType = 'numeric'; - } - if (columnType === 'date' || columnType === 'datetime') { + } else if (columnType === 'date' || columnType === 'datetime') { loadColumnType = 'date'; - } - if (columnType === 'boolean') { + } else if (columnType === 'boolean') { loadColumnType = 'boolean'; - } - if (fields[idx].fieldIsEnum) { + } else if (fields[idx].fieldIsEnum) { loadColumnType = 'skip'; + } else if (columnType === 'clob' || columnType === 'blob' || columnType === 'longblob') { + loadColumnType = 'string'; } _%> + <%_ if (fields[idx].fieldType === 'byte[]' && fields[idx].fieldTypeBlobContent !== 'text') { _%> + + <%_ } _%> <%_ } _%> <%_ for (const idx in fields) { diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs index b03c87e08798..d7a6c8629bb8 100644 --- a/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -id;<% for (idx in fields) { %><%=fields[idx].fieldNameAsDatabaseColumn%><% if (idx < fields.length - 1) { %>;<% } } %> +id;<% for (idx in fields) { %><%=fields[idx].fieldNameAsDatabaseColumn%><%if (fields[idx].fieldType === 'byte[]' && fields[idx].fieldTypeBlobContent !== 'text') {%>;<%=fields[idx].fieldNameAsDatabaseColumn%>_content_type<% } %><% if (idx < fields.length - 1) { %>;<% } } %> <%_ let table = []; for (lineNb = 1; lineNb <= 20; lineNb++) { @@ -24,15 +24,14 @@ for (lineNb = 1; lineNb <= 20; lineNb++) { for (idx in fields) { let data = ''; let columnType = fields[idx].columnType; - if (columnType === 'integer' || columnType === 'bigint') { + let fieldType = fields[idx].fieldType; + if (columnType === 'integer' || columnType === 'bigint' || columnType.startsWith('decimal')) { data = this.faker.random.number(); - } - if (columnType === 'date' || columnType === 'datetime') { + } else if (columnType === 'date' || columnType === 'datetime') { // Write the date without milliseconds so Java can parse it // See https://stackoverflow.com/a/34053802/150868 data = this.faker.date.recent().toISOString().split('.')[0]; - } - if (columnType.startsWith('varchar')) { + } else if (columnType.startsWith('varchar')) { let columnName = fields[idx].fieldNameAsDatabaseColumn; if (columnName === 'first_name') { data = this.faker.name.firstName(); @@ -80,11 +79,16 @@ for (lineNb = 1; lineNb <= 20; lineNb++) { let maxlength = fields[idx].fieldValidateRulesMaxlength; data = data.substring(0, maxlength); } - } - if (fields[idx].fieldIsEnum) { + } else if (fields[idx].fieldIsEnum) { data = '0'; } + if (fieldType === 'byte[]') { + data = Buffer.from(this.faker.random.words(), 'utf8').toString('hex'); + } line.push(data); + if (fieldType === 'byte[]' && fields[idx].fieldTypeBlobContent !== 'text') { + line.push('image/png'); + } } table.push(line); } diff --git a/package-lock.json b/package-lock.json index 6d9fa17d1c61..8a2532d5c389 100644 --- a/package-lock.json +++ b/package-lock.json @@ -722,37 +722,6 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, - "concat-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", - "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.0.2", - "typedarray": "^0.0.6" - }, - "dependencies": { - "readable-stream": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.1.1.tgz", - "integrity": "sha512-DkN66hPyqDhnIQ6Jcsvx9bFjhw214O4poMBcIMgPVpQvNy9a0e0Uhg5SqySyDKAmUlwt8LonTBz1ezOnM8pUdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "string_decoder": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", - "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, "conf": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/conf/-/conf-2.0.0.tgz", @@ -793,14 +762,6 @@ "which": "^1.2.9" } }, - "csv-stringify": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-5.1.2.tgz", - "integrity": "sha512-rvNEMy8IwVe/gnCjnF4a/3cxKPm8oaAZEBB8RIzlx9HcNrLrn3NlgacUIFZBRH86tKF76WVA13nkFF0mX7G2EQ==", - "requires": { - "lodash.get": "~4.4.2" - } - }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", @@ -2973,7 +2934,8 @@ "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true }, "lodash.pad": { "version": "4.5.1", @@ -5339,7 +5301,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -5353,7 +5315,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" @@ -5377,7 +5339,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -5391,7 +5353,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" From 7b12f5cf43c2c8dd0996230891a0a3f808c60015 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 22 Jan 2019 16:54:24 +0100 Subject: [PATCH 131/444] only add Faker.js data in dev profile --- .../liquibase/changelog/added_entity.xml.ejs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs index e74fa22776eb..e7b855e7074d 100644 --- a/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/changelog/added_entity.xml.ejs @@ -146,10 +146,19 @@ + <%_ for (const idx in fields) { + if (fields[idx].fieldType === 'ZonedDateTime' || fields[idx].fieldType === 'Instant') { _%> + + <%_ } + } _%> + + + + tableName="<%= entityTableName %>" + context="dev"> <%_ for (idx in fields) { let loadColumnType = 'string'; @@ -172,11 +181,9 @@ <%_ } _%> <%_ } _%> - <%_ for (const idx in fields) { - if (fields[idx].fieldType === 'ZonedDateTime' || fields[idx].fieldType === 'Instant') { _%> - - <%_ } - } _%> + + + <%_ for (idx in relationships) { const relationshipType = relationships[idx].relationshipType, relationshipName = relationships[idx].relationshipName, From 134791c2aa1c758af8d34ef53c6cc7ac74e97225 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 22 Jan 2019 17:44:34 +0100 Subject: [PATCH 132/444] handle enums with Faker.js --- .../main/resources/config/liquibase/data/table.csv.ejs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs b/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs index d7a6c8629bb8..f300ecf85551 100644 --- a/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs +++ b/generators/entity-server/templates/src/main/resources/config/liquibase/data/table.csv.ejs @@ -79,8 +79,14 @@ for (lineNb = 1; lineNb <= 20; lineNb++) { let maxlength = fields[idx].fieldValidateRulesMaxlength; data = data.substring(0, maxlength); } - } else if (fields[idx].fieldIsEnum) { - data = '0'; + } + if (fields[idx].fieldIsEnum) { + if (fields[idx].fieldValues.length !== 0) { + const enums = fields[idx].fieldValues.split(','); + data = enums[0]; + } else { + data = ''; + } } if (fieldType === 'byte[]') { data = Buffer.from(this.faker.random.words(), 'utf8').toString('hex'); From 25d14e470954385bf5a8b78881680d7bf584d521 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Wed, 23 Jan 2019 09:45:24 +0000 Subject: [PATCH 133/444] Downgrade maven-enforcer-plugin version to 3.0.0-M1 due to regression issue --- generators/server/templates/pom.xml.ejs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index b2b4cd544952..b4ad8a84e278 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -131,7 +131,8 @@ 3.1.0 3.8.0 2.10 - 3.0.0-M2 + + 3.0.0-M1 3.1.0 3.0.0-M3 3.2.2 From 713a8fa49ad9742ebf4386aef12891f6d89e51ff Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 24 Jan 2019 21:48:28 +0000 Subject: [PATCH 134/444] Upgrade jacoco-maven-plugin version to 0.8.3 --- generators/server/templates/gradle/sonar.gradle.ejs | 2 +- generators/server/templates/pom.xml.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/server/templates/gradle/sonar.gradle.ejs b/generators/server/templates/gradle/sonar.gradle.ejs index b4e95af335df..1f5fcf07a27d 100644 --- a/generators/server/templates/gradle/sonar.gradle.ejs +++ b/generators/server/templates/gradle/sonar.gradle.ejs @@ -20,7 +20,7 @@ apply plugin: "org.sonarqube" apply plugin: 'jacoco' jacoco { - toolVersion = '0.8.2' + toolVersion = '0.8.3' } jacocoTestReport { diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index b4ad8a84e278..f89b70c1c078 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -140,7 +140,7 @@ <%_ if (!skipClient) { _%> 1.6 <%_ } _%> - 0.8.2 + 0.8.3 1.0.0 3.4.4 3.5.0.1254 From 62dcf8773e3c2bea0dd41bec97003ae9f5cc28c6 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 24 Jan 2019 21:51:46 +0000 Subject: [PATCH 135/444] Upgrade consul version to 1.4.1 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 38da643f8d72..f6727f9dc8db 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -42,7 +42,7 @@ const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0'; const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0'; const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; const DOCKER_TRAEFIK = 'traefik:1.7.7'; -const DOCKER_CONSUL = 'consul:1.4.0'; +const DOCKER_CONSUL = 'consul:1.4.1'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.6.1'; const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.15.3'; From 005522e48361f0fd010c26bcb87cf61bfdadb1d8 Mon Sep 17 00:00:00 2001 From: Anthony Viard Date: Tue, 29 Jan 2019 18:21:51 +0100 Subject: [PATCH 136/444] Get addMainCSSStyle method back For both css and scss and also both react and angular --- generators/generator-base.js | 68 +++++++++++++++--------------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/generators/generator-base.js b/generators/generator-base.js index eca521e7bbeb..8a698da91a57 100644 --- a/generators/generator-base.js +++ b/generators/generator-base.js @@ -569,7 +569,7 @@ module.exports = class extends PrivateBase { } /** - * Add new css or scss style to the angular application in "global.css" or "global.scss". + * Add new css style to the application. * * @param {string} style - css to add in the file * @param {string} comment - comment to add before css code @@ -587,78 +587,68 @@ module.exports = class extends PrivateBase { * } * */ - addGlobalCSSStyle(style, comment) { - if (this.clientFramework !== 'angularX') { - this.error('Global css is only supported by Angular, for React @see addAppCSSStyle()'); - return; - } - - if (this.useSass) { - this.needleApi.clientAngular.addGlobalSCSSStyle(style, comment); - } else { + addMainCSSStyle(style, comment) { + if (this.clientFramework === 'angularX') { this.needleApi.clientAngular.addGlobalCSSStyle(style, comment); + } else if (this.clientFramework === 'react') { + this.needleApi.clientReact.addAppCSSStyle(style, comment); } } /** - * Add new scss style to the angular application in "vendor.scss". + * Add new scss style to the application. * - * @param {string} style - scss to add in the file + * @param {string} style - css to add in the file * @param {string} comment - comment to add before css code * * example: * - * style = '.success {\n @extend .message;\n border-color: green;\n}' - * comment = 'Message' + * style = '.jhipster {\n color: #baa186;\n}' + * comment = 'New JHipster color' * * * ========================================================================== - * Message + * New JHipster color * ========================================================================== * - * .success { - * @extend .message; - * border-color: green; + * .jhipster { + * color: #baa186; * } * */ - addVendorSCSSStyle(style, comment) { - if (this.clientFramework !== 'angularX') { - this.error('Vendor is only supported by Angular'); - return; + addMainSCSSStyle(style, comment) { + if (this.clientFramework === 'angularX') { + this.needleApi.clientAngular.addGlobalSCSSStyle(style, comment); + } else if (this.clientFramework === 'react') { + this.needleApi.clientReact.addAppSCSSStyle(style, comment); } - - this.needleApi.clientAngular.addVendorSCSSStyle(style, comment); } /** - * Add new css or scss style to the react application in "app.css" or "app.scss". + * Add new scss style to the angular application in "vendor.scss". * - * @param {string} style - css to add in the file + * @param {string} style - scss to add in the file * @param {string} comment - comment to add before css code * * example: * - * style = '.jhipster {\n color: #baa186;\n}' - * comment = 'New JHipster color' + * style = '.success {\n @extend .message;\n border-color: green;\n}' + * comment = 'Message' * * * ========================================================================== - * New JHipster color + * Message * ========================================================================== * - * .jhipster { - * color: #baa186; + * .success { + * @extend .message; + * border-color: green; * } * */ - addAppCSSStyle(style, comment) { - if (this.clientFramework !== 'react') { - this.error('App css is only supported by React'); + addVendorSCSSStyle(style, comment) { + if (this.clientFramework !== 'angularX') { + this.error('Vendor is only supported by Angular'); return; } - if (this.useSass) { - this.needleApi.clientReact.addAppSCSSStyle(style, comment); - } else { - this.needleApi.clientReact.addAppCSSStyle(style, comment); - } + this.needleApi.clientAngular.addVendorSCSSStyle(style, comment); } /** From 9b521b32fe9842c4948b23d76f1d6d630d1e6090 Mon Sep 17 00:00:00 2001 From: Anthony Viard Date: Tue, 29 Jan 2019 18:22:36 +0100 Subject: [PATCH 137/444] Uniform needle in css and scss files --- .../angular/src/main/webapp/content/scss/global.scss.ejs | 2 +- .../client/templates/react/src/main/webapp/app/app.scss.ejs | 2 +- generators/internal/needle-api/needle-client-angular.js | 4 ++-- generators/internal/needle-api/needle-client-react.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/generators/client/templates/angular/src/main/webapp/content/scss/global.scss.ejs b/generators/client/templates/angular/src/main/webapp/content/scss/global.scss.ejs index 4c9e639663d1..81ec4bc399e7 100644 --- a/generators/client/templates/angular/src/main/webapp/content/scss/global.scss.ejs +++ b/generators/client/templates/angular/src/main/webapp/content/scss/global.scss.ejs @@ -236,4 +236,4 @@ ui bootstrap tweaks white-space: nowrap; } -/* jhipster-needle-scss-add-global JHipster will add new css style */ +/* jhipster-needle-scss-add-main JHipster will add new css style */ diff --git a/generators/client/templates/react/src/main/webapp/app/app.scss.ejs b/generators/client/templates/react/src/main/webapp/app/app.scss.ejs index f58fc18afe78..8b4f5d7ba212 100644 --- a/generators/client/templates/react/src/main/webapp/app/app.scss.ejs +++ b/generators/client/templates/react/src/main/webapp/app/app.scss.ejs @@ -336,4 +336,4 @@ http://stackoverflow.com/questions/23436430/bootstrap-3-input-group-100-width */ margin-top: -0.5rem; } -/* jhipster-needle-css-add-main JHipster will add new css style */ +/* jhipster-needle-scss-add-main JHipster will add new css style */ diff --git a/generators/internal/needle-api/needle-client-angular.js b/generators/internal/needle-api/needle-client-angular.js index c221cbee6503..1606df48e56c 100644 --- a/generators/internal/needle-api/needle-client-angular.js +++ b/generators/internal/needle-api/needle-client-angular.js @@ -27,12 +27,12 @@ const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; module.exports = class extends needleClientBase { addGlobalCSSStyle(style, comment) { const filePath = `${CLIENT_MAIN_SRC_DIR}content/css/global.css`; - this.addStyle(style, comment, filePath, 'jhipster-needle-css-add-global'); + this.addStyle(style, comment, filePath, 'jhipster-needle-css-add-main'); } addGlobalSCSSStyle(style, comment) { const filePath = `${CLIENT_MAIN_SRC_DIR}content/scss/global.scss`; - this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-global'); + this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-main'); } addVendorSCSSStyle(style, comment) { diff --git a/generators/internal/needle-api/needle-client-react.js b/generators/internal/needle-api/needle-client-react.js index 5679937a0a84..a2168c91b5e7 100644 --- a/generators/internal/needle-api/needle-client-react.js +++ b/generators/internal/needle-api/needle-client-react.js @@ -27,12 +27,12 @@ const CLIENT_MAIN_SRC_DIR = constants.CLIENT_MAIN_SRC_DIR; module.exports = class extends needleClientBase { addAppCSSStyle(style, comment) { const filePath = `${CLIENT_MAIN_SRC_DIR}app/app.css`; - this.addStyle(style, comment, filePath, 'jhipster-needle-css-add-app'); + this.addStyle(style, comment, filePath, 'jhipster-needle-css-add-main'); } addAppSCSSStyle(style, comment) { const filePath = `${CLIENT_MAIN_SRC_DIR}app/app.scss`; - this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-app'); + this.addStyle(style, comment, filePath, 'jhipster-needle-scss-add-main'); } addEntityToMenu(routerName, enableTranslation, entityTranslationKeyMenu) { From a58412abafbb119df999491f0ce9ff2d86fbaf14 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 29 Jan 2019 17:27:39 +0000 Subject: [PATCH 138/444] Upgrade traefik version to 1.7.8 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index f6727f9dc8db..7741ba152a25 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -41,7 +41,7 @@ const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.0.0'; const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0'; const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0'; const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; -const DOCKER_TRAEFIK = 'traefik:1.7.7'; +const DOCKER_TRAEFIK = 'traefik:1.7.8'; const DOCKER_CONSUL = 'consul:1.4.1'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.6.1'; From 68274d975d840030807b821d39425570b63a0051 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Tue, 29 Jan 2019 17:30:40 +0000 Subject: [PATCH 139/444] Upgrade consul version to 1.4.2 --- generators/generator-constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/generator-constants.js b/generators/generator-constants.js index 7741ba152a25..328eeea20002 100644 --- a/generators/generator-constants.js +++ b/generators/generator-constants.js @@ -42,7 +42,7 @@ const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0'; const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0'; const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0'; const DOCKER_TRAEFIK = 'traefik:1.7.8'; -const DOCKER_CONSUL = 'consul:1.4.1'; +const DOCKER_CONSUL = 'consul:1.4.2'; const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0'; const DOCKER_PROMETHEUS = 'prom/prometheus:v2.6.1'; const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.15.3'; From 25c26387fac8fc69479124db1e4007a6d7574ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Dessoude?= Date: Wed, 30 Jan 2019 11:27:31 +0100 Subject: [PATCH 140/444] Fix missing required validation on relationship on React Add required parameter for required relationship Fix #9128 --- .../src/main/webapp/app/entities/entity-update.tsx.ejs | 8 ++++++-- package-lock.json | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs index a54caf863a1a..d9298fa0a594 100644 --- a/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs +++ b/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs @@ -37,7 +37,7 @@ import { Col, Label <% if (haveFieldWithJavadoc) { %>, UncontrolledTooltip<% } %> } from 'reactstrap'; -import { AvForm, AvGroup, AvInput<% if (fieldsIsReactAvField) { %>, AvField <% } %> } from 'availity-reactstrap-validation'; +import { AvFeedback, AvForm, AvGroup, AvInput<% if (fieldsIsReactAvField) { %>, AvField <% } %> } from 'availity-reactstrap-validation'; // tslint:disable-next-line:no-unused-variable import { Translate, @@ -449,6 +449,7 @@ export class <%= entityReactName %>Update extends React.Component[0] && <%= otherEntityNamePlural %>[0].id : <%= entityInstance %>Entity.<%= relationshipName %>.id} + required > { <%= otherEntityNamePlural %> ? <%= otherEntityNamePlural %>.map(otherEntity => @@ -460,7 +461,8 @@ export class <%= entityReactName %>Update extends React.Component - <%_ } _%> + This field is required. + <%_ } _%> <%_ } else { _%> <%_ if (!relationshipRequired) { _%> Update extends React.Component { <%= otherEntityNamePlural %> ? <%= otherEntityNamePlural %>.map(otherEntity => @@ -497,6 +500,7 @@ export class <%= entityReactName %>Update extends React.Component + This field is required. <%_ } _%> <%_ } _%> diff --git a/package-lock.json b/package-lock.json index 5e6f8cdf1275..ad210e022682 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1209,7 +1209,7 @@ }, "ansi-escapes": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", "dev": true }, @@ -1466,7 +1466,7 @@ }, "load-json-file": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -1754,7 +1754,7 @@ }, "fast-deep-equal": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" }, "fast-diff": { @@ -5281,7 +5281,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -5295,7 +5295,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" From 5b24fe14982287d9bc9abb651ed7e04190b9b84e Mon Sep 17 00:00:00 2001 From: lmbai Date: Thu, 31 Jan 2019 14:07:31 +0800 Subject: [PATCH 141/444] enhance for lang under oauth, update lang mapping --- .../main/webapp/app/core/auth/account.service.ts.ejs | 6 +++--- .../spec/app/core/user/account.service.spec.ts.ejs | 6 +++--- .../main/java/package/service/UserService.java.ejs | 12 ++++++------ .../java/package/service/UserServiceIntTest.java.ejs | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs index 07f7109d278e..1247baaa3a32 100644 --- a/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs @@ -17,7 +17,7 @@ limitations under the License. -%> import { Injectable } from '@angular/core'; -<%_ if (enableTranslation && authenticationType !== 'oauth2' && authenticationType !== 'uaa') { _%> +<%_ if (enableTranslation && authenticationType !== 'uaa') { _%> import { JhiLanguageService } from 'ng-jhipster'; import { SessionStorageService } from 'ngx-webstorage'; <%_ } _%> @@ -38,7 +38,7 @@ export class AccountService { constructor( - <%_ if (enableTranslation && authenticationType !== 'oauth2' && authenticationType !== 'uaa') { _%> + <%_ if (enableTranslation && authenticationType !== 'uaa') { _%> private languageService: JhiLanguageService, private sessionStorage: SessionStorageService, <%_ } _%> @@ -105,7 +105,7 @@ export class AccountService { <%_ if (websocket === 'spring-websocket') { _%> this.trackerService.connect(); <%_ } _%> - <%_ if (enableTranslation && authenticationType !== 'oauth2' && authenticationType !== 'uaa') { _%> + <%_ if (enableTranslation && authenticationType !== 'uaa') { _%> // After retrieve the account info, the language will be changed to // the user's preferred language configured in the account setting const langKey = this.sessionStorage.retrieve('locale') || this.userIdentity.langKey; diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs b/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs index 3c4e2a60ebc3..bf724179ba7b 100644 --- a/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs +++ b/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs @@ -3,12 +3,12 @@ import { TestBed } from '@angular/core/testing'; import { SERVER_API_URL } from 'app/app.constants'; import { AccountService<% if (websocket === 'spring-websocket') { %>, <%= jhiPrefixCapitalized %>TrackerService <% } %> } from 'app/core'; import { JhiDateUtils -<%_ if (enableTranslation && authenticationType !== 'oauth2') { _%> +<%_ if (enableTranslation) { _%> ,JhiLanguageService <%_ } _%> } from 'ng-jhipster'; import { SessionStorageService } from 'ngx-webstorage'; -<%_ if (enableTranslation && authenticationType !== 'oauth2') { _%> +<%_ if (enableTranslation) { _%> import { MockLanguageService } from '../../../helpers/mock-language.service'; <%_ } _%> <%_ if (websocket === 'spring-websocket') { _%> @@ -26,7 +26,7 @@ describe('Service Tests', () => { providers: [ JhiDateUtils, SessionStorageService, - <%_ if (enableTranslation && authenticationType !== 'oauth2') { _%> + <%_ if (enableTranslation) { _%> { provide: JhiLanguageService, useClass: MockLanguageService diff --git a/generators/server/templates/src/main/java/package/service/UserService.java.ejs b/generators/server/templates/src/main/java/package/service/UserService.java.ejs index 631dc109ec1b..e3d8d78342c8 100644 --- a/generators/server/templates/src/main/java/package/service/UserService.java.ejs +++ b/generators/server/templates/src/main/java/package/service/UserService.java.ejs @@ -823,14 +823,14 @@ public class UserService { if (details.get("langKey") != null) { user.setLangKey((String) details.get("langKey")); } else if (details.get("locale") != null) { + // for the locale issue, we suggest you should adjust the format based on the oauth server. here we can't cater for all the cases + // https://github.com/jhipster/generator-jhipster/issues/7866 + // for the en_US or en_** issue. since jhipter only have one "en" language, we will handle it here, for other language, please handle it accordingly. String locale = (String) details.get("locale"); - if (locale.contains("-")) { - String langKey = locale.substring(0, locale.indexOf('-')); - user.setLangKey(langKey); - } else if (locale.contains("_")) { - String langKey = locale.substring(0, locale.indexOf('_')); - user.setLangKey(langKey); + if(locale.startsWith("en_") || locale.startsWith("en-")) { + locale = "en"; } + user.setLangKey(locale.toLowerCase()); } if (details.get("picture") != null) { user.setImageUrl((String) details.get("picture")); diff --git a/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs b/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs index 5b9830f32d21..fc426c219e76 100644 --- a/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs @@ -421,7 +421,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends userDTO = userService.getUserFromAuthentication(authentication); - assertThat(userDTO.getLangKey()).isEqualTo("it"); + assertThat(userDTO.getLangKey()).isEqualTo("it-it"); } private OAuth2Authentication createMockOAuth2AuthenticationWithDetails(Map userDetails) { From 9e36f6a96e9f346038e0008606af70f211a1decf Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Thu, 31 Jan 2019 11:36:50 +0100 Subject: [PATCH 142/444] wording --- .../templates/README-KUBERNETES-HELM.md.ejs | 18 +++++++------- generators/kubernetes/prompts.js | 4 ++-- .../templates/README-KUBERNETES.md.ejs | 24 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/generators/kubernetes-helm/templates/README-KUBERNETES-HELM.md.ejs b/generators/kubernetes-helm/templates/README-KUBERNETES-HELM.md.ejs index 2ce69a78e638..ff69f0ee2f11 100644 --- a/generators/kubernetes-helm/templates/README-KUBERNETES-HELM.md.ejs +++ b/generators/kubernetes-helm/templates/README-KUBERNETES-HELM.md.ejs @@ -18,19 +18,19 @@ $ <%= dockerPushCommand %> <%= appConfigs[i].targetImageName %> To use the templates generated by this sub-generator `helm cli and tiller` should be installed. Instructions on installing `helm` can be referred at [https://github.com/helm/helm](https://github.com/helm/helm) -Once, helm is installed, then you need to add the below repositories, +Once Helm is installed you need to add the below repositories: ``` helm repo add stable https://kubernetes-charts.storage.googleapis.com helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com -``` -These repos should be added to the local cache, because this sub-generator will pull some charts from these repos. +``` +These repositories should be added to the local cache, because this sub-generator will pull some charts from them. -This repo in turn uses `kubernets` sub-generator for the microservices manifests and few service like db, elk, prometheus etc. are referred from the above repos. +This repository in turn uses the `kubernetes` sub-generator for the microservices manifests and few service like database, Elasticsearch, Prometheus etc. that are referred from the above repositories. ## Deployment -You can deploy all your apps by running the below bash command: +You can deploy all your applications by running the following bash command: ``` bash helm-apply.sh (or) ./helm-apply.sh @@ -38,16 +38,16 @@ bash helm-apply.sh (or) ./helm-apply.sh `helm-apply.sh` will always do a clean install. Any of the existing charts with the same identity gets removed first and then it does a clean install. - -You can upgrade all your apps (if at all if you have made any changes to the generated manifests) by running the below bash command: +You can upgrade all your apps (if you have made any changes to the generated manifests) by running the following bash command: ``` bash helm-upgrade.sh (or) ./helm-upgrade.sh ``` -For kubernetes specific info, refer `kubernetes` sub-generator readme instructions. +For Kubernetes specific information, refer to the `kubernetes` sub-generator Readme instructions. ### Backlogs to be covered -* Couchbase is yet to be integrated with helm repo, it is still referring the k8s sub generator manifest. Not tested. + +* Couchbase is yet to be integrated with Helm repository, it is still referring the Kubernetes sub-generator manifest - to be tested * helm upgrade - to be tested * Istio - to be tested diff --git a/generators/kubernetes/prompts.js b/generators/kubernetes/prompts.js index 06c0e6c4e8ba..f962d066b8d1 100644 --- a/generators/kubernetes/prompts.js +++ b/generators/kubernetes/prompts.js @@ -54,11 +54,11 @@ function askForKubernetesServiceType() { { type: 'list', name: 'kubernetesServiceType', - message: 'Choose the kubernetes service type for your edge services', + message: 'Choose the Kubernetes service type for your edge services', choices: [ { value: 'LoadBalancer', - name: 'LoadBalancer - Let a kubernetes cloud provider automatically assign an IP' + name: 'LoadBalancer - Let a Kubernetes cloud provider automatically assign an IP' }, { value: 'NodePort', diff --git a/generators/kubernetes/templates/README-KUBERNETES.md.ejs b/generators/kubernetes/templates/README-KUBERNETES.md.ejs index 9a5431e5031c..e96b6a527b21 100644 --- a/generators/kubernetes/templates/README-KUBERNETES.md.ejs +++ b/generators/kubernetes/templates/README-KUBERNETES.md.ejs @@ -1,4 +1,4 @@ -# JHipster generated kubernetes configuration +# JHipster-generated Kubernetes configuration ## Preparation @@ -52,7 +52,7 @@ The default way to update a running app in kubernetes, is to deploy a new image $ kubectl set image deployment/-app = <%= kubernetesNamespace === 'default' ? '' : ` -n ${kubernetesNamespace}` %> ``` -Using livenessProbes and readinessProbe allows you to tell kubernetes about the state of your apps, in order to ensure availablity of your services. You will need minimum 2 replicas for every app deployment, you want to have zero-downtime deployed. This is because the rolling upgrade strategy first kills a running replica in order to place a new. Running only one replica, will cause a short downtime during upgrades. +Using livenessProbes and readinessProbe allow you to tell Kubernetes about the state of your applications, in order to ensure availablity of your services. You will need minimum 2 replicas for every application deployment if you want to have zero-downtime deployed. This is because the rolling upgrade strategy first kills a running replica in order to place a new. Running only one replica, will cause a short downtime during upgrades. <%_ if (monitoring === 'elk' || monitoring === 'prometheus') { _%> ## Monitoring tools @@ -122,26 +122,26 @@ $ kubectl scale statefulset jhipster-registry --replicas 3<%= kubernetesNamespac > my apps doesn't get pulled, because of 'imagePullBackof' -check the registry your kubernetes cluster is accessing. If you are using a private registry, you should add it to your namespace by `kubectl create secret docker-registry` (check the [docs](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) for more info) +Check the registry your Kubernetes cluster is accessing. If you are using a private registry, you should add it to your namespace by `kubectl create secret docker-registry` (check the [docs](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) for more info) -> my apps get killed, before they can boot up +> my applications get killed, before they can boot up -This can occur, if your cluster has low resource (e.g. Minikube). Increase the `initialDelySeconds` value of livenessProbe of your deployments +This can occur if your cluster has low resource (e.g. Minikube). Increase the `initialDelySeconds` value of livenessProbe of your deployments -> my apps are starting very slow, despite I have a cluster with many resources +> my applications are starting very slow, despite I have a cluster with many resources -The default setting are optimized for middle scale clusters. You are free to increase the JAVA_OPTS environment variable, and resource requests and limits to improve the performance. Be careful! +The default setting are optimized for middle-scale clusters. You are free to increase the JAVA_OPTS environment variable, and resource requests and limits to improve the performance. Be careful! <%_ if (monitoring === 'prometheus') { _%> -> I have selected prometheus but no targets are visible +> I have selected Prometheus but no targets are visible -This depends on the setup of prometheus operator and the access control policies in your cluster. Version 1.6.0+ is needed for the RBAC setup to work. +This depends on the setup of the Prometheus operator and the access control policies in your cluster. Version 1.6.0+ is needed for the RBAC setup to work. -> I have selected prometheus, but my targets never get scraped +> I have selected Prometheus, but my targets never get scraped -This means your apps are probably not built using the `prometheus` profile in Maven/Gradle +This means your applications are probably not built using the `prometheus` profile in Maven/Gradle <%_ } _%> -> my SQL based microservice stuck during liquibase initialization when running multiple replicas +> my SQL-based microservice is stuck during Liquibase initialization when running multiple replicas Sometimes the database changelog lock gets corrupted. You will need to connect to the database using `kubectl exec -it` and remove all lines of liquibases `databasechangeloglock` table. From cdbdbe850df1a1505a585ae6814ccf6168b1a58a Mon Sep 17 00:00:00 2001 From: bailm Date: Fri, 1 Feb 2019 00:34:28 +0800 Subject: [PATCH 143/444] Enhancement for language under Oauth fix the DI issue in https://github.com/jhipster/generator-jhipster/issues/8761 --- .../auth-expired.interceptor.ts.ejs | 6 ++---- .../app/core/auth/account.service.ts.ejs | 6 +++--- .../app/core/login/login.service.ts.ejs | 21 ++++++------------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/auth-expired.interceptor.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/auth-expired.interceptor.ts.ejs index 598685a1dc04..232b18626426 100644 --- a/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/auth-expired.interceptor.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/blocks/interceptor/auth-expired.interceptor.ts.ejs @@ -25,7 +25,6 @@ import { tap } from 'rxjs/operators'; import { Router } from '@angular/router'; import { LoginModalService } from 'app/core/login/login-modal.service'; -import { AccountService } from 'app/core/auth/account.service'; <%_ } _%> import { LoginService } from 'app/core/login/login.service'; <%_ } _%> @@ -49,7 +48,6 @@ export class AuthExpiredInterceptor implements HttpInterceptor { <%_ if (['oauth2', 'jwt', 'uaa'].includes(authenticationType)) { _%> <%_ if (authenticationType === 'uaa') { _%> private loginModalService: LoginModalService, - private accountService: AccountService, private router: Router, <%_ } _%> <%_ if (authenticationType === 'oauth2') { _%> @@ -67,8 +65,8 @@ export class AuthExpiredInterceptor implements HttpInterceptor { <%_ if (authenticationType === 'jwt') { _%> this.loginService.logout(); <% } if (authenticationType === 'uaa') { %> - if (this.accountService.isAuthenticated()) { - this.accountService.authenticate(null); + if (this.loginService.isAuthenticated()) { + this.loginService.logoutDirectly(); this.loginModalService.open(); } else { this.loginService.logout(); diff --git a/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs index 07f7109d278e..4e8048710635 100644 --- a/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/core/auth/account.service.ts.ejs @@ -17,7 +17,7 @@ limitations under the License. -%> import { Injectable } from '@angular/core'; -<%_ if (enableTranslation && authenticationType !== 'oauth2' && authenticationType !== 'uaa') { _%> +<%_ if (enableTranslation) { _%> import { JhiLanguageService } from 'ng-jhipster'; import { SessionStorageService } from 'ngx-webstorage'; <%_ } _%> @@ -38,7 +38,7 @@ export class AccountService { constructor( - <%_ if (enableTranslation && authenticationType !== 'oauth2' && authenticationType !== 'uaa') { _%> + <%_ if (enableTranslation) { _%> private languageService: JhiLanguageService, private sessionStorage: SessionStorageService, <%_ } _%> @@ -105,7 +105,7 @@ export class AccountService { <%_ if (websocket === 'spring-websocket') { _%> this.trackerService.connect(); <%_ } _%> - <%_ if (enableTranslation && authenticationType !== 'oauth2' && authenticationType !== 'uaa') { _%> + <%_ if (enableTranslation) { _%> // After retrieve the account info, the language will be changed to // the user's preferred language configured in the account setting const langKey = this.sessionStorage.retrieve('locale') || this.userIdentity.langKey; diff --git a/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs index bf154d6bf174..e83c5f891641 100644 --- a/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs @@ -18,11 +18,6 @@ -%> import { Injectable } from '@angular/core'; -<%_ if (enableTranslation && authenticationType === 'uaa') { _%> -import { JhiLanguageService } from 'ng-jhipster'; -import { SessionStorageService } from 'ngx-webstorage'; -import { IUser } from 'app/core/user/user.model'; -<%_ } _%> import { AccountService } from 'app/core/auth/account.service'; <%_ if (authenticationType === 'jwt' || authenticationType === 'uaa') { _%> import { AuthServerProvider } from 'app/core/auth/auth-jwt.service'; @@ -41,10 +36,6 @@ export class LoginService { <%_ if (websocket === 'spring-websocket') { _%> private trackerService: <%=jhiPrefixCapitalized%>TrackerService, <%_ } _%> - <%_ if (enableTranslation && authenticationType === 'uaa') { _%> - private languageService: JhiLanguageService, - private sessionStorage: SessionStorageService, - <%_ } _%> private authServerProvider: AuthServerProvider ) {} @@ -63,9 +54,6 @@ export class LoginService { <%_ if (websocket === 'spring-websocket') { _%> this.trackerService.sendActivity(); <%_ } _%> - <%_ if (enableTranslation && authenticationType === 'uaa') { _%> - this.setPreferredLanguage(account); - <%_ } _%> resolve(data); }); return cb(); @@ -85,9 +73,12 @@ export class LoginService { <%_ } _%> <%_ if (enableTranslation && authenticationType === 'uaa') { _%> - setPreferredLanguage(account: IUser) { - const langKey = account.langKey || this.sessionStorage.retrieve('locale'); - this.languageService.changeLanguage(langKey); + isAuthenticated() { + return this.accountService.isAuthenticated(); + } + + logoutDirectly() { + this.accountService.authenticate(null); } <%_ } _%> From c369e338926a95d3824660fc3d1a215cf21c9aa0 Mon Sep 17 00:00:00 2001 From: bailm Date: Fri, 1 Feb 2019 06:52:03 +0800 Subject: [PATCH 144/444] update test case --- .../spec/app/core/user/account.service.spec.ts.ejs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs b/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs index 3c4e2a60ebc3..bf724179ba7b 100644 --- a/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs +++ b/generators/client/templates/angular/src/test/javascript/spec/app/core/user/account.service.spec.ts.ejs @@ -3,12 +3,12 @@ import { TestBed } from '@angular/core/testing'; import { SERVER_API_URL } from 'app/app.constants'; import { AccountService<% if (websocket === 'spring-websocket') { %>, <%= jhiPrefixCapitalized %>TrackerService <% } %> } from 'app/core'; import { JhiDateUtils -<%_ if (enableTranslation && authenticationType !== 'oauth2') { _%> +<%_ if (enableTranslation) { _%> ,JhiLanguageService <%_ } _%> } from 'ng-jhipster'; import { SessionStorageService } from 'ngx-webstorage'; -<%_ if (enableTranslation && authenticationType !== 'oauth2') { _%> +<%_ if (enableTranslation) { _%> import { MockLanguageService } from '../../../helpers/mock-language.service'; <%_ } _%> <%_ if (websocket === 'spring-websocket') { _%> @@ -26,7 +26,7 @@ describe('Service Tests', () => { providers: [ JhiDateUtils, SessionStorageService, - <%_ if (enableTranslation && authenticationType !== 'oauth2') { _%> + <%_ if (enableTranslation) { _%> { provide: JhiLanguageService, useClass: MockLanguageService From 3bed3dda8f4145aacc54c738f5230be16593ead6 Mon Sep 17 00:00:00 2001 From: DanielFran Date: Thu, 31 Jan 2019 23:11:20 +0000 Subject: [PATCH 145/444] Upgrade sonar-maven-plugin version to 3.6.0.1398 --- generators/server/templates/pom.xml.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index f89b70c1c078..899740443509 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -143,7 +143,7 @@ 0.8.3 1.0.0 3.4.4 - 3.5.0.1254 + 3.6.0.1398 <%_ if (enableSwaggerCodegen) { _%> 3.3.4 <%_ } _%> From e4ef12be56380ec5b80c18731d2d63148187f306 Mon Sep 17 00:00:00 2001 From: Allsimon Date: Wed, 30 Jan 2019 15:41:13 +0100 Subject: [PATCH 146/444] rename integration tests to *IT.java currently JHipster mix unit tests and integration tests, this change allows to run unit test via `mvn test` and unit+integration via `mvn verify` Fixes #8868 --- generators/cleanup.js | 2 +- generators/entity-server/files.js | 4 +- ...est.java.ejs => EntityResourceIT.java.ejs} | 10 +-- generators/server/files.js | 90 +++++++++---------- generators/server/templates/build.gradle.ejs | 4 +- generators/server/templates/pom.xml.ejs | 42 ++++----- ....java.ejs => CassandraKeyspaceIT.java.ejs} | 2 +- ....ejs => CassandraConfigurationIT.java.ejs} | 4 +- ...a.ejs => DatabaseConfigurationIT.java.ejs} | 4 +- ....java.ejs => HibernateTimeZoneIT.java.ejs} | 2 +- ...umberTest.java.ejs => CucumberIT.java.ejs} | 2 +- ... => CustomAuditEventRepositoryIT.java.ejs} | 2 +- ...js => DomainUserDetailsServiceIT.java.ejs} | 2 +- ...ntTest.java.ejs => MailServiceIT.java.ejs} | 2 +- ...ntTest.java.ejs => UserServiceIT.java.ejs} | 2 +- ...perTest.java.ejs => UserMapperIT.java.ejs} | 2 +- ...st.java.ejs => AccountResourceIT.java.ejs} | 4 +- ...Test.java.ejs => AuditResourceIT.java.ejs} | 2 +- ...est.java.ejs => LogoutResourceIT.java.ejs} | 2 +- ...tTest.java.ejs => LogsResourceIT.java.ejs} | 2 +- ....java.ejs => UserJWTControllerIT.java.ejs} | 2 +- ...tTest.java.ejs => UserResourceIT.java.ejs} | 2 +- ...ava.ejs => ExceptionTranslatorIT.java.ejs} | 4 +- generators/spring-controller/index.js | 4 +- ...ceIntTest.java.ejs => ResourceIT.java.ejs} | 2 +- test/spring-controller.spec.js | 4 +- test/utils/expected-files.js | 16 ++-- 27 files changed, 107 insertions(+), 113 deletions(-) rename generators/entity-server/templates/src/test/java/package/web/rest/{EntityResourceIntTest.java.ejs => EntityResourceIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/{CassandraKeyspaceUnitTest.java.ejs => CassandraKeyspaceIT.java.ejs} (95%) rename generators/server/templates/src/test/java/package/config/{CassandraTestConfiguration.java.ejs => CassandraConfigurationIT.java.ejs} (95%) rename generators/server/templates/src/test/java/package/config/{DatabaseTestConfiguration.java.ejs => DatabaseConfigurationIT.java.ejs} (95%) rename generators/server/templates/src/test/java/package/config/timezone/{HibernateTimeZoneTest.java.ejs => HibernateTimeZoneIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/cucumber/{CucumberTest.java.ejs => CucumberIT.java.ejs} (90%) rename generators/server/templates/src/test/java/package/repository/{CustomAuditEventRepositoryIntTest.java.ejs => CustomAuditEventRepositoryIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/security/{DomainUserDetailsServiceIntTest.java.ejs => DomainUserDetailsServiceIT.java.ejs} (98%) rename generators/server/templates/src/test/java/package/service/{MailServiceIntTest.java.ejs => MailServiceIT.java.ejs} (98%) rename generators/server/templates/src/test/java/package/service/{UserServiceIntTest.java.ejs => UserServiceIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/service/mapper/{UserMapperTest.java.ejs => UserMapperIT.java.ejs} (98%) rename generators/server/templates/src/test/java/package/web/rest/{AccountResourceIntTest.java.ejs => AccountResourceIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/web/rest/{AuditResourceIntTest.java.ejs => AuditResourceIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/web/rest/{LogoutResourceIntTest.java.ejs => LogoutResourceIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/web/rest/{LogsResourceIntTest.java.ejs => LogsResourceIT.java.ejs} (97%) rename generators/server/templates/src/test/java/package/web/rest/{UserJWTControllerIntTest.java.ejs => UserJWTControllerIT.java.ejs} (98%) rename generators/server/templates/src/test/java/package/web/rest/{UserResourceIntTest.java.ejs => UserResourceIT.java.ejs} (99%) rename generators/server/templates/src/test/java/package/web/rest/errors/{ExceptionTranslatorIntTest.java.ejs => ExceptionTranslatorIT.java.ejs} (98%) rename generators/spring-controller/templates/src/test/java/package/web/rest/{ResourceIntTest.java.ejs => ResourceIT.java.ejs} (98%) diff --git a/generators/cleanup.js b/generators/cleanup.js index 9a24a4ea5e8a..9b0599a0a8f4 100644 --- a/generators/cleanup.js +++ b/generators/cleanup.js @@ -157,7 +157,7 @@ function cleanupOldServerFiles(generator, javaDir, testDir, mainResourceDir, tes generator.removeFile(`${mainResourceDir}mails/passwordResetEmail.html`); generator.removeFile(`${mainResourceDir}mails/socialRegistrationValidationEmail.html`); generator.removeFile(`${testResourceDir}mail/testEmail.html`); - generator.removeFile(`${testDir}web/rest/ProfileInfoResourceIntTest.java`); + generator.removeFile(`${testDir}web/rest/ProfileInfoResourceIT.java`); generator.removeFile('gradle/mapstruct.gradle'); } if (generator.isJhipsterVersionLessThan('5.2.2')) { diff --git a/generators/entity-server/files.js b/generators/entity-server/files.js index e214ab01ef65..31ed6985cfdf 100644 --- a/generators/entity-server/files.js +++ b/generators/entity-server/files.js @@ -174,7 +174,7 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/web/rest/EntityResourceIntTest.java', + file: 'package/web/rest/EntityResourceIT.java', options: { context: { randexp, @@ -184,7 +184,7 @@ const serverFiles = { SERVER_TEST_SRC_DIR } }, - renameTo: generator => `${generator.packageFolder}/web/rest/${generator.entityClass}ResourceIntTest.java` + renameTo: generator => `${generator.packageFolder}/web/rest/${generator.entityClass}ResourceIT.java` } ] }, diff --git a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIntTest.java.ejs b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs similarity index 99% rename from generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIntTest.java.ejs rename to generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs index 13b79bbc5ffe..553dcac645da 100644 --- a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIntTest.java.ejs +++ b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs @@ -150,11 +150,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. <%_ } else { _%> @SpringBootTest(classes = <%= mainClass %>.class) <%_ } _%> -public class <%= entityClass %>ResourceIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ <%_ let oldSource = ''; try { - oldSource = this.fs.readFileSync(this.SERVER_TEST_SRC_DIR + packageFolder + '/web/rest/' + entityClass + 'ResourceIntTest.java', 'utf8'); + oldSource = this.fs.readFileSync(this.SERVER_TEST_SRC_DIR + packageFolder + '/web/rest/' + entityClass + 'ResourceIT.java', 'utf8'); } catch (e) {} _%> <%_ for (idx in fields) { @@ -245,7 +245,7 @@ _%> updatedTextString = updatedTextString + "B"; log(this.chalkRed('Randomly generated first and second test values for entity "' + entityClass + '" field "' + fields[idx].fieldName + '" with pattern "' + fields[idx].fieldValidateRulesPattern + - '" in file "' + entityClass + 'ResourceIntTest" where equal, added symbol "B" to second value.')); + '" in file "' + entityClass + 'ResourceIT" where equal, added symbol "B" to second value.')); } }_%> @@ -428,7 +428,7 @@ _%> if ((relationshipValidate !== null && relationshipValidate === true) || mapsIdUse === true) { _%> // Add required entity <%_ if (alreadyGeneratedEntities.indexOf(otherEntityName) == -1) { _%> - <%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIntTest.createEntity(<% if (databaseType === 'sql') { %>em<% } %>); + <%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIT.createEntity(<% if (databaseType === 'sql') { %>em<% } %>); <%_ if (databaseType === 'sql') { _%> em.persist(<%= otherEntityName %>); em.flush(); @@ -734,7 +734,7 @@ _%> @Transactional<% } %> public void getAll<%= entityClassPlural %>By<%= relationship.relationshipNameCapitalized %>IsEqualToSomething() throws Exception { // Initialize the database - <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIntTest.createEntity(em); + <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIT.createEntity(em); em.persist(<%= relationship.relationshipFieldName %>); em.flush(); <%_ if (relationship.relationshipType === 'many-to-many' || relationship.relationshipType === 'one-to-many') { _%> diff --git a/generators/server/files.js b/generators/server/files.js index d18e4befd631..7edff467d568 100644 --- a/generators/server/files.js +++ b/generators/server/files.js @@ -1162,13 +1162,13 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/CassandraKeyspaceUnitTest.java', - renameTo: generator => `${generator.testDir}CassandraKeyspaceUnitTest.java` + file: 'package/CassandraKeyspaceIT.java', + renameTo: generator => `${generator.testDir}CassandraKeyspaceIT.java` }, { file: 'package/AbstractCassandraTest.java', renameTo: generator => `${generator.testDir}AbstractCassandraTest.java` }, { - file: 'package/config/CassandraTestConfiguration.java', - renameTo: generator => `${generator.testDir}config/CassandraTestConfiguration.java` + file: 'package/config/CassandraConfigurationIT.java', + renameTo: generator => `${generator.testDir}config/CassandraConfigurationIT.java` } ] }, @@ -1182,8 +1182,8 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/config/DatabaseTestConfiguration.java', - renameTo: generator => `${generator.testDir}config/DatabaseTestConfiguration.java` + file: 'package/config/DatabaseConfigurationIT.java', + renameTo: generator => `${generator.testDir}config/DatabaseConfigurationIT.java` } ] }, @@ -1192,12 +1192,12 @@ const serverFiles = { templates: [ { file: 'package/web/rest/TestUtil.java', renameTo: generator => `${generator.testDir}web/rest/TestUtil.java` }, { - file: 'package/web/rest/LogsResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/LogsResourceIntTest.java` + file: 'package/web/rest/LogsResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/LogsResourceIT.java` }, { - file: 'package/web/rest/errors/ExceptionTranslatorIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/errors/ExceptionTranslatorIntTest.java` + file: 'package/web/rest/errors/ExceptionTranslatorIT.java', + renameTo: generator => `${generator.testDir}web/rest/errors/ExceptionTranslatorIT.java` }, { file: 'package/web/rest/errors/ExceptionTranslatorTestController.java', @@ -1214,8 +1214,8 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/config/timezone/HibernateTimeZoneTest.java', - renameTo: generator => `${generator.testDir}config/timezone/HibernateTimeZoneTest.java` + file: 'package/config/timezone/HibernateTimeZoneIT.java', + renameTo: generator => `${generator.testDir}config/timezone/HibernateTimeZoneIT.java` }, { file: 'package/repository/timezone/DateTimeWrapper.java', @@ -1305,8 +1305,8 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/web/rest/LogoutResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/LogoutResourceIntTest.java` + file: 'package/web/rest/LogoutResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/LogoutResourceIT.java` } ] }, @@ -1332,7 +1332,7 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ // Create Cucumber test files - { file: 'package/cucumber/CucumberTest.java', renameTo: generator => `${generator.testDir}cucumber/CucumberTest.java` }, + { file: 'package/cucumber/CucumberIT.java', renameTo: generator => `${generator.testDir}cucumber/CucumberIT.java` }, { file: 'package/cucumber/stepdefs/StepDefs.java', renameTo: generator => `${generator.testDir}cucumber/stepdefs/StepDefs.java` @@ -1350,8 +1350,8 @@ const serverFiles = { templates: [ // Create auth config test files { - file: 'package/security/DomainUserDetailsServiceIntTest.java', - renameTo: generator => `${generator.testDir}security/DomainUserDetailsServiceIntTest.java` + file: 'package/security/DomainUserDetailsServiceIT.java', + renameTo: generator => `${generator.testDir}security/DomainUserDetailsServiceIT.java` } ] } @@ -1435,16 +1435,16 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/service/UserServiceIntTest.java', - renameTo: generator => `${generator.testDir}service/UserServiceIntTest.java` + file: 'package/service/UserServiceIT.java', + renameTo: generator => `${generator.testDir}service/UserServiceIT.java` }, { - file: 'package/service/mapper/UserMapperTest.java', - renameTo: generator => `${generator.testDir}service/mapper/UserMapperTest.java` + file: 'package/service/mapper/UserMapperIT.java', + renameTo: generator => `${generator.testDir}service/mapper/UserMapperIT.java` }, { - file: 'package/web/rest/UserResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/UserResourceIntTest.java` + file: 'package/web/rest/UserResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/UserResourceIT.java` } ] }, @@ -1456,8 +1456,8 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/web/rest/AccountResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/AccountResourceIntTest.java` + file: 'package/web/rest/AccountResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/AccountResourceIT.java` } ] }, @@ -1517,12 +1517,12 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/repository/CustomAuditEventRepositoryIntTest.java', - renameTo: generator => `${generator.testDir}repository/CustomAuditEventRepositoryIntTest.java` + file: 'package/repository/CustomAuditEventRepositoryIT.java', + renameTo: generator => `${generator.testDir}repository/CustomAuditEventRepositoryIT.java` }, { - file: 'package/web/rest/AuditResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/AuditResourceIntTest.java` + file: 'package/web/rest/AuditResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/AuditResourceIT.java` } ] }, @@ -1652,8 +1652,8 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/web/rest/UserJWTControllerIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/UserJWTControllerIntTest.java` + file: 'package/web/rest/UserJWTControllerIT.java', + renameTo: generator => `${generator.testDir}web/rest/UserJWTControllerIT.java` } ] }, @@ -1664,8 +1664,8 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/web/rest/AuditResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/AuditResourceIntTest.java` + file: 'package/web/rest/AuditResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/AuditResourceIT.java` } ] }, @@ -1674,8 +1674,8 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/repository/CustomAuditEventRepositoryIntTest.java', - renameTo: generator => `${generator.testDir}repository/CustomAuditEventRepositoryIntTest.java` + file: 'package/repository/CustomAuditEventRepositoryIT.java', + renameTo: generator => `${generator.testDir}repository/CustomAuditEventRepositoryIT.java` } ] }, @@ -1704,24 +1704,24 @@ const serverFiles = { path: SERVER_TEST_SRC_DIR, templates: [ { - file: 'package/service/MailServiceIntTest.java', - renameTo: generator => `${generator.testDir}service/MailServiceIntTest.java` + file: 'package/service/MailServiceIT.java', + renameTo: generator => `${generator.testDir}service/MailServiceIT.java` }, { - file: 'package/service/UserServiceIntTest.java', - renameTo: generator => `${generator.testDir}service/UserServiceIntTest.java` + file: 'package/service/UserServiceIT.java', + renameTo: generator => `${generator.testDir}service/UserServiceIT.java` }, { - file: 'package/service/mapper/UserMapperTest.java', - renameTo: generator => `${generator.testDir}service/mapper/UserMapperTest.java` + file: 'package/service/mapper/UserMapperIT.java', + renameTo: generator => `${generator.testDir}service/mapper/UserMapperIT.java` }, { - file: 'package/web/rest/AccountResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/AccountResourceIntTest.java` + file: 'package/web/rest/AccountResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/AccountResourceIT.java` }, { - file: 'package/web/rest/UserResourceIntTest.java', - renameTo: generator => `${generator.testDir}web/rest/UserResourceIntTest.java` + file: 'package/web/rest/UserResourceIT.java', + renameTo: generator => `${generator.testDir}web/rest/UserResourceIT.java` } ] } diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs index c142cbeed266..7c602f499593 100644 --- a/generators/server/templates/build.gradle.ejs +++ b/generators/server/templates/build.gradle.ejs @@ -127,7 +127,7 @@ if (OperatingSystem.current().isWindows()) { } test { - exclude '**/CucumberTest*' + exclude '**/*CucumberIT*' // uncomment if the tests reports are not generated // see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484 @@ -139,7 +139,7 @@ test { task cucumberTest(type: Test) { description = "Execute cucumber BDD tests." group = "verification" - include '**/CucumberTest*' + include '**/*CucumberIT*' // uncomment if the tests reports are not generated // see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484 diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 86f7abf44838..74e2877dc5c3 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -106,6 +106,7 @@ 3.8.0 2.10 3.0.0-M2 + 3.0.0-M3 2.2.1 3.1.0 2.22.1 @@ -786,6 +787,10 @@ org.apache.maven.plugins maven-surefire-plugin + + org.apache.maven.plugins + maven-failsafe-plugin + org.jacoco jacoco-maven-plugin @@ -1082,30 +1087,6 @@ org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} - <%_ if (cucumberTests) { _%> - - - default-test - - - **/Abstract*.java - **/*Cucumber*.java - - - - - without-cucumber - - test - - - - **/*Cucumber*.java - - - - - <%_ } _%> alphabetical @@ -1115,6 +1096,19 @@ ${sonar.junit.reportsPath} + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven-failsafe-plugin.version} + + + + integration-test + verify + + + + org.apache.maven.plugins maven-war-plugin diff --git a/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs b/generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs similarity index 95% rename from generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs rename to generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs index 3c9103e3061d..e2bc9a09fdcd 100644 --- a/generators/server/templates/src/test/java/package/CassandraKeyspaceUnitTest.java.ejs +++ b/generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class CassandraKeyspaceUnitTest extends AbstractCassandraTest { +public class CassandraKeyspaceIT extends AbstractCassandraTest { protected final Logger log = LoggerFactory.getLogger(this.getClass().getCanonicalName()); diff --git a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs b/generators/server/templates/src/test/java/package/config/CassandraConfigurationIT.java.ejs similarity index 95% rename from generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs rename to generators/server/templates/src/test/java/package/config/CassandraConfigurationIT.java.ejs index 5726f7d6ac55..9595fc3ce218 100644 --- a/generators/server/templates/src/test/java/package/config/CassandraTestConfiguration.java.ejs +++ b/generators/server/templates/src/test/java/package/config/CassandraConfigurationIT.java.ejs @@ -31,9 +31,9 @@ import org.springframework.context.annotation.Profile; @Configuration @Profile(JHipsterConstants.SPRING_PROFILE_TEST) -public class CassandraTestConfiguration extends CassandraConfiguration { +public class CassandraConfigurationIT extends CassandraConfiguration { - private final Logger log = LoggerFactory.getLogger(CassandraTestConfiguration.class); + private final Logger log = LoggerFactory.getLogger(CassandraConfigurationIT.class); /** * Override how to get the port to connect to the Cassandra cluster diff --git a/generators/server/templates/src/test/java/package/config/DatabaseTestConfiguration.java.ejs b/generators/server/templates/src/test/java/package/config/DatabaseConfigurationIT.java.ejs similarity index 95% rename from generators/server/templates/src/test/java/package/config/DatabaseTestConfiguration.java.ejs rename to generators/server/templates/src/test/java/package/config/DatabaseConfigurationIT.java.ejs index 81e0d8923899..30e14c38dfdb 100644 --- a/generators/server/templates/src/test/java/package/config/DatabaseTestConfiguration.java.ejs +++ b/generators/server/templates/src/test/java/package/config/DatabaseConfigurationIT.java.ejs @@ -34,13 +34,13 @@ import org.testcontainers.couchbase.CouchbaseContainer; import java.util.List; @Configuration -public class DatabaseTestConfiguration extends AbstractCouchbaseConfiguration { +public class DatabaseConfigurationIT extends AbstractCouchbaseConfiguration { private CouchbaseProperties couchbaseProperties; private static CouchbaseContainer> couchbaseContainer; - public DatabaseTestConfiguration(CouchbaseProperties couchbaseProperties) { + public DatabaseConfigurationIT(CouchbaseProperties couchbaseProperties) { this.couchbaseProperties = couchbaseProperties; } diff --git a/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneTest.java.ejs b/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneIT.java.ejs similarity index 99% rename from generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneTest.java.ejs rename to generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneIT.java.ejs index 6040123ae512..538543a67483 100644 --- a/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneTest.java.ejs +++ b/generators/server/templates/src/test/java/package/config/timezone/HibernateTimeZoneIT.java.ejs @@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat; <%_ } else { _%> @SpringBootTest(classes = <%= mainClass %>.class) <%_ } _%> -public class HibernateTimeZoneTest { +public class HibernateTimeZoneIT { @Autowired private DateTimeWrapperRepository dateTimeWrapperRepository; diff --git a/generators/server/templates/src/test/java/package/cucumber/CucumberTest.java.ejs b/generators/server/templates/src/test/java/package/cucumber/CucumberIT.java.ejs similarity index 90% rename from generators/server/templates/src/test/java/package/cucumber/CucumberTest.java.ejs rename to generators/server/templates/src/test/java/package/cucumber/CucumberIT.java.ejs index 904c21d95c49..3a28c309e919 100644 --- a/generators/server/templates/src/test/java/package/cucumber/CucumberTest.java.ejs +++ b/generators/server/templates/src/test/java/package/cucumber/CucumberIT.java.ejs @@ -27,6 +27,6 @@ import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(plugin = "pretty", features = "<%= TEST_DIR %>features") -public class CucumberTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest<% } %> { +public class CucumberIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest<% } %> { } diff --git a/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIntTest.java.ejs b/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIT.java.ejs similarity index 99% rename from generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIntTest.java.ejs rename to generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIT.java.ejs index 2ed29a125bbb..52c02cf50fe9 100644 --- a/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/repository/CustomAuditEventRepositoryIT.java.ejs @@ -54,7 +54,7 @@ import static <%=packageName%>.repository.CustomAuditEventRepository.EVENT_DATA_ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class)<% if (databaseType === 'sql') { %> @Transactional<% } %> -public class CustomAuditEventRepositoryIntTest { +public class CustomAuditEventRepositoryIT { @Autowired private PersistenceAuditEventRepository persistenceAuditEventRepository; diff --git a/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIntTest.java.ejs b/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs similarity index 98% rename from generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs index 233105036369..9ff88f43ed46 100644 --- a/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs @@ -69,7 +69,7 @@ import static org.assertj.core.api.Assertions.assertThat; <%_ if (databaseType === 'couchbase') { _%> @WithMockUser("test-user-one") <%_ } _%> -public class DomainUserDetailsServiceIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class DomainUserDetailsServiceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ private static final String USER_ONE_LOGIN = "test-user-one"; private static final String USER_ONE_EMAIL = "test-user-one@localhost"; diff --git a/generators/server/templates/src/test/java/package/service/MailServiceIntTest.java.ejs b/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs similarity index 98% rename from generators/server/templates/src/test/java/package/service/MailServiceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs index ffd0b3a79a21..76e465213640 100644 --- a/generators/server/templates/src/test/java/package/service/MailServiceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs @@ -50,7 +50,7 @@ import static org.mockito.Mockito.*; @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class MailServiceIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class MailServiceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ @Autowired private JHipsterProperties jHipsterProperties; diff --git a/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs b/generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs similarity index 99% rename from generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs index 5b9830f32d21..ac5215cfcfb0 100644 --- a/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs @@ -126,7 +126,7 @@ import static org.mockito.Mockito.when; @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class)<% if (databaseType === 'sql') { %> @Transactional<% } %> -public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class UserServiceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ <%_ if ((databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') && authenticationType === 'session') { _%> @Autowired diff --git a/generators/server/templates/src/test/java/package/service/mapper/UserMapperTest.java.ejs b/generators/server/templates/src/test/java/package/service/mapper/UserMapperIT.java.ejs similarity index 98% rename from generators/server/templates/src/test/java/package/service/mapper/UserMapperTest.java.ejs rename to generators/server/templates/src/test/java/package/service/mapper/UserMapperIT.java.ejs index a4f3176f67ce..f11d9bc32d46 100644 --- a/generators/server/templates/src/test/java/package/service/mapper/UserMapperTest.java.ejs +++ b/generators/server/templates/src/test/java/package/service/mapper/UserMapperIT.java.ejs @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class UserMapperIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ private static final String DEFAULT_LOGIN = "johndoe"; diff --git a/generators/server/templates/src/test/java/package/web/rest/AccountResourceIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs similarity index 99% rename from generators/server/templates/src/test/java/package/web/rest/AccountResourceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs index b75b825a1b6f..1a8909d979c1 100644 --- a/generators/server/templates/src/test/java/package/web/rest/AccountResourceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs @@ -61,7 +61,7 @@ import org.springframework.web.context.WebApplicationContext; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class AccountResourceIntTest<% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class AccountResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ @Autowired private UserRepository userRepository; @@ -248,7 +248,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class AccountResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ @Autowired private UserRepository userRepository; diff --git a/generators/server/templates/src/test/java/package/web/rest/AuditResourceIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/AuditResourceIT.java.ejs similarity index 99% rename from generators/server/templates/src/test/java/package/web/rest/AuditResourceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/web/rest/AuditResourceIT.java.ejs index ce06dbe49430..199e84a731a4 100644 --- a/generators/server/templates/src/test/java/package/web/rest/AuditResourceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/AuditResourceIT.java.ejs @@ -56,7 +56,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class)<% if (databaseType === 'sql') { %> @Transactional<% } %> -public class AuditResourceIntTest { +public class AuditResourceIT { private static final String SAMPLE_PRINCIPAL = "SAMPLE_PRINCIPAL"; private static final String SAMPLE_TYPE = "SAMPLE_TYPE"; diff --git a/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIT.java.ejs similarity index 99% rename from generators/server/templates/src/test/java/package/web/rest/LogoutResourceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/web/rest/LogoutResourceIT.java.ejs index 375fceaf6751..fd18547ad4dc 100644 --- a/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/LogoutResourceIT.java.ejs @@ -49,7 +49,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class LogoutResourceIntTest { +public class LogoutResourceIT { @Autowired private MappingJackson2HttpMessageConverter jacksonMessageConverter; diff --git a/generators/server/templates/src/test/java/package/web/rest/LogsResourceIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/LogsResourceIT.java.ejs similarity index 97% rename from generators/server/templates/src/test/java/package/web/rest/LogsResourceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/web/rest/LogsResourceIT.java.ejs index ab7fce3df700..77674cc15c13 100644 --- a/generators/server/templates/src/test/java/package/web/rest/LogsResourceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/LogsResourceIT.java.ejs @@ -61,7 +61,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. <%_ } else { _%> @SpringBootTest(classes = <%= mainClass %>.class) <%_ } _%> -public class LogsResourceIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class LogsResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ <%_ if (reactive) { _%> private WebTestClient webTestClient; diff --git a/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs similarity index 98% rename from generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIntTest.java.ejs rename to generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs index be5f90d46075..c15848f864c0 100644 --- a/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs @@ -65,7 +65,7 @@ import static org.hamcrest.Matchers.not; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class UserJWTControllerIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class UserJWTControllerIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ @Autowired private TokenProvider tokenProvider; diff --git a/generators/server/templates/src/test/java/package/web/rest/UserResourceIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs similarity index 99% rename from generators/server/templates/src/test/java/package/web/rest/UserResourceIntTest.java.ejs rename to generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs index 069155524da6..e39cd1297d27 100644 --- a/generators/server/templates/src/test/java/package/web/rest/UserResourceIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs @@ -106,7 +106,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class UserResourceIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ private static final String DEFAULT_LOGIN = "johndoe"; <%_ if (authenticationType !== 'oauth2') { _%> diff --git a/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs similarity index 98% rename from generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs rename to generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs index 60305fa3a794..aeee310b3c6c 100644 --- a/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIntTest.java.ejs +++ b/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs @@ -54,7 +54,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. <%_ } else { _%> @SpringBootTest(classes = <%= mainClass %>.class) <%_ } _%> -public class ExceptionTranslatorIntTest <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ +public class ExceptionTranslatorIT <% if (databaseType === 'cassandra') { %>extends AbstractCassandraTest <% } %>{ @Autowired private ExceptionTranslatorTestController controller; @@ -199,7 +199,7 @@ import java.util.List; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class ExceptionTranslatorIntTest { +public class ExceptionTranslatorIT { @Autowired private ExceptionTranslatorTestController controller; diff --git a/generators/spring-controller/index.js b/generators/spring-controller/index.js index c31c7e4d20c0..8feb88c0a787 100644 --- a/generators/spring-controller/index.js +++ b/generators/spring-controller/index.js @@ -166,8 +166,8 @@ module.exports = class extends BaseBlueprintGenerator { this.template( `${this.fetchFromInstalledJHipster( 'spring-controller/templates' - )}/${SERVER_TEST_SRC_DIR}package/web/rest/ResourceIntTest.java.ejs`, - `${SERVER_TEST_SRC_DIR}${this.packageFolder}/web/rest/${this.controllerClass}IntTest.java` + )}/${SERVER_TEST_SRC_DIR}package/web/rest/ResourceIT.java.ejs`, + `${SERVER_TEST_SRC_DIR}${this.packageFolder}/web/rest/${this.controllerClass}IT.java` ); } }; diff --git a/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIntTest.java.ejs b/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs similarity index 98% rename from generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIntTest.java.ejs rename to generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs index 1d5f6267ea29..339915eb2160 100644 --- a/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIntTest.java.ejs +++ b/generators/spring-controller/templates/src/test/java/package/web/rest/ResourceIT.java.ejs @@ -39,7 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = <%= mainClass %>.class) -public class <%= controllerClass %>IntTest { +public class <%= controllerClass %>IT { private MockMvc restMockMvc; diff --git a/test/spring-controller.spec.js b/test/spring-controller.spec.js index 5d3550e9a14e..063eeb19f64c 100644 --- a/test/spring-controller.spec.js +++ b/test/spring-controller.spec.js @@ -25,7 +25,7 @@ describe('JHipster generator spring-controller', () => { it('creates controller files', () => { assert.file([`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/FooResource.java`]); - assert.file([`${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/FooResourceIntTest.java`]); + assert.file([`${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/FooResourceIT.java`]); }); }); @@ -44,7 +44,7 @@ describe('JHipster generator spring-controller', () => { it('creates controller files', () => { assert.file([`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/FooResource.java`]); - assert.file([`${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/FooResourceIntTest.java`]); + assert.file([`${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/FooResourceIT.java`]); }); }); }); diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js index 564a2c80fab0..f50c633f8e99 100644 --- a/test/utils/expected-files.js +++ b/test/utils/expected-files.js @@ -125,7 +125,7 @@ const expectedFiles = { `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/FooRepository.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/FooResource.java`, // SERVER_MAIN_RES_DIR + 'config/liquibase/changelog/20160120213555_added_entity_Foo.xml', - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/FooResourceIntTest.java` + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/FooResourceIT.java` ], gatling: [`${TEST_DIR}gatling/user-files/simulations/FooGatlingTest.scala`] }, @@ -201,7 +201,7 @@ const expectedFiles = { `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/package-info.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/LogsResource.java`, `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/security/SecurityUtilsUnitTest.java`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/LogsResourceIntTest.java`, + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/LogsResourceIT.java`, `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/TestUtil.java`, `${SERVER_TEST_RES_DIR}config/application.yml`, `${SERVER_TEST_RES_DIR}logback.xml` @@ -234,10 +234,10 @@ const expectedFiles = { `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/UserResource.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/vm/KeyAndPasswordVM.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/vm/ManagedUserVM.java`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/AccountResourceIntTest.java`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/AuditResourceIntTest.java`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/UserResourceIntTest.java`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/service/UserServiceIntTest.java` + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/AccountResourceIT.java`, + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/AuditResourceIT.java`, + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/UserResourceIT.java`, + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/service/UserServiceIT.java` ], infinispan: [`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheFactoryConfiguration.java`], @@ -642,7 +642,7 @@ const expectedFiles = { couchbase: [ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/N1qlCouchbaseRepository.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/CustomN1qlCouchbaseRepository.java`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/config/DatabaseTestConfiguration.java`, + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/config/DatabaseConfigurationIT.java`, `${SERVER_MAIN_RES_DIR}config/couchmove/changelog/V0__create_indexes.n1ql`, `${SERVER_MAIN_RES_DIR}config/couchmove/changelog/V0.1__initial_setup/ROLE_ADMIN.json`, `${SERVER_MAIN_RES_DIR}config/couchmove/changelog/V0.1__initial_setup/ROLE_USER.json`, @@ -682,7 +682,7 @@ const expectedFiles = { `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/cucumber/CucumberContextConfiguration.java`, `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/cucumber/stepdefs/UserStepDefs.java`, `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/cucumber/stepdefs/StepDefs.java`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/cucumber/CucumberTest.java` + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/cucumber/CucumberIT.java` ], eureka: [ From 5851d26cd40712f78fe24d600f6298fdc504492c Mon Sep 17 00:00:00 2001 From: Massimo Siani Date: Thu, 31 Jan 2019 20:23:16 +0100 Subject: [PATCH 147/444] fix the newline in the service implementation --- .../main/java/package/service/impl/EntityServiceImpl.java.ejs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs b/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs index bd80d34e89e6..2a877e54bbee 100644 --- a/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs @@ -186,7 +186,8 @@ public class <%= serviceClassName %><% if (service === 'serviceImpl') { %> imple @Override <%_ } _%> public void delete(<%= pkType %> id) { - log.debug("Request to delete <%= entityClass %> : {}", id);<%- include('../../common/delete_template', {viaService: viaService}); -%> + log.debug("Request to delete <%= entityClass %> : {}", id); +<%- include('../../common/delete_template', {viaService: viaService}); -%> } <%_ if (searchEngine === 'elasticsearch') { _%> From 00a2674cab48c5cbe07a061bfc257d964d05cea0 Mon Sep 17 00:00:00 2001 From: charliemordant Date: Tue, 29 Jan 2019 21:07:41 +0100 Subject: [PATCH 148/444] Use Angular reactive forms --- .../password-reset-finish.component.html.ejs | 30 +-- .../password-reset-finish.component.ts.ejs | 22 +- .../password-reset-init.component.html.ejs | 16 +- .../init/password-reset-init.component.ts.ejs | 19 +- .../password/password.component.html.ejs | 43 ++- .../password/password.component.ts.ejs | 17 +- .../register/register.component.html.ejs | 58 ++--- .../register/register.component.ts.ejs | 40 ++- .../settings/settings.component.html.ejs | 36 +-- .../settings/settings.component.ts.ejs | 29 ++- .../user-management-update.component.html.ejs | 53 ++-- .../user-management-update.component.ts.ejs | 38 ++- .../app/shared/login/login.component.html.ejs | 6 +- .../app/shared/login/login.component.ts.ejs | 27 +- .../app/shared/shared-libs.module.ts.ejs | 8 +- ...assword-reset-finish.component.spec.ts.ejs | 23 +- .../password-reset-init.component.spec.ts.ejs | 18 +- .../password/password.component.spec.ts.ejs | 26 +- .../register/register.component.spec.ts.ejs | 33 ++- .../settings/settings.component.spec.ts.ejs | 12 +- ...er-management-update.component.spec.ts.ejs | 2 + .../shared/login/login.component.spec.ts.ejs | 34 ++- ...ntity-management-update.component.html.ejs | 224 ++++++++-------- .../entity-management-update.component.ts.ejs | 244 ++++++++++++++---- ...ty-management-update.component.spec.ts.ejs | 8 +- 25 files changed, 675 insertions(+), 391 deletions(-) diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs index 90e25e669484..1e06b7d36067 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.html.ejs @@ -43,50 +43,50 @@

-
+
- -
+ formControlName="newPassword"> +
+ *ngIf="passwordForm.get(['newPassword']).errors.required" jhiTranslate="global.messages.validate.newpassword.required"> Your password is required. + *ngIf="passwordForm.get(['newPassword']).errors.minlength" jhiTranslate="global.messages.validate.newpassword.minlength"> Your password is required to be at least 4 characters. + *ngIf="passwordForm.get(['newPassword']).errors.maxlength" jhiTranslate="global.messages.validate.newpassword.maxlength"> Your password cannot be longer than 50 characters.
- <<%= jhiPrefixDashed %>-password-strength-bar [passwordToCheck]="resetAccount.password">-password-strength-bar> + <<%= jhiPrefixDashed %>-password-strength-bar [passwordToCheck]="passwordForm.get(['newPassword']).value">-password-strength-bar>
- -
+ formControlName="confirmPassword"> +
+ *ngIf="passwordForm.get(['confirmPassword']).errors.required" jhiTranslate="global.messages.validate.confirmpassword.required"> Your password confirmation is required. + *ngIf="passwordForm.get(['confirmPassword']).errors.minlength" jhiTranslate="global.messages.validate.confirmpassword.minlength"> Your password confirmation is required to be at least 4 characters. + *ngIf="passwordForm.get(['confirmPassword']).errors.maxlength" jhiTranslate="global.messages.validate.confirmpassword.maxlength"> Your password confirmation cannot be longer than 50 characters.
- +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs index 54fe44da3a8c..74ba990a8aaf 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts.ejs @@ -17,9 +17,11 @@ limitations under the License. -%> import { Component, OnInit, AfterViewInit, Renderer, ElementRef } from '@angular/core'; -import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; +import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; + import { LoginModalService } from 'app/core'; import { PasswordResetFinishService } from './password-reset-finish.service'; @@ -28,20 +30,25 @@ import { PasswordResetFinishService } from './password-reset-finish.service'; templateUrl: './password-reset-finish.component.html' }) export class PasswordResetFinishComponent implements OnInit, AfterViewInit { - confirmPassword: string; doNotMatch: string; error: string; keyMissing: boolean; - resetAccount: any; success: string; modalRef: NgbModalRef; key: string; + passwordForm = this.fb.group({ + newPassword: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]], + confirmPassword: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]], + }); + constructor( private passwordResetFinishService: PasswordResetFinishService, private loginModalService: LoginModalService, private route: ActivatedRoute, - private elementRef: ElementRef, private renderer: Renderer + private elementRef: ElementRef, + private renderer: Renderer, + private fb: FormBuilder ) { } @@ -49,7 +56,6 @@ export class PasswordResetFinishComponent implements OnInit, AfterViewInit { this.route.queryParams.subscribe((params) => { this.key = params['key']; }); - this.resetAccount = {}; this.keyMissing = !this.key; } @@ -62,10 +68,12 @@ export class PasswordResetFinishComponent implements OnInit, AfterViewInit { finishReset() { this.doNotMatch = null; this.error = null; - if (this.resetAccount.password !== this.confirmPassword) { + const password = this.passwordForm.get(['newPassword']).value + const confirmPassword = this.passwordForm.get(['confirmPassword']).value + if (password !== confirmPassword) { this.doNotMatch = 'ERROR'; } else { - this.passwordResetFinishService.save({key: this.key, newPassword: this.resetAccount.password}).subscribe(() => { + this.passwordResetFinishService.save({key: this.key, newPassword: password}).subscribe(() => { this.success = 'OK'; }, () => { this.success = null; diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs index 7433d8fca43e..0fb05f6f3717 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html.ejs @@ -33,31 +33,31 @@

Check your emails for details on how to reset your password.

-
+
-
+ formControlName="email"> +
+ *ngIf="resetRequestForm.get(['email']).errors.required" jhiTranslate="global.messages.validate.email.required"> Your email is required. + *ngIf="resetRequestForm.get(['email']).errors.email" jhiTranslate="global.messages.validate.email.invalid"> Your email is invalid. + *ngIf="resetRequestForm.get(['email']).errors.minlength" jhiTranslate="global.messages.validate.email.minlength"> Your email is required to be at least 5 characters. + *ngIf="resetRequestForm.get(['email']).errors.maxlength" jhiTranslate="global.messages.validate.email.maxlength"> Your email cannot be longer than 100 characters.
- +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts.ejs index b613051da13b..3b0cdac39347 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts.ejs @@ -16,7 +16,9 @@ See the License for the specific language governing permissions and limitations under the License. -%> -import { Component, OnInit, AfterViewInit, Renderer, ElementRef } from '@angular/core'; +import { Component, AfterViewInit, Renderer, ElementRef } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; + import { EMAIL_NOT_FOUND_TYPE } from 'app/shared'; import { PasswordResetInitService } from './password-reset-init.service'; @@ -25,23 +27,22 @@ import { PasswordResetInitService } from './password-reset-init.service'; selector: '<%= jhiPrefixDashed %>-password-reset-init', templateUrl: './password-reset-init.component.html' }) -export class PasswordResetInitComponent implements OnInit, AfterViewInit { +export class PasswordResetInitComponent implements AfterViewInit { error: string; errorEmailNotExists: string; - resetAccount: any; success: string; + resetRequestForm = this.fb.group({ + email: ['', [Validators.required, Validators.minLength(5), Validators.maxLength(254), Validators.email]] + }); constructor( private passwordResetInitService: PasswordResetInitService, private elementRef: ElementRef, - private renderer: Renderer + private renderer: Renderer, + private fb: FormBuilder ) { } - ngOnInit() { - this.resetAccount = {}; - } - ngAfterViewInit() { this.renderer.invokeElementMethod(this.elementRef.nativeElement.querySelector('#email'), 'focus', []); } @@ -50,7 +51,7 @@ export class PasswordResetInitComponent implements OnInit, AfterViewInit { this.error = null; this.errorEmailNotExists = null; - this.passwordResetInitService.save(this.resetAccount.email).subscribe(() => { + this.passwordResetInitService.save(this.resetRequestForm.get(['email']).value).subscribe(() => { this.success = 'OK'; }, (response) => { this.success = null; diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs index d12c69970720..82a6039116bf 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.html.ejs @@ -32,63 +32,62 @@ The password and its confirmation do not match! -
+
- -
+ formControlName="currentPassword"> +
+ *ngIf="passwordForm.get(['currentPassword']).errors.required" jhiTranslate="global.messages.validate.newpassword.required"> Your password is required.
- -
+ +
+ *ngIf="passwordForm.get(['newPassword']).errors.required" jhiTranslate="global.messages.validate.newpassword.required"> Your password is required. + *ngIf="passwordForm.get(['newPassword']).errors.minlength" jhiTranslate="global.messages.validate.newpassword.minlength"> Your password is required to be at least 4 characters. + *ngIf="passwordForm.get(['newPassword']).errors.maxlength" jhiTranslate="global.messages.validate.newpassword.maxlength"> Your password cannot be longer than 50 characters.
- <<%= jhiPrefixDashed %>-password-strength-bar [passwordToCheck]="newPassword">-password-strength-bar> + <<%= jhiPrefixDashed %>-password-strength-bar [passwordToCheck]="passwordForm.get(['newPassword']).value">-password-strength-bar>
- -
+ +
+ *ngIf="passwordForm.get(['confirmPassword']).errors.required" jhiTranslate="global.messages.validate.confirmpassword.required"> Your confirmation password is required. + *ngIf="passwordForm.get(['confirmPassword']).errors.minlength" jhiTranslate="global.messages.validate.confirmpassword.minlength"> Your confirmation password is required to be at least 4 characters. + *ngIf="passwordForm.get(['confirmPassword']).errors.maxlength" jhiTranslate="global.messages.validate.confirmpassword.maxlength"> Your confirmation password cannot be longer than 50 characters.
- - +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs index 671411a5298b..aaf39d86a968 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/password/password.component.ts.ejs @@ -17,6 +17,7 @@ limitations under the License. -%> import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { AccountService } from 'app/core'; import { PasswordService } from './password.service'; @@ -30,13 +31,16 @@ export class PasswordComponent implements OnInit { error: string; success: string; account: any; - currentPassword: string; - newPassword: string; - confirmPassword: string; + passwordForm = this.fb.group({ + currentPassword: ['', [Validators.required]], + newPassword: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]], + confirmPassword: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]] + }); constructor( private passwordService: PasswordService, - private accountService: AccountService + private accountService: AccountService, + private fb: FormBuilder ) { } @@ -47,13 +51,14 @@ export class PasswordComponent implements OnInit { } changePassword() { - if (this.newPassword !== this.confirmPassword) { + const newPassword = this.passwordForm.get(['newPassword']).value + if (newPassword !== this.passwordForm.get(['confirmPassword']).value) { this.error = null; this.success = null; this.doNotMatch = 'ERROR'; } else { this.doNotMatch = null; - this.passwordService.save(this.newPassword, this.currentPassword).subscribe(() => { + this.passwordService.save(newPassword, this.passwordForm.get(['currentPassword']).value).subscribe(() => { this.error = null; this.success = 'OK'; }, () => { diff --git a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs index 5d8834220687..e429828e7e9a 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.html.ejs @@ -44,24 +44,24 @@
-
+
- -
- + +
+ Your username is required. - Your username is required to be at least 1 character. - Your username cannot be longer than 50 characters. - Your username can only contain letters and digits. @@ -69,22 +69,22 @@
- -
- +
+ Your email is required. - Your email is invalid. - Your email is required to be at least 5 characters. - Your email cannot be longer than 100 characters. @@ -92,45 +92,45 @@
- -
- +
+ Your password is required. - Your password is required to be at least 4 characters. - Your password cannot be longer than 50 characters.
- <<%= jhiPrefixDashed %>-password-strength-bar [passwordToCheck]="registerAccount.password">-password-strength-bar> + <<%= jhiPrefixDashed %>-password-strength-bar [passwordToCheck]="registerForm.get(['password']).value">-password-strength-bar>
- -
- +
+ Your confirmation password is required. - Your confirmation password is required to be at least 4 characters. - Your confirmation password cannot be longer than 50 characters.
- +

diff --git a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs index ca820c066746..96b654847318 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/register/register.component.ts.ejs @@ -18,6 +18,7 @@ -%> import { Component, OnInit, AfterViewInit, Renderer, ElementRef } from '@angular/core'; import { HttpErrorResponse } from '@angular/common/http'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { JhiLanguageService } from 'ng-jhipster'; @@ -31,27 +32,32 @@ import { Register } from './register.service'; }) export class RegisterComponent implements OnInit, AfterViewInit { - confirmPassword: string; doNotMatch: string; error: string; errorEmailExists: string; errorUserExists: string; - registerAccount: any; success: boolean; modalRef: NgbModalRef; + registerForm = this.fb.group({ + login: ['', [Validators.required, Validators.minLength(1), Validators.maxLength(50), Validators.pattern('^[_.@A-Za-z0-9-]*$')]], + email: ['', [Validators.required, Validators.minLength(5), Validators.maxLength(254), Validators.email]], + password: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]], + confirmPassword: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]] + }); + constructor( private languageService: JhiLanguageService, private loginModalService: LoginModalService, private registerService: Register, private elementRef: ElementRef, - private renderer: Renderer + private renderer: Renderer, + private fb: FormBuilder ) { } ngOnInit() { this.success = false; - this.registerAccount = {}; } ngAfterViewInit() { @@ -59,23 +65,37 @@ export class RegisterComponent implements OnInit, AfterViewInit { } register() { - if (this.registerAccount.password !== this.confirmPassword) { + let registerAccount = {}; + const login = this.registerForm.get(['login']).value; + const email = this.registerForm.get(['email']).value; + const password = this.registerForm.get(['password']).value; + if (password !== this.registerForm.get(['confirmPassword']).value) { this.doNotMatch = 'ERROR'; } else { + registerAccount = {...registerAccount, + login, + email, + password + }; this.doNotMatch = null; this.error = null; this.errorUserExists = null; this.errorEmailExists = null; <%_ if (enableTranslation) { _%> - this.languageService.getCurrent().then((key) => { - this.registerAccount.langKey = key; - this.registerService.save(this.registerAccount).subscribe(() => { + this.languageService.getCurrent().then((langKey) => { + registerAccount = {...registerAccount, + langKey + }; + this.registerService.save(registerAccount).subscribe(() => { this.success = true; }, (response) => this.processError(response)); }); <%_ } else { _%> - this.registerAccount.langKey = 'en'; - this.registerService.save(this.registerAccount).subscribe(() => { + registerAccount = {...registerAccount, + langKey: 'en' + }; + + this.registerService.save(registerAccount).subscribe(() => { this.success = true; }, (response) => this.processError(response)); <%_ } _%> diff --git a/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs index a410133c9a14..a4016b48475e 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.html.ejs @@ -27,23 +27,23 @@ <<%= jhiPrefixDashed %>-alert-error>-alert-error> -
+
-
+ formControlName="firstName"> +
+ *ngIf="settingsForm.get(['firstName']).errors.required" jhiTranslate="settings.messages.validate.firstname.required"> Your first name is required. + *ngIf="settingsForm.get(['firstName']).errors.minlength" jhiTranslate="settings.messages.validate.firstname.minlength"> Your first name is required to be at least 1 character. + *ngIf="settingsForm.get(['firstName']).errors.maxlength" jhiTranslate="settings.messages.validate.firstname.maxlength"> Your first name cannot be longer than 50 characters.
@@ -51,18 +51,18 @@
-
+ formControlName="lastName"> +
+ *ngIf="settingsForm.get(['lastName']).errors.required" jhiTranslate="settings.messages.validate.lastname.required"> Your last name is required. + *ngIf="settingsForm.get(['lastName']).errors.minlength" jhiTranslate="settings.messages.validate.lastname.minlength"> Your last name is required to be at least 1 character. + *ngIf="settingsForm.get(['lastName']).errors.maxlength" jhiTranslate="settings.messages.validate.lastname.maxlength"> Your last name cannot be longer than 50 characters.
@@ -70,22 +70,22 @@
-
+ formControlName="email"> +
+ *ngIf="settingsForm.get(['email']).errors.required" jhiTranslate="global.messages.validate.email.required"> Your email is required. + *ngIf="settingsForm.get(['email']).errors.email" jhiTranslate="global.messages.validate.email.invalid"> Your email is invalid. + *ngIf="settingsForm.get(['email']).errors.minlength" jhiTranslate="global.messages.validate.email.minlength"> Your email is required to be at least 5 characters. + *ngIf="settingsForm.get(['email']).errors.maxlength" jhiTranslate="global.messages.validate.email.maxlength"> Your email cannot be longer than 100 characters.
@@ -98,7 +98,7 @@
<%_ } _%> - +
diff --git a/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.ts.ejs index ed1bfb22e741..c97242ad908c 100644 --- a/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/account/settings/settings.component.ts.ejs @@ -17,6 +17,7 @@ limitations under the License. -%> import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { JhiLanguageService } from 'ng-jhipster'; import { AccountService<% if (enableTranslation) { %>, JhiLanguageHelper<% } %> } from 'app/core'; @@ -30,9 +31,15 @@ export class SettingsComponent implements OnInit { success: string; settingsAccount: any; languages: any[]; + settingsForm = this.fb.group({ + firstName: ['', [Validators.required, Validators.minLength(1), Validators.maxLength(50)]], + lastName: ['', [Validators.required, Validators.minLength(1), Validators.maxLength(50)]], + email: ['', [Validators.required, Validators.minLength(5), Validators.maxLength(254), Validators.email]] + }); constructor( - private accountService: AccountService<% if (enableTranslation) { %>, + private accountService: AccountService, + private fb: FormBuilder<% if (enableTranslation) { %>, private languageService: JhiLanguageService, private languageHelper: JhiLanguageHelper<% } %> ) { @@ -41,20 +48,24 @@ export class SettingsComponent implements OnInit { ngOnInit() { this.accountService.identity().then((account) => { this.settingsAccount = this.copyAccount(account); + this.updateForm(this.settingsAccount); }); <%_ if (enableTranslation) { _%> this.languageHelper.getAll().then((languages) => { this.languages = languages; }); <%_ } _%> + } save() { + this.updateAccount(this.settingsAccount); this.accountService.save(this.settingsAccount).subscribe(() => { this.error = null; this.success = 'OK'; this.accountService.identity(true).then((account) => { this.settingsAccount = this.copyAccount(account); + this.updateForm(account); }); <%_ if (enableTranslation) { _%> this.languageService.getCurrent().then((current) => { @@ -69,7 +80,21 @@ export class SettingsComponent implements OnInit { }); } - copyAccount(account) { + private updateAccount(account) { + account.firstName = this.settingsForm.get(['firstName']).value; + account.lastName = this.settingsForm.get(['lastName']).value; + account.email = this.settingsForm.get(['email']).value; + } + + private updateForm(account): void { + this.settingsForm.patchValue({ + firstName: account.firstName, + lastName: account.lastName, + email: account.email + }); + } + + private copyAccount(account) { return { activated: account.activated, email: account.email, diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.html.ejs index 84adfbee4412..6911b3e3891b 100644 --- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.html.ejs @@ -18,7 +18,7 @@ -%>
-
+

Create or edit a User

@@ -27,40 +27,40 @@
+ [ngModel]="user.id" readonly>
- + -
+
+ *ngIf="editForm.get(['login']).errors.required" jhiTranslate="entity.validation.required"> This field is required. This field cannot be longer than 50 characters. + *ngIf="editForm.get(['login']).errors.pattern" jhiTranslate="entity.validation.patternLogin"> This field can only contain letters, digits and e-mail addresses.
- + -
+
This field cannot be longer than 50 characters. @@ -68,12 +68,12 @@
- + -
+
This field cannot be longer than 50 characters. @@ -81,36 +81,35 @@
- + -
+
+ *ngIf="editForm.get(['email']).errors.required" jhiTranslate="entity.validation.required"> This field is required. This field cannot be longer than 100 characters. This field is required to be at least 5 characters. + *ngIf="editForm.get(['email']).errors.email" jhiTranslate="global.messages.validate.email.invalid"> Your email is invalid.
@@ -118,14 +117,14 @@ <%_ if (enableTranslation) { _%>
-
<%_ } _%>
-
@@ -135,7 +134,7 @@  Cancel -
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.ts.ejs index e5cc3dcbd3c3..917a8faba872 100644 --- a/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.ts.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/admin/user-management/user-management-update.component.ts.ejs @@ -17,6 +17,7 @@ limitations under the License. -%> import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { <% if (enableTranslation) { %>JhiLanguageHelper,<% } %> User, UserService } from 'app/core'; @@ -32,19 +33,31 @@ export class UserMgmtUpdateComponent implements OnInit { authorities: any[]; isSaving: boolean; + editForm = this.fb.group({ + login: ['', [Validators.required, Validators.minLength(1), Validators.maxLength(50), Validators.pattern('^[_.@A-Za-z0-9-]*')]], + firstName: ['', [Validators.maxLength(50)]], + lastName: ['', [Validators.maxLength(50)]], + email: ['', [Validators.minLength(5), Validators.maxLength(254), Validators.email]], + activated: [true], + langKey: [], + authorities: [] + }); + constructor( <%_ if (enableTranslation) { _%> private languageHelper: JhiLanguageHelper, <%_ } _%> private userService: UserService, private route: ActivatedRoute, - private router: Router + private router: Router, + private fb: FormBuilder ) {} ngOnInit() { this.isSaving = false; this.route.data.subscribe(({user}) => { this.user = user.body ? user.body : user; + this.updateForm(this.user); }); this.authorities = []; this.userService.authorities().subscribe((authorities) => { @@ -57,12 +70,25 @@ export class UserMgmtUpdateComponent implements OnInit { <%_ } _%> } + private updateForm(user: User): void { + this.editForm.patchValue({ + login: user.login, + firstName: user.firstName, + lastName: user.lastName, + email: user.email, + activated: user.activated, + langKey: user.langKey, + authorities: user.authorities + }); + } + previousState() { window.history.back(); } save() { this.isSaving = true; + this.updateUser(this.user); if (this.user.id !== null) { this.userService.update(this.user).subscribe((response) => this.onSaveSuccess(response), () => this.onSaveError()); } else {<% if (!enableTranslation) { %> @@ -71,6 +97,16 @@ export class UserMgmtUpdateComponent implements OnInit { } } + private updateUser(user: User): void { + user.login = this.editForm.get(['login']).value; + user.firstName = this.editForm.get(['firstName']).value; + user.lastName = this.editForm.get(['lastName']).value; + user.email = this.editForm.get(['email']).value; + user.activated = this.editForm.get(['activated']).value; + user.langKey = this.editForm.get(['langKey']).value; + user.authorities = this.editForm.get(['authorities']).value; + } + private onSaveSuccess(result) { this.isSaving = false; this.previousState(); diff --git a/generators/client/templates/angular/src/main/webapp/app/shared/login/login.component.html.ejs b/generators/client/templates/angular/src/main/webapp/app/shared/login/login.component.html.ejs index ce91ec9c178f..72243199dd76 100644 --- a/generators/client/templates/angular/src/main/webapp/app/shared/login/login.component.html.ejs +++ b/generators/client/templates/angular/src/main/webapp/app/shared/login/login.component.html.ejs @@ -29,16 +29,16 @@
- +
+ formControlName="username">
+ formControlName="password">