FileDocCategorySizeDatePackage
CLIManFileFinderTest.javaAPI DocGlassfish v2 API6510Fri May 04 22:25:28 BST 2007com.sun.enterprise.cli.framework

CLIManFileFinderTest

public class CLIManFileFinderTest extends TestCase
author
Toby H Ferguson
version
$Revision: 1.5 $

Fields Summary
Constructors Summary
public CLIManFileFinderTest(String name)

	super(name);
  
Methods Summary
public static voidmain(java.lang.String[] args)

	if (args.length == 0){
	  junit.textui.TestRunner.run(CLIManFileFinderTest.class);
	} else {
	  junit.textui.TestRunner.run(makeSuite(args));
	}
  
private static junit.framework.TestSuitemakeSuite(java.lang.String[] args)

	final TestSuite ts = new TestSuite();
	for (int i = 0; i < args.length; i++){
	  ts.addTest(new CLIManFileFinderTest(args[i]));
	}
	return ts;
  
private voidnyi()

	fail("Not Yet Implemented");
  
protected voidsetUp()

  
protected voidtearDown()

  
public voidtestEmptyVariant()

	CLIManFileFinder c = new CLIManFileFinder();
	Locale l = new Locale("en", "uk", "");
	assertEquals(3,c.getLocaleLocations(l).length);
	assertEquals("/en/UK", c.getLocaleLocations(l)[0]);
	assertEquals("/en", c.getLocaleLocations(l)[1]);
	  assertEquals("", c.getLocaleLocations(l)[2]);
  
public voidtestEndOfFirstSearch()

	  CLIManFileFinder c = new CLIManFileFinder();
	  Locale l = new Locale("en", "UK", "v1");
	  Iterator it = c.getPossibleLocations("command", l);
	  for (int i = 0; i < 17; i++){
		it.next();
	  }
	  assertEquals("help/en/UK/v1/command.9m", (String) it.next());
	  assertEquals("help/en/UK/command.1", (String) it.next());
  
public voidtestEndOfIterator()

	  CLIManFileFinder c = new CLIManFileFinder();
	  Locale l = new Locale("en", "UK", "v1");
	  Iterator it = c.getPossibleLocations("command", l);
	  for (int i = 0; i < 71; i++){
		it.next();
	  }
	  assertEquals("help/command.9m", (String) it.next());
	  assertTrue(!it.hasNext());
	  try {
		it.next();
		fail("Expected NoSuchElementException indicating we'd read beyond the end of the interator");
	  }
	  catch (NoSuchElementException nse){
	  }
		
  
public voidtestEndOfSecondSearch()

	  CLIManFileFinder c = new CLIManFileFinder();
	  Locale l = new Locale("en", "UK", "v1");
	  Iterator it = c.getPossibleLocations("command", l);
	  for (int i = 0; i < 35; i++){
		it.next();
	  }
	  assertEquals("help/en/UK/command.9m", (String) it.next());
	  assertEquals("help/en/command.1", (String) it.next());
  
public voidtestEndOfThirdSearch()

	  CLIManFileFinder c = new CLIManFileFinder();
	  Locale l = new Locale("en", "UK", "v1");
	  Iterator it = c.getPossibleLocations("command", l);
	  for (int i = 0; i < 53; i++){
		it.next();
	  }
	  assertEquals("help/en/command.9m", (String) it.next());
	  assertEquals("help/command.1", (String) it.next());
  
public voidtestLocations()

	  CLIManFileFinder c = new CLIManFileFinder();
	  Locale l = new Locale("en", "UK", "v1");
	  Iterator it = c.getPossibleLocations("command", l);
	  assertEquals("help/en/UK/v1/command.1", (String) it.next());
	  assertEquals("help/en/UK/v1/command.1m",(String) it.next());
	  assertEquals("help/en/UK/v1/command.2", (String) it.next());
	  for (int i = 0; i < 5; i++){
		it.next();
	  }
	  assertEquals("help/en/UK/v1/command.5", (String) it.next());
  
public voidtestNoCountry()

	  CLIManFileFinder c = new CLIManFileFinder();
	  Locale l = new Locale("en", "", "v1");
	  assertEquals(2,c.getLocaleLocations(l).length);
	  assertEquals("/en", c.getLocaleLocations(l)[0]);
	  assertEquals("", c.getLocaleLocations(l)[1]);
	
public voidtestNoLanguage()

	  CLIManFileFinder c = new CLIManFileFinder();
	  Locale l = new Locale("", "UK", "v1");
	  assertEquals(1,c.getLocaleLocations(l).length);
	  assertEquals("", c.getLocaleLocations(l)[0]);
	
public voidtestNoVariant()

	CLIManFileFinder c = new CLIManFileFinder();
	Locale l = new Locale("en", "uk");
	assertEquals(3,c.getLocaleLocations(l).length);
	assertEquals("/en/UK", c.getLocaleLocations(l)[0]);
	assertEquals("/en", c.getLocaleLocations(l)[1]);
	  assertEquals("", c.getLocaleLocations(l)[2]);
  
public voidtestSimpleLocation()

	CLIManFileFinder c = new CLIManFileFinder();
	Locale l = new Locale("en", "uk", "v1");
	assertEquals(4,c.getLocaleLocations(l).length);
	assertEquals("/en/UK/v1", c.getLocaleLocations(l)[0]);
	assertEquals("/en/UK", c.getLocaleLocations(l)[1]);
	assertEquals("/en", c.getLocaleLocations(l)[2]);
	assertEquals("", c.getLocaleLocations(l)[3]);