aboutsummaryrefslogtreecommitdiffstats
path: root/filedistribution/src/test
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-01-30 09:33:06 +0100
committerHarald Musum <musum@oath.com>2018-01-30 09:33:06 +0100
commit9869141c46d299e84ac9285a3ee575e49cb1970a (patch)
treeb40990015d6fb48059654c3ba2fcd66a3c34ea17 /filedistribution/src/test
parent0e6ec009fcce1796b4d9ad0ad7accaa403221930 (diff)
Fix bug where nextContent() always returned all data
Diffstat (limited to 'filedistribution/src/test')
-rw-r--r--filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReferenceDataTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReferenceDataTest.java b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReferenceDataTest.java
new file mode 100644
index 00000000000..0b85def5809
--- /dev/null
+++ b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReferenceDataTest.java
@@ -0,0 +1,28 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.filedistribution;
+
+import com.yahoo.config.FileReference;
+import com.yahoo.text.Utf8;
+import org.junit.Test;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+
+public class FileReferenceDataTest {
+
+ @Test
+ public void testDataBlob() {
+ String content = "blob";
+ FileReferenceData fileReferenceData =
+ new FileReferenceDataBlob(new FileReference("ref"), "foo", FileReferenceData.Type.compressed, Utf8.toBytes(content));
+ ByteBuffer byteBuffer = ByteBuffer.allocate(100);
+ assertEquals(4, fileReferenceData.nextContent(byteBuffer));
+ assertEquals(content, Utf8.toString(Arrays.copyOfRange(byteBuffer.array(), 0, 4)));
+
+ // nextContent() will always return everything for FileReferenceDataBlob, so nothing more should be read
+ assertEquals(-1, fileReferenceData.nextContent(byteBuffer));
+ }
+
+}