mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 23:29:52 +01:00
Non-JUnit tests for LAN socket plugin.
This commit is contained in:
38
test/net/sf/briar/plugins/socket/LanSocketClientTest.java
Normal file
38
test/net/sf/briar/plugins/socket/LanSocketClientTest.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
26
test/net/sf/briar/plugins/socket/LanSocketServerTest.java
Normal file
26
test/net/sf/briar/plugins/socket/LanSocketServerTest.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user