package com.coderising.download;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.coderising.download.api.ConnectionManager;
import com.coderising.download.api.DownloadListener;
import com.coderising.download.impl.ConnectionManagerImpl;
public class FileDownloaderTest {
boolean downloadFinished = false;
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testDownload() {
//String url = "http://10.10.1.65:1024/wxl.jpg";
String url = "http://10.10.1.65:1024/java.pdf";
FileDownloader downloader = new FileDownloader(url);
ConnectionManager cm = new ConnectionManagerImpl();
downloader.setConnectionManager(cm);
downloader.setListener(new DownloadListener() {
@Override
public void notifyFinished() {
downloadFinished = true;
}
});
downloader.execute();
// �ȴ����߳����س���ִ�����
while (!downloadFinished) {
try {
System.out.println("��û��������ɣ���������");
//����5��
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("������ɣ�");
}
}