Skip to content
Snippets Groups Projects
Commit dfc9cd1b authored by Guy Zana's avatar Guy Zana
Browse files

test: add a TCPDownloadFile test that downloads index.html from bbc.co.uk

uses Java nio.* for downloading a file, writing it to /tmp
parent dc362c2c
No related branches found
No related tags found
No related merge requests found
package com.cloudius.cli.tests;
import java.io.FileOutputStream;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
public class TCPDownloadFile implements Test {
@Override
public boolean run() {
try {
URL website = new URL("http://212.58.244.66/");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("/tmp/bbc.co.uk.html");
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
fos.close();
} catch (Exception ex) {
ex.printStackTrace();
return (false);
}
return (true);
}
}
......@@ -66,6 +66,7 @@ public class TestRunner extends ScriptableObject {
public void registerAllTests() {
this.register("TCPEchoServerTest", new TCPEchoServerTest());
this.register("TCPExternalCommunication", new TCPExternalCommunication());
this.register("TCPDownloadFile", new TCPDownloadFile());
this.registerELFTests();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment