@Test
public void testDownloadFileLarge() throws IOException
{
setupForDownloadFileTests();
final States state = context.states("readStep").startsAs("1");
context.checking(new Expectations()
{
{
oneOf(httpReader).read(with(any(char[].class)), with(any(int.class)), with(any(int.class)));
when(state.is("1"));
then(state.is("2"));
will(new ReadAction("ABCDEFGHIJ"));
oneOf(httpReader).read(with(any(char[].class)), with(any(int.class)), with(any(int.class)));
when(state.is("2"));
then(state.is("3"));
will(new ReadAction("abcdefghij"));
oneOf(httpReader).read(with(any(char[].class)));
when(state.is("3"));
then(state.is("4"));
will(new ReadAction("MMM"));
oneOf(httpReader).read(with(any(char[].class)));
when(state.is("4"));
then(state.is("5"));
will(new ReadAction("ZZZ"));
oneOf(httpReader).read(with(any(char[].class)));
when(state.is("5"));
then(state.is("6"));
will(returnValue(-1));
oneOf(httpReader).close();
when(state.is("6"));
then(state.is("E"));
}
});
assertEquals("ABCDEFGHIJabcdefghijMMMZZZ", sut.downloadFile(URL, ACCOUNT_ID));