diff options
author | Kenny Root <kroot@google.com> | 2015-01-08 01:26:18 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-08 01:26:18 +0000 |
commit | 138152ab385f27a80cf6520f79e39f91a35c04fb (patch) | |
tree | 4b831666422a7fec635f689601b76012588440e3 /support/src/test/java | |
parent | 54abd315f40479c09d571db4620eca02d2d92c14 (diff) | |
parent | ed755e7c7aed927e164eb513d6ea92131667cdfa (diff) | |
download | libcore-138152ab385f27a80cf6520f79e39f91a35c04fb.zip libcore-138152ab385f27a80cf6520f79e39f91a35c04fb.tar.gz libcore-138152ab385f27a80cf6520f79e39f91a35c04fb.tar.bz2 |
am ed755e7c: Merge "SSLEngineTest: position should be same as produced/consumed"
* commit 'ed755e7c7aed927e164eb513d6ea92131667cdfa':
SSLEngineTest: position should be same as produced/consumed
Diffstat (limited to 'support/src/test/java')
-rw-r--r-- | support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java b/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java index 709f568..6c2c943 100644 --- a/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java +++ b/support/src/test/java/libcore/javax/net/ssl/TestSSLEnginePair.java @@ -134,8 +134,6 @@ public final class TestSSLEnginePair extends Assert { void beforeBeginHandshake(SSLEngine client, SSLEngine server) {} } - private static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.allocate(0); - private static boolean handshakeCompleted(SSLEngine engine, ByteBuffer output, ByteBuffer input, @@ -165,9 +163,12 @@ public final class TestSSLEnginePair extends Assert { if (input.remaining() == 0) { return false; } + int inputPositionBefore = input.position(); SSLEngineResult unwrapResult = engine.unwrap(input, scratch); assertEquals(SSLEngineResult.Status.OK, unwrapResult.getStatus()); assertEquals(0, scratch.position()); + assertEquals(0, unwrapResult.bytesProduced()); + assertEquals(input.position() - inputPositionBefore, unwrapResult.bytesConsumed()); assertFinishedOnce(finished, unwrapResult); return true; } @@ -177,8 +178,15 @@ public final class TestSSLEnginePair extends Assert { if (output.remaining() != output.capacity()) { return false; } - SSLEngineResult wrapResult = engine.wrap(EMPTY_BYTE_BUFFER, output); + ByteBuffer emptyByteBuffer = ByteBuffer.allocate(0); + int inputPositionBefore = emptyByteBuffer.position(); + int outputPositionBefore = output.position(); + SSLEngineResult wrapResult = engine.wrap(emptyByteBuffer, output); assertEquals(SSLEngineResult.Status.OK, wrapResult.getStatus()); + assertEquals(0, wrapResult.bytesConsumed()); + assertEquals(inputPositionBefore, emptyByteBuffer.position()); + assertEquals(output.position() - outputPositionBefore, + wrapResult.bytesProduced()); assertFinishedOnce(finished, wrapResult); return true; } |