1 9 package org.jboss.portal.test.common; 10 11 import java.util.Iterator ; 12 import java.util.Locale ; 13 14 import junit.framework.TestCase; 15 16 import org.jboss.portal.common.util.LocaleInfo; 17 18 22 public class LocaleInfoTestCase extends TestCase 23 { 24 public LocaleInfoTestCase(String key) 25 { 26 super(key); 27 } 28 29 public void testParent() 30 { 31 LocaleInfo info1 = null; 33 for (Iterator i = LocaleInfo.getAll().iterator();i.hasNext();) 34 { 35 LocaleInfo tmp = (LocaleInfo)i.next(); 36 if (tmp.getLocale().getVariant() != null && tmp.getLocale().getVariant().length() > 0) 37 { 38 info1 = tmp; 39 break; 40 } 41 } 42 43 assertNotNull("Cannot found a locale with language/country/variant", info1); 45 46 LocaleInfo info2 = info1.getParent(); 48 assertNotNull(info2); 49 assertEquals(new Locale (info1.getLocale().getLanguage(), info1.getLocale().getCountry(), ""), info2.getLocale()); 50 51 LocaleInfo info3 = info2.getParent(); 53 assertNotNull(info3); 54 assertEquals(new Locale (info1.getLocale().getLanguage(), "", ""), info3.getLocale()); 55 56 LocaleInfo info4 = info3.getParent(); 58 assertNull(info4); 59 } 60 } 61 | Popular Tags |