GP-3615 - Added a test harness method to make it easier to change log output from a test. The test harness will reset any changes made at the end of the test.

This commit is contained in:
dragonmacher 2023-07-19 12:47:47 -04:00
parent f8ec071906
commit bd0c491263
9 changed files with 170 additions and 105 deletions

View file

@ -23,8 +23,7 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.*;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.Level;
import org.junit.*;
import generic.concurrent.GThreadPool;
@ -46,7 +45,6 @@ public class GTaskTest extends AbstractGenericTest {
};
public GTaskTest() {
super();
}
@Before
@ -420,8 +418,7 @@ public class GTaskTest extends AbstractGenericTest {
public void testExceptionInTaskListenerTaskCompleted() {
// disable printing of exception below
Logger logger = LogManager.getLogger(GTaskManager.class);
Configurator.setLevel(logger.getName(), Level.OFF);
setLogLevel(GTaskManager.class, Level.OFF);
gTaskManager.addTaskListener(new GTaskListenerAdapter() {
@Override
@ -434,16 +431,13 @@ public class GTaskTest extends AbstractGenericTest {
// this is testing that the exception does cause the taskManager to timeout still busy
waitForTaskManager();
Configurator.setLevel(logger.getName(), Level.DEBUG);
}
@Test
public void testExceptionInTaskListenerTaskStarted() {
// disable printing of exception below
Logger logger = LogManager.getLogger(GTaskManager.class);
Configurator.setLevel(logger.getName(), Level.OFF);
setLogLevel(GTaskManager.class, Level.OFF);
gTaskManager.addTaskListener(new GTaskListenerAdapter() {
@Override
@ -456,8 +450,6 @@ public class GTaskTest extends AbstractGenericTest {
// this is testing that the exception does cause the taskManager to timeout still busy
waitForTaskManager();
Configurator.setLevel(logger.getName(), Level.DEBUG);
}
private void cancelCurrentTask() {