Added logger to unit test
This commit is contained in:
parent
353164fac5
commit
99d9c743cb
@ -28,6 +28,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import dorkbox.network.connection.Connection;
|
import dorkbox.network.connection.Connection;
|
||||||
import dorkbox.network.connection.Listener;
|
import dorkbox.network.connection.Listener;
|
||||||
@ -39,6 +41,8 @@ public
|
|||||||
class ReconnectTest extends BaseTest {
|
class ReconnectTest extends BaseTest {
|
||||||
private final AtomicInteger receivedCount = new AtomicInteger(0);
|
private final AtomicInteger receivedCount = new AtomicInteger(0);
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ReconnectTest.class.getSimpleName());
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public
|
public
|
||||||
void socketReuseUDP() throws IOException, SecurityException {
|
void socketReuseUDP() throws IOException, SecurityException {
|
||||||
@ -97,7 +101,7 @@ class ReconnectTest extends BaseTest {
|
|||||||
public
|
public
|
||||||
void received(Connection connection, String object) {
|
void received(Connection connection, String object) {
|
||||||
int incrementAndGet = ReconnectTest.this.receivedCount.incrementAndGet();
|
int incrementAndGet = ReconnectTest.this.receivedCount.incrementAndGet();
|
||||||
System.out.println("----- <S " + connection + "> " + incrementAndGet + " : " + object);
|
logger.error("----- <S " + connection + "> " + incrementAndGet + " : " + object);
|
||||||
|
|
||||||
latch.get().countDown();
|
latch.get().countDown();
|
||||||
}
|
}
|
||||||
@ -129,7 +133,7 @@ class ReconnectTest extends BaseTest {
|
|||||||
public
|
public
|
||||||
void received(Connection connection, String object) {
|
void received(Connection connection, String object) {
|
||||||
int incrementAndGet = ReconnectTest.this.receivedCount.incrementAndGet();
|
int incrementAndGet = ReconnectTest.this.receivedCount.incrementAndGet();
|
||||||
System.out.println("----- <C " + connection + "> " + incrementAndGet + " : " + object);
|
logger.error("----- <C " + connection + "> " + incrementAndGet + " : " + object);
|
||||||
|
|
||||||
latch.get().countDown();
|
latch.get().countDown();
|
||||||
}
|
}
|
||||||
@ -148,7 +152,7 @@ class ReconnectTest extends BaseTest {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for (int i = 1; i < count + 1; i++) {
|
for (int i = 1; i < count + 1; i++) {
|
||||||
System.out.println(".....");
|
logger.error(".....");
|
||||||
latch.set(new CountDownLatch(latchCount));
|
latch.set(new CountDownLatch(latchCount));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -176,7 +180,7 @@ class ReconnectTest extends BaseTest {
|
|||||||
// check to see if we changed at all...
|
// check to see if we changed at all...
|
||||||
if (lastRetryCount == this.receivedCount.get()) {
|
if (lastRetryCount == this.receivedCount.get()) {
|
||||||
if (retryCount-- < 0) {
|
if (retryCount-- < 0) {
|
||||||
System.err.println("Aborting unit test... wrong count!");
|
logger.error("Aborting unit test... wrong count!");
|
||||||
if (useUDP) {
|
if (useUDP) {
|
||||||
// If TCP and UDP both fill the pipe, THERE WILL BE FRAGMENTATION and dropped UDP packets!
|
// If TCP and UDP both fill the pipe, THERE WILL BE FRAGMENTATION and dropped UDP packets!
|
||||||
// it results in severe UDP packet loss and contention.
|
// it results in severe UDP packet loss and contention.
|
||||||
@ -185,7 +189,7 @@ class ReconnectTest extends BaseTest {
|
|||||||
// also, a google search on just "INET97/proceedings/F3/F3_1.HTM" turns up interesting problems.
|
// also, a google search on just "INET97/proceedings/F3/F3_1.HTM" turns up interesting problems.
|
||||||
// Usually it's with ISPs.
|
// Usually it's with ISPs.
|
||||||
|
|
||||||
System.err.println("NOTE: UDP can fail, even on loopback! See: http://www.isoc.org/INET97/proceedings/F3/F3_1.HTM");
|
logger.error("NOTE: UDP can fail, even on loopback! See: http://www.isoc.org/INET97/proceedings/F3/F3_1.HTM");
|
||||||
}
|
}
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
@ -197,10 +201,9 @@ class ReconnectTest extends BaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.close();
|
client.close();
|
||||||
System.out.println(".....");
|
logger.error(".....");
|
||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user