Skip to content

Commit

Permalink
Added a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
gaojieliu committed Nov 15, 2024
1 parent be94e25 commit 8a0ce3a
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.linkedin.venice.compression;

import static org.testng.Assert.assertThrows;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.expectThrows;

import com.github.luben.zstd.Zstd;
import com.linkedin.venice.exceptions.VeniceException;
import com.linkedin.venice.utils.ByteUtils;
import com.linkedin.venice.utils.TestUtils;
import com.linkedin.venice.utils.Time;
Expand All @@ -14,6 +19,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.Assert;
Expand Down Expand Up @@ -173,7 +179,7 @@ private enum SourceDataType {

@Test
public void testZSTDThrowsExceptionOnNullDictionary() {
Assert.assertThrows(
assertThrows(
() -> new CompressorFactory()
.createVersionSpecificCompressorIfNotExist(CompressionStrategy.ZSTD_WITH_DICT, "foo_v1", null));
}
Expand Down Expand Up @@ -205,4 +211,15 @@ public void testCompressorEqual() {
}
}
}

@Test
public void testCompressorClose() throws IOException {
VeniceCompressor compressor = new ZstdWithDictCompressor("abc".getBytes(), Zstd.maxCompressionLevel());
String largePayload = RandomStringUtils.randomAlphabetic(500000);
compressor.compress(largePayload.getBytes());
compressor.close();
VeniceException exception =
expectThrows(VeniceException.class, () -> compressor.compress(ByteBuffer.wrap(largePayload.getBytes()), 4));
assertTrue(exception.getMessage().contains("has been closed"));
}
}

0 comments on commit 8a0ce3a

Please sign in to comment.