Package com.sun.appserv.management.base

Examples of com.sun.appserv.management.base.NotificationService


    public void
  testCreate()
    throws Exception
  {
    final NotificationService  proxy  = create();
   
    removeNotificationService( proxy );
  }
View Full Code Here


    public void
  testGetFromEmpty()
    throws Exception
  {
    final NotificationService  proxy  = create();
   
    assert( proxy.getListeneeSet().size() == 0 );
    final Object  id  = proxy.createBuffer( 10, null);
    final Map<String,Object>  result  = proxy.getBufferNotifications( id, 0 );
    final Notification[]  notifs  = (Notification[])result.get( proxy.NOTIFICATIONS_KEY );
    assertEquals( 0, notifs.length );
  }
View Full Code Here

 
    public void
  testListen()
    throws Exception
  {
    final NotificationService  proxy  = create();
 
    final QueryMgr  queryMgr  = getQueryMgr();
    final ObjectName  objectName  = Util.getObjectName( queryMgr );
   
    final Object  id  = proxy.createBuffer( 10, null);
    final NotificationServiceHelper  helper  = new NotificationServiceHelper( proxy, id);
    proxy.listenTo( objectName, null );
    assert( proxy.getListeneeSet().size() == 1 );
    assert( Util.getObjectName( (Util.asAMX(proxy.getListeneeSet().iterator().next())) ).equals( objectName ) );
   
    final MyListener  myListener  = new MyListener();
    proxy.addNotificationListener( myListener, null, null );
    
    final Level  saveLevel = queryMgr.getMBeanLogLevel();
    queryMgr.setMBeanLogLevel( Level.INFO );
    queryMgr.setMBeanLogLevel( saveLevel );
   
    // delivery may be asynchronous; wait until done
    while ( myListener.getCount() < 2 )
    {
      sleep( 20 );
    }
    assert( myListener.getCount() == 2 );
   
    Notification[]  notifs  = helper.getNotifications();
   
    assertEquals( 2, notifs.length );
    assert( notifs[ 0 ].getType().equals( AttributeChangeNotification.ATTRIBUTE_CHANGE ) );
    assert( notifs[ 1 ].getType().equals( AttributeChangeNotification.ATTRIBUTE_CHANGE ) );
    notifs  = helper.getNotifications();
    assert( notifs.length == 0 );
   
   
    proxy.dontListenTo( objectName );
    assert( proxy.getListeneeSet().size() == 0 );
   
    removeNotificationService( proxy );
  }
View Full Code Here

  {
    // use the NotificationServiceMgr as a convenient way of making
    // an MBean (a NotificationService) come and go.
    final NotificationServiceMgr  mgr  = getDomainRoot().getNotificationServiceMgr();
   
    final NotificationService  ns  = mgr.createNotificationService( "UserData", 10 );
    assert( ns.getUserData().equals( "UserData" ) );
    final ObjectName  nsObjectName  = Util.getObjectName( ns );
   
    mgr.removeNotificationService( ns.getName() );
    try
    {
      // all calls should fail
      Util.getObjectName( ns );
      ns.getName();
      ns.getUserData();
      failure( "expecting exception due to missing MBean" );
    }
    catch( Exception e )
    {
      // root cause should be an InstanceNotFoundException containing the ObjectName
View Full Code Here

    throws InstanceNotFoundException
  {
    // use the NotificationServiceMgr as a convenient way of making
    // an MBean (a NotificationService) come and go.
    final NotificationServiceMgr  mgr  = getDomainRoot().getNotificationServiceMgr();
    final NotificationService  ns  = mgr.createNotificationService( "UserData", 10 );
    final ObjectName  nsObjectName  = Util.getObjectName( ns );
    assert( ns.getUserData().equals( "UserData" ) );
   
    final ProxyFactory  factory  = getProxyFactory();
    final NotificationService  proxy  =
      factory.getProxy( nsObjectName, NotificationService.class, false );
    assert( proxy == ns ) : "proxies differ: " + ns + "\n" + proxy;
   
    mgr.removeNotificationService( ns.getName() );
View Full Code Here

  testCreateRemove()
    throws Exception
  {
    final NotificationServiceMgr  proxy  = getNotificationServiceMgr();
   
    final NotificationService  service  = proxy.createNotificationService( "test1", 512 );
   
    final ObjectName  objectName  = Util.getObjectName( service );
   
    proxy.removeNotificationService( service.getName() );
    assert( ! getConnection().isRegistered( objectName ) );
  }
View Full Code Here

TOP

Related Classes of com.sun.appserv.management.base.NotificationService

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.