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

GlobalsManagerTest

public class GlobalsManagerTest extends TestCase
author
Toby H Ferguson
version
$Revision: 1.6 $

Fields Summary
Constructors Summary
public GlobalsManagerTest(String name)

        super(name);
    
Methods Summary
private static final java.lang.StringgetCommandPackageName()

        return "com.sun.enterprise.cli";
    
public static voidmain(java.lang.String[] args)

        if (args.length == 0){
            junit.textui.TestRunner.run(GlobalsManagerTest.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 GlobalsManagerTest(args[i]));
        }
        return ts;
    
private voidnyi()

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

    
protected voidtearDown()

    
public voidtestCommandStringLocalization()

        final ICommandEnvironment env = new Env();
        final GlobalsManager gm = new GlobalsManager(env);
        GlobalsManager.setInstance(gm);
        GlobalsManager.setBasePackage(getCommandPackageName());
        GlobalsManager.setPropertyFile("CommandPropertyFile");
        assertEquals("command property", GlobalsManager.getString("a"));
        assertEquals("command property", GlobalsManager.getString("a", (Object []) null));
        GlobalsManager.setBasePackage((String) null);
    
public voidtestCommandStringLocalizationNoBundle()

        final ICommandEnvironment env = new Env();
        final GlobalsManager gm = new GlobalsManager(env);
        GlobalsManager.setInstance(gm);
        try {
            assertEquals("", GlobalsManager.getString("a"));
            fail("Expected error indicating no base package could be found");
        }
        catch (CommandException ce){
//            assertEquals("Can't find bundle for base name null.CommandPropertyFile, locale en_US", ce.getMessage());
            assertEquals("Can't find bundle for base name null.CommandPropertyFile, locale "+Locale.getDefault(), ce.getMessage());            
            assertNull(ce.getCause());
        }
    
public voidtestEnvironment()

        final ICommandEnvironment env = new Env();
        final GlobalsManager gm = new GlobalsManager(env);
        final ICommandEnvironment env2 = new Env();
        gm.setGlobalsEnv(env2);
        assertEquals(env2, gm.getGlobalsEnv());
    
public voidtestFrameworkStringLocalization()

        final ICommandEnvironment env = new Env();
        final GlobalsManager gm = new GlobalsManager(env);
        GlobalsManager.setInstance(gm);
        assertEquals("framework property", GlobalsManager.getFrameworkString("a", (Object []) null));
        assertEquals("framework property", GlobalsManager.getFrameworkString("a"));
    
public voidtestGetSetRemove()

        final ICommandEnvironment env = new Env();
        final GlobalsManager gm = new GlobalsManager(env);
        gm.setOption("key", "value");
        assertEquals("value", gm.getOption("key"));
        gm.removeOption("key");
        assertNull(gm.getOption("key"));
    
public voidtestSimpleConstructionAndObservers()

        final ICommandEnvironment env = new Env();
        final GlobalsManager gm = new GlobalsManager(env);
        assertEquals(env, gm.getGlobalsEnv());
    
public voidtestSingletonMethods()

        final ICommandEnvironment env = new Env();
        final GlobalsManager gm = new GlobalsManager(env);
        GlobalsManager.setInstance(gm);
        assertEquals(gm, GlobalsManager.getInstance());