summaryrefslogtreecommitdiffstats
path: root/filedistribution/src/test
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-04-03 07:52:51 +0200
committerGitHub <noreply@github.com>2018-04-03 07:52:51 +0200
commit275e3c9d402ac1bc4b02eb2b20f8554cb1b92daf (patch)
tree2cd1f855371b391fb5cdeee9035b5012c1eded0e /filedistribution/src/test
parent0337ed04d70c616c3da66c3b7d0df628afefb483 (diff)
Revert "Remove method only used in tests"
Diffstat (limited to 'filedistribution/src/test')
-rw-r--r--filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java15
-rw-r--r--filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReceiverTest.java6
2 files changed, 9 insertions, 12 deletions
diff --git a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java
index 123fa51cdab..e0ef2ecf7e4 100644
--- a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java
+++ b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java
@@ -13,14 +13,11 @@ import com.yahoo.jrt.Transport;
import com.yahoo.text.Utf8;
import com.yahoo.vespa.config.Connection;
import com.yahoo.vespa.config.ConnectionPool;
-import net.jpountz.xxhash.XXHash64;
-import net.jpountz.xxhash.XXHashFactory;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
-import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
@@ -46,7 +43,7 @@ public class FileDownloaderTest {
downloadDir = Files.createTempDirectory("filedistribution").toFile();
tempDir = Files.createTempDirectory("download").toFile();
connection = new MockConnection();
- fileDownloader = new FileDownloader(connection, downloadDir, Duration.ofSeconds(2), Duration.ofMillis(100));
+ fileDownloader = new FileDownloader(connection, downloadDir, tempDir, Duration.ofSeconds(2), Duration.ofMillis(100));
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
@@ -152,7 +149,7 @@ public class FileDownloaderTest {
@Test
public void getFileWhenConnectionError() throws IOException {
- fileDownloader = new FileDownloader(connection, downloadDir, Duration.ofSeconds(3), Duration.ofMillis(100));
+ fileDownloader = new FileDownloader(connection, downloadDir, tempDir, Duration.ofSeconds(3), Duration.ofMillis(100));
File downloadDir = fileDownloader.downloadDirectory();
int timesToFail = 2;
@@ -189,7 +186,7 @@ public class FileDownloaderTest {
File downloadDir = Files.createTempDirectory("filedistribution").toFile();
MockConnection connectionPool = new MockConnection();
connectionPool.setResponseHandler(new MockConnection.WaitResponseHandler(timeout.plus(Duration.ofMillis(1000))));
- FileDownloader fileDownloader = new FileDownloader(connectionPool, downloadDir, timeout, sleepBetweenRetries);
+ FileDownloader fileDownloader = new FileDownloader(connectionPool, downloadDir, tempDir, timeout, sleepBetweenRetries);
FileReference foo = new FileReference("foo");
FileReference bar = new FileReference("bar");
fileDownloader.queueForAsyncDownload(new FileReferenceDownload(foo));
@@ -228,11 +225,7 @@ public class FileDownloaderTest {
}
private void receiveFile(FileReference fileReference, String filename, FileReferenceData.Type type, byte[] content) {
- XXHash64 hasher = XXHashFactory.fastestInstance().hash64();
- FileReceiver.Session session =
- new FileReceiver.Session(downloadDir, tempDir, 1, fileReference, type, filename, content.length);
- session.addPart(0, content);
- session.close(hasher.hash(ByteBuffer.wrap(content), 0));
+ fileDownloader.receiveFile(new FileReferenceDataBlob(fileReference, filename, type, content));
}
private static class MockConnection implements ConnectionPool, com.yahoo.vespa.config.Connection {
diff --git a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReceiverTest.java b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReceiverTest.java
index 8dda0bcce66..78fc094a9ef 100644
--- a/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReceiverTest.java
+++ b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileReceiverTest.java
@@ -14,10 +14,14 @@ import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.assertEquals;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
public class FileReceiverTest {
private File root;
@@ -88,7 +92,7 @@ public class FileReceiverTest {
assertEquals(all, Utf8.toString(allReadBytes));
}
- private void transferCompressedData(FileReference ref, String fileName, byte[] data) {
+ private void transferCompressedData(FileReference ref, String fileName, byte[] data) throws IOException {
FileReceiver.Session session =
new FileReceiver.Session(root, tempDir, 1, ref, FileReferenceData.Type.compressed, fileName, data.length);
session.addPart(0, data);