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

ObjectNameQueryImplTest

public class ObjectNameQueryImplTest extends TestCase

Fields Summary
static final Set
EmptySet
static final String[]
EmptyStrings
Constructors Summary
public ObjectNameQueryImplTest()

        super( "ObjectNameQueryImplTest" );
    
public ObjectNameQueryImplTest(String name)

        super( name );
    
Methods Summary
static javax.management.ObjectNamecreateName(java.lang.String nameString)

		ObjectName	name	= null;
		
		try
		{
			name	= new ObjectName( nameString );
		}
		catch( Exception e )
		{
			assert( false );
		}
		return( name );
	
static java.util.SetcreateSet(javax.management.ObjectName name)

	
		 
	   
	
		final Set<ObjectName>	s	= new HashSet<ObjectName>();
		
		s.add( name );
		
		return( s );
	
static java.util.SetcreateSet(javax.management.ObjectName[] names)

		final Set<ObjectName>	s	= new HashSet<ObjectName>();
		
		for( int i = 0; i < names.length; ++i )
		{
			s.add( names[ i ] );
		}
		
		return( s );
	
public voidtestCreation()

		new ObjectNameQueryImpl();
	
public voidtestEmptySet()

		final ObjectNameQuery	q	= new ObjectNameQueryImpl();
		
		assertEquals( 0, q.matchAny( EmptySet, null, null ).size() );
		assertEquals( 0, q.matchAny( EmptySet, EmptyStrings, EmptyStrings ).size() );
		assertEquals( 0, q.matchAny( EmptySet, null, EmptyStrings ).size() );
		assertEquals( 0, q.matchAny( EmptySet, EmptyStrings, null ).size() );
		
		assertEquals( 0, q.matchAll( EmptySet, null, null ).size() );
		assertEquals( 0, q.matchAll( EmptySet, EmptyStrings, EmptyStrings ).size() );
		assertEquals( 0, q.matchAll( EmptySet, null, EmptyStrings ).size() );
		assertEquals( 0, q.matchAll( EmptySet, EmptyStrings, null ).size() );
	
public voidtestSingleItem()

		final ObjectName	name1	= createName( ":name=test,type=test" );
		final Set<ObjectName>			testSet	= createSet( name1 );
		
		final ObjectNameQuery	q	= new ObjectNameQueryImpl();
		
		assertEquals( 1, q.matchAny( testSet,
			null,
			null ).size() );
		
		assertEquals( 1, q.matchAny( testSet, 
			new String [] { "type" },
			new String [] { "test" } ).size() );
			
		assertEquals( 1, q.matchAny( testSet, 
			new String [] { "type" },
			null ).size() );
			
		assertEquals( 1, q.matchAny( testSet, 
			null,
			new String [] { "test" } ).size() );
			
			
		assertEquals( 1, q.matchAny( testSet, 
			new String [] { "t.*" },
			new String [] { ".*e.*" } ).size() );
			
			
		assertEquals( 1, q.matchAny( testSet, 
			null,
			new String [] { ".*e.*" } ).size() );
		
		
		assertEquals( 0, q.matchAny( testSet, EmptyStrings, EmptyStrings ).size() );
		assertEquals( 0, q.matchAny( testSet, null, EmptyStrings ).size() );
		assertEquals( 0, q.matchAny( testSet, EmptyStrings, null ).size() );