Package com.irurueta.geometry.io
Class LoaderPLYTest
java.lang.Object
com.irurueta.geometry.io.LoaderPLYTest
- All Implemented Interfaces:
LoaderListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate booleanprivate booleanprivate floatprivate booleanprivate intprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]private static voidcheckLocked(LoaderPLY loader) private static byte[]concat(byte[]... arrays) private static voidLoads a file and iterates over all its chunks.private static Stream<org.junit.jupiter.params.provider.Arguments> Provides crafted files with hostile counts and list lengths.private static Stream<org.junit.jupiter.params.provider.Arguments> Provides headers that are not valid.private booleanprivate booleanprivate booleanprivate boolean(package private) voidChecks that a non numeric number of element instances raises an I/O error.(package private) voidisValidFile_whenGeneratedFile_returnsTrue(String format, Path dir) Checks that generated files with header comments are valid and loadable in every storage mode.(package private) voidChecks that a header can have extra blank spaces and that data type aliases are accepted.(package private) voidisValidFile_whenHeaderIsInvalid_returnsFalse(String name, String header, Path dir) Checks that every invalid header is reported as an invalid file.(package private) voidChecks that negative element counts are rejected.(package private) voidload_whenFileIsHostile_throwsLoaderException(String name, byte[] bytes, Path dir) Checks that crafted files only fail with loader exceptions when being loaded.(package private) voidload_whenHeaderIsInvalid_throwsLoaderException(String name, String header, Path dir) Checks that loading a file with invalid header fails.(package private) voidload_whenHeaderIsTruncated_throwsLoaderException(String header, Path dir) Checks that headers truncated at the end of the stream are rejected with a loader exception.(package private) voidChecks 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.voidvoidonLoadProgressChange(Loader loader, float progress) voidonLoadStart(Loader loader) private void(package private) void(package private) void(package private) void(package private) void(package private) void(package private) void(package private) void(package private) void(package private) void
-
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
- Throws:
IOException
-
testHasSetFileAndIsReady
- Throws:
LockedExceptionIOException
-
testGetSetListener
- Throws:
LockedExceptionIOException
-
testGetSetMaxVerticesInChunk
- Throws:
LockedExceptionIOException
-
testGetSetAllowDuplicateVerticesInChunk
- Throws:
LockedExceptionIOException
-
testGetSetMaxStreamPositions
- Throws:
LockedExceptionIOException
-
testIsValidFile
- Throws:
LockedExceptionIOException
-
testLoadAndIterate
@Test void 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
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
Loads a file and iterates over all its chunks.- Parameters:
loader- loader.- Throws:
Exception- if any error occurs.
-
hostileFiles
Provides crafted files with hostile counts and list lengths.- Returns:
- test case names and file contents.
-
ascii
-
concat
private static byte[] concat(byte[]... arrays) -
invalidHeaders
Provides headers that are not valid.- Returns:
- test case names and headers.
-
onLoadStart
- Specified by:
onLoadStartin interfaceLoaderListener
-
onLoadEnd
- Specified by:
onLoadEndin interfaceLoaderListener
-
onLoadProgressChange
- Specified by:
onLoadProgressChangein interfaceLoaderListener
-
checkLocked
-
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.
-