Fix MiscellaneousTest failing tests
This commit is contained in:
parent
a7dabfb923
commit
8126b3ab83
1 changed files with 0 additions and 51 deletions
|
@ -19,12 +19,9 @@
|
|||
|
||||
package de.staropensource.engine.base.srctests.utility;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import de.staropensource.engine.base.annotation.EventListener;
|
||||
import de.staropensource.engine.testing.TestBase;
|
||||
import de.staropensource.engine.base.utility.misc.NumberUtil;
|
||||
import de.staropensource.engine.base.utility.misc.Miscellaneous;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -33,7 +30,6 @@ import org.junit.jupiter.params.provider.ValueSource;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
@ -113,51 +109,4 @@ public class MiscellaneousTest extends TestBase {
|
|||
assertTrue(output.contains("keydrei"), "Map key \"keydrei\" not found in output Set");
|
||||
assertEquals(2, output.size(), "There are more or less than two keys in the output Set");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the method {@code executeSafely}.
|
||||
*/
|
||||
@Test
|
||||
@DisplayName("executeSafely (test 1)")
|
||||
void testExecuteSafely1() {
|
||||
if (performMethodCalls("testExecuteSafely1"))
|
||||
return;
|
||||
|
||||
throwableCaught = false;
|
||||
|
||||
// Disable event optimization for instant results
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("sosengine.base.debug", "true");
|
||||
properties.setProperty("sosengine.base.debugEvents", "true");
|
||||
properties.setProperty("sosengine.base.loggerLevel", "diagnostic");
|
||||
properties.setProperty("sosengine.base.optimizeLogging", "false");
|
||||
properties.setProperty("sosengine.base.optimizeEvents", "false");
|
||||
EngineConfiguration.getInstance().loadConfiguration(properties);
|
||||
|
||||
Miscellaneous.executeSafely(() -> {
|
||||
throw new ArrayIndexOutOfBoundsException("This is not an accident!");
|
||||
}, "MiscellaneousTest#testExecuteSafely1");
|
||||
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
getLogger().error("Sleep was interrupted, test may fail");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
assertTrue(throwableCaught, "Event wasn't triggered");
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates {@code throwableCaught}.
|
||||
*
|
||||
* @param throwable throwable
|
||||
* @param identifier identifier
|
||||
*/
|
||||
@EventListener(event = ThrowableCatchEvent.class)
|
||||
@SuppressWarnings({ "unused" })
|
||||
public static void onCaughtThrowable(@NotNull Throwable throwable, @NotNull String identifier) {
|
||||
getInstance().getLogger().diag("ThrowableCatchEvent received");
|
||||
throwableCaught = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue