FileDocCategorySizeDatePackage
SettingsTest.javaAPI DocExample2814Mon Jul 23 13:26:24 BST 2007org.apache.struts2.config

SettingsTest

public class SettingsTest extends org.apache.struts2.StrutsTestCase
Unit test for {@link SettingsTest}.

Fields Summary
Constructors Summary
Methods Summary
private intgetKeyCount()

        int count = 0;
        Iterator keyNames = Settings.list();

        while (keyNames.hasNext()) {
            keyNames.next();
            count++;
        }

        return count;
    
public voidtestDefaultResourceBundlesLoaded()

        assertEquals("testmessages,testmessages2", Settings.get(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES));
        assertEquals("This is a test message", LocalizedTextUtil.findDefaultText("default.testmessage", Locale.getDefault()));
        assertEquals("This is another test message", LocalizedTextUtil.findDefaultText("default.testmessage2", Locale.getDefault()));
    
public voidtestSetSettings()

        Settings.setInstance(new TestSettings());

        String keyName = "a.long.property.key.name";
        assertEquals(keyName, Settings.get(keyName));
        assertEquals(2, getKeyCount());
    
public voidtestSettings()

        assertEquals("12345", Settings.get(StrutsConstants.STRUTS_MULTIPART_MAXSIZE));
        assertEquals("\temp", Settings.get(StrutsConstants.STRUTS_MULTIPART_SAVEDIR));

        assertEquals("test,org/apache/struts2/othertest", Settings.get( StrutsConstants.STRUTS_CUSTOM_PROPERTIES));
        assertEquals("testvalue", Settings.get("testkey"));
        assertEquals("othertestvalue", Settings.get("othertestkey"));

        Locale locale = Settings.getLocale();
        assertEquals("de", locale.getLanguage());

        int count = getKeyCount();
        assertEquals(11, count);