Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make publisher tests use only ephemeral ports

This way the tests can't interfere with each other or a running system.
  • Loading branch information...
commit d4fe000ef819cd965f9d5beb7491395c547807c0 1 parent f2889c2
@semmerson semmerson authored
View
10 src/main/java/edu/ucar/unidata/sruth/Publisher.java
@@ -81,9 +81,8 @@
/**
* Constructs from the pathname of the root of the file-tree. The tracker
- * will listen on its IANA-assigned port, the source-node server will listen
- * on an ephemeral port, and an ephemeral port will also be used for reports
- * of unavailable servers.
+ * will listen on its IANA-assigned port. Ephemeral ports will be used for
+ * the data-exchange server and for reporting unavailable servers.
*
* @param rootDir
* Pathname of the root of the file-tree.
@@ -99,9 +98,8 @@ public Publisher(final Path rootDir) throws IOException {
}
/**
- * Constructs from the pathname of the root of the file-tree and the port on
- * which the tracker will listen. The source-node server will listen on an
- * ephemeral port.
+ * Constructs from the pathname of the root of the file-tree and the port
+ * numbers to be used.
*
* @param rootDir
* Pathname of the root of the file-tree
View
10 src/test/java/edu/ucar/unidata/sruth/NodeTest.java
@@ -11,6 +11,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.file.Path;
@@ -198,7 +199,8 @@ public void testNodes() throws IOException, InterruptedException,
/*
* Create and start the tracker.
*/
- final Tracker tracker = new Tracker(serverSocketAddress);
+ final Tracker tracker = new Tracker(serverSocketAddress,
+ new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
final InetSocketAddress trackerAddress = tracker.getServerAddress();
final Future<Void> trackerFuture = start(tracker);
@@ -257,7 +259,8 @@ public void testNodeDelivery() throws IOException, InterruptedException,
/*
* Create and start the tracker.
*/
- final Tracker tracker = new Tracker(serverSocketAddress);
+ final Tracker tracker = new Tracker(serverSocketAddress,
+ new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
final InetSocketAddress trackerAddress = tracker.getServerAddress();
final Future<Void> trackerFuture = start(tracker);
/*
@@ -346,7 +349,8 @@ public void testRemoval() throws IOException, InterruptedException,
/*
* Create and start the tracker.
*/
- final Tracker tracker = new Tracker(serverSocketAddress);
+ final Tracker tracker = new Tracker(serverSocketAddress,
+ new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
final InetSocketAddress trackerAddress = tracker.getServerAddress();
final Future<Void> trackerFuture = start(tracker);
/*
View
10 src/test/java/edu/ucar/unidata/sruth/PubSubTest.java
@@ -252,7 +252,7 @@ public void testRapidNewDirectoryPublishing() throws IOException,
/*
* Create and start the publisher.
*/
- final Publisher publisher = new Publisher(PUB_ROOT);
+ final Publisher publisher = new Publisher(PUB_ROOT, 0, 0, 0);
final Future<Void> pubFuture = start(publisher);
publisher.waitUntilRunning();
@@ -316,7 +316,7 @@ public void testPubSub() throws IOException, InterruptedException,
/*
* Create and start the publisher.
*/
- final Publisher publisher = new Publisher(PUB_ROOT);
+ final Publisher publisher = new Publisher(PUB_ROOT, 0, 0, 0);
final Future<Void> pubFuture = start(publisher);
publisher.waitUntilRunning();
@@ -384,7 +384,7 @@ public void testPublisherRestart() throws IOException,
/*
* Create and start the publisher.
*/
- Publisher publisher = new Publisher(PUB_ROOT);
+ Publisher publisher = new Publisher(PUB_ROOT, 0, 0, 0);
Future<Void> pubFuture = start(publisher);
publisher.waitUntilRunning();
@@ -426,7 +426,7 @@ public void testPublisherRestart() throws IOException,
stop(pubFuture);
publisher.awaitCompletion();
Thread.sleep(sleepAmount);
- publisher = new Publisher(PUB_ROOT);
+ publisher = new Publisher(PUB_ROOT, trackerAddress.getPort(), 0, 0);
pubFuture = start(publisher);
publisher.waitUntilRunning();
@@ -467,7 +467,7 @@ public void testDynamicNetworking() throws IOException,
/*
* Create and start the publisher.
*/
- final Publisher publisher = new Publisher(PUB_ROOT);
+ final Publisher publisher = new Publisher(PUB_ROOT, 0, 0, 0);
final Future<Void> pubFuture = start(publisher);
assertNotNull(pubFuture);
publisher.waitUntilRunning();
Please sign in to comment.
Something went wrong with that request. Please try again.