Skip to content

Commit

Permalink
use proper tempfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
crschardt committed Dec 17, 2023
1 parent f47543d commit 9875719
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,31 @@ public static void cleanup() throws IOException {
public void testJacksonHandlesOldVersions() throws IOException {
var str =
"{\"baseName\":\"aaaaaa\",\"uniqueName\":\"aaaaaa\",\"nickname\":\"aaaaaa\",\"FOV\":70.0,\"path\":\"dev/vid\",\"cameraType\":\"UsbCamera\",\"currentPipelineIndex\":0,\"camPitch\":{\"radians\":0.0},\"calibrations\":[], \"cameraLEDs\":[]}";
var writer = new FileWriter("test.json");
File tempFile = File.createTempFile("test", ".json");
tempFile.deleteOnExit();
var writer = new FileWriter(tempFile);
writer.write(str);
writer.flush();
writer.close();
Assertions.assertDoesNotThrow(
() -> JacksonUtils.deserialize(Path.of("test.json"), CameraConfiguration.class));
() -> JacksonUtils.deserialize(tempFile.toPath(), CameraConfiguration.class));

new File("test.json").delete();
tempFile.delete();
}

@Test
public void testJacksonHandlesOldTargetEnum() throws IOException {
var str =
"[ \"AprilTagPipelineSettings\", {\n" + " \"targetModel\" : \"k6in_16h5\"\n" + "} ]\n";
var writer = new FileWriter("test.json");
var str = "[ \"AprilTagPipelineSettings\", {\n \"targetModel\" : \"k6in_16h5\"\n} ]\n";

File tempFile = File.createTempFile("test", ".json");
tempFile.deleteOnExit();
var writer = new FileWriter(tempFile);
writer.write(str);
writer.flush();
writer.close();
Assertions.assertDoesNotThrow(
() -> JacksonUtils.deserialize(Path.of("test.json"), CVPipelineSettings.class));
() -> JacksonUtils.deserialize(tempFile.toPath(), CVPipelineSettings.class));

new File("test.json").delete();
tempFile.delete();
}
}

0 comments on commit 9875719

Please sign in to comment.