NotificationListenerBaseTestpublic class NotificationListenerBaseTest extends JMXTestBase
Fields Summary |
---|
private MBeanServer | mServer | private static final String | TEST | private static final String | DUMMY_OBJECT_NAME_PREFIX | private static final String | REG_DOMAIN | private static final int | REG_COUNT |
Constructors Summary |
---|
public NotificationListenerBaseTest()
mServer = null;
|
Methods Summary |
---|
private com.sun.enterprise.management.util.jmx.NotificationListenerBaseTest$MyListener | create(java.lang.String pattern)
final MyListener listener =
new MyListener( mServer, JMXUtil.newObjectName( pattern ), null );
listener.startListening();
return listener;
| private javax.management.ObjectName | createObjectName(java.lang.String domain, int id, java.lang.String name)
String s = domain + ":" +
"name=" + name +
",id=" + id +
(",category=" + ((id % 2) == 0 ? "even":"odd"));
return JMXUtil.newObjectName( s );
| java.util.Set | registerDummies(int count, java.lang.String name)
return registerDummies( TEST, count, name );
| java.util.Set | registerDummies(java.lang.String domain, int count, java.lang.String name)
final Set<ObjectName> s = new HashSet<ObjectName>();
for( int i = 0; i < count; ++i )
{
final Dummy d = new Dummy();
d.setDummy( i );
final ObjectName on = createObjectName( domain, i, name );
final ObjectName objectName = registerMBean( d, on );
s.add( objectName );
}
return s;
| protected javax.management.ObjectName | registerMBean(java.lang.Object mbean, javax.management.ObjectName objectName)
return mServer.registerMBean( mbean, objectName ).getObjectName();
| public void | setUp()
mServer = MBeanServerFactory.newMBeanServer( "test" );
| public void | tearDown()
mServer = null;
| public void | testCreate()
final MyListener b = create( "*:*" );
assert( b.getListenees().size() != 0 );
b.getMBeanServerConnection();
b.cleanup();
assert( b.getListenees().size() == 0 );
| public void | testGetListenees()
final int NUM = 10;
final String NAME = "bbb";
registerDummies( NUM, NAME );
final MyListener odd = create( TEST + ":category=odd,*" );
assert( odd.getListenees().size() == NUM / 2 );
for( final ObjectName item : odd.getListenees() )
{
assert( item.getKeyProperty( "category" ).equals( "odd" ) );
}
assert( odd.isAlive() );
final MyListener even = create( TEST + ":category=even,*" );
assert( even.getListenees().size() == NUM / 2 );
for( final ObjectName item : even.getListenees() )
{
assert( item.getKeyProperty( "category" ).equals( "even" ) );
}
assert( even.isAlive() );
final MyListener all = create( TEST + ":name=bbb,*" );
assert( all.getListenees().size() == NUM );
for( final ObjectName item : all.getListenees() )
{
assert( item.getKeyProperty( "name" ).equals( NAME ) );
}
assert( all.isAlive() );
| private void | testListenForRegistration(java.lang.String domain, java.lang.String name, int count, java.lang.String constrainStr)
final ObjectName constrain = (constrainStr == null) ? null :
JMXUtil.newObjectName( constrainStr );
final MyRegListener listener = new MyRegListener( constrain );
listener.startListening();
assert( listener.getListenees().size() == 1 );
final Set<ObjectName> s = registerDummies( domain, count, name );
assert( listener.mRegCount == count );
for( final ObjectName objectName : s )
{
mServer.unregisterMBean( objectName );
}
assert( listener.mUnregCount == count );
listener.cleanup();
assert( listener.getListenees().size() == 0 );
| public void | testListenForRegistration1()
final String NAME = "zzz";
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, null );
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, "*:*");
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, REG_DOMAIN +":*");
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, "*:" + "name=" + NAME);
| public void | testListenForRegistration2()
final String NAME = "zzzz";
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, null );
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, "*:*");
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, REG_DOMAIN +":*");
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, "*:" + "name=" + NAME);
| public void | testListenForRegistration3()
final String NAME = "zzzzz";
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, null );
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, "*:*");
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, REG_DOMAIN +":*");
testListenForRegistration( REG_DOMAIN, NAME, REG_COUNT, "*:" + "name=" + NAME);
|
|