Methods Summary |
---|
public ManagementRuleConfig | createAndTestRule(int id)
final ManagementRulesConfig rules = getManagementRulesConfig();
final String name = createName( id );
if ( rules.getManagementRuleConfigMap().get( name ) != null )
{
removeRule( name );
warning( "Removed left over ManagementRuleConfig: " + StringUtil.quote( name ) );
}
String actionMBeanName = ((id%2) ==0) ? ACTION_MBEAN_NAME : null;
ManagementRuleConfig ruleConfig =
createRule( rules, name, EventTypeValues.TRACE, actionMBeanName, getDummyProperties(), getOptional() );
testRuleConfig( ruleConfig );
ActionConfig actionConfig = ruleConfig.getActionConfig();
if ( actionConfig == null )
{
actionConfig = ruleConfig.createActionConfig( ACTION_MBEAN_NAME );
testRuleConfig( ruleConfig );
}
try
{
ruleConfig.createActionConfig( ACTION_MBEAN_NAME );
}
catch( Exception e )
{
// good, we expect to be here
}
try
{
ruleConfig.createActionConfig( null );
}
catch( Exception e )
{
// good, we expect to be here
}
return ruleConfig;
|
private java.lang.String | createName(int i)
return "rule" + i;
|
private static ManagementRuleConfig | createRule(ManagementRulesConfig rules, java.lang.String name, java.lang.String eventType, java.lang.String actionMBeanName, java.util.Properties props, java.util.Map optional)
final ManagementRuleConfig rule =
rules.createManagementRuleConfig(
name, eventType, actionMBeanName, props, optional );
return rule;
|
public static ManagementRuleConfig | ensureDefaultInstance(ConfigConfig config)
final ManagementRulesConfig rules = getManagementRulesConfig(config);
ManagementRuleConfig result =
rules.getManagementRuleConfigMap().get( getDefaultInstanceName() );
if ( result == null )
{
result = createRule( rules, getDefaultInstanceName(), EventTypeValues.TRACE, ACTION_MBEAN_NAME, null, null );
}
return result;
|
public static java.lang.String | getDefaultInstanceName()
return getDefaultInstanceName( "ManagementRulesConfigTest" );
|
private java.util.Properties | getDummyProperties()
final Properties props = new Properties();
props.put( "Dummy1", "Dummy1-value" );
props.put( "Dummy2", "Dummy2-value" );
return props;
|
private static ManagementRulesConfig | getManagementRulesConfig(ConfigConfig config)
return config.getManagementRulesConfig();
|
private ManagementRulesConfig | getManagementRulesConfig()
return getManagementRulesConfig( getConfigConfig() );
|
private java.util.Map | getOptional()
final Map<String,String> optional = new HashMap<String,String>();
optional.put( EVENT_LOG_ENABLED_KEY, "true" );
optional.put( EVENT_LEVEL_KEY, "INFO" );
return optional;
|
private void | removeRule(java.lang.String name)
getManagementRulesConfig().removeManagementRuleConfig( name );
|
public void | testCreateRule()
final ManagementRulesConfig rulesConfig = getManagementRulesConfig();
if ( rulesConfig == null )
{
warning( "testCreateRule: ManagementRulesConfig is null...skipping test" );
return;
}
final int NUM = 6;
final ManagementRuleConfig[] ruleConfigs = new ManagementRuleConfig[ NUM ];
try
{
for( int i = 0; i < NUM; ++i )
{
ruleConfigs[ i ] = createAndTestRule( i );
}
}
finally
{
for( int i = 0; i < NUM; ++i )
{
if ( ruleConfigs[ i ] != null )
{
removeRule( ruleConfigs[ i ].getName() );
}
}
}
|
private void | testEventConfig(EventConfig eventConfig)
assert( eventConfig != null );
final String eventType = eventConfig.getType();
eventConfig.setType( eventType );
eventConfig.setDescription( "test description" );
|
public void | testGet()
final ManagementRulesConfig rulesConfig = getManagementRulesConfig();
if ( rulesConfig != null )
{
final Map<String,ManagementRuleConfig> ruleConfigs =
rulesConfig.getManagementRuleConfigMap();
assert( ruleConfigs != null );
}
else
{
warning( "testGet: ManagementRulesConfig is null...skipping test" );
}
|
private void | testRuleConfig(ManagementRuleConfig ruleConfig)
final EventConfig eventConfig = ruleConfig.getEventConfig();
assert( eventConfig != null );
testEventConfig( eventConfig );
final ActionConfig actionConfig = ruleConfig.getActionConfig();
if ( actionConfig != null )
{
final String mbeanName = actionConfig.getActionMBeanName();
actionConfig.setActionMBeanName( mbeanName );
}
|