Class RequiredLibrary

java.lang.Object
org.dbunit.dataset.RequiredLibrary

public final class RequiredLibrary extends Object
A library that only some of dbUnit's features need, and so is an optional dependency, with the means to say what to add when it is missing. Without this check the first use of the library surfaces as a bare NoClassDefFoundError from deep inside a producer, writer or comparer, naming one of the library's classes and not what to do about it.

Whether the library is present is asked of the class loader of the class that needs it, since that is the loader that will resolve the library's classes.

Since:
3.6.0
Author:
Jeff Jensen
  • Field Details

    • JACKSON

      public static final RequiredLibrary JACKSON
      Jackson, needed to read and write JSON datasets and to compare JSON column values.
    • SNAKEYAML

      public static final RequiredLibrary SNAKEYAML
      SnakeYAML, needed to read and write YAML datasets.
  • Method Details

    • require

      public void require(Class<?> requester) throws DataSetException
      Fails with a message saying what to add when the library is not on the classpath of the class that needs it. A library that is present but cannot be used, such as a jar built for a newer Java, is not reported as missing: loading it fails with its own, more telling error.
      Parameters:
      requester - The class that needs the library; its class loader is the one asked.
      Throws:
      DataSetException - If the library is not present.
    • requireUnchecked

      public void requireUnchecked(Class<?> requester)
      Like require(Class), for a constructor that declares no checked exception.
      Parameters:
      requester - The class that needs the library; its class loader is the one asked.
      Throws:
      DatabaseUnitRuntimeException - If the library is not present.