Created
November 26, 2010 19:01
-
-
Save jfarcand/717095 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test(groups = "standalone") | |
public void basicDefaultTest() throws Throwable { | |
AsyncHttpClientConfig client = new AsyncHttpClientConfig.Builder().setResumableDownload(true).build(); | |
AsyncHttpClient c = new AsyncHttpClient(client); | |
final RandomAccessFile file = new RandomAccessFile("800m.avi", "rw"); | |
Response r = c.prepareGet("http://192.168.2.106:8081/800m.avi").execute(new AsyncCompletionHandlerBase(){ | |
private long byteTransferred = 0; | |
/* @Override */ | |
public STATE onBodyPartReceived(final HttpResponseBodyPart content) throws Exception { | |
file.seek(byteTransferred); | |
file.write(content.getBodyPartBytes()); | |
byteTransferred += content.getBodyPartBytes().length; | |
return STATE.CONTINUE; | |
} | |
}).get(); | |
assertEquals(r.getStatusCode(), 200); | |
file.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment