Package net.shibboleth.shared.testing
Class TestSupport
java.lang.Object
net.shibboleth.shared.testing.TestSupport
A collection of methods supporting test class execution.
Methods named
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.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static intgetJavaVersion(String versionStr) Extracts the major version number from a Java version string.static booleanDeprecated, for removal: This API element is subject to removal in a future version.static booleanDeprecated, for removal: This API element is subject to removal in a future version.static booleanDeprecated, for removal: This API element is subject to removal in a future version.static booleanDeprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
TestSupport
private TestSupport()Constructor.
-
-
Method Details
-
getJavaVersion
Extracts the major version number from a Java version string. This is not part of the API of the class, but is available as a protected method for self-testing. The version string given by thejava.versionproperty 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-4681.7.0_511.8.0_144
+or-may appear. This means that version strings like "10+43" are possible, and have been observed. -
isJavaV7OrLater
Deprecated, for removal: This API element is subject to removal in a future version.Indicates whether the tests are running under Java 7 or a later version.- Returns:
trueif the runtime environment is Java 7 or later
-
isJavaV8OrLater
Deprecated, for removal: This API element is subject to removal in a future version.Indicates whether the tests are running under Java 8 or a later version.- Returns:
trueif the runtime environment is Java 8 or later
-
isJavaV9OrLater
Deprecated, for removal: This API element is subject to removal in a future version.Indicates whether the tests are running under Java 9 or a later version.- Returns:
trueif the runtime environment is Java 9 or later
-
isJavaV11OrLater
Deprecated, for removal: This API element is subject to removal in a future version.Indicates whether the tests are running under Java 11 or a later version.- Returns:
trueif the runtime environment is Java 11 or later
-