FileDocCategorySizeDatePackage
LocalStringsManagerFactoryTest.javaAPI DocGlassfish v2 API6631Fri May 04 22:25:30 BST 2007com.sun.enterprise.cli.framework

LocalStringsManagerFactoryTest

public class LocalStringsManagerFactoryTest extends TestCase
Execute these tests using gmake (and Ant) by: cd gmake ANT_TARGETS=LocalStringsManagerFactoryTest

Fields Summary
private static final String
P1_PROP
private static final String
P2_PROP
private static final String
PACKAGE
Properties
p1
Properties
p2
Constructors Summary
public LocalStringsManagerFactoryTest(String name)

        super(name);
    
Methods Summary
voidinitProperty(java.util.Properties prop, java.lang.String file)

        prop.setProperty("base-package", PACKAGE);
        prop.setProperty("property-file-name", file);
    
public static voidmain(java.lang.String[] args)

        final TestRunner runner= new TestRunner();
        final TestResult result = runner.doRun(LocalStringsManagerFactoryTest.suite(), false);
        System.exit(result.errorCount() + result.failureCount());
    
private voidnyi()

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

        p1 = new Properties();
        p2 = new Properties();
        initProperty(p1, P1_PROP);
        initProperty(p2, P2_PROP);
    
public static junit.framework.Testsuite()

        TestSuite suite = new TestSuite(LocalStringsManagerFactoryTest.class);
        return suite;
    
protected voidtearDown()

    
public voidtestConstructor()


      
        final LocalStringsManagerFactory lsmf = new LocalStringsManagerFactory();
    
public voidtestMultiplePropertyLookupOverride()

        List hs = new ArrayList();
        hs.add(p1);
        hs.add(p2);

        LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(hs.iterator());
        LocalStringsManager lsm = LocalStringsManagerFactory.getCommandLocalStringsManager();
        assertEquals("expected a to be overridden and come from P1", "P1.a", lsm.getString("a"));
    
public voidtestMultiplePropertyUniqueValuesMissing()

        Set hs = new HashSet();
        hs.add(p1);
        hs.add(p2);
        LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(hs.iterator());
        LocalStringsManager lsm = LocalStringsManagerFactory.getCommandLocalStringsManager();
        assertEquals("expected b to be from P1", "P1.b", lsm.getString("b"));
        assertEquals("expected c to be from P2", "P2.c", lsm.getString("c"));
    
public voidtestP1Lookup()

        Set hs = new HashSet();
        hs.add(p1);
        LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(hs.iterator());
        LocalStringsManager lsm = LocalStringsManagerFactory.getCommandLocalStringsManager();
        assertEquals("P1.a", lsm.getString("a"));
        assertEquals("P1.b", lsm.getString("b"));
    
public voidtestP2Lookup()

        Set hs = new HashSet();
        hs.add(p2);
        LocalStringsManagerFactory.setCommandLocalStringsManagerProperties(hs.iterator());
        LocalStringsManager lsm = LocalStringsManagerFactory.getCommandLocalStringsManager();
        assertEquals("P2.a", lsm.getString("a"));
        assertEquals("P2.c", lsm.getString("c"));
	
    
public voidtestSetInstance()

        final LocalStringsManager lsm = new LocalStringsManager(PACKAGE, P1_PROP);
        LocalStringsManagerFactory.setInstance(PACKAGE, lsm);
        assertEquals(lsm, LocalStringsManagerFactory.getLocalStringsManager(PACKAGE, P1_PROP));