Skip to content

Commit

Permalink
MNG-6964 is fixed upstream (#105)
Browse files Browse the repository at this point in the history
Co-authored-by: Roberto Cortez <[email protected]>
  • Loading branch information
dmlloyd and radcortez authored Oct 11, 2021
1 parent f4d40be commit 77c1148
Showing 1 changed file with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,35 @@

import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Properties;

import org.apache.maven.artifact.versioning.ComparableVersion;
import org.junit.BeforeClass;
import org.junit.Test;

@SuppressWarnings("SpellCheckingInspection")
public class MavenVersionTest {
static volatile String artifactPluginVersion;

@BeforeClass
public static void setUp() throws IOException {
InputStream stream = MavenVersionTest.class.getClassLoader()
.getResourceAsStream("META-INF/maven/org.apache.maven/maven-artifact/pom.properties");
if (stream != null) {
try (InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
Properties properties = new Properties();
properties.load(reader);
if ((artifactPluginVersion = properties.getProperty("version")) != null) {
return;
}
}
}
throw new IllegalStateException("Could not determine plugin version");
}

@Test
public void testMavenCompare() {
Expand Down Expand Up @@ -45,12 +69,19 @@ public void testMavenCompare() {
checkMavenConsistency("12-foo", "12_FOO");
checkMavenConsistency("0_0", "0");
checkMavenConsistency("0_0", "0_0final");
// https://issues.apache.org/jira/browse/MNG-6964
// checkMavenConsistency("1-0.alpha", "1");
assertEquals(1, VersionScheme.MAVEN.compare("1-0.alpha", "1"));
// https://issues.apache.org/jira/browse/MNG-6964
//checkMavenConsistency("1-0.beta", "1");
assertEquals(1, VersionScheme.MAVEN.compare("1-0.beta", "1"));
boolean atLeast382 = VersionScheme.MAVEN.compare(artifactPluginVersion, "3.8.2") >= 0;
if (atLeast382) {
// https://issues.apache.org/jira/browse/MNG-6964 - fixed since 3.8.2
checkMavenConsistency("1-0.alpha", "1");
} else {
assertEquals(1, VersionScheme.MAVEN.compare("1-0.alpha", "1"));
}
if (atLeast382) {
// https://issues.apache.org/jira/browse/MNG-6964 - fixed since 3.8.2
checkMavenConsistency("1-0.beta", "1");
} else {
assertEquals(1, VersionScheme.MAVEN.compare("1-0.beta", "1"));
}
}

private static void checkMavenConsistency(String v1, String v2) {
Expand Down

0 comments on commit 77c1148

Please sign in to comment.