From bfe87655f7a1bd06d4006b880db6825e2d3ecfc1 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Mon, 12 Jun 2023 14:20:55 +0100 Subject: [PATCH] [core] Reset SOP list in test - Add SOPList#reset - fixes overloading of transfer options --- .../src/main/java/pt/ua/dicoogle/server/SOPList.java | 12 ++++++++++-- .../core/settings/LegacyServerSettingsTest.java | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dicoogle/src/main/java/pt/ua/dicoogle/server/SOPList.java b/dicoogle/src/main/java/pt/ua/dicoogle/server/SOPList.java index 039610f51..83370fbee 100644 --- a/dicoogle/src/main/java/pt/ua/dicoogle/server/SOPList.java +++ b/dicoogle/src/main/java/pt/ua/dicoogle/server/SOPList.java @@ -145,11 +145,19 @@ public static synchronized SOPList getInstance() { * Creates a new list */ private SOPList() { - table = new Hashtable<>(); + this.reset(); + } + + /** Reset the SOP list to an empty slate. + * + * This is not recommended unless you know what you're doing. + */ + public final void reset() { + this.table = new Hashtable<>(); // Hardcoded (pre-#498) SOPs for (String sop : SOP) { - table.put(sop, new TransfersStorage()); + this.table.put(sop, new TransfersStorage()); } } diff --git a/dicoogle/src/test/java/pt/ua/dicoogle/core/settings/LegacyServerSettingsTest.java b/dicoogle/src/test/java/pt/ua/dicoogle/core/settings/LegacyServerSettingsTest.java index aac9fe6cc..a3739a79c 100644 --- a/dicoogle/src/test/java/pt/ua/dicoogle/core/settings/LegacyServerSettingsTest.java +++ b/dicoogle/src/test/java/pt/ua/dicoogle/core/settings/LegacyServerSettingsTest.java @@ -109,6 +109,9 @@ private static void assertSameContent(Collection o1, Collection o2) { @Test public void testMigrate() throws IOException { + // clean up SOP list from past tests + SOPList.getInstance().reset(); + Path newconf = Files.createTempFile("conf", ".xml"); // load legacy server settings