Issue #2525 - Clean up SharedBlockingCallback.

Improved test logging.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2018-05-14 12:08:33 +02:00
parent 317a8a5c66
commit a719c29b40
1 changed files with 7 additions and 1 deletions

View File

@ -26,6 +26,8 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.util.SharedBlockingCallback.Blocker; import org.eclipse.jetty.util.SharedBlockingCallback.Blocker;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -39,6 +41,8 @@ import static org.junit.Assert.fail;
public class SharedBlockingCallbackTest public class SharedBlockingCallbackTest
{ {
private static final Logger LOG = Log.getLogger(SharedBlockingCallback.class);
final AtomicInteger notComplete = new AtomicInteger(); final AtomicInteger notComplete = new AtomicInteger();
final SharedBlockingCallback sbcb= new SharedBlockingCallback() final SharedBlockingCallback sbcb= new SharedBlockingCallback()
{ {
@ -207,7 +211,7 @@ public class SharedBlockingCallbackTest
{ {
try (Blocker blocker=sbcb.acquire()) try (Blocker blocker=sbcb.acquire())
{ {
// Immediately close() without calling succeeded(). LOG.info("Blocker not complete "+blocker+" warning is expected...");
} }
Assert.assertEquals(1,notComplete.get()); Assert.assertEquals(1,notComplete.get());
@ -216,6 +220,7 @@ public class SharedBlockingCallbackTest
@Test @Test
public void testBlockerTimeout() throws Exception public void testBlockerTimeout() throws Exception
{ {
LOG.info("Succeeded after ... warning is expected...");
Blocker b0=null; Blocker b0=null;
try try
{ {
@ -262,6 +267,7 @@ public class SharedBlockingCallbackTest
} }
// Blocker.close() has been called by try-with-resources. // Blocker.close() has been called by try-with-resources.
// Simulate callback completion, must not throw. // Simulate callback completion, must not throw.
LOG.info("Succeeded after ... warning is expected...");
blocker0.succeeded(); blocker0.succeeded();
try (Blocker blocker = sbcb.acquire()) try (Blocker blocker = sbcb.acquire())