Class LightAirApi

java.lang.Object
net.sf.lightair.LightAirApi
All Implemented Interfaces:
Keywords
Direct Known Subclasses:
Api

public class LightAirApi extends Object implements Keywords
Light Air's programmatic API.

The general contract is to initialize(String) and shutdown() and in between perform either generateXsd() call or (a series of) setup(Map) and verify(Map) or await(Map) calls.

To generate XSD files:

Api.initialize(Api.getPropertiesFileName());
Api.generateXsd();
Api.shutdown();

To set up and verify database:

Map<String, List<String>> fileNames = new HashMap<>();
fileNames.put(Keywords.DEFAULT_PROFILE, Arrays.asList("my-dataset-1.xml", "my-dataset-2.xml"));

Api.initialize(Api.getPropertiesFileName());
Api.setup(fileNames);
// ...execute function under test...
Api.verify(fileNames);
// ...or for asynchronous functionality:
Api.await(fileNames);
// ...possibly repeat setup and verify / await for other tests...
Api.shutdown();
  • Field Details

  • Constructor Details

    • LightAirApi

      public LightAirApi()
  • Method Details

    • getPropertiesFileName

      public static String getPropertiesFileName()
      Get the file name of the main properties file.
      Returns:
      file name
    • initialize

      public static void initialize(String propertiesFileName)
      Initialize Light Air.

      NOTE: ALWAYS call shutdown() after initialize() to properly release resources.

      Parameters:
      propertiesFileName - file name of the main Light Air properties
    • shutdown

      public static void shutdown()
      Shutdown previously initialized Light Air to properly release resources, like DB connections.
    • reInitialize

      public static void reInitialize()
      Re-initialize already initialized Light Air.

      Reloads the properties file(s) and cleanly re-initializes Light Air.

    • ensureInitialized

      public static void ensureInitialized(String propertiesFileName)
      Initialize Light Air if it is not initialized already.
      Parameters:
      propertiesFileName - file name of the main Light Air properties
    • ensureShutdown

      public static void ensureShutdown()
      Shutdown Light Air to properly release resources, like DB connections, if it is not shutdown already.
    • generateXsd

      public static void generateXsd()
      Generate XSD files from the database structure.
    • setup

      public static void setup(Map<String, List<String>> fileNames)
      Setup database.
      Parameters:
      fileNames - map of profile names to lists of names of setup dataset files for the profile
    • verify

      public static void verify(Map<String, List<String>> fileNames)
      Verify database.
      Parameters:
      fileNames - map of profile names to lists of names of verification dataset files for the profile
    • await

      public static void await(Map<String, List<String>> fileNames)
      Verify database after an asynchronous test.

      Verifies the database repeatedly until either the result is successful or timeout has expired.

      Parameters:
      fileNames - map of profile names to lists of names of verification dataset files for the profile
    • setClock

      public static void setClock(Clock clock)
      Set the clock to be used for time-based data types processing.
      Parameters:
      clock - Clock instance to be used
    • setFixedTime

      public static void setFixedTime(ZonedDateTime fixedTime)
      Set a fixed time to be used for time-based data types processing.
      Parameters:
      fixedTime - Time to fix
    • resetClock

      public static void resetClock()
      Reset the clock to be used for time-based data types processing to system time in the system default time zone.