rawMigrationScripts = migrationScriptReader.read();
if (rawMigrationScripts.size() > getConfig().getHistoryMaxQuerySize()) {
- throw new MigrationException(String.format("configured historyMaxQuerySize of '%s' is to low for the number of migration scripts of '%s'",
+ throw new MigrationException("configured historyMaxQuerySize of '%s' is to low for the number of migration scripts of '%s'".formatted(
getConfig().getHistoryMaxQuerySize(), rawMigrationScripts.size()));
}
@@ -151,7 +151,8 @@ protected MigrationScriptReader createMigrationScriptReader() {
getConfig().getEncoding(),
getConfig().getEsMigrationPrefix(),
getConfig().getEsMigrationSuffixes(),
- getConfig().getLineSeparator());
+ getConfig().getLineSeparator(),
+ getConfig().isTrimTrailingNewlineInMigrations());
}
protected HistoryRepository createHistoryRepository() {
diff --git a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/api/config/ElasticsearchEvolutionConfig.java b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/api/config/ElasticsearchEvolutionConfig.java
index 7983add7..6d93a194 100644
--- a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/api/config/ElasticsearchEvolutionConfig.java
+++ b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/api/config/ElasticsearchEvolutionConfig.java
@@ -41,7 +41,8 @@ public class ElasticsearchEvolutionConfig {
/**
* Line separator, used only temporary between reading raw migration file line-by-line and parsing it later.
- * Only needed for backward compatibility / checksum stability!
+ *
+ * NOTE: Only needed for backward compatibility / checksum stability!
*
* Should be one of
* - '\n' (LF - Linux/Unix/OS X)
@@ -103,6 +104,13 @@ public class ElasticsearchEvolutionConfig {
*/
private boolean validateOnMigrate = true;
+ /**
+ * Whether to remove a trailing newline in migration scripts.
+ *
+ * NOTE: This is only needed for backward compatibility / checksum stability!
+ */
+ private boolean trimTrailingNewlineInMigrations = false;
+
/**
* version to use as a baseline.
* The baseline version will be the first one applied, the versions below will be ignored.
@@ -295,6 +303,15 @@ public ElasticsearchEvolutionConfig setValidateOnMigrate(boolean validateOnMigra
return this;
}
+ public boolean isTrimTrailingNewlineInMigrations() {
+ return trimTrailingNewlineInMigrations;
+ }
+
+ public ElasticsearchEvolutionConfig setTrimTrailingNewlineInMigrations(boolean trimTrailingNewlineInMigrations) {
+ this.trimTrailingNewlineInMigrations = trimTrailingNewlineInMigrations;
+ return this;
+ }
+
public String getBaselineVersion() {
return baselineVersion;
}
@@ -330,6 +347,7 @@ public String toString() {
", historyIndex='" + historyIndex + '\'' +
", historyMaxQuerySize=" + historyMaxQuerySize +
", validateOnMigrate=" + validateOnMigrate +
+ ", trimTrailingNewlineInMigrations=" + trimTrailingNewlineInMigrations +
", baselineVersion='" + baselineVersion + '\'' +
", outOfOrder='" + outOfOrder + '\'' +
'}';
diff --git a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/HistoryRepositoryImpl.java b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/HistoryRepositoryImpl.java
index 6478264c..14a7c9c1 100644
--- a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/HistoryRepositoryImpl.java
+++ b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/HistoryRepositoryImpl.java
@@ -91,7 +91,7 @@ public void saveOrUpdate(MigrationScriptProtocol migrationScriptProtocol) throws
}
validateHttpStatusIs2xx(res, "saveOrUpdate");
} catch (IOException e) {
- throw new MigrationException(String.format("saveOrUpdate of '%s' failed!", migrationScriptProtocol), e);
+ throw new MigrationException("saveOrUpdate of '%s' failed!".formatted(migrationScriptProtocol), e);
}
}
@@ -238,7 +238,7 @@ private void validateHttpStatusIs2xx(Response response, String description) thro
void validateHttpStatusIs2xx(int statusCode, String description) throws MigrationException {
if (isNotStatusCode2xx(statusCode)) {
- throw new MigrationException(String.format("%s - response status is not OK: %s", description, statusCode));
+ throw new MigrationException("%s - response status is not OK: %s".formatted(description, statusCode));
}
}
diff --git a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImpl.java b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImpl.java
index b12b2615..875aa61e 100644
--- a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImpl.java
+++ b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImpl.java
@@ -148,14 +148,14 @@ ExecutionResult executeScript(ParsedMigrationScript scriptToExecute) {
if (statusCode >= 200 && statusCode < 300) {
success = true;
} else {
- error = Optional.of(new MigrationException(String.format(
- "execution of script '%s' failed with HTTP status %s: %s",
+ error = Optional.of(new MigrationException(
+ "execution of script '%s' failed with HTTP status %s: %s".formatted(
scriptToExecute.getFileNameInfo(),
statusCode,
response.toString())));
}
} catch (RuntimeException | IOException e) {
- error = Optional.of(new MigrationException(String.format("execution of script '%s' failed", scriptToExecute.getFileNameInfo()), e));
+ error = Optional.of(new MigrationException("execution of script '%s' failed".formatted(scriptToExecute.getFileNameInfo()), e));
}
return new ExecutionResult(
@@ -199,10 +199,12 @@ List getPendingScriptsToBeExecuted(Collection getPendingScriptsToBeExecuted(Collection getPendingScriptsToBeExecuted(Collection parse(Collection ra
requireNonNull(rawMigrationScripts, "rawMigrationScripts must not be null");
return rawMigrationScripts.stream()
.map(this::parse)
- .collect(Collectors.toList());
+ .toList();
}
ParsedMigrationScript parse(RawMigrationScript rawMigrationScript) {
@@ -111,8 +110,8 @@ private MigrationScriptRequest parseContent(RawMigrationScript script) {
private void parseHeader(MigrationScriptRequest res, String line) {
String[] header = line.trim().split("[:=]", 2);
if (header.length != 2) {
- throw new MigrationException(String.format(
- "can't parse header: '%s'. Header must be separated by ':' and should look like this: 'Content-Type: application/json'",
+ throw new MigrationException(
+ "can't parse header: '%s'. Header must be separated by ':' and should look like this: 'Content-Type: application/json'".formatted(
line));
}
res.addHttpHeader(header[0].trim(), header[1].trim());
@@ -121,8 +120,8 @@ private void parseHeader(MigrationScriptRequest res, String line) {
private void parseMethodWithPath(MigrationScriptRequest res, String line) {
String[] methodAndPath = line.trim().split(" +", 2);
if (methodAndPath.length != 2) {
- throw new MigrationException(String.format(
- "can't parse method and path: '%s'. Method and path must be separated by space and should look like this: 'PUT /my_index'",
+ throw new MigrationException(
+ "can't parse method and path: '%s'. Method and path must be separated by space and should look like this: 'PUT /my_index'".formatted(
line));
}
res.setHttpMethod(HttpMethod.create(methodAndPath[0]))
@@ -163,8 +162,8 @@ FileNameInfo parseFileName(String migrationName,
String version;
String description;
if (separatorPos < 0) {
- throw new MigrationException(String.format(
- "Description in migration filename is required: '%s'. It should look like this: '%s1.2%ssome_desctiption here%s'",
+ throw new MigrationException(
+ "Description in migration filename is required: '%s'. It should look like this: '%s1.2%ssome_desctiption here%s'".formatted(
migrationName, prefix, separator, suffixes.get(0)));
}
@@ -193,8 +192,8 @@ private String cleanMigrationName(String migrationName, String prefix, List esMigrationSuffixes;
private final String lineSeparator;
+ private final boolean trimTrailingNewlineInMigrations;
/**
- * @param locations Locations of migrations scripts, e.g classpath:es/migration or file:/home/migration
- * @param encoding migrations scripts encoding
- * @param esMigrationFilePrefix File name prefix for ES migrations.
- * @param esMigrationFileSuffixes File name suffix for ES migrations.
- * @param lineSeparator Line separator. should be '\n' per default and only something else for backward compatibility / hash stability
+ * @param locations Locations of migrations scripts, e.g classpath:es/migration or file:/home/migration
+ * @param encoding migrations scripts encoding
+ * @param esMigrationFilePrefix File name prefix for ES migrations.
+ * @param esMigrationFileSuffixes File name suffix for ES migrations.
+ * @param lineSeparator Line separator. should be '\n' per default and only something else for backward compatibility / checksum stability
+ * @param trimTrailingNewlineInMigrations Whether to remove a trailing newline in migration scripts.
*/
-
public MigrationScriptReaderImpl(List locations,
Charset encoding,
String esMigrationFilePrefix,
List esMigrationFileSuffixes,
- String lineSeparator) {
+ String lineSeparator,
+ boolean trimTrailingNewlineInMigrations) {
this.locations = locations;
this.encoding = encoding;
this.esMigrationPrefix = esMigrationFilePrefix;
this.esMigrationSuffixes = esMigrationFileSuffixes;
this.lineSeparator = lineSeparator;
+ this.trimTrailingNewlineInMigrations = trimTrailingNewlineInMigrations;
}
/**
@@ -72,11 +74,11 @@ public List read() {
return readFromLocation(location);
} catch (URISyntaxException | IOException e) {
throw new MigrationException(
- String.format("couldn't read scripts from %s", location), e);
+ "couldn't read scripts from %s".formatted(location), e);
}
})
.distinct()
- .collect(Collectors.toList());
+ .toList();
}
/**
@@ -94,8 +96,10 @@ protected Stream readFromLocation(String location) throws UR
} else if (location.startsWith(FILE_PREFIX)) {
return readScriptsFromFilesystem(location);
} else {
- throw new MigrationException(String.format("could not read location path %s, " +
- "should look like this: %ses/migration or this: %s/home/scripts/migration",
+ throw new MigrationException(("""
+ could not read location path %s, \
+ should look like this: %ses/migration or this: %s/home/scripts/migration\
+ """).formatted(
location, CLASSPATH_PREFIX, FILE_PREFIX));
}
}
@@ -142,7 +146,7 @@ private Stream readScriptsFromClassPath(String location) {
logger.debug("reading migration script '{}' from classpath...", resource);
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(resource.load()), encoding))) {
Path p = Paths.get(resource.getPath());
- res.addAll(read(bufferedReader, p.getFileName().toString()).collect(Collectors.toList()));
+ res.addAll(read(bufferedReader, p.getFileName().toString()).toList());
} catch (IOException e) {
throw new MigrationException("can't read script from classpath: " + resource, e);
}
@@ -163,6 +167,11 @@ Stream read(BufferedReader reader, String filename) throws I
if (content.isEmpty()) {
return Stream.empty();
}
+
+ if (trimTrailingNewlineInMigrations && content.endsWith(lineSeparator)) {
+ content = content.substring(0, content.length() - lineSeparator.length());
+ }
+
return Stream.of(new RawMigrationScript().setFileName(filename).setContent(content));
}
diff --git a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/model/migration/MigrationScriptRequest.java b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/model/migration/MigrationScriptRequest.java
index 1e5c0d26..76d28aa2 100644
--- a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/model/migration/MigrationScriptRequest.java
+++ b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/model/migration/MigrationScriptRequest.java
@@ -147,9 +147,9 @@ public static HttpMethod create(String method) throws MigrationException {
return Arrays.stream(values())
.filter(m -> m.name().equals(normalizedMethod))
.findFirst()
- .orElseThrow(() -> new MigrationException(String.format(
- "Method '%s' not supported, only %s is supported.",
- method, Arrays.toString(values()))));
+ .orElseThrow(() -> new MigrationException(
+ "Method '%s' not supported, only %s is supported.".formatted(
+ method, Arrays.toString(values()))));
}
}
}
diff --git a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/utils/AssertionUtils.java b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/utils/AssertionUtils.java
index 99720e88..2a5c6eee 100644
--- a/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/utils/AssertionUtils.java
+++ b/elasticsearch-evolution-core/src/main/java/com/senacor/elasticsearch/evolution/core/internal/utils/AssertionUtils.java
@@ -9,30 +9,33 @@
*/
public class AssertionUtils {
+ private AssertionUtils() {
+ }
+
public static String requireNotEmpty(String obj, String message, Object... args) {
if (Objects.requireNonNull(obj, message).isEmpty()) {
- throw new IllegalStateException(String.format(message, args));
+ throw new IllegalStateException(message.formatted(args));
}
return obj;
}
public static String requireNotBlank(String obj, String message, Object... args) {
if (Objects.requireNonNull(obj, message).trim().isEmpty()) {
- throw new IllegalStateException(String.format(message, args));
+ throw new IllegalStateException(message.formatted(args));
}
return obj;
}
public static Collection> requireNotEmpty(Collection> obj, String message, Object... args) {
if (Objects.requireNonNull(obj, message).isEmpty()) {
- throw new IllegalStateException(String.format(message, args));
+ throw new IllegalStateException(message.formatted(args));
}
return obj;
}
public static T requireCondition(T value, Predicate predicate, String message, Object... args) {
if (!predicate.test(value)) {
- throw new IllegalStateException(String.format(message, args));
+ throw new IllegalStateException(message.formatted(args));
}
return value;
}
diff --git a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImplTest.java b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImplTest.java
index a90dc400..9126a73e 100644
--- a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImplTest.java
+++ b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/execution/MigrationServiceImplTest.java
@@ -316,9 +316,11 @@ void successfulScriptWasEdited_shouldThrowChecksumMismatchException() {
assertThatThrownBy(() -> underTest.getPendingScriptsToBeExecuted(parsedMigrationScripts))
.isInstanceOf(MigrationException.class)
- .hasMessage("The logged execution for the migration script version 1.1 (V1.1__1.1.http) " +
- "has a different checksum from the given migration script! " +
- "Modifying already-executed scripts is not supported.");
+ .hasMessage("""
+ The logged execution for the migration script version 1.1 (V1.1__1.1.http) \
+ has a different checksum from the given migration script! \
+ Modifying already-executed scripts is not supported.\
+ """);
}
@Test
diff --git a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/input/MigrationScriptReaderImplTest.java b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/input/MigrationScriptReaderImplTest.java
index 0217d734..1e9db964 100644
--- a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/input/MigrationScriptReaderImplTest.java
+++ b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/internal/migration/input/MigrationScriptReaderImplTest.java
@@ -36,7 +36,7 @@ void nonJarFile() {
singletonList("classpath:scriptreader"),
StandardCharsets.UTF_8,
"c",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
assertThat(actual)
.containsExactlyInAnyOrder(
@@ -50,7 +50,7 @@ void inJarFile() {
singletonList("classpath:META-INF"),
StandardCharsets.UTF_8,
"MANIFEST",
- singletonList(".MF"), "\n");
+ singletonList(".MF"), "\n", false);
List res = reader.read();
@@ -67,7 +67,7 @@ void invalidClasspath() {
singletonList(classpath),
StandardCharsets.UTF_8,
"c",
- singletonList(".http"), "\n") {
+ singletonList(".http"), "\n", false) {
@Override
protected Stream readFromLocation(String location) throws URISyntaxException, IOException {
throw new URISyntaxException("input", "reason");
@@ -85,7 +85,7 @@ void multipleSuffixes() {
singletonList("classpath:scriptreader"),
StandardCharsets.UTF_8,
"c",
- Arrays.asList(".http", ".other"), "\n");
+ Arrays.asList(".http", ".other"), "\n", false);
List actual = reader.read();
assertThat(actual)
.containsExactlyInAnyOrder(
@@ -100,7 +100,7 @@ void handlingDuplicates() {
Arrays.asList("classpath:scriptreader", "classpath:scriptreader"),
StandardCharsets.UTF_8,
"c",
- Arrays.asList(".http", ".other"), "\n");
+ Arrays.asList(".http", ".other"), "\n", false);
List actual = reader.read();
assertThat(actual)
.containsExactlyInAnyOrder(
@@ -115,7 +115,7 @@ void exclude_locations_with_suffix() {
singletonList("classpath:scriptreader/issue36/location"),
StandardCharsets.UTF_8,
"c",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
@@ -132,7 +132,7 @@ void handle_locations_with_suffix() {
"classpath:scriptreader/issue36/location_with_suffix"),
StandardCharsets.UTF_8,
"c",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
@@ -148,7 +148,7 @@ void include_trailing_newlines() {
Arrays.asList("classpath:scriptreader/issue293_trailing_newlines"),
StandardCharsets.UTF_8,
"w",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
@@ -163,11 +163,13 @@ void withWrongProtocol() {
Arrays.asList("classpath:scriptreader", "http:scriptreader"),
StandardCharsets.UTF_8,
"c",
- Arrays.asList(".http", ".other"), "\n");
+ Arrays.asList(".http", ".other"), "\n", false);
assertThatThrownBy(reader::read)
.isInstanceOf(MigrationException.class)
- .hasMessage("could not read location path http:scriptreader, should look like this: " +
- "classpath:es/migration or this: file:/home/scripts/migration");
+ .hasMessage("""
+ could not read location path http:scriptreader, should look like this: \
+ classpath:es/migration or this: file:/home/scripts/migration\
+ """);
}
}
@@ -181,7 +183,7 @@ void normalPath() throws URISyntaxException {
singletonList("file:" + absolutePathToScriptreader),
StandardCharsets.UTF_8,
"c",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
assertThat(actual)
.containsExactlyInAnyOrder(
@@ -197,7 +199,7 @@ void exclude_locations_with_suffix() throws URISyntaxException {
singletonList("file:"+absolutePathToScriptreader+"/issue36/location"),
StandardCharsets.UTF_8,
"c",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
@@ -216,7 +218,7 @@ void handle_locations_with_suffix() throws URISyntaxException {
"file:"+absolutePathToScriptreader+"/issue36/location_with_suffix"),
StandardCharsets.UTF_8,
"c",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
@@ -228,12 +230,12 @@ void handle_locations_with_suffix() throws URISyntaxException {
@Test
void invalidPath() {
- assertThatThrownBy(() ->
- new MigrationScriptReaderImpl(
- singletonList("file:X:/snc/scripts"),
- StandardCharsets.UTF_8,
- "c",
- singletonList(".http"), "\n").read())
+ final MigrationScriptReaderImpl underTest = new MigrationScriptReaderImpl(
+ singletonList("file:X:/snc/scripts"),
+ StandardCharsets.UTF_8,
+ "c",
+ singletonList(".http"), "\n", false);
+ assertThatThrownBy(() -> underTest.read())
.isInstanceOf(MigrationException.class)
.hasMessage("couldn't read scripts from file:X:/snc/scripts");
}
@@ -243,12 +245,12 @@ void invalidPath() {
void validAndInvalidPath() throws URISyntaxException {
URL resourceDirectory = resolveURL("scriptreader");
String absolutePathToScriptreader = Paths.get(resourceDirectory.toURI()).toFile().getAbsolutePath();
- assertThatThrownBy(() ->
- new MigrationScriptReaderImpl(
- Arrays.asList("file:X:/snc/scripts", "file:" + absolutePathToScriptreader),
- StandardCharsets.UTF_8,
- "c",
- singletonList(".http"), "\n").read())
+ final MigrationScriptReaderImpl underTest = new MigrationScriptReaderImpl(
+ Arrays.asList("file:X:/snc/scripts", "file:" + absolutePathToScriptreader),
+ StandardCharsets.UTF_8,
+ "c",
+ singletonList(".http"), "\n", false);
+ assertThatThrownBy(() -> underTest.read())
.isInstanceOf(MigrationException.class)
.hasMessage("couldn't read scripts from file:X:/snc/scripts");
}
@@ -261,7 +263,7 @@ void validPathButNoFiles() throws URISyntaxException {
singletonList("file:" + absolutePathToScriptreader),
StandardCharsets.UTF_8,
"d",
- singletonList(".http"), "\n");
+ singletonList(".http"), "\n", false);
List actual = reader.read();
assertThat(actual).isEmpty();
}
@@ -270,9 +272,9 @@ void validPathButNoFiles() throws URISyntaxException {
@ParameterizedTest
@ValueSource(strings = {
- "foo\nbar",
- "foo\r\nbar",
- "foo\rbar"
+ "foo\nbar\n",
+ "foo\r\nbar\r\n",
+ "foo\rbar\r"
})
void read_should_normalize_new_lines_to_defined_line_separator(String input) throws IOException {
final String lineSeparator = "";
@@ -280,7 +282,34 @@ void read_should_normalize_new_lines_to_defined_line_separator(String input) thr
singletonList("ignore"),
StandardCharsets.UTF_8,
"ignore",
- singletonList(".ignore"), lineSeparator);
+ singletonList(".ignore"),
+ lineSeparator,
+ false);
+
+ final Stream res;
+ try (BufferedReader bufferedReader = new BufferedReader(new StringReader(input))) {
+ res = reader.read(bufferedReader, "filename");
+ }
+
+ assertThat(res)
+ .containsExactlyInAnyOrder(new RawMigrationScript().setFileName("filename").setContent("foo" + lineSeparator + "bar" + lineSeparator));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ "foo\nbar\n",
+ "foo\r\nbar\r\n",
+ "foo\rbar\r"
+ })
+ void read_should_trim_trailing_newlines_if_config_is_set(String input) throws IOException {
+ final String lineSeparator = "";
+ MigrationScriptReaderImpl reader = new MigrationScriptReaderImpl(
+ singletonList("ignore"),
+ StandardCharsets.UTF_8,
+ "ignore",
+ singletonList(".ignore"),
+ lineSeparator,
+ true);
final Stream res;
try (BufferedReader bufferedReader = new BufferedReader(new StringReader(input))) {
@@ -288,7 +317,7 @@ void read_should_normalize_new_lines_to_defined_line_separator(String input) thr
}
assertThat(res)
- .containsExactlyInAnyOrder(new RawMigrationScript().setFileName("filename").setContent("foo"+lineSeparator+"bar"));
+ .containsExactlyInAnyOrder(new RawMigrationScript().setFileName("filename").setContent("foo" + lineSeparator + "bar"));
}
private URL resolveURL(String path) {
diff --git a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EmbeddedElasticsearchExtension.java b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EmbeddedElasticsearchExtension.java
index ce5ab940..2e956cee 100644
--- a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EmbeddedElasticsearchExtension.java
+++ b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EmbeddedElasticsearchExtension.java
@@ -18,7 +18,7 @@
import org.junit.jupiter.params.provider.ArgumentsProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.util.SocketUtils;
+import org.springframework.test.util.TestSocketUtils;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.elasticsearch.ElasticsearchContainer;
import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
@@ -84,11 +84,8 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) {
.withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
.withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
.withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- // SocketUtils replacement: https://github.com/spring-projects/spring-framework/issues/28210
- // https://github.com/spring-cloud/spring-cloud-function/issues/825
- // https://github.com/spring-cloud/spring-cloud-deployer-local/pull/214
- int httpPort = SocketUtils.findAvailableTcpPort(5000, 30000);
- int transportPort = SocketUtils.findAvailableTcpPort(30001, 65535);
+ int httpPort = TestSocketUtils.findAvailableTcpPort();
+ int transportPort = TestSocketUtils.findAvailableTcpPort();
container.setPortBindings(Arrays.asList(httpPort + ":9200", transportPort + ":" + searchContainer.transportPort));
// container.setWaitStrategy(new HttpWaitStrategy()
// .forPort(9200)
diff --git a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EsUtils.java b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EsUtils.java
index 31c20aaf..657bf0c2 100644
--- a/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EsUtils.java
+++ b/elasticsearch-evolution-core/src/test/java/com/senacor/elasticsearch/evolution/core/test/EsUtils.java
@@ -39,11 +39,13 @@ public void refreshIndices() {
public List fetchAllDocuments(String index) {
try {
Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
+ post.setJsonEntity("""
+ {\
+ "query": {\
+ "match_all": {}\
+ }\
+ }\
+ """);
Response response = restClient.performRequest(post);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode < 200 || statusCode >= 300) {
@@ -76,7 +78,7 @@ public void indexDocument(String index, String id, HashMap sourc
indexRequest.setJsonEntity(OBJECT_MAPPER.writeValueAsString(source));
final Response res = restClient.performRequest(indexRequest);
if (res.getStatusLine().getStatusCode() != 201) {
- throw new IllegalStateException(String.format("indexDocument failed with status code %s: %s",
+ throw new IllegalStateException("indexDocument failed with status code %s: %s".formatted(
res.getStatusLine().getStatusCode(),
res.getStatusLine().getReasonPhrase()));
}
diff --git a/pom.xml b/pom.xml
index 76814b9c..1ec7215c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
com.senacor.elasticsearch.evolution
elasticsearch-evolution-parent
- 0.5.2
+ 0.6.0
pom
org.springframework.boot
spring-boot-dependencies
- 2.7.18
+ 3.2.5
elasticsearch-evolution
@@ -87,7 +87,7 @@
UTF-8
UTF-8
- 1.8
+ 17
${java.version}
${java.version}
@@ -180,6 +180,16 @@
org.eluder.coveralls
coveralls-maven-plugin
${coveralls-maven-plugin.version}
+
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+
+
maven-compiler-plugin
@@ -277,9 +287,30 @@
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+ 5.31.0
+
+
+ org.openrewrite.java.migrate.UpgradeToJava17
+
+
+
+
+ org.openrewrite.recipe
+ rewrite-migrate-java
+ 2.14.0
+
+
+
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+
maven-failsafe-plugin
diff --git a/spring-boot-starter-elasticsearch-evolution/pom.xml b/spring-boot-starter-elasticsearch-evolution/pom.xml
index 3c9164ef..398b40a9 100644
--- a/spring-boot-starter-elasticsearch-evolution/pom.xml
+++ b/spring-boot-starter-elasticsearch-evolution/pom.xml
@@ -6,7 +6,7 @@
com.senacor.elasticsearch.evolution
elasticsearch-evolution-parent
- 0.5.2
+ 0.6.0
../
spring-boot-starter-elasticsearch-evolution
diff --git a/tests/migration-scripts/pom.xml b/tests/migration-scripts/pom.xml
index 4da39f50..dbfb84f1 100644
--- a/tests/migration-scripts/pom.xml
+++ b/tests/migration-scripts/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.senacor.elasticsearch.evolution
migration-scripts
- 0.5.2
+ 0.6.0
jar containing migration files
jar
@@ -14,4 +14,25 @@
UTF-8
+
+
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+ 5.31.0
+
+
+ org.openrewrite.java.migrate.UpgradeToJava17
+
+
+
+
+ org.openrewrite.recipe
+ rewrite-migrate-java
+ 2.14.0
+
+
+
+
+
diff --git a/tests/pom.xml b/tests/pom.xml
index 3aa7f426..0c376514 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -6,7 +6,7 @@
com.senacor.elasticsearch.evolution
elasticsearch-evolution-parent
- 0.5.2
+ 0.6.0
../
tests
@@ -19,27 +19,8 @@
migration-scripts
- test-spring-boot-2.7
- test-spring-boot-2.6
- test-spring-boot-2.5-scriptsInJarFile
- test-spring-boot-2.4
- test-spring-boot-2.3
- test-spring-boot-2.2
- test-spring-boot-2.1-scriptsInJarFile
+ test-spring-boot-3.0-scriptsInJarFile
+ test-spring-boot-3.1
+ test-spring-boot-3.2
-
-
-
- jdk17+
-
-
- [17,)
-
-
- test-spring-boot-3.0-scriptsInJarFile
- test-spring-boot-3.1
- test-spring-boot-3.2
-
-
-
diff --git a/tests/test-spring-boot-2.1-scriptsInJarFile/pom.xml b/tests/test-spring-boot-2.1-scriptsInJarFile/pom.xml
deleted file mode 100644
index d69246c3..00000000
--- a/tests/test-spring-boot-2.1-scriptsInJarFile/pom.xml
+++ /dev/null
@@ -1,114 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.1.18.RELEASE
-
-
- com.senacor.elasticsearch.evolution
- test-spring-boot-2.1-scriptsInJarFile
- 0.5.2
- Demo project for Spring Boot
-
-
- 1.8
-
- 2.16.1
- 7.5.2
- 1.19.8
-
-
-
-
-
- ${project.groupId}
- migration-scripts
- ${project.version}
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- ${project.groupId}
- spring-boot-starter-elasticsearch-evolution
- ${project.version}
-
-
-
-
- org.testcontainers
- elasticsearch
- ${testcontainers.elasticsearch.version}
- test
-
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
-
-
-
-
- oss.sonatype.org-snapshot
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
-
- 0.8.12
-
-
- prepare-agent
-
- prepare-agent
-
-
-
- report
- post-integration-test
-
- report
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
diff --git a/tests/test-spring-boot-2.1-scriptsInJarFile/src/main/java/com/senacor/elasticsearch/evolution/springboot21/Application.java b/tests/test-spring-boot-2.1-scriptsInJarFile/src/main/java/com/senacor/elasticsearch/evolution/springboot21/Application.java
deleted file mode 100644
index a4c1aa3b..00000000
--- a/tests/test-spring-boot-2.1-scriptsInJarFile/src/main/java/com/senacor/elasticsearch/evolution/springboot21/Application.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot21;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.1-scriptsInJarFile/src/main/resources/application.properties b/tests/test-spring-boot-2.1-scriptsInJarFile/src/main/resources/application.properties
deleted file mode 100644
index 5db1f692..00000000
--- a/tests/test-spring-boot-2.1-scriptsInJarFile/src/main/resources/application.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-spring.elasticsearch.evolution.locations[0]=classpath:es/mig
-spring.elasticsearch.evolution.placeholders.index=test_1
-logging.level.com.senacor.elasticsearch.evolution=DEBUG
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.1-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot21/ApplicationTests.java b/tests/test-spring-boot-2.1-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot21/ApplicationTests.java
deleted file mode 100644
index 50f66bc8..00000000
--- a/tests/test-spring-boot-2.1-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot21/ApplicationTests.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot21;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import org.apache.http.HttpHost;
-import org.elasticsearch.client.RestClient;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(properties = {"spring.elasticsearch.rest.uris=http://localhost:" + ApplicationTests.ELASTICSEARCH_PORT})
-public class ApplicationTests {
-
- static final int ELASTICSEARCH_PORT = 18769;
-
- @Autowired
- private EsUtils esUtils;
-
- @Test
- public void contextLoads() {
- esUtils.refreshIndices();
-
- List documents = esUtils.fetchAllDocuments("test_1");
-
- assertThat(documents).hasSize(1);
- }
-
- @TestConfiguration
- static class Config {
- @Bean(destroyMethod = "stop")
- public ElasticsearchContainer elasticsearchContainer(@Value("${elasticsearch.version:7.5.2}") String esVersion) {
- ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName
- .parse("docker.elastic.co/elasticsearch/elasticsearch")
- .withTag(esVersion)) {
- @Override
- protected void containerIsStarted(InspectContainerResponse containerInfo) {
- // since testcontainers 1.17 it detects if ES 8.x is running and copies a certificate in this case
- // but we don't want security
- }
- }
- .withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx128m")
- // since elasticsearch 8 security / https is enabled per default - but for testing it should be disabled
- .withEnv("xpack.security.enabled", "false")
- .withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
- .withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
- .withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- container.setPortBindings(Collections.singletonList(ELASTICSEARCH_PORT + ":9200"));
- container.start();
- return container;
- }
-
- @Bean
- public EsUtils esUtils(ElasticsearchContainer elasticsearchContainer) {
- return new EsUtils(RestClient.builder(HttpHost.create(elasticsearchContainer.getHttpHostAddress())).build());
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.1-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot21/EsUtils.java b/tests/test-spring-boot-2.1-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot21/EsUtils.java
deleted file mode 100644
index 49eae087..00000000
--- a/tests/test-spring-boot-2.1-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot21/EsUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot21;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * @author Andreas Keefer
- */
-public class EsUtils {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private final RestClient restClient;
-
- public EsUtils(RestClient restClient) {
- this.restClient = restClient;
- }
-
- public void refreshIndices() {
- try {
- restClient.performRequest(new Request("GET", "/_refresh"));
- } catch (IOException e) {
- throw new IllegalStateException("refreshIndices failed", e);
- }
- }
-
- public List fetchAllDocuments(String index) {
- try {
- Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
- Response response = restClient.performRequest(post);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < 200 || statusCode >= 300) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed with HTTP status " +
- statusCode + ": " + response.toString());
- }
- String body = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
-
- return parseDocuments(body)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed", e);
- }
- }
-
- private Stream parseDocuments(String body) {
- try {
- JsonNode jsonNode = OBJECT_MAPPER.readTree(body);
- return StreamSupport.stream(jsonNode.get("hits").get("hits").spliterator(), false)
- .map(hitNode -> hitNode.get("_source"))
- .map(JsonNode::toString);
- } catch (IOException e) {
- throw new IllegalStateException("parseDocuments failed. body=" + body, e);
- }
- }
-}
-
diff --git a/tests/test-spring-boot-2.2/pom.xml b/tests/test-spring-boot-2.2/pom.xml
deleted file mode 100644
index 617ad88e..00000000
--- a/tests/test-spring-boot-2.2/pom.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.2.13.RELEASE
-
-
- com.senacor.elasticsearch.evolution
- test-spring-boot-2.2
- 0.5.2
- Demo project for Spring Boot
-
-
- 1.8
-
- 2.16.1
- 7.5.2
- 1.19.8
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- ${project.groupId}
- spring-boot-starter-elasticsearch-evolution
- ${project.version}
-
-
-
-
- org.testcontainers
- elasticsearch
- ${testcontainers.elasticsearch.version}
- test
-
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
-
-
-
-
- oss.sonatype.org-snapshot
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
- 0.8.12
-
-
- prepare-agent
-
- prepare-agent
-
-
-
- report
- post-integration-test
-
- report
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
diff --git a/tests/test-spring-boot-2.2/src/main/java/com/senacor/elasticsearch/evolution/springboot22/Application.java b/tests/test-spring-boot-2.2/src/main/java/com/senacor/elasticsearch/evolution/springboot22/Application.java
deleted file mode 100644
index 114042fa..00000000
--- a/tests/test-spring-boot-2.2/src/main/java/com/senacor/elasticsearch/evolution/springboot22/Application.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot22;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.2/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http b/tests/test-spring-boot-2.2/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
deleted file mode 100644
index fbd7df47..00000000
--- a/tests/test-spring-boot-2.2/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
+++ /dev/null
@@ -1,35 +0,0 @@
-PUT _template/test_1
-Content-Type: application/json
-
-{
- "index_patterns" : [
- "test_*"
- ],
- "order" : 1,
- "version" : 1,
- "settings" : {
- "number_of_shards" : 1
- },
- "mappings" : {
- "dynamic" : "strict",
- "properties" : {
- "doc" : {
- "dynamic" : false,
- "properties" : {}
- },
- "searchable" : {
- "dynamic" : false,
- "properties" : {
- "version" : {
- "type" : "keyword",
- "ignore_above" : 20,
- "similarity" : "boolean"
- },
- "locked" : {
- "type" : "boolean"
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.2/src/main/resources/es/migration/V001.01__addDocument.http b/tests/test-spring-boot-2.2/src/main/resources/es/migration/V001.01__addDocument.http
deleted file mode 100644
index 4f18ba0a..00000000
--- a/tests/test-spring-boot-2.2/src/main/resources/es/migration/V001.01__addDocument.http
+++ /dev/null
@@ -1,17 +0,0 @@
-PUT /test_1/_doc/1?refresh
-Content-Type: application/json
-
-{
- "searchable": {
- "version": "1",
- "locked": false
- },
- "doc": {
- "version": "1",
- "locked": false,
- "success": true,
- "a": "a a a",
- "b": true,
- "c": "c"
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.2/src/test/java/com/senacor/elasticsearch/evolution/springboot22/ApplicationTests.java b/tests/test-spring-boot-2.2/src/test/java/com/senacor/elasticsearch/evolution/springboot22/ApplicationTests.java
deleted file mode 100644
index 2b48d2c7..00000000
--- a/tests/test-spring-boot-2.2/src/test/java/com/senacor/elasticsearch/evolution/springboot22/ApplicationTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot22;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import org.apache.http.HttpHost;
-import org.elasticsearch.client.RestClient;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@SpringBootTest(properties = {"spring.elasticsearch.rest.uris=http://localhost:" + ApplicationTests.ELASTICSEARCH_PORT})
-class ApplicationTests {
-
- static final int ELASTICSEARCH_PORT = 18759;
-
- @Autowired
- private EsUtils esUtils;
-
- @Test
- void contextLoads() {
- esUtils.refreshIndices();
-
- List documents = esUtils.fetchAllDocuments("test_1");
-
- assertThat(documents).hasSize(1);
- }
-
- @TestConfiguration
- static class Config {
- @Bean(destroyMethod = "stop")
- public ElasticsearchContainer elasticsearchContainer(@Value("${elasticsearch.version:7.5.2}") String esVersion) {
- ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName
- .parse("docker.elastic.co/elasticsearch/elasticsearch")
- .withTag(esVersion)) {
- @Override
- protected void containerIsStarted(InspectContainerResponse containerInfo) {
- // since testcontainers 1.17 it detects if ES 8.x is running and copies a certificate in this case
- // but we don't want security
- }
- }
- .withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx128m")
- // since elasticsearch 8 security / https is enabled per default - but for testing it should be disabled
- .withEnv("xpack.security.enabled", "false")
- .withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
- .withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
- .withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- container.setPortBindings(Collections.singletonList(ELASTICSEARCH_PORT + ":9200"));
- container.start();
- return container;
- }
-
- @Bean
- public EsUtils esUtils(ElasticsearchContainer elasticsearchContainer) {
- return new EsUtils(RestClient.builder(HttpHost.create(elasticsearchContainer.getHttpHostAddress())).build());
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.2/src/test/java/com/senacor/elasticsearch/evolution/springboot22/EsUtils.java b/tests/test-spring-boot-2.2/src/test/java/com/senacor/elasticsearch/evolution/springboot22/EsUtils.java
deleted file mode 100644
index b2350948..00000000
--- a/tests/test-spring-boot-2.2/src/test/java/com/senacor/elasticsearch/evolution/springboot22/EsUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot22;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * @author Andreas Keefer
- */
-public class EsUtils {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private final RestClient restClient;
-
- public EsUtils(RestClient restClient) {
- this.restClient = restClient;
- }
-
- public void refreshIndices() {
- try {
- restClient.performRequest(new Request("GET", "/_refresh"));
- } catch (IOException e) {
- throw new IllegalStateException("refreshIndices failed", e);
- }
- }
-
- public List fetchAllDocuments(String index) {
- try {
- Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
- Response response = restClient.performRequest(post);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < 200 || statusCode >= 300) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed with HTTP status " +
- statusCode + ": " + response.toString());
- }
- String body = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
-
- return parseDocuments(body)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed", e);
- }
- }
-
- private Stream parseDocuments(String body) {
- try {
- JsonNode jsonNode = OBJECT_MAPPER.readTree(body);
- return StreamSupport.stream(jsonNode.get("hits").get("hits").spliterator(), false)
- .map(hitNode -> hitNode.get("_source"))
- .map(JsonNode::toString);
- } catch (IOException e) {
- throw new IllegalStateException("parseDocuments failed. body=" + body, e);
- }
- }
-}
-
diff --git a/tests/test-spring-boot-2.3/pom.xml b/tests/test-spring-boot-2.3/pom.xml
deleted file mode 100644
index 7a4eb7ab..00000000
--- a/tests/test-spring-boot-2.3/pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.3.12.RELEASE
-
-
- com.senacor.elasticsearch.evolution
- test-spring-boot-2.3
- 0.5.2
- Demo project for Spring Boot
-
-
- 1.8
-
- 2.16.1
- 7.5.2
- 1.19.8
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- ${project.groupId}
- spring-boot-starter-elasticsearch-evolution
- ${project.version}
-
-
-
-
- org.testcontainers
- elasticsearch
- ${testcontainers.elasticsearch.version}
- test
-
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
-
-
-
-
- oss.sonatype.org-snapshot
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
-
- 0.8.12
-
-
- prepare-agent
-
- prepare-agent
-
-
-
- report
- post-integration-test
-
- report
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
diff --git a/tests/test-spring-boot-2.3/src/main/java/com/senacor/elasticsearch/evolution/springboot23/Application.java b/tests/test-spring-boot-2.3/src/main/java/com/senacor/elasticsearch/evolution/springboot23/Application.java
deleted file mode 100644
index 4b792124..00000000
--- a/tests/test-spring-boot-2.3/src/main/java/com/senacor/elasticsearch/evolution/springboot23/Application.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot23;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.3/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http b/tests/test-spring-boot-2.3/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
deleted file mode 100644
index fbd7df47..00000000
--- a/tests/test-spring-boot-2.3/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
+++ /dev/null
@@ -1,35 +0,0 @@
-PUT _template/test_1
-Content-Type: application/json
-
-{
- "index_patterns" : [
- "test_*"
- ],
- "order" : 1,
- "version" : 1,
- "settings" : {
- "number_of_shards" : 1
- },
- "mappings" : {
- "dynamic" : "strict",
- "properties" : {
- "doc" : {
- "dynamic" : false,
- "properties" : {}
- },
- "searchable" : {
- "dynamic" : false,
- "properties" : {
- "version" : {
- "type" : "keyword",
- "ignore_above" : 20,
- "similarity" : "boolean"
- },
- "locked" : {
- "type" : "boolean"
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.3/src/main/resources/es/migration/V001.01__addDocument.http b/tests/test-spring-boot-2.3/src/main/resources/es/migration/V001.01__addDocument.http
deleted file mode 100644
index 4f18ba0a..00000000
--- a/tests/test-spring-boot-2.3/src/main/resources/es/migration/V001.01__addDocument.http
+++ /dev/null
@@ -1,17 +0,0 @@
-PUT /test_1/_doc/1?refresh
-Content-Type: application/json
-
-{
- "searchable": {
- "version": "1",
- "locked": false
- },
- "doc": {
- "version": "1",
- "locked": false,
- "success": true,
- "a": "a a a",
- "b": true,
- "c": "c"
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.3/src/test/java/com/senacor/elasticsearch/evolution/springboot23/ApplicationTests.java b/tests/test-spring-boot-2.3/src/test/java/com/senacor/elasticsearch/evolution/springboot23/ApplicationTests.java
deleted file mode 100644
index 8a97507f..00000000
--- a/tests/test-spring-boot-2.3/src/test/java/com/senacor/elasticsearch/evolution/springboot23/ApplicationTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot23;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import org.apache.http.HttpHost;
-import org.elasticsearch.client.RestClient;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@SpringBootTest(properties = {"spring.elasticsearch.rest.uris=http://localhost:" + ApplicationTests.ELASTICSEARCH_PORT})
-class ApplicationTests {
-
- static final int ELASTICSEARCH_PORT = 18761;
-
- @Autowired
- private EsUtils esUtils;
-
- @Test
- void contextLoads() {
- esUtils.refreshIndices();
-
- List documents = esUtils.fetchAllDocuments("test_1");
-
- assertThat(documents).hasSize(1);
- }
-
- @TestConfiguration
- static class Config {
- @Bean(destroyMethod = "stop")
- public ElasticsearchContainer elasticsearchContainer(@Value("${elasticsearch.version:7.5.2}") String esVersion) {
- ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName
- .parse("docker.elastic.co/elasticsearch/elasticsearch")
- .withTag(esVersion)) {
- @Override
- protected void containerIsStarted(InspectContainerResponse containerInfo) {
- // since testcontainers 1.17 it detects if ES 8.x is running and copies a certificate in this case
- // but we don't want security
- }
- }
- .withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx128m")
- // since elasticsearch 8 security / https is enabled per default - but for testing it should be disabled
- .withEnv("xpack.security.enabled", "false")
- .withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
- .withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
- .withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- container.setPortBindings(Collections.singletonList(ELASTICSEARCH_PORT + ":9200"));
- container.start();
- return container;
- }
-
- @Bean
- public EsUtils esUtils(ElasticsearchContainer elasticsearchContainer) {
- return new EsUtils(RestClient.builder(HttpHost.create(elasticsearchContainer.getHttpHostAddress())).build());
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.3/src/test/java/com/senacor/elasticsearch/evolution/springboot23/EsUtils.java b/tests/test-spring-boot-2.3/src/test/java/com/senacor/elasticsearch/evolution/springboot23/EsUtils.java
deleted file mode 100644
index bde1f552..00000000
--- a/tests/test-spring-boot-2.3/src/test/java/com/senacor/elasticsearch/evolution/springboot23/EsUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot23;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * @author Andreas Keefer
- */
-public class EsUtils {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private final RestClient restClient;
-
- public EsUtils(RestClient restClient) {
- this.restClient = restClient;
- }
-
- public void refreshIndices() {
- try {
- restClient.performRequest(new Request("GET", "/_refresh"));
- } catch (IOException e) {
- throw new IllegalStateException("refreshIndices failed", e);
- }
- }
-
- public List fetchAllDocuments(String index) {
- try {
- Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
- Response response = restClient.performRequest(post);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < 200 || statusCode >= 300) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed with HTTP status " +
- statusCode + ": " + response.toString());
- }
- String body = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
-
- return parseDocuments(body)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed", e);
- }
- }
-
- private Stream parseDocuments(String body) {
- try {
- JsonNode jsonNode = OBJECT_MAPPER.readTree(body);
- return StreamSupport.stream(jsonNode.get("hits").get("hits").spliterator(), false)
- .map(hitNode -> hitNode.get("_source"))
- .map(JsonNode::toString);
- } catch (IOException e) {
- throw new IllegalStateException("parseDocuments failed. body=" + body, e);
- }
- }
-}
-
diff --git a/tests/test-spring-boot-2.4/pom.xml b/tests/test-spring-boot-2.4/pom.xml
deleted file mode 100644
index f1133ef4..00000000
--- a/tests/test-spring-boot-2.4/pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.4.13
-
-
- com.senacor.elasticsearch.evolution
- test-spring-boot-2.4
- 0.5.2
- Demo project for Spring Boot
-
-
- 1.8
-
- 2.16.1
- 7.5.2
- 1.19.8
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- ${project.groupId}
- spring-boot-starter-elasticsearch-evolution
- ${project.version}
-
-
-
-
- org.testcontainers
- elasticsearch
- ${testcontainers.elasticsearch.version}
- test
-
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
-
-
-
-
- oss.sonatype.org-snapshot
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
-
- 0.8.12
-
-
- prepare-agent
-
- prepare-agent
-
-
-
- report
- post-integration-test
-
- report
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
diff --git a/tests/test-spring-boot-2.4/src/main/java/com/senacor/elasticsearch/evolution/springboot24/Application.java b/tests/test-spring-boot-2.4/src/main/java/com/senacor/elasticsearch/evolution/springboot24/Application.java
deleted file mode 100644
index 6778bd46..00000000
--- a/tests/test-spring-boot-2.4/src/main/java/com/senacor/elasticsearch/evolution/springboot24/Application.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot24;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.4/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http b/tests/test-spring-boot-2.4/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
deleted file mode 100644
index fbd7df47..00000000
--- a/tests/test-spring-boot-2.4/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
+++ /dev/null
@@ -1,35 +0,0 @@
-PUT _template/test_1
-Content-Type: application/json
-
-{
- "index_patterns" : [
- "test_*"
- ],
- "order" : 1,
- "version" : 1,
- "settings" : {
- "number_of_shards" : 1
- },
- "mappings" : {
- "dynamic" : "strict",
- "properties" : {
- "doc" : {
- "dynamic" : false,
- "properties" : {}
- },
- "searchable" : {
- "dynamic" : false,
- "properties" : {
- "version" : {
- "type" : "keyword",
- "ignore_above" : 20,
- "similarity" : "boolean"
- },
- "locked" : {
- "type" : "boolean"
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.4/src/main/resources/es/migration/V001.01__addDocument.http b/tests/test-spring-boot-2.4/src/main/resources/es/migration/V001.01__addDocument.http
deleted file mode 100644
index 4f18ba0a..00000000
--- a/tests/test-spring-boot-2.4/src/main/resources/es/migration/V001.01__addDocument.http
+++ /dev/null
@@ -1,17 +0,0 @@
-PUT /test_1/_doc/1?refresh
-Content-Type: application/json
-
-{
- "searchable": {
- "version": "1",
- "locked": false
- },
- "doc": {
- "version": "1",
- "locked": false,
- "success": true,
- "a": "a a a",
- "b": true,
- "c": "c"
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.4/src/test/java/com/senacor/elasticsearch/evolution/springboot24/ApplicationTests.java b/tests/test-spring-boot-2.4/src/test/java/com/senacor/elasticsearch/evolution/springboot24/ApplicationTests.java
deleted file mode 100644
index e379f8b1..00000000
--- a/tests/test-spring-boot-2.4/src/test/java/com/senacor/elasticsearch/evolution/springboot24/ApplicationTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot24;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import org.apache.http.HttpHost;
-import org.elasticsearch.client.RestClient;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@SpringBootTest(properties = {"spring.elasticsearch.rest.uris=http://localhost:" + ApplicationTests.ELASTICSEARCH_PORT})
-class ApplicationTests {
-
- static final int ELASTICSEARCH_PORT = 18762;
-
- @Autowired
- private EsUtils esUtils;
-
- @Test
- void contextLoads() {
- esUtils.refreshIndices();
-
- List documents = esUtils.fetchAllDocuments("test_1");
-
- assertThat(documents).hasSize(1);
- }
-
- @TestConfiguration
- static class Config {
- @Bean(destroyMethod = "stop")
- public ElasticsearchContainer elasticsearchContainer(@Value("${elasticsearch.version:7.5.2}") String esVersion) {
- ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName
- .parse("docker.elastic.co/elasticsearch/elasticsearch")
- .withTag(esVersion)) {
- @Override
- protected void containerIsStarted(InspectContainerResponse containerInfo) {
- // since testcontainers 1.17 it detects if ES 8.x is running and copies a certificate in this case
- // but we don't want security
- }
- }
- .withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx128m")
- // since elasticsearch 8 security / https is enabled per default - but for testing it should be disabled
- .withEnv("xpack.security.enabled", "false")
- .withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
- .withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
- .withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- container.setPortBindings(Collections.singletonList(ELASTICSEARCH_PORT + ":9200"));
- container.start();
- return container;
- }
-
- @Bean
- public EsUtils esUtils(ElasticsearchContainer elasticsearchContainer) {
- return new EsUtils(RestClient.builder(HttpHost.create(elasticsearchContainer.getHttpHostAddress())).build());
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.4/src/test/java/com/senacor/elasticsearch/evolution/springboot24/EsUtils.java b/tests/test-spring-boot-2.4/src/test/java/com/senacor/elasticsearch/evolution/springboot24/EsUtils.java
deleted file mode 100644
index 93ad5096..00000000
--- a/tests/test-spring-boot-2.4/src/test/java/com/senacor/elasticsearch/evolution/springboot24/EsUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot24;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * @author Andreas Keefer
- */
-public class EsUtils {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private final RestClient restClient;
-
- public EsUtils(RestClient restClient) {
- this.restClient = restClient;
- }
-
- public void refreshIndices() {
- try {
- restClient.performRequest(new Request("GET", "/_refresh"));
- } catch (IOException e) {
- throw new IllegalStateException("refreshIndices failed", e);
- }
- }
-
- public List fetchAllDocuments(String index) {
- try {
- Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
- Response response = restClient.performRequest(post);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < 200 || statusCode >= 300) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed with HTTP status " +
- statusCode + ": " + response.toString());
- }
- String body = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
-
- return parseDocuments(body)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed", e);
- }
- }
-
- private Stream parseDocuments(String body) {
- try {
- JsonNode jsonNode = OBJECT_MAPPER.readTree(body);
- return StreamSupport.stream(jsonNode.get("hits").get("hits").spliterator(), false)
- .map(hitNode -> hitNode.get("_source"))
- .map(JsonNode::toString);
- } catch (IOException e) {
- throw new IllegalStateException("parseDocuments failed. body=" + body, e);
- }
- }
-}
-
diff --git a/tests/test-spring-boot-2.5-scriptsInJarFile/pom.xml b/tests/test-spring-boot-2.5-scriptsInJarFile/pom.xml
deleted file mode 100644
index 23cb14c3..00000000
--- a/tests/test-spring-boot-2.5-scriptsInJarFile/pom.xml
+++ /dev/null
@@ -1,114 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.5.14
-
-
- com.senacor.elasticsearch.evolution
- test-spring-boot-2.5-scriptsInJarFile
- 0.5.2
- Demo project for Spring Boot
-
-
- 1.8
-
- 2.16.1
- 7.5.2
- 1.19.8
-
-
-
-
-
- ${project.groupId}
- migration-scripts
- ${project.version}
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- ${project.groupId}
- spring-boot-starter-elasticsearch-evolution
- ${project.version}
-
-
-
-
- org.testcontainers
- elasticsearch
- ${testcontainers.elasticsearch.version}
- test
-
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
-
-
-
-
- oss.sonatype.org-snapshot
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
-
- 0.8.12
-
-
- prepare-agent
-
- prepare-agent
-
-
-
- report
- post-integration-test
-
- report
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
diff --git a/tests/test-spring-boot-2.5-scriptsInJarFile/src/main/java/com/senacor/elasticsearch/evolution/springboot25/Application.java b/tests/test-spring-boot-2.5-scriptsInJarFile/src/main/java/com/senacor/elasticsearch/evolution/springboot25/Application.java
deleted file mode 100644
index 15055b27..00000000
--- a/tests/test-spring-boot-2.5-scriptsInJarFile/src/main/java/com/senacor/elasticsearch/evolution/springboot25/Application.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot25;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.5-scriptsInJarFile/src/main/resources/application.properties b/tests/test-spring-boot-2.5-scriptsInJarFile/src/main/resources/application.properties
deleted file mode 100644
index 5db1f692..00000000
--- a/tests/test-spring-boot-2.5-scriptsInJarFile/src/main/resources/application.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-spring.elasticsearch.evolution.locations[0]=classpath:es/mig
-spring.elasticsearch.evolution.placeholders.index=test_1
-logging.level.com.senacor.elasticsearch.evolution=DEBUG
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.5-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot25/ApplicationTest.java b/tests/test-spring-boot-2.5-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot25/ApplicationTest.java
deleted file mode 100644
index b6de4253..00000000
--- a/tests/test-spring-boot-2.5-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot25/ApplicationTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot25;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import org.apache.http.HttpHost;
-import org.elasticsearch.client.RestClient;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@SpringBootTest(properties = {"spring.elasticsearch.rest.uris=http://localhost:" + ApplicationTest.ELASTICSEARCH_PORT})
-class ApplicationTest {
-
- static final int ELASTICSEARCH_PORT = 18768;
-
- @Autowired
- private EsUtils esUtils;
-
- @Test
- void contextLoads() {
- esUtils.refreshIndices();
-
- List documents = esUtils.fetchAllDocuments("test_1");
-
- assertThat(documents).hasSize(1);
- }
-
- @TestConfiguration
- static class Config {
- @Bean(destroyMethod = "stop")
- public ElasticsearchContainer elasticsearchContainer(@Value("${elasticsearch.version:7.5.2}") String esVersion) {
- ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName
- .parse("docker.elastic.co/elasticsearch/elasticsearch")
- .withTag(esVersion)) {
- @Override
- protected void containerIsStarted(InspectContainerResponse containerInfo) {
- // since testcontainers 1.17 it detects if ES 8.x is running and copies a certificate in this case
- // but we don't want security
- }
- }
- .withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx128m")
- // since elasticsearch 8 security / https is enabled per default - but for testing it should be disabled
- .withEnv("xpack.security.enabled", "false")
- .withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
- .withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
- .withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- container.setPortBindings(Collections.singletonList(ELASTICSEARCH_PORT + ":9200"));
- container.start();
- return container;
- }
-
- @Bean
- public EsUtils esUtils(ElasticsearchContainer elasticsearchContainer) {
- return new EsUtils(RestClient.builder(HttpHost.create(elasticsearchContainer.getHttpHostAddress())).build());
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.5-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot25/EsUtils.java b/tests/test-spring-boot-2.5-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot25/EsUtils.java
deleted file mode 100644
index 8f9e5c3a..00000000
--- a/tests/test-spring-boot-2.5-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot25/EsUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot25;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * @author Andreas Keefer
- */
-public class EsUtils {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private final RestClient restClient;
-
- public EsUtils(RestClient restClient) {
- this.restClient = restClient;
- }
-
- public void refreshIndices() {
- try {
- restClient.performRequest(new Request("GET", "/_refresh"));
- } catch (IOException e) {
- throw new IllegalStateException("refreshIndices failed", e);
- }
- }
-
- public List fetchAllDocuments(String index) {
- try {
- Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
- Response response = restClient.performRequest(post);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < 200 || statusCode >= 300) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed with HTTP status " +
- statusCode + ": " + response.toString());
- }
- String body = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
-
- return parseDocuments(body)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed", e);
- }
- }
-
- private Stream parseDocuments(String body) {
- try {
- JsonNode jsonNode = OBJECT_MAPPER.readTree(body);
- return StreamSupport.stream(jsonNode.get("hits").get("hits").spliterator(), false)
- .map(hitNode -> hitNode.get("_source"))
- .map(JsonNode::toString);
- } catch (IOException e) {
- throw new IllegalStateException("parseDocuments failed. body=" + body, e);
- }
- }
-}
-
diff --git a/tests/test-spring-boot-2.6/pom.xml b/tests/test-spring-boot-2.6/pom.xml
deleted file mode 100644
index bd936899..00000000
--- a/tests/test-spring-boot-2.6/pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.6.14
-
-
- com.senacor.elasticsearch.evolution
- test-spring-boot-2.6
- 0.5.2
- Demo project for Spring Boot
-
-
- 1.8
-
- 2.16.1
- 7.5.2
- 1.19.8
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- ${project.groupId}
- spring-boot-starter-elasticsearch-evolution
- ${project.version}
-
-
-
-
- org.testcontainers
- elasticsearch
- ${testcontainers.elasticsearch.version}
- test
-
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
-
-
-
-
- oss.sonatype.org-snapshot
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
-
- 0.8.12
-
-
- prepare-agent
-
- prepare-agent
-
-
-
- report
- post-integration-test
-
- report
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
diff --git a/tests/test-spring-boot-2.6/src/main/java/com/senacor/elasticsearch/evolution/springboot26/Application.java b/tests/test-spring-boot-2.6/src/main/java/com/senacor/elasticsearch/evolution/springboot26/Application.java
deleted file mode 100644
index ac199c30..00000000
--- a/tests/test-spring-boot-2.6/src/main/java/com/senacor/elasticsearch/evolution/springboot26/Application.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot26;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.6/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http b/tests/test-spring-boot-2.6/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
deleted file mode 100644
index fbd7df47..00000000
--- a/tests/test-spring-boot-2.6/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
+++ /dev/null
@@ -1,35 +0,0 @@
-PUT _template/test_1
-Content-Type: application/json
-
-{
- "index_patterns" : [
- "test_*"
- ],
- "order" : 1,
- "version" : 1,
- "settings" : {
- "number_of_shards" : 1
- },
- "mappings" : {
- "dynamic" : "strict",
- "properties" : {
- "doc" : {
- "dynamic" : false,
- "properties" : {}
- },
- "searchable" : {
- "dynamic" : false,
- "properties" : {
- "version" : {
- "type" : "keyword",
- "ignore_above" : 20,
- "similarity" : "boolean"
- },
- "locked" : {
- "type" : "boolean"
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.6/src/main/resources/es/migration/V001.01__addDocument.http b/tests/test-spring-boot-2.6/src/main/resources/es/migration/V001.01__addDocument.http
deleted file mode 100644
index 4f18ba0a..00000000
--- a/tests/test-spring-boot-2.6/src/main/resources/es/migration/V001.01__addDocument.http
+++ /dev/null
@@ -1,17 +0,0 @@
-PUT /test_1/_doc/1?refresh
-Content-Type: application/json
-
-{
- "searchable": {
- "version": "1",
- "locked": false
- },
- "doc": {
- "version": "1",
- "locked": false,
- "success": true,
- "a": "a a a",
- "b": true,
- "c": "c"
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.6/src/test/java/com/senacor/elasticsearch/evolution/springboot26/ApplicationTests.java b/tests/test-spring-boot-2.6/src/test/java/com/senacor/elasticsearch/evolution/springboot26/ApplicationTests.java
deleted file mode 100644
index d8cd75ea..00000000
--- a/tests/test-spring-boot-2.6/src/test/java/com/senacor/elasticsearch/evolution/springboot26/ApplicationTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot26;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import org.apache.http.HttpHost;
-import org.elasticsearch.client.RestClient;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@SpringBootTest(properties = {"spring.elasticsearch.uris=http://localhost:" + ApplicationTests.ELASTICSEARCH_PORT})
-class ApplicationTests {
-
- static final int ELASTICSEARCH_PORT = 18772;
-
- @Autowired
- private EsUtils esUtils;
-
- @Test
- void contextLoads() {
- esUtils.refreshIndices();
-
- List documents = esUtils.fetchAllDocuments("test_1");
-
- assertThat(documents).hasSize(1);
- }
-
- @TestConfiguration
- static class Config {
- @Bean(destroyMethod = "stop")
- public ElasticsearchContainer elasticsearchContainer(@Value("${elasticsearch.version:7.5.2}") String esVersion) {
- ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName
- .parse("docker.elastic.co/elasticsearch/elasticsearch")
- .withTag(esVersion)) {
- @Override
- protected void containerIsStarted(InspectContainerResponse containerInfo) {
- // since testcontainers 1.17 it detects if ES 8.x is running and copies a certificate in this case
- // but we don't want security
- }
- }
- .withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx128m")
- // since elasticsearch 8 security / https is enabled per default - but for testing it should be disabled
- .withEnv("xpack.security.enabled", "false")
- .withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
- .withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
- .withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- container.setPortBindings(Collections.singletonList(ELASTICSEARCH_PORT + ":9200"));
- container.start();
- return container;
- }
-
- @Bean
- public EsUtils esUtils(ElasticsearchContainer elasticsearchContainer) {
- return new EsUtils(RestClient.builder(HttpHost.create(elasticsearchContainer.getHttpHostAddress())).build());
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.6/src/test/java/com/senacor/elasticsearch/evolution/springboot26/EsUtils.java b/tests/test-spring-boot-2.6/src/test/java/com/senacor/elasticsearch/evolution/springboot26/EsUtils.java
deleted file mode 100644
index 31d618ff..00000000
--- a/tests/test-spring-boot-2.6/src/test/java/com/senacor/elasticsearch/evolution/springboot26/EsUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot26;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * @author Andreas Keefer
- */
-public class EsUtils {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private final RestClient restClient;
-
- public EsUtils(RestClient restClient) {
- this.restClient = restClient;
- }
-
- public void refreshIndices() {
- try {
- restClient.performRequest(new Request("GET", "/_refresh"));
- } catch (IOException e) {
- throw new IllegalStateException("refreshIndices failed", e);
- }
- }
-
- public List fetchAllDocuments(String index) {
- try {
- Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
- Response response = restClient.performRequest(post);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < 200 || statusCode >= 300) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed with HTTP status " +
- statusCode + ": " + response.toString());
- }
- String body = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
-
- return parseDocuments(body)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed", e);
- }
- }
-
- private Stream parseDocuments(String body) {
- try {
- JsonNode jsonNode = OBJECT_MAPPER.readTree(body);
- return StreamSupport.stream(jsonNode.get("hits").get("hits").spliterator(), false)
- .map(hitNode -> hitNode.get("_source"))
- .map(JsonNode::toString);
- } catch (IOException e) {
- throw new IllegalStateException("parseDocuments failed. body=" + body, e);
- }
- }
-}
-
diff --git a/tests/test-spring-boot-2.7/pom.xml b/tests/test-spring-boot-2.7/pom.xml
deleted file mode 100644
index 196948b8..00000000
--- a/tests/test-spring-boot-2.7/pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.7.18
-
-
- com.senacor.elasticsearch.evolution
- test-spring-boot-2.7
- 0.5.2
- Demo project for Spring Boot
-
-
- 1.8
-
- 2.16.1
- 7.5.2
- 1.19.8
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- ${project.groupId}
- spring-boot-starter-elasticsearch-evolution
- ${project.version}
-
-
-
-
- org.testcontainers
- elasticsearch
- ${testcontainers.elasticsearch.version}
- test
-
-
- commons-io
- commons-io
- ${commons-io.version}
- test
-
-
-
-
-
- oss.sonatype.org-snapshot
- https://oss.sonatype.org/content/repositories/snapshots
-
- false
-
-
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.jacoco
- jacoco-maven-plugin
-
- 0.8.12
-
-
- prepare-agent
-
- prepare-agent
-
-
-
- report
- post-integration-test
-
- report
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
diff --git a/tests/test-spring-boot-2.7/src/main/java/com/senacor/elasticsearch/evolution/springboot27/Application.java b/tests/test-spring-boot-2.7/src/main/java/com/senacor/elasticsearch/evolution/springboot27/Application.java
deleted file mode 100644
index a22e3a8b..00000000
--- a/tests/test-spring-boot-2.7/src/main/java/com/senacor/elasticsearch/evolution/springboot27/Application.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot27;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.7/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http b/tests/test-spring-boot-2.7/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
deleted file mode 100644
index fbd7df47..00000000
--- a/tests/test-spring-boot-2.7/src/main/resources/es/migration/V001.00__createTemplateWithIndexMapping.http
+++ /dev/null
@@ -1,35 +0,0 @@
-PUT _template/test_1
-Content-Type: application/json
-
-{
- "index_patterns" : [
- "test_*"
- ],
- "order" : 1,
- "version" : 1,
- "settings" : {
- "number_of_shards" : 1
- },
- "mappings" : {
- "dynamic" : "strict",
- "properties" : {
- "doc" : {
- "dynamic" : false,
- "properties" : {}
- },
- "searchable" : {
- "dynamic" : false,
- "properties" : {
- "version" : {
- "type" : "keyword",
- "ignore_above" : 20,
- "similarity" : "boolean"
- },
- "locked" : {
- "type" : "boolean"
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.7/src/main/resources/es/migration/V001.01__addDocument.http b/tests/test-spring-boot-2.7/src/main/resources/es/migration/V001.01__addDocument.http
deleted file mode 100644
index 4f18ba0a..00000000
--- a/tests/test-spring-boot-2.7/src/main/resources/es/migration/V001.01__addDocument.http
+++ /dev/null
@@ -1,17 +0,0 @@
-PUT /test_1/_doc/1?refresh
-Content-Type: application/json
-
-{
- "searchable": {
- "version": "1",
- "locked": false
- },
- "doc": {
- "version": "1",
- "locked": false,
- "success": true,
- "a": "a a a",
- "b": true,
- "c": "c"
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.7/src/test/java/com/senacor/elasticsearch/evolution/springboot27/ApplicationTests.java b/tests/test-spring-boot-2.7/src/test/java/com/senacor/elasticsearch/evolution/springboot27/ApplicationTests.java
deleted file mode 100644
index 40a4e773..00000000
--- a/tests/test-spring-boot-2.7/src/test/java/com/senacor/elasticsearch/evolution/springboot27/ApplicationTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot27;
-
-import com.github.dockerjava.api.command.InspectContainerResponse;
-import org.apache.http.HttpHost;
-import org.elasticsearch.client.RestClient;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@SpringBootTest(properties = {"spring.elasticsearch.uris=http://localhost:" + ApplicationTests.ELASTICSEARCH_PORT})
-class ApplicationTests {
-
- static final int ELASTICSEARCH_PORT = 18773;
-
- @Autowired
- private EsUtils esUtils;
-
- @Test
- void contextLoads() {
- esUtils.refreshIndices();
-
- List documents = esUtils.fetchAllDocuments("test_1");
-
- assertThat(documents).hasSize(1);
- }
-
- @TestConfiguration
- static class Config {
- @Bean(destroyMethod = "stop")
- public ElasticsearchContainer elasticsearchContainer(@Value("${elasticsearch.version:7.5.2}") String esVersion) {
- ElasticsearchContainer container = new ElasticsearchContainer(DockerImageName
- .parse("docker.elastic.co/elasticsearch/elasticsearch")
- .withTag(esVersion)) {
- @Override
- protected void containerIsStarted(InspectContainerResponse containerInfo) {
- // since testcontainers 1.17 it detects if ES 8.x is running and copies a certificate in this case
- // but we don't want security
- }
- }
- .withEnv("ES_JAVA_OPTS", "-Xms128m -Xmx128m")
- // since elasticsearch 8 security / https is enabled per default - but for testing it should be disabled
- .withEnv("xpack.security.enabled", "false")
- .withEnv("cluster.routing.allocation.disk.watermark.low", "97%")
- .withEnv("cluster.routing.allocation.disk.watermark.high", "98%")
- .withEnv("cluster.routing.allocation.disk.watermark.flood_stage", "99%");
- container.setPortBindings(Collections.singletonList(ELASTICSEARCH_PORT + ":9200"));
- container.start();
- return container;
- }
-
- @Bean
- public EsUtils esUtils(ElasticsearchContainer elasticsearchContainer) {
- return new EsUtils(RestClient.builder(HttpHost.create(elasticsearchContainer.getHttpHostAddress())).build());
- }
- }
-}
\ No newline at end of file
diff --git a/tests/test-spring-boot-2.7/src/test/java/com/senacor/elasticsearch/evolution/springboot27/EsUtils.java b/tests/test-spring-boot-2.7/src/test/java/com/senacor/elasticsearch/evolution/springboot27/EsUtils.java
deleted file mode 100644
index 9c550f6a..00000000
--- a/tests/test-spring-boot-2.7/src/test/java/com/senacor/elasticsearch/evolution/springboot27/EsUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.senacor.elasticsearch.evolution.springboot27;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.commons.io.IOUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.client.RestClient;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-/**
- * @author Andreas Keefer
- */
-public class EsUtils {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private final RestClient restClient;
-
- public EsUtils(RestClient restClient) {
- this.restClient = restClient;
- }
-
- public void refreshIndices() {
- try {
- restClient.performRequest(new Request("GET", "/_refresh"));
- } catch (IOException e) {
- throw new IllegalStateException("refreshIndices failed", e);
- }
- }
-
- public List fetchAllDocuments(String index) {
- try {
- Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
- Response response = restClient.performRequest(post);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < 200 || statusCode >= 300) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed with HTTP status " +
- statusCode + ": " + response.toString());
- }
- String body = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
-
- return parseDocuments(body)
- .collect(Collectors.toList());
- } catch (IOException e) {
- throw new IllegalStateException("fetchAllDocuments(" + index + ") failed", e);
- }
- }
-
- private Stream parseDocuments(String body) {
- try {
- JsonNode jsonNode = OBJECT_MAPPER.readTree(body);
- return StreamSupport.stream(jsonNode.get("hits").get("hits").spliterator(), false)
- .map(hitNode -> hitNode.get("_source"))
- .map(JsonNode::toString);
- } catch (IOException e) {
- throw new IllegalStateException("parseDocuments failed. body=" + body, e);
- }
- }
-}
-
diff --git a/tests/test-spring-boot-3.0-scriptsInJarFile/pom.xml b/tests/test-spring-boot-3.0-scriptsInJarFile/pom.xml
index 480c949b..dfa8e16b 100644
--- a/tests/test-spring-boot-3.0-scriptsInJarFile/pom.xml
+++ b/tests/test-spring-boot-3.0-scriptsInJarFile/pom.xml
@@ -10,7 +10,7 @@
com.senacor.elasticsearch.evolution
test-spring-boot-3.0-scriptsInJarFile
- 0.5.2
+ 0.6.0
Demo project for Spring Boot
@@ -108,6 +108,23 @@
true
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+ 5.31.0
+
+
+ org.openrewrite.java.migrate.UpgradeToJava17
+
+
+
+
+ org.openrewrite.recipe
+ rewrite-migrate-java
+ 2.14.0
+
+
+
diff --git a/tests/test-spring-boot-3.0-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot30/EsUtils.java b/tests/test-spring-boot-3.0-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot30/EsUtils.java
index 91518057..7fb150df 100644
--- a/tests/test-spring-boot-3.0-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot30/EsUtils.java
+++ b/tests/test-spring-boot-3.0-scriptsInJarFile/src/test/java/com/senacor/elasticsearch/evolution/springboot30/EsUtils.java
@@ -38,11 +38,13 @@ public void refreshIndices() {
public List fetchAllDocuments(String index) {
try {
Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
+ post.setJsonEntity("""
+ {\
+ "query": {\
+ "match_all": {}\
+ }\
+ }\
+ """);
Response response = restClient.performRequest(post);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode < 200 || statusCode >= 300) {
diff --git a/tests/test-spring-boot-3.1/pom.xml b/tests/test-spring-boot-3.1/pom.xml
index e54f064b..8e2eccd7 100644
--- a/tests/test-spring-boot-3.1/pom.xml
+++ b/tests/test-spring-boot-3.1/pom.xml
@@ -10,7 +10,7 @@
com.senacor.elasticsearch.evolution
test-spring-boot-3.1
- 0.5.2
+ 0.6.0
Demo project for Spring Boot
@@ -101,6 +101,23 @@
true
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+ 5.31.0
+
+
+ org.openrewrite.java.migrate.UpgradeToJava17
+
+
+
+
+ org.openrewrite.recipe
+ rewrite-migrate-java
+ 2.14.0
+
+
+
diff --git a/tests/test-spring-boot-3.1/src/test/java/com/senacor/elasticsearch/evolution/springboot31/EsUtils.java b/tests/test-spring-boot-3.1/src/test/java/com/senacor/elasticsearch/evolution/springboot31/EsUtils.java
index 4c69d697..89235dcc 100644
--- a/tests/test-spring-boot-3.1/src/test/java/com/senacor/elasticsearch/evolution/springboot31/EsUtils.java
+++ b/tests/test-spring-boot-3.1/src/test/java/com/senacor/elasticsearch/evolution/springboot31/EsUtils.java
@@ -38,11 +38,13 @@ public void refreshIndices() {
public List fetchAllDocuments(String index) {
try {
Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
+ post.setJsonEntity("""
+ {\
+ "query": {\
+ "match_all": {}\
+ }\
+ }\
+ """);
Response response = restClient.performRequest(post);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode < 200 || statusCode >= 300) {
diff --git a/tests/test-spring-boot-3.2/pom.xml b/tests/test-spring-boot-3.2/pom.xml
index a739046a..7483ce87 100644
--- a/tests/test-spring-boot-3.2/pom.xml
+++ b/tests/test-spring-boot-3.2/pom.xml
@@ -10,7 +10,7 @@
com.senacor.elasticsearch.evolution
test-spring-boot-3.2
- 0.5.2
+ 0.6.0
Demo project for Spring Boot
@@ -101,6 +101,23 @@
true
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+ 5.31.0
+
+
+ org.openrewrite.java.migrate.UpgradeToJava17
+
+
+
+
+ org.openrewrite.recipe
+ rewrite-migrate-java
+ 2.14.0
+
+
+
diff --git a/tests/test-spring-boot-3.2/src/test/java/com/senacor/elasticsearch/evolution/springboot32/EsUtils.java b/tests/test-spring-boot-3.2/src/test/java/com/senacor/elasticsearch/evolution/springboot32/EsUtils.java
index e4129a2c..7258feb2 100644
--- a/tests/test-spring-boot-3.2/src/test/java/com/senacor/elasticsearch/evolution/springboot32/EsUtils.java
+++ b/tests/test-spring-boot-3.2/src/test/java/com/senacor/elasticsearch/evolution/springboot32/EsUtils.java
@@ -38,11 +38,13 @@ public void refreshIndices() {
public List fetchAllDocuments(String index) {
try {
Request post = new Request("POST", "/" + index + "/_search");
- post.setJsonEntity("{" +
- " \"query\": {" +
- " \"match_all\": {}" +
- " }" +
- "}");
+ post.setJsonEntity("""
+ {\
+ "query": {\
+ "match_all": {}\
+ }\
+ }\
+ """);
Response response = restClient.performRequest(post);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode < 200 || statusCode >= 300) {