JAVA-18116 Review log statements for projects - Week 7 - 2023 (#13583)
JAVA-18116 Review log statements for projects - Week 7 - 2023 (#13583) --------- Co-authored-by: jogra <joseph.sterling.grah@miles.no>
This commit is contained in:
+10
-5
@@ -4,6 +4,9 @@ import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Phaser;
|
||||
@@ -13,6 +16,8 @@ import static junit.framework.TestCase.assertEquals;
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class PhaserUnitTest {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(PhaserUnitTest.class);
|
||||
|
||||
@Test
|
||||
public void givenPhaser_whenCoordinateWorksBetweenThreads_thenShouldCoordinateBetweenMultiplePhases() {
|
||||
//given
|
||||
@@ -26,19 +31,19 @@ public class PhaserUnitTest {
|
||||
executorService.submit(new LongRunningAction("thread-3", ph));
|
||||
|
||||
//then
|
||||
System.out.println("Thread " + Thread.currentThread().getName() + " waiting for others");
|
||||
log.debug("Thread {} waiting for others", Thread.currentThread().getName());
|
||||
ph.arriveAndAwaitAdvance();
|
||||
System.out.println("Thread " + Thread.currentThread().getName() + " proceeding in phase " + ph.getPhase());
|
||||
log.debug("Thread {} proceeding in phase {}", Thread.currentThread().getName(), ph.getPhase());
|
||||
|
||||
assertEquals(1, ph.getPhase());
|
||||
|
||||
//and
|
||||
executorService.submit(new LongRunningAction("thread-4", ph));
|
||||
executorService.submit(new LongRunningAction("thread-5", ph));
|
||||
|
||||
System.out.println("Thread " + Thread.currentThread().getName() + " waiting for others");
|
||||
|
||||
log.debug("Thread {} waiting for others", Thread.currentThread().getName());
|
||||
ph.arriveAndAwaitAdvance();
|
||||
System.out.println("Thread " + Thread.currentThread().getName() + " proceeding in phase " + ph.getPhase());
|
||||
log.debug("Thread {} proceeding in phase {}", Thread.currentThread().getName(), ph.getPhase());
|
||||
|
||||
assertEquals(2, ph.getPhase());
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework" level="WARN" />
|
||||
<logger name="org.springframework.transaction" level="WARN" />
|
||||
|
||||
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
|
||||
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user