diff --git a/generators/cleanup.js b/generators/cleanup.js index 9d2d8178db9d..880cfcea1b53 100644 --- a/generators/cleanup.js +++ b/generators/cleanup.js @@ -242,6 +242,10 @@ function cleanupOldServerFiles(generator, javaDir, testDir, mainResourceDir, tes generator.removeFile(`${javaDir}config/ReactivePageableHandlerMethodArgumentResolver.java`); generator.removeFile(`${javaDir}config/ReactiveSortHandlerMethodArgumentResolver.java`); } + + if (generator.isJhipsterVersionLessThan('6.10.0')) { + generator.removeFile(`${testDir}config/ElasticsearchTestConfiguration.java`); + } } /** diff --git a/generators/server/files.js b/generators/server/files.js index bba587c80db7..9b3e092653db 100644 --- a/generators/server/files.js +++ b/generators/server/files.js @@ -1119,16 +1119,6 @@ const serverFiles = { }, ], }, - { - condition: generator => generator.searchEngine === 'elasticsearch', - path: SERVER_TEST_SRC_DIR, - templates: [ - { - file: 'package/config/ElasticsearchTestConfiguration.java', - renameTo: generator => `${generator.testDir}config/ElasticsearchTestConfiguration.java`, - }, - ], - }, ], serverJavaDomain: [ { 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 f6ed2029fcc0..1cec5246425e 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 @@ -174,10 +174,9 @@ spring: keyspaceName: <%= baseName %> <%_ } _%> <%_ if (searchEngine === 'elasticsearch') { _%> - elasticsearch: - properties: - path: - home: <%= BUILD_DIR %>elasticsearch + elasticsearch: + rest: + uris: http://localhost:9200 <%_ } _%> <%_ if (databaseType === 'couchbase') { _%> couchbase: diff --git a/generators/server/templates/src/test/java/package/config/ElasticsearchTestConfiguration.java.ejs b/generators/server/templates/src/test/java/package/config/ElasticsearchTestConfiguration.java.ejs deleted file mode 100644 index 4cacbc5e1733..000000000000 --- a/generators/server/templates/src/test/java/package/config/ElasticsearchTestConfiguration.java.ejs +++ /dev/null @@ -1,37 +0,0 @@ -<%# -Copyright 2013-2020 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%>.config; - -import org.assertj.core.util.Files; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -import java.io.File; - -@Configuration -public class ElasticsearchTestConfiguration { - @Autowired - public void elasticsearchProperties(ElasticsearchProperties elasticsearchProperties) { - File tempdir = Files.newTemporaryFolder(); - elasticsearchProperties.getProperties().put("path.home", tempdir.getAbsolutePath()); - } -} 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 020089fc5ee8..6a92dcdfdc85 100644 --- a/generators/server/templates/src/test/resources/config/application.yml.ejs +++ b/generators/server/templates/src/test/resources/config/application.yml.ejs @@ -89,7 +89,7 @@ spring: hibernate.hbm2ddl.auto: validate hibernate.jdbc.time_zone: UTC <%_ } _%> - <%_ if (databaseType === 'mongodb' || databaseType === 'cassandra' || searchEngine === 'elasticsearch') { _%> + <%_ if (databaseType === 'mongodb' || databaseType === 'cassandra') { _%> data: <%_ } _%> <%_ if (databaseType === 'mongodb') { _%> @@ -106,17 +106,6 @@ spring: compression: NONE keyspaceName: cassandra_unit_keyspace <%_ } _%> - <%_ if (searchEngine === 'elasticsearch') { _%> - elasticsearch: - properties: - path: - home: <%= BUILD_DIR %>elasticsearch - <%_ if (cucumberTests) { _%> - # See https://github.com/jhipster/generator-jhipster/issues/10302 - node: - max_local_storage_nodes: 2 - <%_ } _%> - <%_ } _%> <%_ if (databaseType === 'couchbase') { _%> couchbase: bucket: diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js index 6af40c14f931..a4213d498db3 100644 --- a/test/utils/expected-files.js +++ b/test/utils/expected-files.js @@ -768,7 +768,6 @@ const expectedFiles = { elasticsearch: [ `${DOCKER_DIR}elasticsearch.yml`, - `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/config/ElasticsearchTestConfiguration.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/search/UserSearchRepository.java`, `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/repository/search/UserSearchRepositoryMockConfiguration.java`, ],