Annotation Type LoadSamples


@Retention(RUNTIME)
@Target(METHOD)
public @interface LoadSamples
The @LoadSamples-annotation may be used at any test method as a convenient way to load Samples from a JSON-file. The JSON-file is usually created using @SaveSamples.

It is possible to load the file either from a local filesystem or from the classpath (property source())

The filename may be defined using the property value(). The default filename is composed using the full qualified name of the test class and the test method.

This annotation must be used in combination with @UseSamplerFixture.

It is possible to register some extensions to customize the deserialization using the annotations @UseJsonDeserializer and @UseBeanConverterExtension.

  • Optional Element Summary

    Optional Elements
    Modifier and Type Optional Element Description
    de.ppi.deepsampler.junit.FileSource source
    Defines from where the file is loaded.
    java.lang.String value
    The name of the json file.
  • Element Details

    • value

      java.lang.String value
      The name of the json file. If this property is omitted, the name will be composed like so: [package of the test class]/[Test class name]_[test method].json

      The root path of relative filenames for source

      • FileSource.FILE_SYSTEM is by default './'. It can be changed, using the annotation SampleRootPath.
      • FileSource.CLASSPATH is the classpath itself. value() will be interpreted exactly as it is described by ClassLoader.getResource(String). Since the ClassLoader is retrieved from the current test class, value() can also be defined relative to the test class. The annotation SampleRootPath is ignored.
      • *
      Returns:
      the name of the sample JSON file.
      Default:
      "`v\u00b0\u00b0v\u00b4$de.ppi.deepsampler.junit.AnnotationConstants$$$DefaultValueMustBeCalculated$"
    • source

      de.ppi.deepsampler.junit.FileSource source
      Defines from where the file is loaded. Either the classpath or the vanilla filesystem can be used. Default is FileSource.FILE_SYSTEM.
      Returns:
      The source of the file.
      Default:
      FILE_SYSTEM