code polish

This commit is contained in:
nathan 2016-02-29 02:42:10 +01:00
parent 39504af041
commit dfd9e2c69d

View File

@ -16,8 +16,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
public public
class LargeBufferTest extends BaseTest { class LargeResizeBufferTest extends BaseTest {
private static final int OBJ_SIZE = 1024 * 10; private static final int OBJ_SIZE = 1024 * 100;
private volatile int finalCheckAmount = 0; private volatile int finalCheckAmount = 0;
private volatile int serverCheck = -1; private volatile int serverCheck = -1;
@ -58,8 +58,8 @@ class LargeBufferTest extends BaseTest {
if (this.received.incrementAndGet() == messageCount) { if (this.received.incrementAndGet() == messageCount) {
System.out.println("Server received all " + messageCount + " messages!"); System.out.println("Server received all " + messageCount + " messages!");
System.out.println("Server received and sent " + this.receivedBytes.get() + " bytes."); System.out.println("Server received and sent " + this.receivedBytes.get() + " bytes.");
LargeBufferTest.this.serverCheck = LargeBufferTest.this.finalCheckAmount - this.receivedBytes.get(); LargeResizeBufferTest.this.serverCheck = LargeResizeBufferTest.this.finalCheckAmount - this.receivedBytes.get();
System.out.println("Server missed " + LargeBufferTest.this.serverCheck + " bytes."); System.out.println("Server missed " + LargeResizeBufferTest.this.serverCheck + " bytes.");
stopEndPoints(); stopEndPoints();
} }
} }
@ -85,8 +85,8 @@ class LargeBufferTest extends BaseTest {
if (count == messageCount) { if (count == messageCount) {
System.out.println("Client received all " + messageCount + " messages!"); System.out.println("Client received all " + messageCount + " messages!");
System.out.println("Client received and sent " + this.receivedBytes.get() + " bytes."); System.out.println("Client received and sent " + this.receivedBytes.get() + " bytes.");
LargeBufferTest.this.clientCheck = LargeBufferTest.this.finalCheckAmount - this.receivedBytes.get(); LargeResizeBufferTest.this.clientCheck = LargeResizeBufferTest.this.finalCheckAmount - this.receivedBytes.get();
System.out.println("Client missed " + LargeBufferTest.this.clientCheck + " bytes."); System.out.println("Client missed " + LargeResizeBufferTest.this.clientCheck + " bytes.");
} }
} }
}); });
@ -96,13 +96,21 @@ class LargeBufferTest extends BaseTest {
System.err.println(" Client sending " + messageCount + " messages"); System.err.println(" Client sending " + messageCount + " messages");
for (int i = 0; i < messageCount; i++) { for (int i = 0; i < messageCount; i++) {
this.finalCheckAmount += OBJ_SIZE; this.finalCheckAmount += OBJ_SIZE; // keep increasing size
byte[] b = new byte[OBJ_SIZE]; byte[] b = new byte[OBJ_SIZE];
random.nextBytes(b); random.nextBytes(b);
// set some of the bytes to be all `244`, just so some compression can occur (to test that as well)
for (int j = 0; j < 400; j++) {
b[j] = (byte) 244;
}
// System.err.println("Sending " + b.length + " bytes");
client.send() client.send()
.TCP(new LargeMessage(b)); .TCP(new LargeMessage(b));
} }
System.err.println("Client has queued " + messageCount + " messages."); System.err.println("Client has queued " + messageCount + " messages.");
waitForThreads(); waitForThreads();