}
@Override
- public Keyed<Optional<Key>> redirectTo(String uri) {
+ public WithUri<Optional<Key>> redirectTo(String uri) {
this.redirectUri.set(Objects.requireNonNull(uri, "uri must not be null"));
return this::key;
}
@Override
- public Keyed<Optional<Key>> from(File file) {
+ public WithUri<Optional<Key>> from(File file) {
this.file.set(Objects.requireNonNull(file, "file must not be null"));
return this::key;
}
@Override
- public Lengthed<Keyed<Optional<Key>>> from(InputStream inputStream) {
+ public Lengthed<WithUri<Optional<Key>>> from(InputStream inputStream) {
payload.set(Objects.requireNonNull(inputStream, "inputStream must not be null"));
return this::length;
}
- private Keyed<Optional<Key>> length(long length) {
+ private WithUri<Optional<Key>> length(long length) {
this.length.set(length);
return this::key;
}
- private ListenableFuture<Optional<Key>> key(Key key) {
+ private ListenableFuture<Optional<Key>> key(String uri) {
String identifier = new RandomIdentifierGenerator().generate();
- ClientPut clientPut = createClientPutCommand(key.getKey(), identifier);
+ ClientPut clientPut = createClientPutCommand(uri, identifier);
return threadPool.submit(() -> new ClientPutReplySequence().send(clientPut).get());
}
fcpClient.clientPut()
.from(new ByteArrayInputStream("Hello\n".getBytes()))
.length(6)
- .key(new Key("KSK@foo.txt"));
+ .uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("Hello"));
assertThat(lines, matchesFcpMessage("ClientPut", "UploadFrom=direct", "DataLength=6", "URI=KSK@foo.txt"));
Future<Optional<Key>> key = fcpClient.clientPut()
.from(new ByteArrayInputStream("Hello\n".getBytes()))
.length(6)
- .key(new Key("KSK@foo.txt"));
+ .uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("Hello"));
String identifier = extractIdentifier(lines);
Future<Optional<Key>> key = fcpClient.clientPut()
.from(new ByteArrayInputStream("Hello\n".getBytes()))
.length(6)
- .key(new Key("KSK@foo.txt"));
+ .uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("Hello"));
String identifier = extractIdentifier(lines);
.named("otherName.txt")
.from(new ByteArrayInputStream("Hello\n".getBytes()))
.length(6)
- .key(new Key("KSK@foo.txt"));
+ .uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("Hello"));
assertThat(lines, matchesFcpMessage("ClientPut", "TargetFilename=otherName.txt", "UploadFrom=direct",
@Test
public void clientPutWithRedirectSendsCorrectCommand()
throws IOException, ExecutionException, InterruptedException {
- fcpClient.clientPut().redirectTo("KSK@bar.txt").key(new Key("KSK@foo.txt"));
+ fcpClient.clientPut().redirectTo("KSK@bar.txt").uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
assertThat(lines,
@Test
public void clientPutWithFileSendsCorrectCommand() throws InterruptedException, ExecutionException, IOException {
- fcpClient.clientPut().from(new File("/tmp/data.txt")).key(new Key("KSK@foo.txt"));
+ fcpClient.clientPut().from(new File("/tmp/data.txt")).uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
assertThat(lines,
public void clientPutWithFileCanCompleteTestDdaSequence()
throws IOException, ExecutionException, InterruptedException {
File tempFile = createTempFile();
- fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).key(new Key("KSK@foo.txt"));
+ fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
String identifier = extractIdentifier(lines);
@Test
public void clientPutDoesNotReactToProtocolErrorForDifferentIdentifier()
throws InterruptedException, ExecutionException, IOException {
- Future<Optional<Key>> key = fcpClient.clientPut().from(new File("/tmp/data.txt")).key(new Key("KSK@foo.txt"));
+ Future<Optional<Key>> key = fcpClient.clientPut().from(new File("/tmp/data.txt")).uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
String identifier = extractIdentifier(lines);
@Test
public void clientPutAbortsOnProtocolErrorOtherThan25()
throws InterruptedException, ExecutionException, IOException {
- Future<Optional<Key>> key = fcpClient.clientPut().from(new File("/tmp/data.txt")).key(new Key("KSK@foo.txt"));
+ Future<Optional<Key>> key = fcpClient.clientPut().from(new File("/tmp/data.txt")).uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
String identifier = extractIdentifier(lines);
public void clientPutDoesNotReplyToWrongTestDdaReply() throws IOException, ExecutionException,
InterruptedException {
File tempFile = createTempFile();
- fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).key(new Key("KSK@foo.txt"));
+ fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
String identifier = extractIdentifier(lines);
public void clientPutSendsResponseEvenIfFileCanNotBeRead()
throws IOException, ExecutionException, InterruptedException {
File tempFile = createTempFile();
- fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).key(new Key("KSK@foo.txt"));
+ fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
String identifier = extractIdentifier(lines);
public void clientPutDoesNotResendOriginalClientPutOnTestDDACompleteWithWrongDirectory()
throws IOException, ExecutionException, InterruptedException {
File tempFile = createTempFile();
- fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).key(new Key("KSK@foo.txt"));
+ fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).uri("KSK@foo.txt");
connectNode();
List<String> lines = fcpServer.collectUntil(is("EndMessage"));
String identifier = extractIdentifier(lines);