1 5 package com.opensymphony.webwork.config; 6 7 import com.opensymphony.webwork.WebWorkTestCase; 8 import com.opensymphony.xwork.util.LocalizedTextUtil; 9 10 import java.util.Iterator ; 11 import java.util.Locale ; 12 13 14 20 public class ConfigurationTest extends WebWorkTestCase { 21 23 public void testConfiguration() { 24 assertEquals("12345", Configuration.getString("webwork.multipart.maxSize")); 25 assertEquals("\temp", Configuration.getString("webwork.multipart.saveDir")); 26 27 assertEquals("test,com/opensymphony/webwork/othertest", Configuration.getString("webwork.custom.properties")); 28 assertEquals("testvalue", Configuration.getString("testkey")); 29 assertEquals("othertestvalue", Configuration.getString("othertestkey")); 30 31 Locale locale = Configuration.getLocale(); 32 assertEquals("de", locale.getLanguage()); 33 34 int count = getKeyCount(); 35 assertEquals(21, count); 36 } 37 38 public void testDefaultResourceBundlesLoaded() { 39 assertEquals("testmessages,testmessages2", Configuration.getString("webwork.custom.i18n.resources")); 40 assertEquals("This is a test message", LocalizedTextUtil.findDefaultText("default.testmessage", Locale.getDefault())); 41 assertEquals("This is another test message", LocalizedTextUtil.findDefaultText("default.testmessage2", Locale.getDefault())); 42 } 43 44 public void testSetConfiguration() { 45 Configuration.setConfiguration(new TestConfiguration()); 46 47 String keyName = "a.long.property.key.name"; 48 assertEquals(keyName, Configuration.getString(keyName)); 49 assertEquals(2, getKeyCount()); 50 } 51 52 private int getKeyCount() { 53 int count = 0; 54 Iterator keyNames = Configuration.list(); 55 56 while (keyNames.hasNext()) { 57 String key = (String ) keyNames.next(); 58 count++; 59 } 60 61 return count; 62 } 63 } 64 | Popular Tags |