1 package org.jgroups.tests; 2 3 4 import org.jgroups.Channel; 5 import org.jgroups.JChannel; 6 import junit.framework.Test; 7 import junit.framework.TestSuite; 8 import junit.framework.TestCase; 9 10 11 15 public class GossipClientTest extends TestCase { 16 17 18 public void testConnectDisconnectSequence() { 19 String props="TCP(start_port=7800;bind_addr=localhost;loopback=true):" + 21 "TCPGOSSIP(timeout=3000;initial_hosts=localhost[7500]num_initial_members=1):" + 22 "FD(timeout=2000;max_tries=4):" + 23 "VERIFY_SUSPECT(timeout=1500;down_thread=false;up_thread=false):" + 24 "pbcast.NAKACK(gc_lag=100;retransmit_timeout=600,1200,2400,4800):" + 25 "pbcast.GMS(print_local_addr=true;join_timeout=5000;join_retry_timeout=2000;" + 26 "shun=true)"; 27 try { 28 JChannel jChannel=new JChannel(props); 29 jChannel.setOpt(Channel.LOCAL, Boolean.FALSE); 30 jChannel.setOpt(Channel.VIEW, Boolean.TRUE); 31 jChannel.connect("testGroup"); 32 assertTrue(jChannel.isConnected()); 33 assertTrue(jChannel.isOpen()); 34 System.out.println(jChannel.printProtocolSpec(true)); 35 36 jChannel.close(); 37 assertFalse(jChannel.isConnected()); 38 assertFalse(jChannel.isOpen()); 39 } 40 catch(Exception e) { 41 System.out.println("Error channel " + e); 42 fail(e.toString()); 43 } 44 System.out.println("done"); 45 } 46 47 48 public static Test suite() { 49 TestSuite s=new TestSuite(GossipClientTest.class); 50 return s; 51 } 52 53 public static void main(String [] args) { 54 String [] testCaseName={GossipClientTest.class.getName()}; 55 junit.textui.TestRunner.main(testCaseName); 56 } 57 58 } 59 60 | Popular Tags |