Class LoaderPLYTest

java.lang.Object
com.irurueta.geometry.io.LoaderPLYTest
All Implemented Interfaces:
LoaderListener

class LoaderPLYTest extends Object implements LoaderListener
  • Field Details

    • startValid

      private boolean startValid
    • endValid

      private boolean endValid
    • progressValid

      private boolean progressValid
    • lockedValid

      private boolean lockedValid
    • startCounter

      private int startCounter
    • endCounter

      private int endCounter
    • previousProgress

      private float previousProgress
  • Constructor Details

    • LoaderPLYTest

      LoaderPLYTest()
  • Method Details

    • testConstants

      @Test void testConstants()
    • testConstructors

      @Test void testConstructors() throws IOException
      Throws:
      IOException
    • testHasSetFileAndIsReady

      @Test void testHasSetFileAndIsReady() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetListener

      @Test void testGetSetListener() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetMaxVerticesInChunk

      @Test void testGetSetMaxVerticesInChunk() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetAllowDuplicateVerticesInChunk

      @Test void testGetSetAllowDuplicateVerticesInChunk() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testGetSetMaxStreamPositions

      @Test void testGetSetMaxStreamPositions() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testIsValidFile

      @Test void testIsValidFile() throws LockedException, IOException
      Throws:
      LockedException
      IOException
    • testLoadAndIterate

      Throws:
      IOException
      LockedException
      LoaderException
      NotReadyException
      NotAvailableException
    • isValidFile_whenGeneratedFile_returnsTrue

      @ParameterizedTest @ValueSource(strings={"ascii","binary_little_endian","binary_big_endian"}) void isValidFile_whenGeneratedFile_returnsTrue(String format, @TempDir Path dir) throws Exception
      Checks that generated files with header comments are valid and loadable in every storage mode.
      Parameters:
      format - storage format name.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • isValidFile_whenHeaderIsInvalid_returnsFalse

      @ParameterizedTest(name="{0}") @MethodSource("invalidHeaders") void isValidFile_whenHeaderIsInvalid_returnsFalse(String name, String header, @TempDir Path dir) throws Exception
      Checks that every invalid header is reported as an invalid file.
      Parameters:
      name - test case name.
      header - invalid header contents.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • load_whenHeaderIsInvalid_throwsLoaderException

      @ParameterizedTest(name="{0}") @MethodSource("invalidHeaders") void load_whenHeaderIsInvalid_throwsLoaderException(String name, String header, @TempDir Path dir) throws Exception
      Checks that loading a file with invalid header fails.
      Parameters:
      name - test case name.
      header - invalid header contents.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • isValidFile_whenElementCountIsNotANumber_throwsIOException

      @Test void isValidFile_whenElementCountIsNotANumber_throwsIOException(@TempDir Path dir) throws Exception
      Checks that a non numeric number of element instances raises an I/O error.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • isValidFile_whenHeaderHasExtraSpaces_returnsTrue

      @Test void isValidFile_whenHeaderHasExtraSpaces_returnsTrue(@TempDir Path dir) throws Exception
      Checks that a header can have extra blank spaces and that data type aliases are accepted.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • load_whenHeaderIsTruncated_throwsLoaderException

      @ParameterizedTest @ValueSource(strings={"ply\nformat ascii 1.0\ncomment hello\n","ply\nformat ascii 1.0\nelement","ply\nformat ascii 1.0\nelement vertex 1\nproperty","ply\nformat ascii 1.0\nelement vertex 1\nproperty float x\n","ply\nformat ascii 1.0\n","ply\nformat ascii 1.0\nobj_info x\n"}) void load_whenHeaderIsTruncated_throwsLoaderException(String header, @TempDir Path dir) throws Exception
      Checks that headers truncated at the end of the stream are rejected with a loader exception.
      Parameters:
      header - truncated header.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • load_whenElementCountIsNegative_throwsLoaderException

      @Test void load_whenElementCountIsNegative_throwsLoaderException(@TempDir Path dir) throws Exception
      Checks that negative element counts are rejected.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • load_whenFileIsHostile_throwsLoaderException

      @ParameterizedTest(name="{0}") @MethodSource("hostileFiles") void load_whenFileIsHostile_throwsLoaderException(String name, byte[] bytes, @TempDir Path dir) throws Exception
      Checks that crafted files only fail with loader exceptions when being loaded.
      Parameters:
      name - test case name.
      bytes - file content.
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.
    • consume

      private static void consume(LoaderPLY loader) throws Exception
      Loads a file and iterates over all its chunks.
      Parameters:
      loader - loader.
      Throws:
      Exception - if any error occurs.
    • hostileFiles

      private static Stream<org.junit.jupiter.params.provider.Arguments> hostileFiles()
      Provides crafted files with hostile counts and list lengths.
      Returns:
      test case names and file contents.
    • ascii

      private static byte[] ascii(String text)
    • concat

      private static byte[] concat(byte[]... arrays)
    • invalidHeaders

      private static Stream<org.junit.jupiter.params.provider.Arguments> invalidHeaders()
      Provides headers that are not valid.
      Returns:
      test case names and headers.
    • onLoadStart

      public void onLoadStart(Loader loader)
      Specified by:
      onLoadStart in interface LoaderListener
    • onLoadEnd

      public void onLoadEnd(Loader loader)
      Specified by:
      onLoadEnd in interface LoaderListener
    • onLoadProgressChange

      public void onLoadProgressChange(Loader loader, float progress)
      Specified by:
      onLoadProgressChange in interface LoaderListener
    • checkLocked

      private static void checkLocked(LoaderPLY loader)
    • resetListener

      private void resetListener()
    • isStartValid

      private boolean isStartValid()
    • isEndValid

      private boolean isEndValid()
    • isProgressValid

      private boolean isProgressValid()
    • isLockedValid

      private boolean isLockedValid()
    • next_whenAsciiBodyIsTruncated_throwsLoaderExceptionAndUnlocks

      @Test void next_whenAsciiBodyIsTruncated_throwsLoaderExceptionAndUnlocks(@TempDir Path dir) throws Exception
      Checks that an ASCII file whose body ends before all declared values are read is reported as a corrupted file (LoaderException) and that the loader is unlocked afterwards.
      Parameters:
      dir - temporary directory.
      Throws:
      Exception - if any unexpected error occurs.