public void
testAddRemove()
{
final OfflineDottedNamesRegistry reg = create();
final int ITER = 1000;
final Set<String> attrs = dummySet();
final ObjectName[] objectNames = new ObjectName[ ITER ];
final String[] prefixes = new String[ ITER ];
for( int i = 0; i < ITER; ++i )
{
final String prefix = "foo" + i;
final ObjectName objectName = createObjectName( "test" + i, "" + i );
objectNames[ i ] = objectName;
prefixes[ i ] = prefix;
reg.addMapping( objectName, prefix, attrs );
assert( reg.getPrefix( objectName ) == prefix );
assert( reg.getObjectName( prefix ) == objectName );
assert( reg.getLegalAttributes( objectName ).equals( attrs ) );
}
for( int i = 0; i < ITER; ++i )
{
final ObjectName objectName = objectNames[ i ];
final String prefix = prefixes[ i ];
assert( reg.getPrefix( objectName ) == prefix );
assert( reg.getObjectName( prefix ) == objectName );
assert( reg.getLegalAttributes( objectName ).equals( attrs ) );
reg.removeMapping( objectName );
assert( reg.getPrefix( objectName) == null );
assert( reg.getObjectName( prefixes[ i ] ) == null );
assert( reg.getLegalAttributes( objectName ) == null );
}
}