FileDocCategorySizeDatePackage
DottedNameTest.javaAPI DocGlassfish v2 API5853Fri May 04 22:24:16 BST 2007com.sun.enterprise.admin.dottedname

DottedNameTest

public final class DottedNameTest extends TestCase

Fields Summary
public static final String
LEGAL_CHARS
public static final String
ILLEGAL_CHARS
private static final char
BACKSLASH
Constructors Summary
public DottedNameTest()

	
Methods Summary
public voidattemptInvalidName(java.lang.String name)

		try
		{
			final DottedName dottedName	= new DottedName( name );
			fail( "expected dotted name to fail: \"" + name + "\"");
		}
		catch( Exception e )
		{
			// good, we expected to get here
		}
	
public voidtestBadSyntax()

		attemptInvalidName( "." );
		attemptInvalidName( ".." );
		attemptInvalidName( "..." );
		attemptInvalidName( ".x.." );
		attemptInvalidName( "x.x.x." );
	
public voidtestDomainAndScopeOnly()

		new DottedName( "mydomain:domain" );
	
public voidtestDomainOnly()

		attemptInvalidName( "mydomain:" );
	
public voidtestEmptyName()

		attemptInvalidName( "" );
	
public voidtestEscapedDot()

		final String		name	= "test" + BACKSLASH + ".1.part" + BACKSLASH + ".1";
		final DottedName	dn	= new DottedName( name );
		assertEquals( "test.1", dn.getScope() );
		assertEquals( "part.1", dn.getParts().get( 0 ) );
		
		
	
public voidtestEscapedEscapeChar()

		 
	
	
		try
		{
			DottedName	dn	= new DottedName( "test" + BACKSLASH + "Name" );
			assert( false );
		}
		catch( IllegalArgumentException e )
		{
			// good
		}
		
		final DottedName	dn	= new DottedName( "test" + BACKSLASH + BACKSLASH + "Name" );
		assertEquals( "test" + BACKSLASH + BACKSLASH + "Name", dn.toString() );
	
public voidtestEscapedName()

		final DottedName dn	= new DottedName( "domain.server\\.1.port" );
		
		assertEquals( dn.getScope(), "domain" );
		assertEquals( dn.getParts().get( 0 ), "server.1" );
		assertEquals( dn.getParts().get( 1 ), "port" );
	
public voidtestIllegalChars()

		for( int i = 0; i < ILLEGAL_CHARS.length(); ++i )
		{
			final char	theChar	= ILLEGAL_CHARS.charAt( i );
			
			attemptInvalidName( "" + theChar );
			attemptInvalidName( "domain." + theChar + "y" );
		}
	
public voidtestLegalChars()

		for( int i = 0; i < LEGAL_CHARS.length(); ++i )
		{
			final char	theChar	= LEGAL_CHARS.charAt( i );
			
			final String	escapedChar	= DottedName.escapePart( "" + theChar );
			new DottedName( "domain." + escapedChar );
		}
	
public voidtestLongName()

		final DottedName dn	= new DottedName( "mydomain:scope.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p" );
		
		assertEquals( dn.getDomain(), "mydomain" );
		assertEquals( dn.getScope(), "scope" );
		assertEquals( dn.getParts().size(), 15  );
		assertEquals( dn.getParts().get( 14 ), "p"  );
	
public voidtestMissingValue()

		attemptInvalidName( "domain." );
	
public voidtestNameWithPartOfDot()

		new DottedName( "domain." + DottedName.escapePart( "" + '." ) );
	
public voidtestScopeOnly()

		new DottedName( "domain" );
	
public voidtestThatToStringMatchesOrig()

		final String	TEST	= "domain.server\\.1.port";
		final DottedName dn	= new DottedName( TEST );
		
		assertEquals( dn.toString(), TEST );
	
public voidtestWithDomain()

		new DottedName( "mydomain:domain.locale" );
		new DottedName( "mydomain:domain.a.b.c.foo" );