INT-3746: RemoteFileTemplate streaming backport
Resolves https://jira.spring.io/browse/INT-3746
This commit is contained in:
@@ -494,6 +494,10 @@ public class RemoteFileTemplate<F> implements RemoteFileOperations<F>, Initializ
|
||||
}
|
||||
dataInputStream = new ByteArrayInputStream(bytes);
|
||||
}
|
||||
else if (payload instanceof InputStream) {
|
||||
dataInputStream = (InputStream) payload;
|
||||
name = "InputStream payload";
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unsupported payload type. The only supported payloads are " +
|
||||
"java.io.File, java.lang.String, and byte[]");
|
||||
|
||||
@@ -23,7 +23,9 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
@@ -117,4 +119,12 @@ public class RemoteFileTemplateTests {
|
||||
verify(this.session).write(Mockito.any(InputStream.class), Mockito.anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStream() throws IOException {
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream("foo".getBytes());
|
||||
this.template.send(new GenericMessage<InputStream>(stream),
|
||||
FileExistsMode.IGNORE);
|
||||
verify(this.session).write(Mockito.eq(stream), Mockito.any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user