Non-JUnit tests for LAN socket plugin.

This commit is contained in:
akwizgran
2011-10-30 22:39:20 +00:00
parent 1b0bd6961a
commit 29eb900822
2 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package net.sf.briar.plugins.socket;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.TransportConfig;
import net.sf.briar.api.TransportProperties;
import net.sf.briar.plugins.StreamClientTest;
//This is not a JUnit test - it has to be run manually while the server test
//is running on another machine
public class LanSocketClientTest extends StreamClientTest {
private LanSocketClientTest(String serverAddress, String serverPort) {
// Store the server's internal address and port
TransportProperties p = new TransportProperties();
p.put("internal", serverAddress);
p.put("port", serverPort);
Map<ContactId, TransportProperties> remote =
Collections.singletonMap(contactId, p);
// Create the plugin
callback = new ClientCallback(new TransportConfig(),
new TransportProperties(), remote);
Executor e = Executors.newCachedThreadPool();
plugin = new LanSocketPlugin(e, callback, 0L);
}
public static void main(String[] args) throws Exception {
if(args.length != 2) {
System.err.println("Please specify the server's address and port");
System.exit(1);
}
new LanSocketClientTest(args[0], args[1]).run();
}
}

View File

@@ -0,0 +1,26 @@
package net.sf.briar.plugins.socket;
import java.util.Collections;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import net.sf.briar.api.TransportConfig;
import net.sf.briar.api.TransportProperties;
import net.sf.briar.plugins.StreamServerTest;
//This is not a JUnit test - it has to be run manually while the server test
//is running on another machine
public class LanSocketServerTest extends StreamServerTest {
private LanSocketServerTest() {
callback = new ServerCallback(new TransportConfig(),
new TransportProperties(),
Collections.singletonMap(contactId, new TransportProperties()));
Executor e = Executors.newCachedThreadPool();
plugin = new LanSocketPlugin(e, callback, 0L);
}
public static void main(String[] args) throws Exception {
new LanSocketServerTest().run();
}
}