Package org.jboss.remoting.detection.multicast

Examples of org.jboss.remoting.detection.multicast.MulticastDetector


      super.tearDown();
   }

   public void testStopWithoutStart() throws Exception
   {
      MulticastDetector detector = new MulticastDetector();
      server.registerMBean(detector, objectName);
// don't call detector.start();
      Thread.sleep(1000);

      server.unregisterMBean(objectName);
      detector.stop();
   }
View Full Code Here


      detector.stop();
   }

   public void testCallingStopTwice() throws Exception
   {
      MulticastDetector detector = new MulticastDetector();
      server.registerMBean(detector, objectName);
      detector.start();
      Thread.sleep(1000);

      server.unregisterMBean(objectName);
      detector.stop();
      detector.stop();
   }
View Full Code Here

      super(name);
   }

   public void testNotifications() throws Exception
   {
      MulticastDetector detector1 = new MulticastDetector();
      MulticastDetector detector2 = new MulticastDetector();

      Connector connector1 = new Connector();
      Connector connector2 = new Connector();

      NetworkRegistry reg1 = setupServers(detector1, connector1);
      TestNotificationListener notif1 = new TestNotificationListener();
      reg1.addNotificationListener(notif1, null, null);

      NetworkRegistry reg2 = setupServers(detector2, connector2);
      TestNotificationListener notif2 = new TestNotificationListener();
      reg2.addNotificationListener(notif2, null, null);

      // Need to allow heartbeat so have detection
      Thread.currentThread().sleep(5000);

      //Should now have an entry for both of the registries
      int reg1Count = reg1.getServers().length;
      int reg2Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 1 && reg2Count == 1);

      if(reg1Count == 1 && reg2Count == 1)
      {
         System.out.println("PASSED - both registries have found the detectors.");
      }
      else
      {
         System.out.println("FAILED - registries not populated with remote detectors.");
      }

      assertTrue(((String)notif1.notifLog.get(0)).startsWith("ADDED"));
      assertTrue(((String)notif1.notifLog.get(1)).startsWith("ADDED"));
      System.out.println("Notifications from Registry #1--->" + notif1.notifLog);
      assertTrue(((String)notif2.notifLog.get(0)).startsWith("ADDED"));
      assertTrue(((String)notif2.notifLog.get(1)).startsWith("ADDED"));
      System.out.println("Notifications from Registry #2--->" + notif2.notifLog);

      // stop the 2nd detector, so see if 1st one detects it is missing
      connector1.stop();
      connector1.destroy();
      connector1 = null;
      connector2.stop();
      connector2.destroy();
      connector2 = null;
      detector1.stop();

      // sleep for a few seconds so the 1st detector can discover 2nd one down
      Thread.sleep(60000);

      // 1st one should be empty
      reg1Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 0);

      if(reg1Count == 0)
      {
         System.out.println("PASSED - 2nd detector stopped and no longer in registry.");
      }
      else
      {
         System.out.println("FAILED - 2nd detector stopped but still in registry.");
      }

      assertTrue(((String)notif2.notifLog.get(0)).startsWith("ADDED"));
      assertTrue(((String)notif2.notifLog.get(1)).startsWith("ADDED"));
      assertTrue(((String)notif2.notifLog.get(2)).startsWith("REMOVED"));
      assertTrue(((String)notif2.notifLog.get(3)).startsWith("REMOVED"));
      System.out.println("Notifications from Registry #2-->" + notif2.notifLog);

      // cleanup
      detector2.stop();
      //connector2.stop();
      //connector2.destroy();
   }
View Full Code Here

      //connector2.destroy();
   }

   public void testDetectors() throws Exception
   {
      MulticastDetector detector1 = new MulticastDetector();
      MulticastDetector detector2 = new MulticastDetector();

      Connector connector1 = new Connector();
      Connector connector2 = new Connector();

      NetworkRegistry reg1 = setupServers(detector1, connector1);
      NetworkRegistry reg2 = setupServers(detector2, connector2);

      // Need to allow heartbeat so have detection
      Thread.currentThread().sleep(2000);

      //Should now have an entry for both of the registries
      int reg1Count = reg1.getServers().length;
      int reg2Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 1 && reg2Count == 1);

      if(reg1Count == 1 && reg2Count == 1)
      {
         System.out.println("PASSED - both registries have found the detectors.");
      }
      else
      {
         System.out.println("FAILED - registries not populated with remote detectors.");
      }

      // stop the 2nd detector, so see if 1st one detects it is missing
      connector1.stop();
      connector1.destroy();
      connector1 = null;
      connector2.stop();
      connector2.destroy();
      connector2 = null;
      detector1.stop();

      // sleep for a few seconds so the 1st detector can discover 2nd one down
      Thread.currentThread().sleep(60000);

      // 1st one should be empty
      reg1Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 0);

      if(reg1Count == 0)
      {
         System.out.println("PASSED - 2nd detector stopped and no longer in registry.");
      }
      else
      {
         System.out.println("FAILED - 2nd detector stopped but still in registry.");
      }

      // cleanup
      detector2.stop();
      //connector2.stop();
      //connector2.destroy();
   }
View Full Code Here

   private Connector connector;
   private NetworkRegistry registry;

   public void setUp() throws Exception
   {
      detector = new MulticastDetector();

      System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
      System.out.println("jboss.identity = " + System.getProperty("jboss.identity"));

      MBeanServer server = MBeanServerFactory.createMBeanServer();
View Full Code Here

   private MulticastDetector detector;
   private NetworkRegistry registry;

   public void setUp() throws Exception
   {
      detector = new MulticastDetector();

      System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
      System.out.println("jboss.identity = " + System.getProperty("jboss.identity"));

      MBeanServer server = MBeanServerFactory.createMBeanServer();
View Full Code Here

         Detector detector = null;
         ObjectName objName = null;

         if(type.equals(TYPE_MULTICAST))
         {
            MulticastDetector mdet = new MulticastDetector();
            mdet.setPort(port);
            detector = mdet;
            objName = new ObjectName("remoting:type=Detector,transport=multicast");
         }
         else if(type.equals(TYPE_JNDI))
         {
View Full Code Here

TOP

Related Classes of org.jboss.remoting.detection.multicast.MulticastDetector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.