Skip to content

Commit

Permalink
Use ephemeral ports for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
espenhw committed Mar 3, 2009
1 parent fcf31ad commit 2d270a1
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/test/groovy/org/grumblesmurf/malabar/GroovyServerTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ import org.codehaus.groovy.tools.shell.util.ANSI;

class GroovyServerTest
{
int compilerPort = 5555;
int evalPort = 6666;

def servers = [];

@Before
Expand All @@ -52,25 +49,25 @@ class GroovyServerTest
@Test(timeout=2000L)
void singleServer() {
def ready = new CountDownLatch(1);
servers << GroovyServer.startServer(compilerPort, ready);
def server = GroovyServer.startServer(0, ready);
servers << server;
ready.await();
withSocket { s ->
s.connect(localPort(compilerPort), 1000);
s.connect(localPort(server.socket.localPort), 1000);
}
}

@Test(timeout=2000L)
void dualServer() {
def serversReady = new CountDownLatch(2);
servers << GroovyServer.startServer(compilerPort, serversReady);
servers << GroovyServer.startServer(evalPort, serversReady);
servers << GroovyServer.startServer(0, serversReady);
servers << GroovyServer.startServer(0, serversReady);
serversReady.await();

withSocket { s ->
s.connect(localPort(compilerPort), 1000);
}
withSocket { s ->
s.connect(localPort(evalPort), 1000);

servers.each { server ->
withSocket { s ->
s.connect(localPort(server.socket.localPort), 1000);
}
}
}

Expand Down

0 comments on commit 2d270a1

Please sign in to comment.