public class TestSupport extends Object
isJavaVxOrLater
are for use by tests needing to vary what they test, or the results
they expect, depending on the version of Java under which the test
is executing.
For example, code which behaves differently depending on the presence
of cryptographic algorithms only available from some specific version of
the Java platform may be gated by such a method. The code under test
should instead operate on the basis of the presence or absence of the
algorithm in question.
The API provided for Java version detection provides only
isJavaVxOrLater and not a generic
getJavaVersion to avoid any dependency in test code of
knowledge of the ordering of Java version numbers. Such an int
scheme is used internally, but not exposed except for self-tests.
Methods named hasX, describing the presence of
specific features of the run-time environment, are to be preferred
over version-based methods. We don't have any of these yet, though.| Modifier | Constructor and Description |
|---|---|
private |
TestSupport()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static int |
getJavaVersion(String versionStr)
Extracts the major version number from a Java version string.
|
static boolean |
isJavaV11OrLater()
Indicates whether the tests are running under Java 11 or a later
version.
|
static boolean |
isJavaV7OrLater()
Indicates whether the tests are running under Java 7 or a later
version.
|
static boolean |
isJavaV8OrLater()
Indicates whether the tests are running under Java 8 or a later
version.
|
static boolean |
isJavaV9OrLater()
Indicates whether the tests are running under Java 9 or a later
version.
|
protected static int getJavaVersion(@Nonnull String versionStr)
java.version
property has changed format multiple times in its history.
This method acts as a parser for such strings. It is only
required to handle versions of Java from the current platform
baseline onwards (and thus their particular version string
quirks) but in practice may support previous versions.
For Java 6, 7 and 8, the version string has a format
like "1.X.0_123" where X is the version of Java. This means
that there will always be at least two components separated
by periods, and that the first such component will always
be "1".
Examples of versions strings observed in practice:
1.6.0_65-b14-468
1.7.0_51
1.8.0_144
+ or - may
appear. This means that version strings like "10+43" are possible, and
have been observed.public static boolean isJavaV7OrLater()
true if the runtime environment is Java 7 or laterpublic static boolean isJavaV8OrLater()
true if the runtime environment is Java 8 or laterpublic static boolean isJavaV9OrLater()
true if the runtime environment is Java 9 or laterpublic static boolean isJavaV11OrLater()
true if the runtime environment is Java 11 or laterCopyright © 1999–2019 Shibboleth Consortium. All rights reserved.