From 29eb900822070ac32ba9100801c4daaf9fb05467 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Sun, 30 Oct 2011 22:39:20 +0000
Subject: [PATCH] Non-JUnit tests for LAN socket plugin.

---
 .../plugins/socket/LanSocketClientTest.java   | 38 +++++++++++++++++++
 .../plugins/socket/LanSocketServerTest.java   | 26 +++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 test/net/sf/briar/plugins/socket/LanSocketClientTest.java
 create mode 100644 test/net/sf/briar/plugins/socket/LanSocketServerTest.java

diff --git a/test/net/sf/briar/plugins/socket/LanSocketClientTest.java b/test/net/sf/briar/plugins/socket/LanSocketClientTest.java
new file mode 100644
index 0000000000..b0a8d44c7d
--- /dev/null
+++ b/test/net/sf/briar/plugins/socket/LanSocketClientTest.java
@@ -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();
+	}
+}
diff --git a/test/net/sf/briar/plugins/socket/LanSocketServerTest.java b/test/net/sf/briar/plugins/socket/LanSocketServerTest.java
new file mode 100644
index 0000000000..6ca078c554
--- /dev/null
+++ b/test/net/sf/briar/plugins/socket/LanSocketServerTest.java
@@ -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();
+	}
+}
-- 
GitLab