Polish Serialization Tests

If Instancio fails to instatiate the class sample, it will
now also delete the serialized sample file. Otherwise, it will
leave a zero-byte file on the filesystem, confusing future test runs
This commit is contained in:
Josh Cummings 2025-05-05 15:39:33 -06:00
parent d04f7071c2
commit 12a18c3792
No known key found for this signature in database
GPG Key ID: 869B37A20E876129

View File

@ -775,10 +775,10 @@ class SpringSecurityCoreVersionSerializableTests {
return;
}
Files.createFile(filePath);
Object instance = instancioWithDefaults(clazz).create();
assertThat(instance).isInstanceOf(clazz);
try (FileOutputStream fileOutputStream = new FileOutputStream(file);
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
Object instance = instancioWithDefaults(clazz).create();
assertThat(instance).isInstanceOf(clazz);
objectOutputStream.writeObject(instance);
objectOutputStream.flush();
}