FileDocCategorySizeDatePackage
ObjectNameComparatorTest.javaAPI DocGlassfish v2 API4644Fri May 04 22:24:06 BST 2007com.sun.enterprise.management.util.jmx

ObjectNameComparatorTest

public class ObjectNameComparatorTest extends TestCase

Fields Summary
private final com.sun.appserv.management.util.jmx.ObjectNameComparator
mComparator
Constructors Summary
public ObjectNameComparatorTest()

        super( "ObjectNameComparatorTest" );
        
        mComparator = ObjectNameComparator.INSTANCE;
    
Methods Summary
private javax.management.ObjectNamenewObjectName(java.lang.String s)

        return JMXUtil.newObjectName( s );
    
public voidtestEquals()

        final ObjectName  name1   = newObjectName( "amx:j2eeType=FOO,name=FOO-NAME" );
        final ObjectName  name2   = newObjectName( "amx:name=FOO-NAME,j2eeType=FOO" );
        
        assert mComparator.compare( name1, name2 ) == 0;
        assert mComparator.compare( name2, name1 ) == 0;
    
public voidtestUnequal()

        final ObjectName  name1   = newObjectName( "amx:j2eeType=FOO,name=FOO-NAME" );
        final ObjectName  name2   = newObjectName( "amx:name=FOO-NAME,j2eeType=FOO" );
        
        final ObjectName  name3   = newObjectName( "amx:j2eeType=FOO,name=FOO-BAR" );
        final ObjectName  name4   = newObjectName( "amx:name=FOO-BAR,j2eeType=FOO" );
        
        final ObjectName  nameA     = newObjectName( "amx:name=A" );
        final ObjectName  nameB     = newObjectName( "amx:name=B" );
        
        final ObjectName  bbb     = newObjectName( "bbb:name=foo" );
        
        assert mComparator.compare( name1, name2 ) == 0;
        assert mComparator.compare( name2, name1 ) == 0;
        assert mComparator.compare( name3, name4 ) == 0;
        assert mComparator.compare( name4, name3 ) == 0;
        
        assert mComparator.compare( name1, name3 ) > 0;
        assert mComparator.compare( name2, name3 ) > 0;
        assert mComparator.compare( name3, name1 ) < 0;
        assert mComparator.compare( name3, name2 ) < 0;
        
        assert mComparator.compare( name1, name4 ) > 0;
        assert mComparator.compare( name2, name4 ) > 0;
        assert mComparator.compare( name4, name2 ) < 0;
        assert mComparator.compare( name4, name1 ) < 0;
        
        assert mComparator.compare( name1, nameA ) < 0;
        assert mComparator.compare( nameA, name1 ) > 0;
        
        assert mComparator.compare( nameA, nameB ) < 0;
        assert mComparator.compare( nameB, nameA ) > 0;
        
        assert mComparator.compare( name1, bbb ) < 0;
        assert mComparator.compare( bbb, name1 ) > 0;