Class AssumeTestGroupUtil

java.lang.Object
org.jboss.as.test.shared.util.AssumeTestGroupUtil

public class AssumeTestGroupUtil extends Object
Helper methods which help to skip tests for functionality which is not yet fully working or where the test is not expected to work in certain execution environments. Put the call of the method directly into the failing test method, or if you want to skip whole test class, then put the method call into method annotated with BeforeClass.

Methods whose names begin with 'assume' throw AssumptionViolatedException if the described assumption is not met; otherwise they return normally. Other methods and constants in this class are meant for related use cases.

Author:
Josef Cacek, Brian Stansberry
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
     
    static void
    Assume for tests that require a docker installation.
    static void
    Assume for test failures when running against a full distribution.
    static void
    assumeJDKVersionAfter(int javaSpecificationVersion)
    Assume for tests that fail when the JVM version is too low.
    static void
    assumeJDKVersionBefore(int javaSpecificationVersion)
    Assume for tests that fail when the JVM version is too high.
    static void
    Assume for tests that should not run against a WildFly Preview installation.
    static void
    Assume for tests that fail when the security manager is enabled.
    static void
    Assume for tests that fail when the security manager is enabled or the JDK version is prior to a given version
    static void
     
    static org.jboss.shrinkwrap.api.spec.EnterpriseArchive
    Creates an empty (except for a manifest) EnterpriseArchive with the name empty.ear.
    static org.jboss.shrinkwrap.api.spec.EnterpriseArchive
    Creates an empty (except for a manifest) EnterpriseArchive with the given name.
    static org.jboss.shrinkwrap.api.spec.JavaArchive
    Creates an empty (except for a manifest) JavaArchive with the name empty.jar.
    static org.jboss.shrinkwrap.api.spec.JavaArchive
    Creates an empty (except for a manifest) JavaArchive with the given name.
    static org.jboss.shrinkwrap.api.spec.WebArchive
    Creates an empty (except for a manifest) WebArchive with the name empty.war.
    static org.jboss.shrinkwrap.api.spec.WebArchive
    Creates an empty (except for a manifest) WebArchive with the given name.
    static boolean
     
    static boolean
    Checks whether a docker installation is available.
    static boolean
    Checks whether tests are running against a full distribution.
    static boolean
    isJDKVersionAfter(int javaSpecificationVersion)
    Check if the current JDK specification version is greater than the given value.
    static boolean
    isJDKVersionBefore(int javaSpecificationVersion)
    Check if the current JDK specification version is less than the given value.
    static boolean
    Check if the JDK Security Manager is disabled.
    static boolean
    Check if the JDK Security Manager is enabled/strong>.
    static boolean
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AssumeTestGroupUtil

      public AssumeTestGroupUtil()
  • Method Details

    • emptyJar

      public static org.jboss.shrinkwrap.api.spec.JavaArchive emptyJar()
      Creates an empty (except for a manifest) JavaArchive with the name empty.jar.
      Returns:
      the archive
    • emptyJar

      public static org.jboss.shrinkwrap.api.spec.JavaArchive emptyJar(String name)
      Creates an empty (except for a manifest) JavaArchive with the given name.
      Parameters:
      name - the jar name. Can end with the '.jar' extension, but if not it will be added
      Returns:
      the archive
    • emptyWar

      public static org.jboss.shrinkwrap.api.spec.WebArchive emptyWar()
      Creates an empty (except for a manifest) WebArchive with the name empty.war.
      Returns:
      the archive
    • emptyWar

      public static org.jboss.shrinkwrap.api.spec.WebArchive emptyWar(String name)
      Creates an empty (except for a manifest) WebArchive with the given name.
      Parameters:
      name - the jar name. Can end with the '.war' extension, but if not it will be added
      Returns:
      the archive
    • emptyEar

      public static org.jboss.shrinkwrap.api.spec.EnterpriseArchive emptyEar()
      Creates an empty (except for a manifest) EnterpriseArchive with the name empty.ear.
      Returns:
      the archive
    • emptyEar

      public static org.jboss.shrinkwrap.api.spec.EnterpriseArchive emptyEar(String name)
      Creates an empty (except for a manifest) EnterpriseArchive with the given name.
      Parameters:
      name - the jar name. Can end with the '.ear' extension, but if not it will be added
      Returns:
      the archive
    • assumeSecurityManagerDisabled

      public static void assumeSecurityManagerDisabled()
      Assume for tests that fail when the security manager is enabled. This should be used sparingly and issues should be filed for failing tests so a proper fix can be done.

      Note that this checks the security.manager system property and not that the System.getSecurityManager() is null. The property is checked so that the assumption check can be done in a @Before or @BeforeClass method.

      Throws:
      org.junit.AssumptionViolatedException - if the security manager is enabled
    • isSecurityManagerEnabled

      public static boolean isSecurityManagerEnabled()
      Check if the JDK Security Manager is enabled/strong>.

      Note that this checks the security.manager system property and not that the System.getSecurityManager() is not null. The property is checked so that the assumption check can be done in a @Before or @BeforeClass method.

      Returns:
      true if the security.manager system property is null.
    • isSecurityManagerDisabled

      public static boolean isSecurityManagerDisabled()
      Check if the JDK Security Manager is disabled.

      Note that this checks the security.manager system property and not that the System.getSecurityManager() is null. The property is checked so that the assumption check can be done in a @Before or @BeforeClass method.

      Returns:
      true if the security.manager system property is null.
    • assumeSecurityManagerDisabledOrAssumeJDKVersionBefore

      public static void assumeSecurityManagerDisabledOrAssumeJDKVersionBefore(int javaSpecificationVersion)
      Assume for tests that fail when the security manager is enabled or the JDK version is prior to a given version

      Note that this checks the security.manager system property and not that the System.getSecurityManager() is null. The property is checked so that the assumption check can be done in a @Before or @BeforeClass method.

      Parameters:
      javaSpecificationVersion - the JDK specification version
      Throws:
      org.junit.AssumptionViolatedException - if the security manager is enabled or the JDK version is greater than or equal to javaSpecificationVersion
    • assumeJDKVersionAfter

      public static void assumeJDKVersionAfter(int javaSpecificationVersion)
      Assume for tests that fail when the JVM version is too low. This should be used sparingly.
      Parameters:
      javaSpecificationVersion - the JDK specification version. Use 8 for JDK 8. Must be 8 or higher.
      Throws:
      org.junit.AssumptionViolatedException - if the JDK version is less than or equal to javaSpecificationVersion
    • assumeJDKVersionBefore

      public static void assumeJDKVersionBefore(int javaSpecificationVersion)
      Assume for tests that fail when the JVM version is too high. This should be used sparingly.
      Parameters:
      javaSpecificationVersion - the JDK specification version. Must be 9 or higher.
      Throws:
      org.junit.AssumptionViolatedException - if the JDK version is greater than or equal to javaSpecificationVersion
    • isJDKVersionAfter

      public static boolean isJDKVersionAfter(int javaSpecificationVersion)
      Check if the current JDK specification version is greater than the given value.
      Parameters:
      javaSpecificationVersion - the JDK specification version. Use 8 for JDK 8.
    • isJDKVersionBefore

      public static boolean isJDKVersionBefore(int javaSpecificationVersion)
      Check if the current JDK specification version is less than the given value.
      Parameters:
      javaSpecificationVersion - the JDK specification version. Use 8 for JDK 8.
    • assumeFullDistribution

      public static void assumeFullDistribution()
      Assume for test failures when running against a full distribution. Full distributions are available from build/dist modules. It skips tests in case '-Dtestsuite.default.build.project.prefix' Maven argument is used with a non empty value, e.g. testsuite.default.build.project.prefix=ee- which means we are using ee-build/ee-dist modules as the source where to find the server under test.
      Throws:
      org.junit.AssumptionViolatedException - if property testsuite.default.build.project.prefix is set to a non-empty value
    • isFullDistribution

      public static boolean isFullDistribution()
      Checks whether tests are running against a full distribution. Full distributions are available from build/dist modules. It skips tests in case '-Dtestsuite.default.build.project.prefix' Maven argument is used with a non empty value, e.g. testsuite.default.build.project.prefix=ee- which means we are using ee-build/ee-dist modules as the source where to find the server under test.
    • assumeDockerAvailable

      public static void assumeDockerAvailable()
      Assume for tests that require a docker installation.
      Throws:
      org.junit.AssumptionViolatedException - if a docker client cannot be initialized
      RuntimeException - if a docker client is required but is unavailable or not properly configured
    • isDockerAvailable

      public static boolean isDockerAvailable()
      Checks whether a docker installation is available.
      Throws:
      org.junit.AssumptionViolatedException - if a docker client cannot be initialized
    • assumeNotWildFlyPreview

      public static void assumeNotWildFlyPreview()
      Assume for tests that should not run against a WildFly Preview installation.
      Throws:
      org.junit.AssumptionViolatedException - if one of the system properties that indicates WildFly Preview is being tested is set
    • assumeWildFlyPreview

      public static void assumeWildFlyPreview()
    • isWildFlyPreview

      public static boolean isWildFlyPreview()
    • assumeBootableJar

      public static void assumeBootableJar()
    • isBootableJar

      public static boolean isBootableJar()