Package javax.management

Examples of javax.management.NotificationFilterSupport


  /**
   * Enable a prefix that matched multiple types.
   */
  public void testPrefix()
  {
    NotificationFilterSupport nfs = new NotificationFilterSupport();
    nfs.enableType("type1");
    assertEquals(true, nfs.isNotificationEnabled(n1));
    assertEquals(true, nfs.isNotificationEnabled(n2));
    assertEquals(true, nfs.isNotificationEnabled(n3));
    assertEquals(false, nfs.isNotificationEnabled(n4));
    assertEquals(false, nfs.isNotificationEnabled(n5));
  }
View Full Code Here


   * Test the get enabled types.
   */
  public void testGetEnabledTypes()
  {
    Vector v;
    NotificationFilterSupport nfs = new NotificationFilterSupport();

    // By default should contain nothing
    assertEquals(0, nfs.getEnabledTypes().size());

    // Add two
    nfs.enableType("type1");
    nfs.enableType("type2");
    v = nfs.getEnabledTypes();
    assertEquals(2, v.size());
    assertEquals(true, v.contains("type1"));
    assertEquals(true, v.contains("type2"));

    // Remove one
    nfs.disableType("type1");
    v = nfs.getEnabledTypes();
    assertEquals(1, v.size());
    assertEquals(false, v.contains("type1"));
    assertEquals(true, v.contains("type2"));

    // Remove all
    nfs.enableType("type2");
    nfs.disableAllTypes();
    v = nfs.getEnabledTypes();
    assertEquals(0, v.size());

    // Test duplication
    nfs.enableType("type1");
    nfs.enableType("type1");
    v = nfs.getEnabledTypes();
    assertEquals(1, v.size());

    // Test duplication removal
    nfs.disableType("type1");
    v = nfs.getEnabledTypes();
    assertEquals(0, v.size());
  }
View Full Code Here

  /**
   * Test serialization.
   */
  public void testSerialization()
  {
    NotificationFilterSupport nfs = new NotificationFilterSupport();
    NotificationFilterSupport nfs2 = null;

    // Add two
    nfs.enableType("type1");
    nfs.enableType("type2");

    try
    {
      // Serialize it
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(nfs);
   
      // Deserialize it
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      ObjectInputStream ois = new ObjectInputStream(bais);
      nfs2 = (NotificationFilterSupport) ois.readObject();
    }
    catch (IOException ioe)
    {
      fail(ioe.toString());
    }
    catch (ClassNotFoundException cnfe)
    {
      fail(cnfe.toString());
    }

    // Did it work?
    Vector v = nfs2.getEnabledTypes();
    assertEquals(2, v.size());
    assertEquals(true, v.contains("type1"));
    assertEquals(true, v.contains("type2"));
  }
View Full Code Here

   {
      NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();

      broadcaster.addNotificationListener(new Listener(), null, null);

      broadcaster.addNotificationListener(new Listener(), new NotificationFilterSupport(), null);

      broadcaster.addNotificationListener(new Listener(), null, new Object());

      broadcaster.addNotificationListener(new Listener(), new NotificationFilterSupport(), new Object());
   }
View Full Code Here

      assertTrue("Expected IllegalArgumentException for null listener", caught);

      caught = false;
      try
      {
         broadcaster.addNotificationListener(null, new NotificationFilterSupport(), null);
      }
      catch (IllegalArgumentException e)
      {
         caught = true;
      }
      assertTrue("Expected IllegalArgumentException for null listener", caught);

      caught = false;
      try
      {
         broadcaster.addNotificationListener(null, null, new Object());
      }
      catch (IllegalArgumentException e)
      {
         caught = true;
      }
      assertTrue("Expected IllegalArgumentException for null listener", caught);

      caught = false;
      try
      {
         broadcaster.addNotificationListener(null, new NotificationFilterSupport(), new Object());
      }
      catch (IllegalArgumentException e)
      {
         caught = true;
      }
View Full Code Here

      throws Exception
   {
      NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();

      Listener listener = new Listener();
      NotificationFilterSupport filter = new NotificationFilterSupport();
      filter.enableType(DEFAULT_TYPE);
      broadcaster.addNotificationListener(listener, filter, null);

      clear();
      createNotification(broadcaster);
View Full Code Here

      throws Exception
   {
      NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();

      Listener listener = new Listener();
      NotificationFilterSupport filter = new NotificationFilterSupport();
      filter.disableType(DEFAULT_TYPE);
      broadcaster.addNotificationListener(listener, filter, null);

      clear();
      createNotification(broadcaster);
View Full Code Here

      throws Exception
   {
      NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();

      Listener listener = new Listener();
      NotificationFilterSupport filter = new NotificationFilterSupport();
      filter.enableType(DEFAULT_TYPE);
      filter.enableType(ANOTHER_TYPE);
      broadcaster.addNotificationListener(listener, filter, null);

      clear();
      createNotification(broadcaster);
      createNotification(broadcaster, ANOTHER_TYPE);
View Full Code Here

      throws Exception
   {
      NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();

      Listener listener = new Listener();
      NotificationFilterSupport filter = new NotificationFilterSupport();
      filter.enableType(DEFAULT_TYPE);
      broadcaster.addNotificationListener(listener, filter, null);

      clear();
      createNotification(broadcaster);
      createNotification(broadcaster, ANOTHER_TYPE);
View Full Code Here

   {
      NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();

      Listener listener = new Listener();
      broadcaster.addNotificationListener(listener, null, null);
      NotificationFilterSupport filter = new NotificationFilterSupport();
      filter.disableType(DEFAULT_TYPE);
      broadcaster.addNotificationListener(listener, filter, null);

      clear();
      createNotification(broadcaster);
View Full Code Here

TOP

Related Classes of javax.management.NotificationFilterSupport

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.