Class ResourceFile

java.lang.Object
org.springframework.core.test.tools.DynamicFile
org.springframework.core.test.tools.ResourceFile
All Implemented Interfaces:
org.assertj.core.api.AssertProvider<ResourceFileAssert>

public final class ResourceFile extends DynamicFile implements org.assertj.core.api.AssertProvider<ResourceFileAssert>
DynamicFile that holds resource file content and provides ResourceFileAssert support.
Since:
6.0
Author:
Phillip Webb
  • Method Details

    • of

      public static ResourceFile of(String path, CharSequence charSequence)
      Factory method to create a new ResourceFile from the given CharSequence.
      Parameters:
      path - the relative path of the file or null to have the path deduced
      charSequence - a char sequence containing the file contents
      Returns:
      a ResourceFile instance
    • of

      public static ResourceFile of(String path, byte[] bytes)
      Factory method to create a new ResourceFile from the given byte[].
      Parameters:
      path - the relative path of the file or null to have the path deduced
      bytes - a byte array containing the file contents
      Returns:
      a ResourceFile instance
    • of

      public static ResourceFile of(String path, org.springframework.core.io.InputStreamSource inputStreamSource)
      Factory method to create a new ResourceFile from the given InputStreamSource.
      Parameters:
      path - the relative path of the file
      inputStreamSource - the source for the file
      Returns:
      a ResourceFile instance
    • of

      public static ResourceFile of(String path, WritableContent writableContent)
      Factory method to create a new SourceFile from the given WritableContent.
      Parameters:
      path - the relative path of the file
      writableContent - the content to write to the file
      Returns:
      a ResourceFile instance
    • assertThat

      public ResourceFileAssert assertThat()
      Use assertThat(sourceFile) rather than calling this method directly.
      Specified by:
      assertThat in interface org.assertj.core.api.AssertProvider<ResourceFileAssert>