Adjusted Config tests for proper singleton pattern
This commit is contained in:
@@ -2,6 +2,7 @@ package de.rwu.easydrop.util;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
@@ -20,17 +21,18 @@ class ConfigTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetInstanceNull() {
|
void testGetInstance() {
|
||||||
config = null;
|
|
||||||
|
|
||||||
Config newConfig = Config.getInstance();
|
Config newConfig = Config.getInstance();
|
||||||
assertNotNull(newConfig);
|
assertNotNull(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetInstanceNotNull() {
|
void testGetInstanceEquality() {
|
||||||
Config newConfig = Config.getInstance();
|
// Create "two" instances to check validity of Singleton pattern
|
||||||
assertNotNull(newConfig);
|
Config instance1 = Config.getInstance();
|
||||||
|
Config instance2 = Config.getInstance();
|
||||||
|
|
||||||
|
assertSame(instance1, instance2, "Instances should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user