Skip to content

Commit

Permalink
Polishing #1519
Browse files Browse the repository at this point in the history
Adapt code to changed GZip output on Java 16.
  • Loading branch information
mp911de committed Nov 14, 2020
1 parent 7cc67bd commit a7aed8f
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
*/
package io.lettuce.core.codec;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.*;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

import org.junit.jupiter.api.Test;

/**
* Unit tests for {@link CompressionCodec}.
*
* @author Mark Paluch
*/
class CompressionCodecUnitTests {
Expand All @@ -50,21 +51,19 @@ void gzipValueTest() {
RedisCodec<String, String> sut = CompressionCodec.valueCompressor(StringCodec.UTF8,
CompressionCodec.CompressionType.GZIP);
ByteBuffer byteBuffer = sut.encodeValue(key);
assertThat(toBytes(byteBuffer.duplicate())).isEqualTo(keyGzipBytes);

String s = sut.decodeValue(ByteBuffer.wrap(keyGzipBytes));
assertThat(s).isEqualTo(key);
assertThat(sut.decodeValue(byteBuffer)).isEqualTo(key);
assertThat(sut.decodeValue(ByteBuffer.wrap(keyGzipBytes))).isEqualTo(key);
}

@Test
void deflateValueTest() {
RedisCodec<String, String> sut = CompressionCodec.valueCompressor(StringCodec.UTF8,
CompressionCodec.CompressionType.DEFLATE);
ByteBuffer byteBuffer = sut.encodeValue(key);
assertThat(toBytes(byteBuffer.duplicate())).isEqualTo(keyDeflateBytes);

String s = sut.decodeValue(ByteBuffer.wrap(keyDeflateBytes));
assertThat(s).isEqualTo(key);
assertThat(sut.decodeValue(byteBuffer)).isEqualTo(key);
assertThat(sut.decodeValue(ByteBuffer.wrap(keyDeflateBytes))).isEqualTo(key);
}

@Test
Expand Down

0 comments on commit a7aed8f

Please sign in to comment.