FileDocCategorySizeDatePackage
ObjectNameQueryImplTest.javaAPI DocGlassfish v2 API4751Fri May 04 22:25:00 BST 2007com.sun.cli.jmx.util

ObjectNameQueryImplTest

public class ObjectNameQueryImplTest extends TestCase

Fields Summary
static final Set
EmptySet
static final String[]
EmptyStrings
Constructors Summary
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 HashSet	s	= new HashSet();
		
		s.add( name );
		
		return( s );
	
static java.util.SetcreateSet(javax.management.ObjectName[] names)

		final HashSet	s	= new HashSet();
		
		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			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() );