diff --git a/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java b/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java index 26116ef0bcc5b852fcb208af9bf09a926b3ee35f..6710db1d5461565f2102ed7f85bf7f0cfa855875 100644 --- a/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java +++ b/briar-tests/src/org/briarproject/plugins/file/UnixRemovableDriveMonitorTest.java @@ -1,7 +1,6 @@ package org.briarproject.plugins.file; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.junit.Assume.assumeTrue; import java.io.File; import java.io.IOException; @@ -23,12 +22,15 @@ public class UnixRemovableDriveMonitorTest extends BriarTestCase { @Before public void setUp() { - assumeTrue(OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer()); testDir.mkdirs(); } @Test public void testNonexistentDir() throws Exception { + if(!(OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer())) { + System.err.println("WARNING: Skipping test, can't run on this OS"); + return; + } File doesNotExist = new File(testDir, "doesNotExist"); RemovableDriveMonitor monitor = createMonitor(doesNotExist); monitor.start(new Callback() { @@ -46,6 +48,10 @@ public class UnixRemovableDriveMonitorTest extends BriarTestCase { @Test public void testOneCallbackPerFile() throws Exception { + if(!(OsUtils.isLinux() || OsUtils.isMacLeopardOrNewer())) { + System.err.println("WARNING: Skipping test, can't run on this OS"); + return; + } // Create a callback that will wait for two files before stopping final List<File> detected = new ArrayList<File>(); final CountDownLatch latch = new CountDownLatch(2); diff --git a/briar-tests/src/org/briarproject/plugins/tcp/LanTcpPluginTest.java b/briar-tests/src/org/briarproject/plugins/tcp/LanTcpPluginTest.java index f5bd88d294895ac2569dedc05f6fc9d098f80032..fcbb30c52bbcc228481eb7d9d2ea1049f6c51f46 100644 --- a/briar-tests/src/org/briarproject/plugins/tcp/LanTcpPluginTest.java +++ b/briar-tests/src/org/briarproject/plugins/tcp/LanTcpPluginTest.java @@ -6,8 +6,10 @@ import java.io.IOException; import java.net.Inet4Address; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.NetworkInterface; import java.net.ServerSocket; import java.net.Socket; +import java.util.Collections; import java.util.Hashtable; import java.util.Map; import java.util.concurrent.CountDownLatch; @@ -73,6 +75,10 @@ public class LanTcpPluginTest extends BriarTestCase { @Test public void testIncomingConnection() throws Exception { + if(!systemHasLocalIpv4Address()) { + System.err.println("WARNING: Skipping test, no local IPv4 address"); + return; + } Callback callback = new Callback(); Executor executor = Executors.newCachedThreadPool(); DuplexPlugin plugin = new LanTcpPlugin(executor, callback, 0, 0, 0); @@ -101,6 +107,10 @@ public class LanTcpPluginTest extends BriarTestCase { @Test public void testOutgoingConnection() throws Exception { + if(!systemHasLocalIpv4Address()) { + System.err.println("WARNING: Skipping test, no local IPv4 address"); + return; + } Callback callback = new Callback(); Executor executor = Executors.newCachedThreadPool(); DuplexPlugin plugin = new LanTcpPlugin(executor, callback, 0, 0, 0); @@ -143,6 +153,17 @@ public class LanTcpPluginTest extends BriarTestCase { plugin.stop(); } + private boolean systemHasLocalIpv4Address() throws Exception { + for(NetworkInterface i : Collections.list( + NetworkInterface.getNetworkInterfaces())) { + for(InetAddress a : Collections.list(i.getInetAddresses())) { + if(a instanceof Inet4Address) + return a.isLinkLocalAddress() || a.isSiteLocalAddress(); + } + } + return false; + } + private static class Callback implements DuplexPluginCallback { private final Map<ContactId, TransportProperties> remote =