Class MaterialLoaderTest

java.lang.Object
com.irurueta.geometry.io.MaterialLoaderTest

class MaterialLoaderTest extends Object
Tests the shared behaviour of MaterialLoader using MaterialLoaderOBJ as the concrete implementation.
  • Field Details

    • LARGE_FILE_SIZE

      private static final long LARGE_FILE_SIZE
      Size in bytes of files that must not be kept in memory.
      See Also:
    • CONTENT

      private static final String CONTENT
      Content written into small temporary files.
      See Also:
    • tempDir

      @TempDir Path tempDir
      Temporary folder where generated files are stored.
  • Constructor Details

    • MaterialLoaderTest

      MaterialLoaderTest()
  • Method Details

    • constructor_whenSmallFile_usesMappedReader

      @Test void constructor_whenSmallFile_usesMappedReader() throws IOException
      Checks that a file smaller than the limit is read through a memory mapped reader.
      Throws:
      IOException - if an I/O error occurs.
    • constructor_whenLargeFile_usesFileReader

      @Test void constructor_whenLargeFile_usesFileReader() throws IOException
      Checks that a file reaching the limit is read through a regular file reader.
      Throws:
      IOException - if an I/O error occurs.
    • constructor_whenLargeFileAndListener_usesFileReader

      @Test void constructor_whenLargeFileAndListener_usesFileReader() throws IOException
      Checks that a file and listener constructor uses a regular file reader for large files.
      Throws:
      IOException - if an I/O error occurs.
    • setFileSizeLimitToKeepInMemory_whenLocked_throwsLockedException

      @Test void setFileSizeLimitToKeepInMemory_whenLocked_throwsLockedException() throws IOException, LockedException
      Checks that changing the file size limit while unlocked is stored and that it is rejected while locked.
      Throws:
      IOException - if an I/O error occurs.
      LockedException - if the loader is unexpectedly locked.
    • setFile_whenPreviousFileAndLimitChanges_replacesReader

      @Test void setFile_whenPreviousFileAndLimitChanges_replacesReader() throws IOException, LockedException
      Checks that setting a file replaces and closes any previous reader, and that the limit selects the reader type.
      Throws:
      IOException - if an I/O error occurs.
      LockedException - if the loader is unexpectedly locked.
    • setFile_whenLocked_throwsLockedException

      @Test void setFile_whenLocked_throwsLockedException() throws IOException
      Checks that setting a file or a listener while locked throws.
      Throws:
      IOException - if an I/O error occurs.
    • close_whenCalledTwice_releasesReaderOnce

      @Test void close_whenCalledTwice_releasesReaderOnce() throws IOException
      Checks that closing releases the reader and that closing twice is harmless.
      Throws:
      IOException - if an I/O error occurs.
    • createSmallFile

      private File createSmallFile(String name) throws IOException
      Creates a small file in the temporary folder.
      Parameters:
      name - name of the file.
      Returns:
      created file.
      Throws:
      IOException - if an I/O error occurs.
    • createLargeFile

      private File createLargeFile(String name) throws IOException
      Creates a (sparse) file whose size reaches the limit to keep files in memory.
      Parameters:
      name - name of the file.
      Returns:
      created file.
      Throws:
      IOException - if an I/O error occurs.