[platform] documents Java version parser's ability to recognize the release file format

... and adds a test case
This commit is contained in:
Roman Shevchenko
2019-01-28 16:26:51 +01:00
parent a175c4094f
commit 4a08c2fc67
2 changed files with 7 additions and 4 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.lang;
import com.intellij.openapi.util.text.StringUtil;
@@ -182,7 +182,8 @@ public final class JavaVersion implements Comparable<JavaVersion> {
* - values of Java compiler -source/-target/--release options ("$MAJOR", "1.$MAJOR")</br>
* - output of "{@code java -version}" (usually "java version \"$VERSION\"")<br>
* - a second line of the above command (something like to "Java(TM) SE Runtime Environment (build $VERSION)")<br>
* - output of "{@code java --full-version}" ("java $VERSION")</p>
* - output of "{@code java --full-version}" ("java $VERSION")<br>
* - a line of "release" file ("JAVA_VERSION=\"$VERSION\"")</p>
*
* <p>See com.intellij.util.lang.JavaVersionTest for examples.</p>
*
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.lang
import org.assertj.core.api.Assertions.assertThat
@@ -110,7 +110,9 @@ class JavaVersionTest {
"OpenJDK Runtime Environment 18.3 (build $versionString)",
// "java --full-version" (9+)
"java $versionString",
"openjdk $versionString"
"openjdk $versionString",
// `release` file (1.7+)
"JAVA_VERSION=\"$versionString\""
).forEach { assertThat(JavaVersion.parse(it)).describedAs(it).isEqualTo(expected) }
}