mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Fix image-building unit tests on Windows
See gh-32000
This commit is contained in:
parent
5f2f6d32cf
commit
257e236b06
@ -28,9 +28,13 @@ import java.util.Map;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.sun.jna.Platform;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.skyscreamer.jsonassert.JSONAssert;
|
||||
|
||||
import org.springframework.boot.buildpack.platform.docker.DockerApi;
|
||||
import org.springframework.boot.buildpack.platform.docker.DockerApi.ContainerApi;
|
||||
@ -318,9 +322,19 @@ class LifecycleTests {
|
||||
|
||||
private IOConsumer<ContainerConfig> withExpectedConfig(String name) {
|
||||
return (config) -> {
|
||||
InputStream in = getClass().getResourceAsStream(name);
|
||||
String json = FileCopyUtils.copyToString(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
assertThat(config.toString()).isEqualToIgnoringWhitespace(json);
|
||||
try {
|
||||
InputStream in = getClass().getResourceAsStream(name);
|
||||
String jsonString = FileCopyUtils.copyToString(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
JSONObject json = new JSONObject(jsonString);
|
||||
if (Platform.isWindows()) {
|
||||
JSONObject hostConfig = json.getJSONObject("HostConfig");
|
||||
hostConfig.remove("SecurityOpt");
|
||||
}
|
||||
JSONAssert.assertEquals(config.toString(), json, true);
|
||||
}
|
||||
catch (JSONException ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user