diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-05-10 07:53:16 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-05-10 07:53:16 +0400 |
commit | 914f71b8594f5e7a30b8028cc7b2adc78976f8b4 (patch) | |
tree | 49f8e99a9cece22a090549410f35618d04415e3b | |
parent | a219f93ee60bb6339d5077d1ce9a3c1ead611dee (diff) |
Exchange some application packets after handshake
-rw-r--r-- | src/test/java/org/bouncycastle/crypto/tls/test/DTLSProtocolTest.java | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/test/java/org/bouncycastle/crypto/tls/test/DTLSProtocolTest.java b/src/test/java/org/bouncycastle/crypto/tls/test/DTLSProtocolTest.java index 04f7e15e..339ea3bc 100644 --- a/src/test/java/org/bouncycastle/crypto/tls/test/DTLSProtocolTest.java +++ b/src/test/java/org/bouncycastle/crypto/tls/test/DTLSProtocolTest.java @@ -8,6 +8,7 @@ import org.bouncycastle.crypto.tls.DTLSClientProtocol; import org.bouncycastle.crypto.tls.DTLSServerProtocol;
import org.bouncycastle.crypto.tls.DTLSTransport;
import org.bouncycastle.crypto.tls.DatagramTransport;
+import org.bouncycastle.util.Arrays;
public class DTLSProtocolTest extends TestCase {
@@ -32,20 +33,18 @@ public class DTLSProtocolTest extends TestCase { MockDTLSClient client = new MockDTLSClient();
DTLSTransport dtlsClient = clientProtocol.connect(client, clientTransport);
- // byte[] data = new byte[64];
- // secureRandom.nextBytes(data);
- //
- // OutputStream output = clientProtocol.getOutputStream();
- // output.write(data);
- // output.close();
- //
- // byte[] echo = Streams.readAll(clientProtocol.getInputStream());
+ for (int i = 1; i <= 10; ++i) {
+ byte[] data = new byte[i];
+ Arrays.fill(data, (byte)i);
+ dtlsClient.send(data, 0, data.length);
+ }
+
+ byte[] buf = new byte[dtlsClient.getReceiveLimit()];
+ while (dtlsClient.receive(buf, 0, buf.length, 1000) >= 0);
dtlsClient.close();
serverThread.shutdown();
-
- // assertTrue(Arrays.areEqual(data, echo));
}
static class ServerThread extends Thread {
@@ -66,12 +65,12 @@ public class DTLSProtocolTest extends TestCase { while (!isShutdown) {
int length = dtlsServer.receive(buf, 0, buf.length, 1000);
if (length >= 0) {
- serverTransport.send(buf, 0, length);
+ dtlsServer.send(buf, 0, length);
}
}
dtlsServer.close();
} catch (Exception e) {
- throw new RuntimeException(e);
+ e.printStackTrace();
}
}
|