Skip to content

Commit

Permalink
[MNG-7909] Apply Resolver 2.0.0 changes (apache#317)
Browse files Browse the repository at this point in the history
Changes:
* IT MNG-4368 "smart install" undone
* IT MNG-5175 force Wagon as it uses Wagon config
* IT MNG-7470 adapt to new default and new transport
  • Loading branch information
cstamas authored Nov 7, 2023
1 parent ad25b2e commit d77141d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4368">MNG-4368</a>.
* Resolver 2.0.0 (in use since Maven 4.0.0-alpha-9) undoes this "smart" solution.
*
* @author Benjamin Bentmann
*/
public class MavenITmng4368TimestampAwareArtifactInstallerTest extends AbstractMavenIntegrationTestCase {

public MavenITmng4368TimestampAwareArtifactInstallerTest() {
super("[2.0.3,3.0-alpha-1),[3.0-alpha-6,)");
super("[2.0.3,3.0-alpha-1),[3.0-alpha-6,4.0.0-alpha-8]");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public void testmng5175_ReadTimeOutFromSettings() throws Exception {
verifier.addCliArgument("--errors");
verifier.addCliArgument("-X");
verifier.addCliArgument("validate");
verifier.addCliArgument(
"-Dmaven.resolver.transport=wagon"); // this tests Wagon integration and uses Wagon specific config
verifier.execute();

verifier.verifyTextInLog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -39,6 +42,11 @@ public class MavenITmng7470ResolverTransportTest extends AbstractMavenIntegratio

private int port;

private static final ArtifactVersion JDK_TRANSPORT_USABLE_ON_JDK_SINCE = new DefaultArtifactVersion("11");

private static final ArtifactVersion JDK_TRANSPORT_IN_MAVEN_SINCE =
new DefaultArtifactVersion("4.0.0-alpha-9-SNAPSHOT");

public MavenITmng7470ResolverTransportTest() {
super("[3.9.0,)");
}
Expand Down Expand Up @@ -99,11 +107,35 @@ private void performTest(/* nullable */ final String transport, final String log

private static final String WAGON_LOG_SNIPPET = "[DEBUG] Using transporter WagonTransporter";

private static final String NATIVE_LOG_SNIPPET = "[DEBUG] Using transporter HttpTransporter";
private static final String APACHE_LOG_SNIPPET = "[DEBUG] Using transporter HttpTransporter";

private static final String JDK_LOG_SNIPPET = "[DEBUG] Using transporter JdkHttpTransporter";

/**
* Returns {@code true} if JDK HttpClient transport is usable (Java11 or better).
*/
private boolean isJdkTransportUsable() {
return JDK_TRANSPORT_USABLE_ON_JDK_SINCE.compareTo(getJavaVersion()) < 1;
}

/**
* Returns {@code true} if JDK HttpClient transport is present in Maven (since 4.0.0-alpha-9, the Resovler 2.0.0
* upgrade).
*/
private boolean isJdkTransportPresent() {
return JDK_TRANSPORT_IN_MAVEN_SINCE.compareTo(getMavenVersion()) < 1;
}

private String defaultLogSnippet() {
if (isJdkTransportUsable() && isJdkTransportPresent()) {
return JDK_LOG_SNIPPET;
}
return APACHE_LOG_SNIPPET;
}

@Test
public void testResolverTransportDefault() throws Exception {
performTest(null, NATIVE_LOG_SNIPPET);
performTest(null, defaultLogSnippet());
}

@Test
Expand All @@ -112,7 +144,13 @@ public void testResolverTransportWagon() throws Exception {
}

@Test
public void testResolverTransportNative() throws Exception {
performTest("native", NATIVE_LOG_SNIPPET);
public void testResolverTransportApache() throws Exception {
performTest(isJdkTransportPresent() ? "apache" : "native", APACHE_LOG_SNIPPET);
}

@Test
public void testResolverTransportJdk() throws Exception {
Assumptions.assumeTrue(isJdkTransportUsable() && isJdkTransportPresent());
performTest("jdk", JDK_LOG_SNIPPET);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected String getName() {
*
* @return The Java version, never <code>null</code>.
*/
private static ArtifactVersion getJavaVersion() {
protected static ArtifactVersion getJavaVersion() {
if (javaVersion == null) {
String version = System.getProperty("java.version");
version = version.replaceAll("[_-]", ".");
Expand Down

0 comments on commit d77141d

Please sign in to comment.