Methods Summary |
---|
public void | attemptInvalidName(java.lang.String name)
try
{
create().createAlias( name, "bad name" );
fail( "expected alias to fail: \"" + name + "\"");
}
catch( Exception e )
{
// good, we expected to get here
}
|
AliasMgrMBean | create()
return( new AliasMgr( new AliasMgrHashMapImpl() ) );
|
public void | testEmptyName()
attemptInvalidName( "" );
|
public void | testIllegalChars()
for( int i = 0; i < ILLEGAL_CHARS.length(); ++i )
{
final char theChar = ILLEGAL_CHARS.charAt( i );
attemptInvalidName( "" + theChar );
attemptInvalidName( "x" + theChar + "y" );
}
|
public void | testLegalChars()
final AliasMgrMBean aliasMgr = create();
aliasMgr.createAlias( LEGAL_CHARS, "test" );
for( int i = 0; i < LEGAL_CHARS.length(); ++i )
{
final char theChar = LEGAL_CHARS.charAt( i );
aliasMgr.createAlias( "" + theChar, "test" );
}
|
public void | testLifecycle()
final AliasMgrMBean aliasMgr = create();
aliasMgr.createAlias( TEST, TEST_VALUE );
assertEquals( TEST_VALUE, aliasMgr.resolveAlias( TEST ) );
aliasMgr.deleteAlias( TEST );
assertEquals( null, aliasMgr.resolveAlias( TEST ) );
|
public void | testList()
final AliasMgrMBean aliasMgr = create();
assertEquals( 0, aliasMgr.listAliases( true ).length );
assertEquals( 0, aliasMgr.getAliases( ).length );
aliasMgr.createAlias( TEST, TEST_VALUE );
assertEquals( 1, aliasMgr.listAliases( true ).length );
assertEquals( 1, aliasMgr.listAliases( false ).length );
assertEquals( 1, aliasMgr.getAliases( ).length );
String [] listedAliases = aliasMgr.listAliases( false );
assertEquals( TEST, listedAliases[ 0 ] );
listedAliases = aliasMgr.listAliases( true );
assertEquals( TEST + "=" + TEST_VALUE , listedAliases[ 0 ] );
|