Class TestSupport
- java.lang.Object
-
- net.shibboleth.utilities.java.support.testing.TestSupport
-
public class TestSupport extends Object
A collection of methods supporting test class execution. Methods namedisJavaVxOrLaterare 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 onlyisJavaVxOrLaterand not a genericgetJavaVersionto avoid any dependency in test code of knowledge of the ordering of Java version numbers. Such anintscheme is used internally, but not exposed except for self-tests. Methods namedhasX, 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 Modifier Constructor Description privateTestSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static intgetJavaVersion(String versionStr)Extracts the major version number from a Java version string.static booleanisJavaV11OrLater()Deprecated, for removal: This API element is subject to removal in a future version.static booleanisJavaV7OrLater()Deprecated, for removal: This API element is subject to removal in a future version.static booleanisJavaV8OrLater()Deprecated, for removal: This API element is subject to removal in a future version.static booleanisJavaV9OrLater()Deprecated, for removal: This API element is subject to removal in a future version.
-
-
-
Method Detail
-
getJavaVersion
protected static int getJavaVersion(@Nonnull String versionStr)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(forRemoval=true, since="4.1") public static boolean 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(forRemoval=true, since="4.1") public static boolean 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(forRemoval=true, since="4.1") public static boolean 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(forRemoval=true, since="4.1") public static boolean 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
-
-