Properly clean up plugin initialization in test code

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-06-16 08:53:45 -06:00
rodzic 8b3cd6866d
commit 43510ce15e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 12 dodań i 0 usunięć

Wyświetl plik

@ -15,6 +15,7 @@ import javax.swing.JMenu;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -54,6 +55,14 @@ public class MapWithAIPluginTest {
info.localversion = VERSION;
}
@After
public void tearDown() {
if (plugin != null) {
plugin.destroy();
plugin = null;
}
}
/**
* Test method for {@link MapWithAIPlugin#getPreferenceSetting()}.
*/
@ -86,6 +95,7 @@ public class MapWithAIPluginTest {
MapPaintStyles.getStyles().getStyleSources().parallelStream()
.filter(source -> source.url != null && source.name.contains("MapWithAI")).count(),
"The paint style was not added");
plugin.destroy();
for (boolean existed : Arrays.asList(false, true)) { // false, true order is important
plugin = new MapWithAIPlugin(info);
@ -109,6 +119,8 @@ public class MapWithAIPluginTest {
MapPaintStyles.getStyles().getStyleSources().parallelStream()
.filter(source -> source.url != null && source.name.contains("MapWithAI")).count(),
"The paint style was added multiple times");
plugin.destroy();
plugin = null; // required to avoid teardown
}
}