Skip to content

Commit

Permalink
Fix up ConnectionTableTest: (i) remove unwanted calls to ConnectionTa…
Browse files Browse the repository at this point in the history
…ble.start() (ii) leave in required calls to ConnectionTableNIO.start() and (iii) add in small delay between each test for socket close to complete
  • Loading branch information
rachmatowicz committed Nov 3, 2009
1 parent 50a8534 commit 165a33b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/junit/org/jgroups/blocks/ConnectionTableTest.java
Expand Up @@ -17,7 +17,7 @@
/**
* Tests ConnectionTable
* @author Bela Ban
* @version $Id: ConnectionTableTest.java,v 1.2.2.6 2009/11/03 16:51:24 rachmatowicz Exp $
* @version $Id: ConnectionTableTest.java,v 1.2.2.7 2009/11/03 21:23:21 rachmatowicz Exp $
*/
public class ConnectionTableTest extends TestCase {
private BasicConnectionTable ct1, ct2;
Expand Down Expand Up @@ -46,6 +46,7 @@ public ConnectionTableTest(String testName) {


protected void setUp() throws Exception {
System.out.println("Starting: " + getName());
super.setUp();
active_threads=Thread.activeCount();
System.out.println("active threads before (" + active_threads + "):\n" + Util.activeThreads());
Expand All @@ -63,7 +64,10 @@ protected void tearDown() throws Exception {
ct1.stop();
ct1=null;
}
// small delay seems to be required to allow ports to be reclaimed
Util.sleep(100) ;
super.tearDown();
System.out.println("Ending: " + getName());
}

/**
Expand All @@ -74,10 +78,9 @@ public void testConcurrentConnect() throws Exception {
Sender sender1, sender2;
CyclicBarrier barrier=new CyclicBarrier(3);

// connection table calls start() within its constructor
ct1=new ConnectionTable(bind_addr, PORT1);
ct1.start();
ct2=new ConnectionTable(bind_addr, PORT2);
ct2.start();
BasicConnectionTable.Receiver dummy=new BasicConnectionTable.Receiver() {
public void receive(Address sender, byte[] data, int offset, int length) {}
};
Expand Down Expand Up @@ -150,18 +153,16 @@ public void run() {


public void testStopConnectionTable() throws Exception {
// ConnectionTable calls start() within its constructor
ct1=new ConnectionTable(new DummyReceiver(), bind_addr, null, PORT1, PORT1, 60000, 120000);
ct2=new ConnectionTable(new DummyReceiver(), bind_addr, null, PORT2, PORT2, 60000, 120000);
// don't forget to start the connection tables and their acceptor thread
// ct1.start();
// ct2.start();
_testStop(ct1, ct2);
}

public void testStopConnectionTableNIO() throws Exception {
// ConnectionTableNIO will not call start() in its constructor, as we passed doStart == false
ct1=new ConnectionTableNIO(new DummyReceiver(), bind_addr, null, PORT1, PORT1, 60000, 120000, false);
ct2=new ConnectionTableNIO(new DummyReceiver(), bind_addr, null, PORT2, PORT2, 60000, 120000, false);
// don't forget to start the connection tables and their acceptor thread
ct1.start();
ct2.start();
_testStop(ct1, ct2);
Expand Down

0 comments on commit 165a33b

Please sign in to comment.