diff --git a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java index cb0b68a9622a0..9564cb156adbf 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java @@ -219,11 +219,13 @@ public void testInlineScriptCompiledOnceCache() throws IOException { public void testDefaultBehaviourFineGrainedSettings() throws IOException { Settings.Builder builder = Settings.builder(); //rarely inject the default settings, which have no effect + boolean deprecate = false; if (rarely()) { builder.put("script.file", "true"); + deprecate = true; } buildScriptService(builder.build()); - createFileScripts("groovy", "mustache", "dtest"); + createFileScripts("dtest"); for (ScriptContext scriptContext : scriptContexts) { // only file scripts are accepted by default @@ -231,7 +233,12 @@ public void testDefaultBehaviourFineGrainedSettings() throws IOException { assertCompileRejected("dtest", "script", ScriptType.STORED, scriptContext); assertCompileAccepted("dtest", "file_script", ScriptType.FILE, scriptContext); } - assertWarnings("File scripts are deprecated. Use stored or inline scripts instead."); + if (deprecate) { + assertSettingDeprecationsAndWarnings(ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.file"), + "File scripts are deprecated. Use stored or inline scripts instead."); + } else { + assertWarnings("File scripts are deprecated. Use stored or inline scripts instead."); + } } public void testFineGrainedSettings() throws IOException { diff --git a/core/src/test/java/org/elasticsearch/script/ScriptSettingsTests.java b/core/src/test/java/org/elasticsearch/script/ScriptSettingsTests.java index 25e38ed7d6fb2..67a94f588075b 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptSettingsTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptSettingsTests.java @@ -33,6 +33,7 @@ import static org.hamcrest.Matchers.equalTo; public class ScriptSettingsTests extends ESTestCase { + public static Setting[] buildDeprecatedSettingsArray(ScriptSettings scriptSettings, String... keys) { return buildDeprecatedSettingsArray(null, scriptSettings, keys); }