From 3aaf6872c1dba7a4afda43063ace603125547211 Mon Sep 17 00:00:00 2001 From: Adriano Machado <60320+ammachado@users.noreply.github.com> Date: Fri, 26 Jan 2024 23:28:05 -0500 Subject: [PATCH] Allow configuration of HTTP timeouts for maven repositories --- .../org/openrewrite/ipc/http/HttpSender.java | 32 ++++- .../ipc/http/HttpUrlConnectionSender.java | 12 +- .../maven/MavenExecutionContextView.java | 2 + .../org/openrewrite/maven/MavenSettings.java | 19 ++- .../openrewrite/maven/UpdateMavenModel.java | 2 + .../maven/internal/MavenPomDownloader.java | 13 +- .../openrewrite/maven/internal/RawPom.java | 2 +- .../maven/tree/MavenRepository.java | 60 +++++++++- .../openrewrite/maven/MavenSettingsTest.java | 113 ++++++++++++++---- .../internal/MavenPomDownloaderTest.java | 6 +- .../maven/tree/MavenRepositoryMirrorTest.java | 2 +- 11 files changed, 224 insertions(+), 39 deletions(-) diff --git a/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpSender.java b/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpSender.java index fe101629cf54..6417dfa7ce62 100644 --- a/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpSender.java +++ b/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpSender.java @@ -24,6 +24,7 @@ import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.time.Duration; import java.util.Base64; import java.util.LinkedHashMap; import java.util.Map; @@ -74,12 +75,16 @@ class Request { private final byte[] entity; private final Method method; private final Map requestHeaders; + private final Duration connectTimeout; + private final Duration readTimeout; - public Request(URL url, byte[] entity, Method method, Map requestHeaders) { + public Request(URL url, byte[] entity, Method method, Map requestHeaders, Duration connectTimeout, Duration readTimeout) { this.url = url; this.entity = entity; this.method = method; this.requestHeaders = requestHeaders; + this.connectTimeout = connectTimeout; + this.readTimeout = readTimeout; } public URL getUrl() { @@ -98,6 +103,14 @@ public Map getRequestHeaders() { return requestHeaders; } + public Duration getConnectTimeout() { + return connectTimeout; + } + + public Duration getReadTimeout() { + return readTimeout; + } + public static Builder build(String uri, HttpSender sender) { return new Builder(uri, sender); } @@ -125,6 +138,8 @@ public static class Builder { private URL url; private byte[] entity = new byte[0]; private Method method; + private Duration connectTimeout; + private Duration readTimeout; Builder(String url, HttpSender sender) { try { @@ -277,8 +292,9 @@ public final Builder compress() throws IOException { * @throws IOException If compression fails. */ public final Builder compressWhen(Supplier when) throws IOException { - if (when.get()) + if (when.get()) { return compress(); + } return this; } @@ -331,7 +347,17 @@ public Response send() { } public Request build() { - return new Request(url, entity, method, requestHeaders); + return new Request(url, entity, method, requestHeaders, connectTimeout, readTimeout); + } + + public Builder withConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + return this; + } + + public Builder withReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; } } } diff --git a/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpUrlConnectionSender.java b/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpUrlConnectionSender.java index 661a5ec4a8cb..38990e1e1e95 100644 --- a/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpUrlConnectionSender.java +++ b/rewrite-core/src/main/java/org/openrewrite/ipc/http/HttpUrlConnectionSender.java @@ -77,8 +77,16 @@ public Response send(Request request) { } else { con = (HttpURLConnection) request.getUrl().openConnection(); } - con.setConnectTimeout(connectTimeoutMs); - con.setReadTimeout(readTimeoutMs); + if (request.getConnectTimeout() != null) { + con.setConnectTimeout((int) request.getConnectTimeout().toMillis()); + } else { + con.setConnectTimeout(connectTimeoutMs); + } + if (request.getReadTimeout() != null) { + con.setReadTimeout((int) request.getReadTimeout().toMillis()); + } else { + con.setReadTimeout(readTimeoutMs); + } Method method = request.getMethod(); con.setRequestMethod(method.name()); diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java b/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java index 1790272ec546..0a667592d5c0 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/MavenExecutionContextView.java @@ -250,6 +250,8 @@ private List mapRepositories(MavenSettings settings, List httpHeaders; + @Nullable + Long connectTimeout; + @Nullable + Long readTimeout; } @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/UpdateMavenModel.java b/rewrite-maven/src/main/java/org/openrewrite/maven/UpdateMavenModel.java index a0ba344772fe..58de657afd62 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/UpdateMavenModel.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/UpdateMavenModel.java @@ -119,6 +119,8 @@ public Xml visitDocument(Xml.Document document, P p) { t.getChild("releases").flatMap(s -> s.getChildValue("enabled")).orElse(null), t.getChild("snapshots").flatMap(s -> s.getChildValue("enabled")).orElse(null), null, + null, + null, null )).collect(Collectors.toList())); } else { diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java index f22ef5f86042..7dff58aa8953 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/MavenPomDownloader.java @@ -751,7 +751,9 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, M repository.getReleases(), repository.getSnapshots(), repository.getUsername(), - repository.getPassword()); + repository.getPassword(), + repository.getConnectTimeout(), + repository.getReadTimeout()); } catch (HttpSenderResponseException e) { //Response was returned from the server, but it was not a 200 OK. The server therefore exists. if (e.getResponseCode() != null) { @@ -761,7 +763,9 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, M repository.getReleases(), repository.getSnapshots(), repository.getUsername(), - repository.getPassword()); + repository.getPassword(), + repository.getConnectTimeout(), + repository.getReadTimeout()); } else if (!e.isClientSideException()) { return originalRepository; } @@ -792,7 +796,10 @@ public MavenRepository normalizeRepository(MavenRepository originalRepository, M */ private byte[] requestAsAuthenticatedOrAnonymous(MavenRepository repo, String uriString) throws HttpSenderResponseException { try { - return sendRequest(applyAuthenticationToRequest(repo, httpSender.get(uriString)).build()); + HttpSender.Request.Builder request = httpSender.get(uriString) + .withConnectTimeout(repo.getConnectTimeout()) + .withReadTimeout(repo.getReadTimeout()); + return sendRequest(applyAuthenticationToRequest(repo, request).build()); } catch (HttpSenderResponseException e) { if (hasCredentials(repo) && e.isClientSideException()) { return retryRequestAnonymously(uriString, e); diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java index 5bb4a40bb576..46116f873750 100755 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/internal/RawPom.java @@ -413,7 +413,7 @@ private List mapRepositories(@Nullable RawRepositories rawRepos pomRepositories.add(new MavenRepository(r.getId(), r.getUrl(), r.getReleases() == null ? null : r.getReleases().getEnabled(), r.getSnapshots() == null ? null : r.getSnapshots().getEnabled(), - false, null, null, null)); + false, null, null, null, null, null)); } } diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java index 4dd1f7200c56..ca50832dcd98 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/tree/MavenRepository.java @@ -29,6 +29,7 @@ import java.io.Serializable; import java.net.URI; import java.nio.file.Paths; +import java.time.Duration; @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@ref") @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @@ -37,9 +38,9 @@ @RequiredArgsConstructor public class MavenRepository implements Serializable { - public static final MavenRepository MAVEN_LOCAL_USER_NEUTRAL = new MavenRepository("local", new File("~/.m2/repository").toString(), "true", "true", true, null, null, false); - public static final MavenRepository MAVEN_LOCAL_DEFAULT = new MavenRepository("local", Paths.get(System.getProperty("user.home"), ".m2", "repository").toUri().toString(), "true", "true", true, null, null, false); - public static final MavenRepository MAVEN_CENTRAL = new MavenRepository("central", "https://repo.maven.apache.org/maven2", "true", "false", true, null, null, true); + public static final MavenRepository MAVEN_LOCAL_USER_NEUTRAL = new MavenRepository("local", new File("~/.m2/repository").toString(), "true", "true", true, null, null, null, null, false); + public static final MavenRepository MAVEN_LOCAL_DEFAULT = new MavenRepository("local", Paths.get(System.getProperty("user.home"), ".m2", "repository").toUri().toString(), "true", "true", true, null, null, null, null, false); + public static final MavenRepository MAVEN_CENTRAL = new MavenRepository("central", "https://repo.maven.apache.org/maven2", "true", "false", true, null, null, null, null, true); @EqualsAndHashCode.Include @With @@ -79,14 +80,51 @@ public class MavenRepository implements Serializable { @Nullable String password; + @With + @Nullable + Duration connectTimeout; + + @With + @Nullable + Duration readTimeout; + @Nullable @NonFinal Boolean deriveMetadataIfMissing; + /** + * Constructor required by {@link org.openrewrite.maven.tree.OpenRewriteModelSerializableTest}. + * + * @deprecated Use {@link #MavenRepository(String, String, String, String, boolean, String, String, Duration, Duration, Boolean)} + */ + @Deprecated + @JsonIgnore + public MavenRepository( + @Nullable String id, String uri, @Nullable String releases, @Nullable String snapshots, + @Nullable String username, @Nullable String password + ) { + this(id, uri, releases, snapshots, false, username, password, null, null, null); + } + + /** + * Constructor required by {@link org.openrewrite.gradle.marker.GradleProject}. + * + * @deprecated Use {@link #MavenRepository(String, String, String, String, boolean, String, String, Duration, Duration, Boolean)} + */ + @Deprecated @JsonIgnore public MavenRepository( @Nullable String id, String uri, @Nullable String releases, @Nullable String snapshots, boolean knownToExist, @Nullable String username, @Nullable String password, @Nullable Boolean deriveMetadataIfMissing + ) { + this(id, uri, releases, snapshots, knownToExist, username, password, null, null, deriveMetadataIfMissing); + } + + @JsonIgnore + public MavenRepository( + @Nullable String id, String uri, @Nullable String releases, @Nullable String snapshots, boolean knownToExist, + @Nullable String username, @Nullable String password, @Nullable Duration connectTimeout, + @Nullable Duration readTimeout, @Nullable Boolean deriveMetadataIfMissing ) { this.id = id; this.uri = uri; @@ -95,6 +133,8 @@ public MavenRepository( this.knownToExist = knownToExist; this.username = username; this.password = password; + this.connectTimeout = connectTimeout; + this.readTimeout = readTimeout; this.deriveMetadataIfMissing = deriveMetadataIfMissing; } @@ -115,12 +155,14 @@ public static class Builder { String username; String password; Boolean deriveMetadataIfMissing; + Duration connectTimeout; + Duration readTimeout; private Builder() { } public MavenRepository build() { - return new MavenRepository(id, uri, releases, snapshots, knownToExist, username, password, deriveMetadataIfMissing); + return new MavenRepository(id, uri, releases, snapshots, knownToExist, username, password, connectTimeout, readTimeout, deriveMetadataIfMissing); } public Builder releases(boolean releases) { @@ -163,6 +205,16 @@ public Builder password(String password) { return this; } + public Builder connectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + return this; + } + + public Builder readTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + return this; + } + @Nullable private static String resolveEnvironmentProperty(@Nullable String rawProperty) { if (rawProperty == null) { diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/MavenSettingsTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/MavenSettingsTest.java index 08c95599f428..619a9f7a7069 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/MavenSettingsTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/MavenSettingsTest.java @@ -15,7 +15,10 @@ */ package org.openrewrite.maven; +import com.fasterxml.jackson.annotation.JsonInclude; import org.assertj.core.api.Condition; +import org.assertj.core.api.InstanceOfAssertFactories; +import org.assertj.core.api.ThrowingConsumer; import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Nested; @@ -23,10 +26,16 @@ import org.openrewrite.InMemoryExecutionContext; import org.openrewrite.Issue; import org.openrewrite.Parser; +import org.openrewrite.maven.internal.MavenXmlMapper; import org.openrewrite.maven.tree.MavenRepository; import org.openrewrite.maven.tree.MavenRepositoryMirror; +import org.openrewrite.xml.SemanticallyEqual; +import org.openrewrite.xml.XmlParser; +import org.openrewrite.xml.tree.Xml; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.lang.reflect.Field; import java.nio.file.Path; import java.nio.file.Paths; @@ -37,9 +46,13 @@ @SuppressWarnings({"HttpUrlsUsage", "ConstantConditions"}) class MavenSettingsTest { + private final MavenExecutionContextView ctx = MavenExecutionContextView.view( + new InMemoryExecutionContext((ThrowingConsumer) input -> { + throw input; + })); + @Test void parse() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -73,7 +86,6 @@ void parse() { @Issue("https://github.com/openrewrite/rewrite/issues/131") @Test void defaultActiveWhenNoOthersAreActive() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -114,7 +126,6 @@ void defaultActiveWhenNoOthersAreActive() { @Test void idCollisionLastRepositoryWins() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -151,13 +162,12 @@ void idCollisionLastRepositoryWins() { assertThat(ctx.getRepositories()) .as("When multiple repositories have the same id in a maven settings file the last one wins. In a pom.xml an error would be thrown.") - .containsExactly(new MavenRepository("repo", "https://lastwins.com", null, null, null, null)); + .containsExactly(new MavenRepository("repo", "https://lastwins.com", null, null, null, null, null, null)); } @Issue("https://github.com/openrewrite/rewrite/issues/131") @Test void defaultOnlyActiveIfNoOthersAreActive() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -198,7 +208,6 @@ void defaultOnlyActiveIfNoOthersAreActive() { """.getBytes() )), ctx)); - assertThat(ctx.getActiveProfiles()) .containsExactly("repo"); @@ -209,7 +218,6 @@ void defaultOnlyActiveIfNoOthersAreActive() { @Issue("https://github.com/openrewrite/rewrite/issues/130") @Test void mirrorReplacesRepository() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -252,7 +260,6 @@ void mirrorReplacesRepository() { @Test void starredMirrorWithExclusion() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -308,7 +315,6 @@ void starredMirrorWithExclusion() { @Test void serverCredentials() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); var settings = MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -334,13 +340,41 @@ void serverCredentials() { .matches(repo -> repo.getPassword().equals("my_password")); } + @Test + void serverTimeouts() { + var settings = MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( + //language=xml + """ + + + + server001 + + 40000 + 50000 + + + + + """.getBytes() + )), ctx); + + assertThat(settings.getServers()).isNotNull(); + assertThat(settings.getServers().getServers()).hasSize(1); + assertThat(settings.getServers().getServers().get(0)) + .matches(repo -> repo.getId().equals("server001")) + .matches(repo -> repo.getConfiguration().getConnectTimeout().equals(40000L)) + .matches(repo -> repo.getConfiguration().getReadTimeout().equals(50000L)); + } + @Nested @Issue("https://github.com/openrewrite/rewrite/issues/1688") class LocalRepositoryTest { @Test void parsesLocalRepositoryPathFromSettingsXml() { var localRepoPath = System.getProperty("java.io.tmpdir"); - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -359,7 +393,6 @@ void parsesLocalRepositoryPathFromSettingsXml() { @Test void parsesLocalRepositoryUriFromSettingsXml() { var localRepoPath = Paths.get(System.getProperty("java.io.tmpdir")).toUri().toString(); - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -378,7 +411,6 @@ void parsesLocalRepositoryUriFromSettingsXml() { @Test void defaultsToTheMavenDefault() { - var ctx = MavenExecutionContextView.view(new InMemoryExecutionContext()); ctx.setMavenSettings(MavenSettings.parse(new Parser.Input(Paths.get("settings.xml"), () -> new ByteArrayInputStream( //language=xml """ @@ -432,7 +464,7 @@ void properties() { """.getBytes() - )), new InMemoryExecutionContext()); + )), ctx); assertThat(settings.getLocalRepository()).isEqualTo("/tmp/maven/local/repository/"); } @@ -472,7 +504,7 @@ void unresolvedPlaceholdersRemainUnchanged() { """.getBytes() - )), new InMemoryExecutionContext()); + )), ctx); assertThat(settings.getLocalRepository()) .isEqualTo("${custom.location.zz}/maven/local/repository/"); @@ -518,7 +550,7 @@ void env() { """.getBytes() - )), new InMemoryExecutionContext()); + )), ctx); assertThat(settings.getServers()).isNotNull(); assertThat(settings.getServers().getServers()).hasSize(1); @@ -591,7 +623,7 @@ class MergingTest { void concatenatesElementsWithUniqueIds() { Path path = Paths.get("settings.xml"); var baseSettings = MavenSettings.parse(new Parser.Input(path, () -> new ByteArrayInputStream( - installationSettings.getBytes())), new InMemoryExecutionContext()); + installationSettings.getBytes())), ctx); var userSettings = MavenSettings.parse(new Parser.Input(path, () -> new ByteArrayInputStream( //language=xml """ @@ -637,7 +669,7 @@ void concatenatesElementsWithUniqueIds() { """.getBytes() - )), new InMemoryExecutionContext()); + )), ctx); var mergedSettings = userSettings.merge(baseSettings); @@ -651,7 +683,7 @@ void concatenatesElementsWithUniqueIds() { void replacesElementsWithMatchingIds() { Path path = Paths.get("settings.xml"); var baseSettings = MavenSettings.parse(new Parser.Input(path, () -> new ByteArrayInputStream( - installationSettings.getBytes())), new InMemoryExecutionContext()); + installationSettings.getBytes())), ctx); var userSettings = MavenSettings.parse(new Parser.Input(path, () -> new ByteArrayInputStream( //language=xml """ @@ -686,7 +718,7 @@ void replacesElementsWithMatchingIds() { """.getBytes() - )), new InMemoryExecutionContext()); + )), ctx); var mergedSettings = userSettings.merge(baseSettings); @@ -742,9 +774,50 @@ void serverHttpHeaders() { """.getBytes() - )), new InMemoryExecutionContext()); + )), ctx); MavenSettings.Server server = settings.getServers().getServers().get(0); assertThat(server.getConfiguration().getHttpHeaders().get(0).getName()).isEqualTo("X-JFrog-Art-Api"); } + + @Test + void canDeserializeSettingsCorrectly() throws IOException { + Xml.Document parsed = (Xml.Document) XmlParser.builder().build().parse(""" + + + + maven-snapshots + + 10000 + + + X-JFrog-Art-Api + myApiToken + + + + + + + """).findFirst().get(); + + MavenSettings.HttpHeader httpHeader = new MavenSettings.HttpHeader("X-JFrog-Art-Api", "myApiToken"); + MavenSettings.ServerConfiguration configuration = new MavenSettings.ServerConfiguration(java.util.Collections.singletonList(httpHeader), 10000L, null); + MavenSettings.Server server = new MavenSettings.Server("maven-snapshots", null, null, configuration); + MavenSettings.Servers servers = new MavenSettings.Servers(java.util.Collections.singletonList(server)); + MavenSettings settings = new MavenSettings(null, null, null, null, servers); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + MavenXmlMapper.writeMapper() + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) + .writerWithDefaultPrettyPrinter() + .writeValue(baos, settings); + + assertThat(XmlParser.builder().build().parse(baos.toString()).findFirst()) + .isPresent() + .get(InstanceOfAssertFactories.type(Xml.Document.class)) + .isNotNull() + .satisfies(serialized -> assertThat(SemanticallyEqual.areEqual(parsed, serialized)).isTrue()); + //.satisfies(serialized -> assertThat(serialized.printAll()).isEqualTo(parsed.printAll())); + } } diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java index 294662132423..f23bf290c0b5 100755 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/internal/MavenPomDownloaderTest.java @@ -124,7 +124,7 @@ void listenerRecordsRepository() { repository.setKnownToExist(true); } - MavenRepository nonexistentRepo = new MavenRepository("repo", "http://internalartifactrepository.yourorg.com", null, null, true, null, null, null); + MavenRepository nonexistentRepo = new MavenRepository("repo", "http://internalartifactrepository.yourorg.com", null, null, true, null, null, null, null, null); List attemptedUris = new ArrayList<>(); List discoveredRepositories = new ArrayList<>(); ctx.setResolutionListener(new ResolutionEventListener() { @@ -159,7 +159,7 @@ void listenerRecordsFailedRepositoryAccess() { repository.setKnownToExist(true); } - MavenRepository nonexistentRepo = new MavenRepository("repo", "http://internalartifactrepository.yourorg.com", null, null, false, null, null, null); + MavenRepository nonexistentRepo = new MavenRepository("repo", "http://internalartifactrepository.yourorg.com", null, null, false, null, null, null, null, null); Map attemptedUris = new HashMap<>(); List discoveredRepositories = new ArrayList<>(); ctx.setResolutionListener(new ResolutionEventListener() { @@ -275,7 +275,7 @@ void retryConnectException() throws Throwable { try (MockWebServer server = new MockWebServer()) { server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.NO_RESPONSE)); server.enqueue(new MockResponse().setResponseCode(200).setBody("body")); - String body = new String(downloader.sendRequest(new HttpSender.Request(server.url("/test").url(), "request".getBytes(), HttpSender.Method.GET, Map.of()))); + String body = new String(downloader.sendRequest(new HttpSender.Request(server.url("/test").url(), "request".getBytes(), HttpSender.Method.GET, Map.of(), null, null))); assertThat(body).isEqualTo("body"); assertThat(server.getRequestCount()).isEqualTo(2); server.shutdown(); diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/tree/MavenRepositoryMirrorTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/tree/MavenRepositoryMirrorTest.java index 4e70fa1aac6d..476e3a0197fb 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/tree/MavenRepositoryMirrorTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/tree/MavenRepositoryMirrorTest.java @@ -25,7 +25,7 @@ class MavenRepositoryMirrorTest { MavenRepositoryMirror one = new MavenRepositoryMirror("one", "https://one.org/m2", "*", true, true); MavenRepositoryMirror two = new MavenRepositoryMirror("two", "https://two.org/m2", "*", true, true); - MavenRepository foo = new MavenRepository("foo", "https://foo.org/m2", "true", "true", null, null); + MavenRepository foo = new MavenRepository("foo", "https://foo.org/m2", "true", "true", null, null, null, null); @Test void useFirstMirror() {