Use Strings.format instead of String.format(Locale.ROOT, ...) in tests (#92106)

Use local-independent `Strings.format` method instead of `String.format(Locale.ROOT, ...)`. 
Inline `ESTestCase.forbidden` calls with `Strings.format` for the consistency sake.
Add `Strings.format` alias in `common.Strings`
This commit is contained in:
Artem Prigoda 2023-01-03 19:28:27 +01:00 committed by GitHub
parent 677766dd1f
commit 2bc7398754
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
340 changed files with 1343 additions and 1167 deletions

View file

@ -13,6 +13,7 @@ import org.elasticsearch.common.blobstore.BlobContainer;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.core.Strings;
import org.elasticsearch.test.ESTestCase;
import java.io.IOException;
@ -57,7 +58,7 @@ public abstract class AbstractURLBlobStoreTests extends ESTestCase {
ignored.read();
fail("Should have thrown NoSuchFileException exception");
} catch (NoSuchFileException e) {
assertEquals(formatted("blob object [%s] not found", incorrectBlobName), e.getMessage());
assertEquals(Strings.format("blob object [%s] not found", incorrectBlobName), e.getMessage());
}
}
}

View file

@ -10,6 +10,7 @@ package org.elasticsearch.common.blobstore.url.http;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.Strings;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
@ -17,7 +18,6 @@ import java.io.IOException;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@ -44,7 +44,7 @@ public class RetryingHttpInputStreamTests extends ESTestCase {
when(secondHttpResponseInputStream.read(any(), anyInt(), anyInt())).thenReturn(blobSize - firstChunkSize).thenReturn(-1);
final Map<String, String> secondResponseHeaders = Map.of(
"Content-Range",
String.format(Locale.ROOT, "bytes %d-%d/%d", firstChunkSize, blobSize - 1, blobSize)
Strings.format("bytes %d-%d/%d", firstChunkSize, blobSize - 1, blobSize)
);
final List<MockHttpResponse> responses = List.of(